From 6384361f0f481de89b39ff542311807f72bcc019 Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Thu, 7 May 2020 23:32:43 +0300 Subject: [PATCH] Fix GetComponentLocation to work with procedural UC instances Previously it would return ComponentLocation.isInsideStructure = false for Variables representing the insides of a procedural UC instance. gitlab #532 Change-Id: I26ae30c8e4217e7c4cde03b884604ee59aa7e85b (cherry picked from commit d8f1f7da4d84424402812f1aa5deed6112f4c665) --- .../structural2/queries/GetComponentLocation.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bundles/org.simantics.structural2/src/org/simantics/structural2/queries/GetComponentLocation.java b/bundles/org.simantics.structural2/src/org/simantics/structural2/queries/GetComponentLocation.java index df6e1598c..e109f59e8 100644 --- a/bundles/org.simantics.structural2/src/org/simantics/structural2/queries/GetComponentLocation.java +++ b/bundles/org.simantics.structural2/src/org/simantics/structural2/queries/GetComponentLocation.java @@ -66,10 +66,16 @@ public class GetComponentLocation extends UnaryRead 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) { -- 2.47.1