public static boolean isTestImplementor(IType type) throws JavaModelException { ITypeHierarchy typeHier= type.newSupertypeHierarchy(null); IType[] superInterfaces= typeHier.getAllInterfaces(); for (int i= 0; i < superInterfaces.length; i++) { if (JUnitCorePlugin.TEST_INTERFACE_NAME.equals(superInterfaces[i].getFullyQualifiedName('.'))) { return true; } } return false; }
public static boolean isTestImplementor(IType type) throws JavaModelException { ITypeHierarchy typeHier= type.newSupertypeHierarchy(null); IType[] superInterfaces= typeHier.getAllInterfaces(); for (int i= 0; i < superInterfaces.length; i++) { if (JUnitCorePlugin.TEST_INTERFACE_NAME.equals(superInterfaces[i].getFullyQualifiedName('.'))) { return true; } } return false; }
/** * determines if the element implements a given interface * @param element the element to check for the interface * @param qname the fully qualified name of the interface to check for * @return true if the element does implement the interface, false otherwise */ private boolean implementsInterface(IJavaElement element, String qname) { try { IType type = getType(element); if(type != null) { IType[] itypes = type.newSupertypeHierarchy(new NullProgressMonitor()).getAllInterfaces(); for(int i = 0; i < itypes.length; i++) { if(itypes[i].getFullyQualifiedName().equals(qname)) { return true; } } } } catch(JavaModelException e) {} return false; }
/** * determines if the element implements a given interface * @param element the element to check for the interface * @param qname the fully qualified name of the interface to check for * @return true if the element does implement the interface, false otherwise */ private boolean implementsInterface(IJavaElement element, String qname) { try { IType type = getType(element); if(type != null) { IType[] itypes = type.newSupertypeHierarchy(new NullProgressMonitor()).getAllInterfaces(); for(int i = 0; i < itypes.length; i++) { if(itypes[i].getFullyQualifiedName().equals(qname)) { return true; } } } } catch(JavaModelException e) {} return false; }
/** * 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; }