/* (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
       }
     }
   }
 }
 /*
  * @see TypeHierarchyContentProvider.getTypesInHierarchy
  */
 @Override
 protected final void getTypesInHierarchy(IType type, List<IType> res) {
   ITypeHierarchy hierarchy = getHierarchy();
   if (hierarchy != null) {
     IType[] types = hierarchy.getSubtypes(type);
     if (isObject(type)) {
       for (int i = 0; i < types.length; i++) {
         IType curr = types[i];
         if (!isAnonymousFromInterface(
             curr)) { // no anonymous classes on 'Object' -> will be children of interface
           res.add(curr);
         }
       }
     } else {
       boolean isHierarchyOnType = (hierarchy.getType() != null);
       boolean isClass = !Flags.isInterface(hierarchy.getCachedFlags(type));
       if (isClass || isHierarchyOnType) {
         for (int i = 0; i < types.length; i++) {
           res.add(types[i]);
         }
       } else {
         for (int i = 0; i < types.length; i++) {
           IType curr = types[i];
           // no classes implementing interfaces, only if anonymous
           if (Flags.isInterface(hierarchy.getCachedFlags(curr)) || isAnonymous(curr)) {
             res.add(curr);
           }
         }
       }
     }
   }
 }
 public int getExpandLevel() {
   ITypeHierarchy hierarchy = getHierarchy();
   if (hierarchy != null) {
     IType input = hierarchy.getType();
     if (input != null) {
       return getDepth(hierarchy, input) + 2;
     } else {
       return 5;
     }
   }
   return 2;
 }