/* (non-Javadoc) * @see org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyContentProvider#getRootTypes(java.util.List) */ @Override protected final void getRootTypes(List<IType> res) { ITypeHierarchy hierarchy = getHierarchy(); if (hierarchy != null) { IType input = hierarchy.getType(); if (input == null) { IType[] classes = hierarchy.getRootClasses(); for (int i = 0; i < classes.length; i++) { res.add(classes[i]); } IType[] interfaces = hierarchy.getRootInterfaces(); for (int i = 0; i < interfaces.length; i++) { res.add(interfaces[i]); } } else { if (Flags.isInterface(hierarchy.getCachedFlags(input))) { res.add(input); } else if (isAnonymousFromInterface(input)) { res.add(hierarchy.getSuperInterfaces(input)[0]); } else { IType[] roots = hierarchy.getRootClasses(); for (int i = 0; i < roots.length; i++) { if (isObject(roots[i])) { res.add(roots[i]); return; } } res.addAll(Arrays.asList(roots)); // something wrong with the hierarchy } } } }
public static XArrayList<IJavaElement> getSuperInterfaces(IJavaElement type) throws Exception { ITypeHierarchy h = ((IType) type).newTypeHierarchy(null); return IJavaElementAnalyzer.convertArray2XArrayList(h.getSuperInterfaces((IType) type)); }