diff options
author | Ed Willink | 2016-10-19 10:08:48 +0000 |
---|---|---|
committer | Ed Willink | 2016-10-19 10:08:48 +0000 |
commit | f4936785040cfbfe2c8bd98a53fc2b70b9cbd63a (patch) | |
tree | fd36bd42a4826a230dfc3e84f5f675304e2258f0 | |
parent | 42e2ecaabbda171ca6cadcd6b247ba18e3755206 (diff) | |
download | org.eclipse.ocl-f4936785040cfbfe2c8bd98a53fc2b70b9cbd63a.tar.gz org.eclipse.ocl-f4936785040cfbfe2c8bd98a53fc2b70b9cbd63a.tar.xz org.eclipse.ocl-f4936785040cfbfe2c8bd98a53fc2b70b9cbd63a.zip |
[506191] Avoid using non-OCL OpaqueExpression bodies
3 files changed, 53 insertions, 1 deletions
diff --git a/plugins/org.eclipse.ocl.pivot.uml/src/org/eclipse/ocl/pivot/uml/internal/es2as/UML2AS.java b/plugins/org.eclipse.ocl.pivot.uml/src/org/eclipse/ocl/pivot/uml/internal/es2as/UML2AS.java index 6286721b72..afaf35d7d5 100644 --- a/plugins/org.eclipse.ocl.pivot.uml/src/org/eclipse/ocl/pivot/uml/internal/es2as/UML2AS.java +++ b/plugins/org.eclipse.ocl.pivot.uml/src/org/eclipse/ocl/pivot/uml/internal/es2as/UML2AS.java @@ -1181,8 +1181,9 @@ public abstract class UML2AS extends AbstractExternal2AS } } } + pivotElement.setBody(umlBody); + break; } - pivotElement.setBody(umlBody); } copyNamedElement(pivotElement, umlExpression); return pivotElement; diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/UMLValidateTest.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/UMLValidateTest.java index a4cf89b4d3..9e02b52f2a 100644 --- a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/UMLValidateTest.java +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/UMLValidateTest.java @@ -774,4 +774,23 @@ public class UMLValidateTest extends AbstractValidateTests assertUMLOCLValidationDiagnostics(ocl, "UML Load", umlResource); ocl.dispose(); } + + public void test_umlValidation_Bug506191() throws IOException { + resetRegistries(); + CommonOptions.DEFAULT_DELEGATION_MODE.setDefaultValue(PivotConstants.OCL_DELEGATE_URI_PIVOT); + if (EcorePlugin.IS_ECLIPSE_RUNNING) { + new CommonPreferenceInitializer().initializeDefaultPreferences(); + } + OCL ocl = createOCL(); + ResourceSet resourceSet = ocl.getResourceSet(); + org.eclipse.ocl.ecore.delegate.OCLDelegateDomain.initialize(resourceSet); + OCLDelegateDomain.initializePivotOnlyDiagnosticianResourceSet(resourceSet); + @SuppressWarnings("null")@NonNull Resource umlResource = doLoadUML(ocl, "Bug506191"); + assertNoResourceErrors("Loading", umlResource); + Map<Object, Object> validationContext = LabelUtil.createDefaultContext(Diagnostician.INSTANCE); + OCLDelegateDomain.initializePivotOnlyDiagnosticianContext(validationContext); + assertValidationDiagnostics("Loading", umlResource, validationContext); + assertUMLOCLValidationDiagnostics(ocl, "UML Load", umlResource); + ocl.dispose(); + } } diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/models/Bug506191.uml b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/models/Bug506191.uml new file mode 100644 index 0000000000..388aa10673 --- /dev/null +++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/models/Bug506191.uml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<uml:Model xmi:version="20131001" xmlns:xmi="http://www.omg.org/spec/XMI/20131001" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xmi:id="_1rkn0JU2EeamVLgE08A0wA" name="RootElement"> + <packagedElement xmi:type="uml:Class" xmi:id="_2uVFUJU2EeamVLgE08A0wA" name="Test"> + <ownedRule xmi:type="uml:Constraint" xmi:id="_BDrIgJU3EeamVLgE08A0wA" name="Working-Single-Language"> + <specification xmi:type="uml:OpaqueExpression" xmi:id="_PpQ44JU3EeamVLgE08A0wA"> + <language>OCL</language> + <body>self.name->includes('toto')</body> + </specification> + </ownedRule> + <ownedRule xmi:type="uml:Constraint" xmi:id="_QV-N4JU3EeamVLgE08A0wA" name="Not-Working-Multi-Language"> + <specification xmi:type="uml:OpaqueExpression" xmi:id="_ad5gIJU3EeamVLgE08A0wA"> + <language>OCL</language> + <language>Other</language> + <body>self.name->includes('toto')</body> + <body>This is not OCL should be ignored</body> + </specification> + </ownedRule> + <ownedRule xmi:type="uml:Constraint" xmi:id="_pJeyQJXQEeaMubR7Ni7AWA" name="Working-Multi-Language-Order-Matters"> + <specification xmi:type="uml:OpaqueExpression" xmi:id="_sq9U8JXQEeaMubR7Ni7AWA"> + <language>Other</language> + <language>OCL</language> + <body>This is not OCL should be ignored</body> + <body>self.name->includes('toto')</body> + </specification> + </ownedRule> + <ownedAttribute xmi:type="uml:Property" xmi:id="_312uEJU2EeamVLgE08A0wA" name="name" visibility="public"> + <type xmi:type="uml:PrimitiveType" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#String"/> + <lowerValue xmi:type="uml:LiteralInteger" xmi:id="__H1t8JU2EeamVLgE08A0wA"/> + <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="__H-34JU2EeamVLgE08A0wA" value="*"/> + </ownedAttribute> + </packagedElement> +</uml:Model> |