From f6a5f71eee23c46793e3845461f27d85fc4dd90f Mon Sep 17 00:00:00 2001
From: Sebastian Bergemann <bergemann@fortiss.org>
Date: Tue, 26 Sep 2023 10:13:12 +0200
Subject: [PATCH] YELLOW

Issue-Ref: 4324
Issue-Url: https://git.fortiss.org/af3/af3/-/issues/4324

Signed-off-by: Sebastian Bergemann <bergemann@fortiss.org>
---
 .../src/org/fortiss/tooling/kernel/internal/.ratings   |  2 +-
 .../kernel/internal/ConstraintCheckerService.java      | 10 +++-------
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/internal/.ratings b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/internal/.ratings
index 6af5a8844..7cff8a5af 100644
--- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/internal/.ratings
+++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/internal/.ratings
@@ -1,7 +1,7 @@
 CommandLineInterfaceService.java 6b5c94c52702f773c60b181eff52204ab379b248 GREEN
 CommandStackService.java 957bda69b5feb91f002aed4d25ed334e92801e7e GREEN
 ConnectionCompositorService.java 5a52f8a3e88c167ae6909c3d9eb3fb4706177e8b GREEN
-ConstraintCheckerService.java 94f1c07c37520161065128d8faaab10ab0c041b0 RED
+ConstraintCheckerService.java df7b4e8c99e8895e14ff45a96cc85ef8403a8658 YELLOW
 DummyTopLevelElement.java 21807bbdafec2e0ef28f0ee9090218f90bd73aee GREEN
 ElementCompositorService.java b1924b5b349118a70149cfac5b48544897d26e9e GREEN
 LoggingService.java da784259f7b456b54bf75c41ec268f64919ce78d GREEN
diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/internal/ConstraintCheckerService.java b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/internal/ConstraintCheckerService.java
index 94f1c07c3..df7b4e8c9 100644
--- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/internal/ConstraintCheckerService.java
+++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/internal/ConstraintCheckerService.java
@@ -17,7 +17,7 @@ package org.fortiss.tooling.kernel.internal;
 
 import static java.util.Collections.emptyList;
 import static java.util.Collections.unmodifiableMap;
-import static org.fortiss.tooling.kernel.utils.EcoreUtils.getParentsWithType;
+import static org.fortiss.tooling.kernel.utils.EcoreUtils.getFirstParentWithType;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -132,14 +132,10 @@ public class ConstraintCheckerService extends EObjectAwareServiceBase<IConstrain
 
 		// Skip constraint checks if the given element itself is excluded from checks or if it
 		// exists within an excluded element.
-		// TODO (TM): Looking through all parents for each excluded type introduces quite an
-		// overhead. As the list of parents is never used, memory and runtime overhead can be
-		// reduced by using `getFirstParentWithType` or, even better, `isAncestor` instead.
 		for(Class<? extends EObject> excludedClass : constraintCheckExclusionTypes) {
-			List<? extends EObject> foundExcludedParents =
-					getParentsWithType(modelElement, excludedClass);
+			Object foundExcludedParent = getFirstParentWithType(modelElement, excludedClass);
 			Class<?> givenClass = modelElement.getClass();
-			if(givenClass.isAssignableFrom(excludedClass) || !foundExcludedParents.isEmpty()) {
+			if(givenClass.isAssignableFrom(excludedClass) || foundExcludedParent != null) {
 				return;
 			}
 		}
-- 
GitLab