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

The following examples show how to use org.eclipse.jdt.core.ITypeHierarchy#getSuperInterfaces() . 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: JavaModelUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static boolean isSuperType(ITypeHierarchy hierarchy, IType possibleSuperType, IType type) {
	// filed bug 112635 to add this method to ITypeHierarchy
	IType superClass= hierarchy.getSuperclass(type);
	if (superClass != null && (possibleSuperType.equals(superClass) || isSuperType(hierarchy, possibleSuperType, superClass))) {
		return true;
	}
	if (Flags.isInterface(hierarchy.getCachedFlags(possibleSuperType))) {
		IType[] superInterfaces= hierarchy.getSuperInterfaces(type);
		for (int i= 0; i < superInterfaces.length; i++) {
			IType curr= superInterfaces[i];
			if (possibleSuperType.equals(curr) || isSuperType(hierarchy, possibleSuperType, curr)) {
				return true;
			}
		}
	}
	return false;
}
 
Example 2
Source File: JavaModelSearch.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private static IMethod findMethodOrCtorInHierarchy(ITypeHierarchy hierarchy,
    IType type, String methodName, String[] paramTypes, boolean isConstructor) {
  IMethod method = findMethodOrCtor(type, methodName, paramTypes,
      isConstructor);
  if (method != null) {
    return method;
  }

  // Check super class
  IType superClass = hierarchy.getSuperclass(type);
  if (superClass != null) {
    method = findMethodOrCtorInHierarchy(hierarchy, superClass, methodName,
        paramTypes, isConstructor);
    if (method != null) {
      return method;
    }
  }

  if (!isConstructor) {
    // Check interfaces
    IType[] superInterfaces = hierarchy.getSuperInterfaces(type);
    for (IType superInterface : superInterfaces) {
      method = findMethodOrCtorInHierarchy(hierarchy, superInterface,
          methodName, paramTypes, false);
      if (method != null) {
        return method;
      }
    }
  }

  return method;
}