Ejemplo n.º 1
0
 private static void populateClasses(
     final Shell shell, final IParent parent, final List<IType> types, final Filter filter) {
   try {
     for (final IJavaElement element : parent.getChildren()) {
       if (element instanceof IType) {
         final IType type = (IType) element;
         if (type.isClass()
             && type.isStructureKnown()
             && !type.isAnonymous()
             && !type.isLocal()
             && !Flags.isAbstract(type.getFlags())
             && Flags.isPublic(type.getFlags())
             && (filter == null || filter.accept(type))) {
           types.add(type);
         }
       } else if (element instanceof IParent
           && !element.getPath().toString().contains("/test/")
           && (!(element instanceof IPackageFragmentRoot)
               || !((IPackageFragmentRoot) element).isExternal())) {
         populateClasses(shell, (IParent) element, types, filter);
       }
     }
   } catch (final JavaModelException e) {
     Activator.error(e);
   }
 }
 private IJavaElement visit(IParent parent) {
   try {
     for (IJavaElement child : parent.getChildren()) {
       IJavaElement elementFound = visit(child);
       if (elementFound != null) {
         return elementFound;
       }
     }
   } catch (JavaModelException e) {
     e.printStackTrace();
   }
   return null;
 }