diff options
| author | Florian Barbin | 2017-05-18 12:10:20 +0000 |
|---|---|---|
| committer | Pierre-Charles David | 2017-05-19 12:48:29 +0000 |
| commit | d0c751786c8aaa67514c92c910984e501ce13e84 (patch) | |
| tree | 1197ce36ab5ea10561a413b565d651bd170968cf | |
| parent | 590c32b265f58127ef20ec54113526ad86ce4cc8 (diff) | |
| download | org.eclipse.sirius-d0c751786c8aaa67514c92c910984e501ce13e84.tar.gz org.eclipse.sirius-d0c751786c8aaa67514c92c910984e501ce13e84.tar.xz org.eclipse.sirius-d0c751786c8aaa67514c92c910984e501ce13e84.zip | |
[479049] Fix self variable for NodeCreation and ContainerCreation tools
The VSM context was inconsistent with the runtime context in
NodeCreation and ContainerCreation tools. The self variable was typed
according to the element created by the tool and not the container in
which the tool is applied.
Bug: 479049
Change-Id: I1e5ba43eacc935a7c60060af260c8ba9d8f5fab2
Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
2 files changed, 50 insertions, 58 deletions
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/description/DiagramInterpretedExpressionQuery.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/description/DiagramInterpretedExpressionQuery.java index 4b39759e76..31554b4c0b 100644 --- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/description/DiagramInterpretedExpressionQuery.java +++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/dialect/description/DiagramInterpretedExpressionQuery.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2015 THALES GLOBAL SERVICES. + * Copyright (c) 2011, 2017 THALES GLOBAL SERVICES and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -86,9 +86,8 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; /** - * Query allowing to get the target domain classes and available packages for a - * given Interpreted expression. This diagram query will treat all generic - * description elements and those related to the diagram concept. + * Query allowing to get the target domain classes and available packages for a given Interpreted expression. This + * diagram query will treat all generic description elements and those related to the diagram concept. * * @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a> * @@ -113,11 +112,10 @@ public class DiagramInterpretedExpressionQuery extends AbstractInterpretedExpres * Default constructor. * * @param target - * the target containing the InterpretedExpression (NodeMapping, - * ModelOperation...) + * the target containing the InterpretedExpression (NodeMapping, ModelOperation...) * @param feature - * the feature corresponding to the InterpretedExpression to - * evaluate ( NodeMapping.semanticCandidatesExpression...) + * the feature corresponding to the InterpretedExpression to evaluate ( + * NodeMapping.semanticCandidatesExpression...) */ public DiagramInterpretedExpressionQuery(EObject target, EStructuralFeature feature) { super(target, feature); @@ -191,12 +189,10 @@ public class DiagramInterpretedExpressionQuery extends AbstractInterpretedExpres Map<String, VariableType> availableVariables = super.getAvailableVariables(); /* - * [428757] tool variables are not displayed in autocompletion. This - * patch adds hard coded variables and hence is a temporary solution. - * The good way would be to put those metadata on the - * EdgeCreationDescription EClass in the diagram.ecore metamodel and to - * complete the AbstractInterpretedExpressionQuery to make it able to - * find specific variables for concrete types. + * [428757] tool variables are not displayed in autocompletion. This patch adds hard coded variables and hence + * is a temporary solution. The good way would be to put those metadata on the EdgeCreationDescription EClass in + * the diagram.ecore metamodel and to complete the AbstractInterpretedExpressionQuery to make it able to find + * specific variables for concrete types. */ if (target instanceof EdgeCreationDescription) { EdgeCreationDescription tool = (EdgeCreationDescription) target; @@ -236,10 +232,8 @@ public class DiagramInterpretedExpressionQuery extends AbstractInterpretedExpres } if (target instanceof ConditionalStyleDescription && this.feature == org.eclipse.sirius.viewpoint.description.DescriptionPackage.Literals.CONDITIONAL_STYLE_DESCRIPTION__PREDICATE_EXPRESSION) { /* - * We don't use the Ecore annotation to define the 'diagram' - * variable as it is only available for subclasses of - * ConditionalStyleDescription which are defined in the - * diagram.description EPackage. + * We don't use the Ecore annotation to define the 'diagram' variable as it is only available for subclasses + * of ConditionalStyleDescription which are defined in the diagram.description EPackage. */ availableVariables.put(IInterpreterSiriusVariables.DIAGRAM, VariableType.fromString(DIAGRAM_D_SEMANTIC_DIAGRAM)); } @@ -467,6 +461,7 @@ public class DiagramInterpretedExpressionQuery extends AbstractInterpretedExpres Collection<String> possibleViewTypes = Sets.newLinkedHashSet(); collectPotentialContainerTypes(possibleSemanticTypes, possibleViewTypes, tool.getNodeMappings()); + changeSelfType(VariableType.fromStrings(possibleSemanticTypes)); refineVariableType(availableVariables, IInterpreterSiriusVariables.CONTAINER, possibleSemanticTypes); refineVariableType(availableVariables, IInterpreterSiriusVariables.CONTAINER_VIEW, possibleViewTypes); } @@ -485,6 +480,7 @@ public class DiagramInterpretedExpressionQuery extends AbstractInterpretedExpres } Collection<String> possibleViewTypes = Sets.newLinkedHashSet(); collectPotentialContainerTypes(possibleTypes, possibleViewTypes, tool.getContainerMappings()); + changeSelfType(VariableType.fromStrings(possibleTypes)); refineVariableType(availableVariables, IInterpreterSiriusVariables.CONTAINER_VIEW, possibleViewTypes); refineVariableType(availableVariables, IInterpreterSiriusVariables.CONTAINER, possibleTypes); @@ -530,8 +526,7 @@ public class DiagramInterpretedExpressionQuery extends AbstractInterpretedExpres possibleViewTypes.add(DIAGRAM_D_SEMANTIC_DIAGRAM); } /* - * besides the container a mapping can be re-used by another one or by a - * diagram description. + * besides the container a mapping can be re-used by another one or by a diagram description. */ ECrossReferenceAdapter crossReferencer = ECrossReferenceAdapter.getCrossReferenceAdapter(mapping); if (crossReferencer != null) { @@ -637,9 +632,8 @@ public class DiagramInterpretedExpressionQuery extends AbstractInterpretedExpres } /** - * An {@link IInterpretedExpressionTargetSwitch} that delegates to the - * defaultSwitch or the diagram specific switch, according to the package of - * the considered element. + * An {@link IInterpretedExpressionTargetSwitch} that delegates to the defaultSwitch or the diagram specific switch, + * according to the package of the considered element. * * @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a> * diff --git a/plugins/org.eclipse.sirius.tests.junit/data/unit/vsm/validateVariableTypes.odesign b/plugins/org.eclipse.sirius.tests.junit/data/unit/vsm/validateVariableTypes.odesign index d2b36dcb7d..eff50a7d74 100644 --- a/plugins/org.eclipse.sirius.tests.junit/data/unit/vsm/validateVariableTypes.odesign +++ b/plugins/org.eclipse.sirius.tests.junit/data/unit/vsm/validateVariableTypes.odesign @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:description_2="http://www.eclipse.org/sirius/table/description/1.1.0" xmlns:filter="http://www.eclipse.org/sirius/diagram/description/filter/1.1.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:tool="http://www.eclipse.org/sirius/description/tool/1.1.0" xmlns:tool_1="http://www.eclipse.org/sirius/diagram/description/tool/1.1.0" xmlns:validation="http://www.eclipse.org/sirius/description/validation/1.1.0" name="vsmtypes" version="11.1.1.201610211630"> +<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" xmlns:description_2="http://www.eclipse.org/sirius/table/description/1.1.0" xmlns:filter="http://www.eclipse.org/sirius/diagram/description/filter/1.1.0" xmlns:style="http://www.eclipse.org/sirius/diagram/description/style/1.1.0" xmlns:tool="http://www.eclipse.org/sirius/description/tool/1.1.0" xmlns:tool_1="http://www.eclipse.org/sirius/diagram/description/tool/1.1.0" xmlns:validation="http://www.eclipse.org/sirius/description/validation/1.1.0" name="vsmtypes" version="12.0.0.2017041100"> <ownedViewpoints name="VSMTypes"> <ownedRepresentations xsi:type="description_1:DiagramDescription" name="SelfTypeInference" domainClass="interactions.Model"> <metamodel href="http://www.eclipse.org/sirius/sample/interactions#/"/> @@ -196,14 +196,14 @@ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:containerView"> <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:edges"/> </subModelOperations> - <subModelOperations xsi:type="tool:ChangeContext" browseExpression="aql:self.returnsAnEClassifier()"> - <subModelOperations xsi:type="tool:ChangeContext" browseExpression="aql:self.instanceClassName"/> + <subModelOperations xsi:type="tool:ChangeContext" browseExpression="aql:self.ownedInteractions"> + <subModelOperations xsi:type="tool:ChangeContext" browseExpression="aql:self.messages"/> </subModelOperations> - <subModelOperations xsi:type="tool:For" expression="aql:self.returnsAListOfEPackages()"> - <subModelOperations xsi:type="tool:ChangeContext" browseExpression="aql:i.nsURI"/> - <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:nsURI"/> + <subModelOperations xsi:type="tool:For" expression="aql:self.ownedInteractions"> + <subModelOperations xsi:type="tool:ChangeContext" browseExpression="aql:i.participants"/> + <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:interactionUses"/> </subModelOperations> - <subModelOperations xsi:type="tool:ChangeContext" browseExpression="aql:self.returnsANonEObjectType().message()"/> + <subModelOperations xsi:type="tool:ChangeContext" browseExpression="aql:self.ownedInteractions.combinedFragments"/> <subModelOperations xsi:type="tool:For" expression="aql:interactions" iteratorName="inter"> <subModelOperations xsi:type="tool:ChangeContext" browseExpression="aql:inter.executions"/> </subModelOperations> @@ -227,6 +227,7 @@ <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:containerView"> <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:edges"/> </subModelOperations> + <subModelOperations xsi:type="tool:CreateInstance" typeName="interactions::Interaction" referenceName="ownedInteractions"/> </firstModelOperations> </initialOperation> </ownedTools> @@ -236,7 +237,7 @@ <initialOperation> <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self"> <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self"> - <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:type"/> + <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:name"/> </subModelOperations> </firstModelOperations> </initialOperation> @@ -438,42 +439,36 @@ <viewVariable name="containerView"/> <initialOperation> <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:self"> - <subModelOperations xsi:type="tool:If" conditionExpression="aql:self.oclIsKindOf(interactions::Interaction)"> - <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:executions"/> - </subModelOperations> - <subModelOperations xsi:type="tool:If" conditionExpression="aql:self.oclIsKindOf(interactions::Participant)"> - <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:type"/> - </subModelOperations> - <subModelOperations xsi:type="tool:If" conditionExpression="aql:self.name <> null and self.oclIsKindOf(interactions::Interaction)"> - <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:executions"/> - </subModelOperations> - <subModelOperations xsi:type="tool:If" conditionExpression="aql:not self.oclIsKindOf(interactions::Interaction)"> - <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:type"/> + <subModelOperations xsi:type="tool:If" conditionExpression="aql:self.name <> null"> + <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:eAllContents"> + <subModelOperations xsi:type="tool:If" conditionExpression="aql:self.oclIsKindOf(interactions::Interaction)"/> + </subModelOperations> </subModelOperations> - <subModelOperations xsi:type="tool:Switch"> - <cases conditionExpression="aql:self.oclIsKindOf(interactions::Interaction)"> - <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:executions"/> - </cases> - <cases conditionExpression="aql:self.oclIsKindOf(interactions::Participant)"> - <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:type"/> - </cases> - <cases conditionExpression="aql:self.name <> null and self.oclIsKindOf(interactions::Interaction)"> - <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:executions"/> - </cases> - <cases conditionExpression="aql:not self.oclIsKindOf(interactions::Interaction)"> - <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:type"/> - </cases> - <default/> + <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:ownedInteractions"/> + <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:name"/> + <subModelOperations xsi:type="tool:CreateInstance" typeName="interactions::Interaction" referenceName="ownedInteractions"> + <subModelOperations xsi:type="tool:SetValue" featureName="name" valueExpression="test"/> + </subModelOperations> + <subModelOperations xsi:type="tool:For" expression="aql:self.eAllContents()"> + <subModelOperations xsi:type="tool:Switch"> + <cases conditionExpression="aql:i.oclIsKindOf(interactions::Interaction)"> + <subModelOperations xsi:type="tool:ChangeContext" browseExpression="aql:containerView"/> + </cases> + <cases conditionExpression="aql:i.oclIsKindOf(ecore::EObject)"> + <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:eClass"/> + </cases> + <default/> + </subModelOperations> </subModelOperations> </firstModelOperations> </initialOperation> </ownedTools> - <ownedTools xsi:type="tool:ToolDescription" name="GenericTool" precondition="aql:element.oclIsKindOf(interactions::Interaction) and elementView.oclIsKindOf(diagram::DNode)"> + <ownedTools xsi:type="tool:ToolDescription" name="GenericTool" precondition="aql:element.oclIsKindOf(interactions::Model) and elementView.oclIsKindOf(diagram::DNode)" forceRefresh="true"> <element name="element"/> <elementView name="elementView"/> <initialOperation> <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:element"> - <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:executions"/> + <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:ownedInteractions"/> <subModelOperations xsi:type="tool:ChangeContext" browseExpression="var:elementView"> <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:width"/> </subModelOperations> @@ -638,6 +633,7 @@ <initialOperation> <firstModelOperations xsi:type="tool:ChangeContext" browseExpression="var:container"> <subModelOperations xsi:type="tool:ChangeContext" browseExpression="feature:nonExistent"/> + <subModelOperations xsi:type="tool:CreateInstance" typeName="interactions::Interaction" referenceName="ownedInteraction"/> </firstModelOperations> </initialOperation> </ownedTools> @@ -757,6 +753,8 @@ </ownedColumnMappings> <intersection name="Intersection Message Participant" lineMapping="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='XTable']/@ownedLineMappings[name='Message%20Line']" columnMapping="//@ownedViewpoints[name='VSMTypes']/@ownedRepresentations[name='XTable']/@ownedColumnMappings.0" labelExpression="X" columnFinderExpression="aql:self.sendingEnd.context"> <directEdit> + <variables name="table" documentation="The current DTable."/> + <variables name="line" documentation="The DLine of the current DCell."/> <variables name="element" documentation="The currently edited element."/> <variables name="lineSemantic" documentation="The semantic element corresponding to the line."/> <variables name="columnSemantic" documentation="The semantic element corresponding to the column (only available for Intersection Mapping)."/> |
