]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Fix GetComponentLocation to work with procedural UC instances 20/4220/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 7 May 2020 20:32:43 +0000 (23:32 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 7 May 2020 20:32:43 +0000 (23:32 +0300)
Previously it would return ComponentLocation.isInsideStructure = false
for Variables representing the insides of a procedural UC instance.

gitlab #532

Change-Id: I26ae30c8e4217e7c4cde03b884604ee59aa7e85b

bundles/org.simantics.structural2/src/org/simantics/structural2/queries/GetComponentLocation.java

index df6e1598c2649312442e3acae4c7186b4bc329c3..e109f59e89538b3574f2abe73c67b39355674a56 100644 (file)
@@ -66,10 +66,16 @@ public class GetComponentLocation extends UnaryRead<Variable, ComponentLocation>
         Variable firstRepresentedParent = findFirstParentWithRepresentation(graph, parameter, STR);
         if (firstRepresentedParent == null)
             return null;
         Variable firstRepresentedParent = findFirstParentWithRepresentation(graph, parameter, STR);
         if (firstRepresentedParent == null)
             return null;
-        Resource realParentComposite = graph.getPossibleObject(firstRepresentedParent.getRepresents(graph), L0.PartOf);
-        if (realParentComposite == null)
-            return null;
-        isInsideStructure = graph.hasStatement(realParentComposite, STR.Defines);
+        Resource representedParent = firstRepresentedParent.getRepresents(graph);
+        Resource representedParentType = graph.getPossibleType(representedParent, STR.Component);
+        if (representedParentType != null && graph.isInstanceOf(representedParentType, STR.ProceduralComponentType)) {
+            isInsideStructure = !parameter.equals(firstRepresentedParent);
+        } else {
+            Resource realParentComposite = graph.getPossibleObject(representedParent, L0.PartOf);
+            if (realParentComposite == null)
+                return null;
+            isInsideStructure = graph.hasStatement(realParentComposite, STR.Defines);
+        }
 
         Variable firstParentComposite = findFirstParentComposite(graph, firstRepresentedParent, STR);
         if (firstParentComposite != null) {
 
         Variable firstParentComposite = findFirstParentComposite(graph, firstRepresentedParent, STR);
         if (firstParentComposite != null) {