/** * Within a given factory, returns all the program elements that match the filter. * * @param <E> the type of the seeked program elements * @param factory the factory that contains the elements where to recursive search on * @param filter the filter which defines the matching criteria */ public static <E extends CtElement> List<E> getElements(Factory factory, Filter<E> filter) { List<E> e = new ArrayList<E>(); for (CtPackage p : factory.Package().getAllRoots()) { e.addAll(getElements(p, filter)); } return e; }
/** * Within a given factory, returns all the program element references that match the filter. * * @param <R> the type of the seeked program element references * @param factory the factory that contains the references where to recursive search on * @param filter the filter which defines the matching criteria */ public static <R extends CtReference> List<R> getReferences( Factory factory, ReferenceFilter<R> filter) { List<R> r = new ArrayList<R>(); for (CtPackage p : factory.Package().getAllRoots()) { r.addAll(getReferences(p, filter)); } return r; }