From c5b3cfcab4d70901731f74b06874ed69bc1b5ba5 Mon Sep 17 00:00:00 2001 From: Tommaso Fonda Date: Wed, 2 Oct 2024 08:45:51 +0200 Subject: [PATCH] EcoreUtil2: Introduce getAllContentsOfType() for resources 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. --- org.eclipse.xtext/src/org/eclipse/xtext/EcoreUtil2.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/org.eclipse.xtext/src/org/eclipse/xtext/EcoreUtil2.java b/org.eclipse.xtext/src/org/eclipse/xtext/EcoreUtil2.java index 9ecc61c07db..8899debe96a 100644 --- a/org.eclipse.xtext/src/org/eclipse/xtext/EcoreUtil2.java +++ b/org.eclipse.xtext/src/org/eclipse/xtext/EcoreUtil2.java @@ -189,6 +189,10 @@ public static List getAllContentsOfType(EObject ele, Clas return Lists.newArrayList(Iterators.filter(ele.eAllContents(), type)); } + public static List getAllContentsOfType(Resource resource, Class type) { + return Lists.newArrayList(Iterators.filter(resource.getAllContents(), type)); + } + public static List typeSelect(List elements, Class clazz) { return Lists.newArrayList(Iterables.filter(elements, clazz)); }