Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmallet2017-04-20 15:29:04 +0000
committerPierre-Charles David2017-04-24 09:55:33 +0000
commit7c22a9a11913c468f5606e5b10470e2b2ceb99ea (patch)
tree541a868ec97d5685b1f523a66218c9bb68cbaf5e
parentf031bb11f67fdd68cb345e3c99ff2b830814f0bf (diff)
downloadorg.eclipse.sirius-7c22a9a11913c468f5606e5b10470e2b2ceb99ea.tar.gz
org.eclipse.sirius-7c22a9a11913c468f5606e5b10470e2b2ceb99ea.tar.xz
org.eclipse.sirius-7c22a9a11913c468f5606e5b10470e2b2ceb99ea.zip
[507778] Remove Stack Overflow with interpreter expression.
When an edgeMapping was referencing itself in its source variables, the interpreter expression was evaluating the edgeMaping and then its sourceVariable that was the edgeMaping and so and so. Therefore, the interpreter expression on adgeMapping have to not evaluate its self in sourceVariable. Bug: 507778 Change-Id: I83a1efbde6f1aab68e1d17106b9c4a7dcd663d4d Signed-off-by: jmallet <jessy.mallet@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/description/DiagramInterpretedExpressionTargetSwitch.java8
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/vsm/interpreted/expression/variables/DiagramVariablesTest.java29
2 files changed, 34 insertions, 3 deletions
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/description/DiagramInterpretedExpressionTargetSwitch.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/description/DiagramInterpretedExpressionTargetSwitch.java
index 0644851c3d..84638d0eda 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/description/DiagramInterpretedExpressionTargetSwitch.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/description/DiagramInterpretedExpressionTargetSwitch.java
@@ -284,9 +284,11 @@ public class DiagramInterpretedExpressionTargetSwitch extends DescriptionSwitch<
case DescriptionPackage.EDGE_MAPPING__SEMANTIC_ELEMENTS:
case DO_NOT_CONSIDER_FEATURE:
for (DiagramElementMapping mapping : edgeMapping.getSourceMapping()) {
- Option<Collection<String>> sourceMappingTarget = globalSwitch.doSwitch(mapping, false);
- if (sourceMappingTarget.some()) {
- target.addAll(sourceMappingTarget.get());
+ if (!(mapping.equals(edgeMapping))) {
+ Option<Collection<String>> sourceMappingTarget = globalSwitch.doSwitch(mapping, false);
+ if (sourceMappingTarget.some()) {
+ target.addAll(sourceMappingTarget.get());
+ }
}
}
result = Options.newSome(target);
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/vsm/interpreted/expression/variables/DiagramVariablesTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/vsm/interpreted/expression/variables/DiagramVariablesTest.java
index 9da0b43fbd..539d67c33f 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/vsm/interpreted/expression/variables/DiagramVariablesTest.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/vsm/interpreted/expression/variables/DiagramVariablesTest.java
@@ -23,6 +23,7 @@ import org.eclipse.sirius.common.tools.api.util.SiriusCrossReferenceAdapterImpl;
import org.eclipse.sirius.diagram.DiagramPackage;
import org.eclipse.sirius.diagram.description.DescriptionFactory;
import org.eclipse.sirius.diagram.description.DiagramDescription;
+import org.eclipse.sirius.diagram.description.EdgeMapping;
import org.eclipse.sirius.diagram.description.NodeMapping;
import org.eclipse.sirius.diagram.description.tool.CreateEdgeView;
import org.eclipse.sirius.diagram.description.tool.CreateView;
@@ -53,6 +54,34 @@ public class DiagramVariablesTest extends AbstractInterpretedExpressionTestCase
super.setUp();
}
+ /**
+ * Test that an interpreterContext for an edgeMapping referencing itself in its source variable is well build.
+ */
+ public void testIterpreterContextForEdgeDescriptionReferencingItSelf() {
+ // Setup
+ DiagramDescription diagramDescription = DescriptionFactory.eINSTANCE.createDiagramDescription();
+ diagramDescription.setDefaultLayer(DescriptionFactory.eINSTANCE.createLayer());
+
+ NodeMapping createNodeMapping = org.eclipse.sirius.diagram.description.DescriptionFactory.eINSTANCE
+ .createNodeMapping();
+ diagramDescription.getDefaultLayer().getNodeMappings().add(createNodeMapping);
+ createNodeMapping.setDomainClass("ecore.EClass");
+
+ EdgeMapping createEdgeMapping = org.eclipse.sirius.diagram.description.DescriptionFactory.eINSTANCE
+ .createEdgeMapping();
+ diagramDescription.getDefaultLayer().getEdgeMappings().add(createEdgeMapping);
+ createEdgeMapping.getSourceMapping().add(createNodeMapping);
+ createEdgeMapping.getSourceMapping().add(createEdgeMapping);
+
+ // Test
+ IInterpreterContext context = SiriusInterpreterContextFactory.createInterpreterContext(createEdgeMapping,
+ ToolPackage.Literals.ABSTRACT_TOOL_DESCRIPTION__PRECONDITION);
+
+ Set<String> variables = context.getVariables().keySet();
+ assertTrue("The interpreter context for " + createEdgeMapping.getName()
+ + " should contains the variable container", variables.contains("container"));
+ }
+
public void testInterpreterContextForAbstractToolPreconditionVariables() {
// Setup
DiagramDescription diagramDescription = DescriptionFactory.eINSTANCE.createDiagramDescription();

Back to the top