public Collection findInterfaces(IType type, IProgressMonitor progressMonitor) { ITypeHierarchy typeHierarchy; try { typeHierarchy = type.newSupertypeHierarchy(progressMonitor); IType[] interfaces = typeHierarchy.getAllSuperInterfaces(type); HashSet result = new HashSet(Arrays.asList(interfaces)); return result; } catch (JavaModelException e) { JavaPlugin.log(e); } return null; } }
@Override public Collection<IType> findInterfaces(IType type, IProgressMonitor progressMonitor) { ITypeHierarchy typeHierarchy; try { typeHierarchy = type.newSupertypeHierarchy(progressMonitor); IType[] interfaces = typeHierarchy.getAllSuperInterfaces(type); HashSet<IType> result = new HashSet<>(Arrays.asList(interfaces)); return result; } catch (JavaModelException e) { JavaPlugin.log(e); } return null; } }
@Override public Collection<IType> findInterfaces(IType type, IProgressMonitor progressMonitor) { ITypeHierarchy typeHierarchy; try { typeHierarchy = type.newSupertypeHierarchy(progressMonitor); IType[] interfaces = typeHierarchy.getAllSuperInterfaces(type); HashSet<IType> result = new HashSet<>(Arrays.asList(interfaces)); return result; } catch (JavaModelException e) { JavaPlugin.log(e); } return null; } }
public static IMethod isDeclaredInInterface(IMethod method, ITypeHierarchy hierarchy, IProgressMonitor monitor) throws JavaModelException { Assert.isTrue(isVirtual(method)); IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 1); try { IType[] classes= hierarchy.getAllClasses(); subMonitor.beginTask("", classes.length); //$NON-NLS-1$ for (int i= 0; i < classes.length; i++) { final IType clazz= classes[i]; IType[] superinterfaces= null; if (clazz.equals(hierarchy.getType())) superinterfaces= hierarchy.getAllSuperInterfaces(clazz); else superinterfaces= clazz.newSupertypeHierarchy(new SubProgressMonitor(subMonitor, 1)).getAllSuperInterfaces(clazz); for (int j= 0; j < superinterfaces.length; j++) { IMethod found= Checks.findSimilarMethod(method, superinterfaces[j]); if (found != null && !found.equals(method)) return found; } subMonitor.worked(1); } return null; } finally { subMonitor.done(); } }
public static IMethod isDeclaredInInterface(IMethod method, ITypeHierarchy hierarchy, IProgressMonitor monitor) throws JavaModelException { Assert.isTrue(isVirtual(method)); IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 1); try { IType[] classes= hierarchy.getAllClasses(); subMonitor.beginTask("", classes.length); //$NON-NLS-1$ for (int i= 0; i < classes.length; i++) { final IType clazz= classes[i]; IType[] superinterfaces= null; if (clazz.equals(hierarchy.getType())) { superinterfaces= hierarchy.getAllSuperInterfaces(clazz); } else { superinterfaces= clazz.newSupertypeHierarchy(new SubProgressMonitor(subMonitor, 1)).getAllSuperInterfaces(clazz); } for (int j= 0; j < superinterfaces.length; j++) { IMethod found= Checks.findSimilarMethod(method, superinterfaces[j]); if (found != null && !found.equals(method)) { return found; } } subMonitor.worked(1); } return null; } finally { subMonitor.done(); } }
public static IMethod isDeclaredInInterface(IMethod method, ITypeHierarchy hierarchy, IProgressMonitor monitor) throws JavaModelException { Assert.isTrue(isVirtual(method)); IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 1); try { IType[] classes= hierarchy.getAllClasses(); subMonitor.beginTask("", classes.length); //$NON-NLS-1$ for (int i= 0; i < classes.length; i++) { final IType clazz= classes[i]; IType[] superinterfaces= null; if (clazz.equals(hierarchy.getType())) superinterfaces= hierarchy.getAllSuperInterfaces(clazz); else superinterfaces= clazz.newSupertypeHierarchy(new SubProgressMonitor(subMonitor, 1)).getAllSuperInterfaces(clazz); for (int j= 0; j < superinterfaces.length; j++) { IMethod found= Checks.findSimilarMethod(method, superinterfaces[j]); if (found != null && !found.equals(method)) return found; } subMonitor.worked(1); } return null; } finally { subMonitor.done(); } }
/** * Checks if the given method is declared in an interface. If the method's declaring type * is an interface the method returns <code>false</code> if it is only declared in that * interface. */ public static IMethod isDeclaredInInterface(IMethod method, ITypeHierarchy hierarchy, IProgressMonitor monitor) throws JavaModelException { Assert.isTrue(isVirtual(method)); IProgressMonitor subMonitor= new SubProgressMonitor(monitor, 1); try { IType[] classes= hierarchy.getAllClasses(); subMonitor.beginTask("", classes.length); //$NON-NLS-1$ for (int i= 0; i < classes.length; i++) { final IType clazz= classes[i]; IType[] superinterfaces= null; if (clazz.equals(hierarchy.getType())) superinterfaces= hierarchy.getAllSuperInterfaces(clazz); else superinterfaces= clazz.newSupertypeHierarchy(new SubProgressMonitor(subMonitor, 1)).getAllSuperInterfaces(clazz); for (int j= 0; j < superinterfaces.length; j++) { IMethod found= Checks.findSimilarMethod(method, superinterfaces[j]); if (found != null && !found.equals(method)) return found; } subMonitor.worked(1); } return null; } finally { subMonitor.done(); } }
private void collectChildrenWithMissingSerialVersionId(IJavaElement[] children, IType serializable, List result) throws JavaModelException { for (int i= 0; i < children.length; i++) { IJavaElement child= children[i]; if (child instanceof IType) { IType type= (IType)child; if (type.isClass()) { IField field= type.getField(NAME_FIELD); if (!field.exists()) { ITypeHierarchy hierarchy= type.newSupertypeHierarchy(new NullProgressMonitor()); IType[] interfaces= hierarchy.getAllSuperInterfaces(type); for (int j= 0; j < interfaces.length; j++) { if (interfaces[j].equals(serializable)) { result.add(type); break; } } } } collectChildrenWithMissingSerialVersionId(type.getChildren(), serializable, result); } else if (child instanceof IMethod) { collectChildrenWithMissingSerialVersionId(((IMethod)child).getChildren(), serializable, result); } else if (child instanceof IField) { collectChildrenWithMissingSerialVersionId(((IField)child).getChildren(), serializable, result); } } } }
private void collectChildrenWithMissingSerialVersionId(IJavaElement[] children, IType serializable, List<IType> result) throws JavaModelException { for (int i = 0; i < children.length; i++) { IJavaElement child = children[i]; if (child instanceof IType) { IType type = (IType) child; if (type.isClass()) { IField field = type.getField(NAME_FIELD); if (!field.exists()) { ITypeHierarchy hierarchy = type.newSupertypeHierarchy(new NullProgressMonitor()); IType[] interfaces = hierarchy.getAllSuperInterfaces(type); for (int j = 0; j < interfaces.length; j++) { if (interfaces[j].equals(serializable)) { result.add(type); break; } } } } collectChildrenWithMissingSerialVersionId(type.getChildren(), serializable, result); } else if (child instanceof IMethod) { collectChildrenWithMissingSerialVersionId(((IMethod) child).getChildren(), serializable, result); } else if (child instanceof IField) { collectChildrenWithMissingSerialVersionId(((IField) child).getChildren(), serializable, result); } } } }
private void collectChildrenWithMissingSerialVersionId(IJavaElement[] children, IType serializable, List<IType> result) throws JavaModelException { for (int i= 0; i < children.length; i++) { IJavaElement child= children[i]; if (child instanceof IType) { IType type= (IType)child; if (type.isClass()) { IField field= type.getField(NAME_FIELD); if (!field.exists()) { ITypeHierarchy hierarchy= type.newSupertypeHierarchy(new NullProgressMonitor()); IType[] interfaces= hierarchy.getAllSuperInterfaces(type); for (int j= 0; j < interfaces.length; j++) { if (interfaces[j].equals(serializable)) { result.add(type); break; } } } } collectChildrenWithMissingSerialVersionId(type.getChildren(), serializable, result); } else if (child instanceof IMethod) { collectChildrenWithMissingSerialVersionId(((IMethod)child).getChildren(), serializable, result); } else if (child instanceof IField) { collectChildrenWithMissingSerialVersionId(((IField)child).getChildren(), serializable, result); } } } }
private void collectChildrenWithMissingSerialVersionId(IJavaElement[] children, IType serializable, List<IType> result) throws JavaModelException { for (int i= 0; i < children.length; i++) { IJavaElement child= children[i]; if (child instanceof IType) { IType type= (IType)child; if (type.isClass()) { IField field= type.getField(NAME_FIELD); if (!field.exists()) { ITypeHierarchy hierarchy= type.newSupertypeHierarchy(new NullProgressMonitor()); IType[] interfaces= hierarchy.getAllSuperInterfaces(type); for (int j= 0; j < interfaces.length; j++) { if (interfaces[j].equals(serializable)) { result.add(type); break; } } } } collectChildrenWithMissingSerialVersionId(type.getChildren(), serializable, result); } else if (child instanceof IMethod) { collectChildrenWithMissingSerialVersionId(((IMethod)child).getChildren(), serializable, result); } else if (child instanceof IField) { collectChildrenWithMissingSerialVersionId(((IField)child).getChildren(), serializable, result); } } } }
private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException { pm.beginTask("", 9); //$NON-NLS-1$ pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden); MethodDeclaration decl= fSourceProvider.getDeclaration(); IMethod method= (IMethod) decl.resolveBinding().getJavaElement(); if (method == null || Flags.isPrivate(method.getFlags())) { pm.worked(8); return; } IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newTypeHierarchy(new SubProgressMonitor(pm, 6)); checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1)); checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1)); checkSuperInterfaces(status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1)); pm.setTaskName(""); //$NON-NLS-1$ }
private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException { pm.beginTask("", 9); //$NON-NLS-1$ pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden); MethodDeclaration decl= fSourceProvider.getDeclaration(); IMethod method= (IMethod) decl.resolveBinding().getJavaElement(); if (method == null || Flags.isPrivate(method.getFlags())) { pm.worked(8); return; } IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newTypeHierarchy(new SubProgressMonitor(pm, 6)); checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1)); checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1)); checkSuperInterfaces(status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1)); pm.setTaskName(""); //$NON-NLS-1$ }
private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException { pm.beginTask("", 9); //$NON-NLS-1$ pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden); MethodDeclaration decl= fSourceProvider.getDeclaration(); IMethod method= (IMethod) decl.resolveBinding().getJavaElement(); if (method == null || Flags.isPrivate(method.getFlags())) { pm.worked(8); return; } IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newTypeHierarchy(new SubProgressMonitor(pm, 6)); checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1)); checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1)); checkSuperInterfaces(status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1)); pm.setTaskName(""); //$NON-NLS-1$ }
private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException { pm.beginTask("", 9); //$NON-NLS-1$ pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden); MethodDeclaration decl= fSourceProvider.getDeclaration(); IMethod method= (IMethod) decl.resolveBinding().getJavaElement(); if (method == null || Flags.isPrivate(method.getFlags())) { pm.worked(8); return; } IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newTypeHierarchy(new SubProgressMonitor(pm, 6)); checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1)); checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1)); checkSuperInterfaces(status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1)); pm.setTaskName(""); //$NON-NLS-1$ }
private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException { pm.beginTask("", 9); //$NON-NLS-1$ pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden); MethodDeclaration decl= fSourceProvider.getDeclaration(); IMethod method= (IMethod) decl.resolveBinding().getJavaElement(); if (method == null || Flags.isPrivate(method.getFlags())) { pm.worked(8); return; } IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newTypeHierarchy(new SubProgressMonitor(pm, 6)); checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1)); checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1)); checkSuperInterfaces(status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1)); pm.setTaskName(""); //$NON-NLS-1$ }
private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException { pm.beginTask("", 9); //$NON-NLS-1$ pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden); MethodDeclaration decl= fSourceProvider.getDeclaration(); IMethod method= (IMethod) decl.resolveBinding().getJavaElement(); if (method == null || Flags.isPrivate(method.getFlags())) { pm.worked(8); return; } IType type= method.getDeclaringType(); ITypeHierarchy hierarchy= type.newTypeHierarchy(new SubProgressMonitor(pm, 6)); checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1)); checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1)); checkSuperInterfaces(status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1)); pm.setTaskName(""); //$NON-NLS-1$ }
for (IType t : h.getAllSuperInterfaces(type)) { ann = getFirstDeclaredAnnotation(t, fullyQualifiedAnnotations); if (exists(ann)) {