Java Code Examples for org.eclipse.jdt.core.ITypeHierarchy#getAllSuperclasses()

The following examples show how to use org.eclipse.jdt.core.ITypeHierarchy#getAllSuperclasses() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GWTJUnitPropertyTester.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private static boolean isGWTTestCaseOrSuite(IType type) {
  try {
    ITypeHierarchy hierarchy = type.newSupertypeHierarchy(null);
    IType[] superclasses = hierarchy.getAllSuperclasses(type);
    for (IType superclass : superclasses) {
      if (GWT_TEST_CASE.equals(superclass.getFullyQualifiedName())
          || GWT_TEST_SUITE.equals(superclass.getFullyQualifiedName())) {
        return true;
      }
    }
    return false;
  } catch (CoreException e) {
    GWTPluginLog.logError(e);
    return false;
  }
}
 
Example 2
Source File: DialogFactoryHelperImpl.java    From jenerate with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean isOverriddenInSuperclass(IType objectClass, String methodName, String[] methodParameterTypes,
        String originalClassFullyQualifiedName) throws JavaModelException {
    ITypeHierarchy typeHierarchy = objectClass.newSupertypeHierarchy(null);
    IType[] superclasses = typeHierarchy.getAllSuperclasses(objectClass);

    if (superclasses.length == 0) {
        return false;
    }

    for (IType superclass : superclasses) {
        if (superclass.getFullyQualifiedName().equals(originalClassFullyQualifiedName)) {
            return false;
        }

        IMethod method = methodFinder.findMethodWithNameAndParameters(superclass, methodName, methodParameterTypes);
        if (method != null) {
            return !Flags.isAbstract(method.getFlags());
        }
    }

    return false;
}
 
Example 3
Source File: JavaElementDelegateJunitLaunch.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected IType[] getAllSuperTypes(IType type) throws JavaModelException {
	/*
	 * https://stackoverflow.com/questions/49611587/developing-a-eclipse-how-to-get-all-inherited-methods-from-a-icompilationunit
	 */
	ITypeHierarchy th = type.newTypeHierarchy(new NullProgressMonitor());
	IType[] superTypes = th.getAllSuperclasses(type);
	return superTypes;
}
 
Example 4
Source File: DialogFactoryHelperImpl.java    From jenerate with Eclipse Public License 1.0 5 votes vote down vote up
private IField[] getNonStaticNonCacheFieldsAndAccessibleNonStaticFieldsOfSuperclasses(IType objectClass,
        PreferencesManager preferencesManager) throws JavaModelException {
    List<IField> result = new ArrayList<>();

    ITypeHierarchy typeHierarchy = objectClass.newSupertypeHierarchy(null);
    IType[] superclasses = typeHierarchy.getAllSuperclasses(objectClass);

    for (int i = 0; i < superclasses.length; i++) {
        IField[] fields = superclasses[i].getFields();

        boolean samePackage = objectClass.getPackageFragment().getElementName()
                .equals(superclasses[i].getPackageFragment().getElementName());

        for (int j = 0; j < fields.length; j++) {

            if (!samePackage && !Flags.isPublic(fields[j].getFlags()) && !Flags.isProtected(fields[j].getFlags())) {
                continue;
            }

            if (!Flags.isPrivate(fields[j].getFlags()) && !Flags.isStatic(fields[j].getFlags())) {
                result.add(fields[j]);
            }
        }
    }

    result.addAll(Arrays.asList(getNonStaticNonCacheFields(objectClass, preferencesManager)));

    return result.toArray(new IField[result.size()]);
}