Skip to content

Commit

Permalink
EcoreUtil2: Introduce getAllContentsOfType() for resources
Browse files Browse the repository at this point in the history
EcoreUtil2 already contains several methods that come in two variants,
one for EObjects and one for Resources. getAllContentsOfType() lacks a
Resource variant, so introduce it to simplify Resource querying.
  • Loading branch information
tfonda-fbk committed Oct 2, 2024
1 parent 76cf645 commit c5b3cfc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions org.eclipse.xtext/src/org/eclipse/xtext/EcoreUtil2.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ public static <T extends EObject> List<T> getAllContentsOfType(EObject ele, Clas
return Lists.newArrayList(Iterators.filter(ele.eAllContents(), type));
}

public static <T extends EObject> List<T> getAllContentsOfType(Resource resource, Class<T> type) {
return Lists.newArrayList(Iterators.filter(resource.getAllContents(), type));
}

public static <T> List<T> typeSelect(List<?> elements, Class<T> clazz) {
return Lists.newArrayList(Iterables.filter(elements, clazz));
}
Expand Down

0 comments on commit c5b3cfc

Please sign in to comment.