From 6483fcee34ae87ee814a43b5d19eca94451b16d6 Mon Sep 17 00:00:00 2001 From: Tiziano Munaro <munaro@fortiss.org> Date: Fri, 19 Feb 2021 14:18:46 +0100 Subject: [PATCH] GREEN Minor modifications: * Adapt parameter names to the other implementations of `getChildrenWithType` Issue-Ref: 4104 Issue-Url: https://git.fortiss.org/af3/af3/-/issues/4104 Signed-off-by: Tiziano Munaro <munaro@fortiss.org> --- .../org/fortiss/tooling/kernel/utils/.ratings | 2 +- .../tooling/kernel/utils/EcoreUtils.java | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/.ratings b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/.ratings index 6b4f47f2c..ae2a46518 100644 --- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/.ratings +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/.ratings @@ -1,7 +1,7 @@ CompositionUtils.java 34c0a191bd0fb4176c94b4d61abb5c88a679d5e8 GREEN EMFResourceUtils.java 68e6712a52349548bf85346900b17aa65b5f0ea9 GREEN EcoreSerializerBase.java 0a0c2969d793d2e68094c55c8f7b0a662ef6e5d5 GREEN -EcoreUtils.java c38ac59cd7abad71a03d8666bf0943b40b90e58d YELLOW +EcoreUtils.java 60e8b9f5ee65c775814f55c7ef22a57da38e7e77 GREEN ExtensionPointUtils.java 7ce63242b49eb9a7cd4eaadd223f5ebce1dfd75b GREEN HierarchicalNameComparator.java 6face1b673126701a0721af48ead2f9766c17d46 GREEN IdentifierUtils.java fff43dc4e84cdd89c3ece4f5d9d89aec4b0749c2 GREEN diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java index c38ac59cd..60e8b9f5e 100644 --- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/EcoreUtils.java @@ -273,20 +273,28 @@ public class EcoreUtils { /** * For the given {@code element}, return the most nested ancestors of type {@code clazz} that * does not have any ancestors of any of the {@code admissibleSpecializations}. + * + * @param parent + * the parent {@link EObject}. + * @param type + * the type. + * @param admissibleSpecializations + * {@link Collection} of admissible specializations of the given type. + * @return a list of children. */ @SuppressWarnings({"rawtypes", "unchecked"}) - public static <T extends EObject> Collection<T> getChildrenWithType(EObject element, - Class<T> clazz, Collection<Class<? extends T>> admissibleSpecializations) { + public static <T extends EObject> Collection<T> getChildrenWithType(EObject parent, + Class<T> type, Collection<Class<? extends T>> admissibleSpecializations) { Predicate<? super EObject> hasApplicableChildren = modelElement -> asStream(modelElement.eAllContents()) .anyMatch(c -> isAssignableFromAny((Collection)admissibleSpecializations, c.getClass())); - Stream<T> executionUnits = asStream(element.eAllContents()).filter(clazz::isInstance) - .filter(hasApplicableChildren.negate()).map(clazz::cast); + Stream<T> children = asStream(parent.eAllContents()).filter(type::isInstance) + .filter(hasApplicableChildren.negate()).map(type::cast); - return executionUnits.collect(toList()); + return children.collect(toList()); } /** -- GitLab