public Collection findImplementingTypes(IType type, IProgressMonitor progressMonitor) { ITypeHierarchy typeHierarchy; try { typeHierarchy = type.newTypeHierarchy(progressMonitor); IType[] implementingTypes = typeHierarchy.getAllClasses(); HashSet result = new HashSet(Arrays.asList(implementingTypes)); return result; } catch (JavaModelException e) { JavaPlugin.log(e); } return null; }
@Override public Collection<IType> findImplementingTypes(IType type, IProgressMonitor progressMonitor) { ITypeHierarchy typeHierarchy; try { typeHierarchy = type.newTypeHierarchy(progressMonitor); IType[] implementingTypes = typeHierarchy.getAllClasses(); HashSet<IType> result = new HashSet<>(Arrays.asList(implementingTypes)); return result; } catch (JavaModelException e) { JavaPlugin.log(e); } return null; }
@Override public Collection<IType> findImplementingTypes(IType type, IProgressMonitor progressMonitor) { ITypeHierarchy typeHierarchy; try { typeHierarchy = type.newTypeHierarchy(progressMonitor); IType[] implementingTypes = typeHierarchy.getAllClasses(); HashSet<IType> result = new HashSet<>(Arrays.asList(implementingTypes)); return result; } catch (JavaModelException e) { JavaPlugin.log(e); } return null; }
final static IMethod[] hierarchyDeclaresMethodName(IProgressMonitor pm, ITypeHierarchy hierarchy, IMethod method, String newName) throws CoreException { Set result= new HashSet(); IType type= method.getDeclaringType(); IMethod foundMethod= Checks.findMethod(newName, method.getParameterTypes().length, false, type); if (foundMethod != null) result.add(foundMethod); IMethod[] foundInHierarchyClasses= classesDeclareMethodName(hierarchy, Arrays.asList(hierarchy.getAllClasses()), method, newName); if (foundInHierarchyClasses != null) result.addAll(Arrays.asList(foundInHierarchyClasses)); IType[] implementingClasses= hierarchy.getImplementingClasses(type); IMethod[] foundInImplementingClasses= classesDeclareMethodName(hierarchy, Arrays.asList(implementingClasses), method, newName); if (foundInImplementingClasses != null) result.addAll(Arrays.asList(foundInImplementingClasses)); return (IMethod[]) result.toArray(new IMethod[result.size()]); }
private List<String> getMethodSuggestions(IType type, MethodChecker checker) throws JavaModelException { ArrayList<String> result= new ArrayList<>(); IType[] classes= type.newSupertypeHierarchy(null).getAllClasses(); for (int i= 0; i < classes.length; i++) { IMethod[] methods= classes[i].getMethods(); for (int j= 0; j < methods.length; j++) { if (checker.isMethodOK(methods[j])) { String name= methods[j].getElementName(); if (!result.contains(name)) result.add(name); } } } return result; }
final static IMethod[] hierarchyDeclaresMethodName(IProgressMonitor pm, ITypeHierarchy hierarchy, IMethod method, String newName) throws CoreException { try { Set<IMethod> result= new HashSet<>(); IType type= method.getDeclaringType(); IMethod foundMethod= Checks.findMethod(newName, method.getParameterTypes().length, false, type); if (foundMethod != null) { result.add(foundMethod); } IMethod[] foundInHierarchyClasses= classesDeclareMethodName(hierarchy, Arrays.asList(hierarchy.getAllClasses()), method, newName); if (foundInHierarchyClasses != null) { result.addAll(Arrays.asList(foundInHierarchyClasses)); } IType[] implementingClasses= hierarchy.getImplementingClasses(type); IMethod[] foundInImplementingClasses= classesDeclareMethodName(hierarchy, Arrays.asList(implementingClasses), method, newName); if (foundInImplementingClasses != null) { result.addAll(Arrays.asList(foundInImplementingClasses)); } return result.toArray(new IMethod[result.size()]); } finally { if (pm != null) { pm.done(); } } }
final static IMethod[] hierarchyDeclaresMethodName(IProgressMonitor pm, ITypeHierarchy hierarchy, IMethod method, String newName) throws CoreException { try { Set<IMethod> result= new HashSet<>(); IType type= method.getDeclaringType(); IMethod foundMethod= Checks.findMethod(newName, method.getParameterTypes().length, false, type); if (foundMethod != null) result.add(foundMethod); IMethod[] foundInHierarchyClasses= classesDeclareMethodName(hierarchy, Arrays.asList(hierarchy.getAllClasses()), method, newName); if (foundInHierarchyClasses != null) result.addAll(Arrays.asList(foundInHierarchyClasses)); IType[] implementingClasses= hierarchy.getImplementingClasses(type); IMethod[] foundInImplementingClasses= classesDeclareMethodName(hierarchy, Arrays.asList(implementingClasses), method, newName); if (foundInImplementingClasses != null) result.addAll(Arrays.asList(foundInImplementingClasses)); return result.toArray(new IMethod[result.size()]); } finally { if (pm != null) { pm.done(); } } }
final static IMethod[] hierarchyDeclaresMethodName(IProgressMonitor pm, ITypeHierarchy hierarchy, IMethod method, String newName) throws CoreException { try { Set<IMethod> result= new HashSet<>(); IType type= method.getDeclaringType(); IMethod foundMethod= Checks.findMethod(newName, method.getParameterTypes().length, false, type); if (foundMethod != null) result.add(foundMethod); IMethod[] foundInHierarchyClasses= classesDeclareMethodName(hierarchy, Arrays.asList(hierarchy.getAllClasses()), method, newName); if (foundInHierarchyClasses != null) result.addAll(Arrays.asList(foundInHierarchyClasses)); IType[] implementingClasses= hierarchy.getImplementingClasses(type); IMethod[] foundInImplementingClasses= classesDeclareMethodName(hierarchy, Arrays.asList(implementingClasses), method, newName); if (foundInImplementingClasses != null) result.addAll(Arrays.asList(foundInImplementingClasses)); return result.toArray(new IMethod[result.size()]); } finally { if (pm != null) { pm.done(); } } }
private List<String> getMethodSuggestions(IType type, MethodChecker checker) throws JavaModelException { ArrayList<String> result= new ArrayList<>(); IType[] classes= type.newSupertypeHierarchy(null).getAllClasses(); for (int i= 0; i < classes.length; i++) { IMethod[] methods= classes[i].getMethods(); for (int j= 0; j < methods.length; j++) { if (checker.isMethodOK(methods[j])) { String name= methods[j].getElementName(); if (!result.contains(name)) result.add(name); } } } return result; }
/** * For the method under rename, checks if any sub-type inherits a method with the same name from a different super type. * * @param pm progress monitor to * @param owner owner of the compilation unit under rename * @param methodHierarchy the type hierarchy of the method under rename * @param methodTypeSubtypes the sub-types of the type under rename * @return {@code false} if there can be no married alien types to the method under rename, {@code true} otherwise. * @throws JavaModelException if creating a type hierarchy fails */ private boolean couldHaveMarriedAlienTypes(IProgressMonitor pm, WorkingCopyOwner owner, ITypeHierarchy methodHierarchy, IType[] methodTypeSubtypes) throws JavaModelException { Set<IType> allTypesInMethodHierarchy= new HashSet<>(); allTypesInMethodHierarchy.addAll(Arrays.asList(methodHierarchy.getAllClasses())); allTypesInMethodHierarchy.addAll(Arrays.asList(methodHierarchy.getAllInterfaces())); for (IType methodTypeSubtype : methodTypeSubtypes) { checkCanceled(pm); ITypeHierarchy subtypeHierarchy= methodTypeSubtype.newTypeHierarchy(owner, pm); IType[] subtypeSuperTypes= subtypeHierarchy.getAllSupertypes(methodTypeSubtype); for (IType subtypeSuperType : subtypeSuperTypes) { checkCanceled(pm); if (!allTypesInMethodHierarchy.contains(subtypeSuperType)) { if (definesSimilarMethod(subtypeSuperType, fMethod)) { return true; } } } } return false; }
IType[] allTypes = hierarchy.getAllClasses();
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(); } }
IType[] allClasses= hierarchy.getAllClasses();
for (IType t : rootTypes) { ITypeHierarchy codeTypeHierarchy = t.newTypeHierarchy(null); for (IType candidate : codeTypeHierarchy.getAllClasses()) { if (S2eUtils.exists(candidate) && !candidate.isInterface() && !candidate.isBinary() && !candidate.isAnonymous() && candidate.getDeclaringType() == null) { types.add(candidate);
IType[] allClasses= hierarchy.getAllClasses();
IType[] allClasses= hierarchy.getAllClasses();
IJavaProject javaProject= getContext().getTypeBinding().getJavaElement().getJavaProject(); IType type= javaProject.findType(getContext().getCustomBuilderClass()); IType[] types= type.newSupertypeHierarchy(null).getAllClasses(); for (int i= 0; i < types.length; i++) { IMethod[] methods= types[i].getMethods();