/** Obtain all the documents of a known type owned by this owner. */ @SuppressWarnings("unchecked") public <T extends PadDocument> Collection<T> documents(Class<T> clazz) { List<T> filtered = new ArrayList<T>(); for (PadDocument doc : documents.values()) { if (clazz.isInstance(doc)) { filtered.add((T) doc); } } return filtered; }
public static void collectCompilationUnits( List<ICompilationUnit> result, IPackageFragmentRoot root) throws JavaModelException { IJavaElement[] elements = root.getChildren(); for (int j = 0; j < elements.length; ++j) { IPackageFragment p = (IPackageFragment) elements[j]; result.addAll(Arrays.asList(p.getCompilationUnits())); } }