Skip to content

Commit 57600ec

Browse files
authored
Merge pull request #554 from Systems-Modeling/ST6RI-684
ST6RI-684 Implement invocation delegates for operations
2 parents c48c17a + 32e3509 commit 57600ec

463 files changed

Lines changed: 7337 additions & 1619 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
package org.omg.kerml.xpect;
22

3+
import org.eclipse.emf.ecore.EOperation;
34
import org.eclipse.emf.ecore.EStructuralFeature;
45
import org.eclipse.xpect.xtext.lib.tests.XtextTests;
56
import org.junit.BeforeClass;
6-
import org.omg.sysml.delegate.DerivedPropertySettingDelegateFactory;
7+
import org.omg.sysml.delegate.setting.DerivedPropertySettingDelegateFactory;
8+
import org.omg.sysml.delegate.invocation.OperationInvocationDelegateFactory;
79

810
public class KerMLXtextTests extends XtextTests {
911

1012
@BeforeClass
1113
public static void setup() {
1214
EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.
1315
put(DerivedPropertySettingDelegateFactory.SYSML_ANNOTATION, new DerivedPropertySettingDelegateFactory());
16+
EOperation.Internal.InvocationDelegate.Factory.Registry.INSTANCE.
17+
put(OperationInvocationDelegateFactory.SYSML_ANNOTATION, new OperationInvocationDelegateFactory());
1418
}
1519

1620
}

org.omg.kerml.xtext/src/org/omg/kerml/xtext/KerMLStandaloneSetup.xtend

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
package org.omg.kerml.xtext
55

66
import org.eclipse.emf.ecore.EStructuralFeature
7-
import org.omg.sysml.delegate.DerivedPropertySettingDelegateFactory;
7+
import org.omg.sysml.delegate.setting.DerivedPropertySettingDelegateFactory;
8+
import org.omg.sysml.delegate.invocation.OperationInvocationDelegateFactory;
89
import com.google.inject.Injector
10+
import org.eclipse.emf.ecore.EOperation
911

1012
/**
1113
* Initialization support for running Xtext languages without Equinox extension registry.
@@ -18,7 +20,9 @@ class KerMLStandaloneSetup extends KerMLStandaloneSetupGenerated {
1820

1921
override Injector createInjectorAndDoEMFRegistration() {
2022
EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.
21-
put("http://www.omg.org/spec/SysML", new DerivedPropertySettingDelegateFactory());
23+
put(DerivedPropertySettingDelegateFactory.SYSML_ANNOTATION, new DerivedPropertySettingDelegateFactory());
24+
EOperation.Internal.InvocationDelegate.Factory.Registry.INSTANCE.
25+
put(OperationInvocationDelegateFactory.SYSML_ANNOTATION, new OperationInvocationDelegateFactory());
2226
return super.createInjectorAndDoEMFRegistration();
2327
}
2428
}

org.omg.kerml.xtext/src/org/omg/kerml/xtext/naming/KerMLQualifiedNameConverter.xtend

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -42,52 +42,14 @@ class KerMLQualifiedNameConverter implements IQualifiedNameConverter {
4242

4343
Preconditions.checkArgument(!qualifiedNameAsText.empty, "Qualified name cannot be empty")
4444

45-
val segments = newArrayList
46-
var i = 0
47-
var j = 0;
48-
var n = qualifiedNameAsText.length()
49-
var isDelimitable = true
50-
51-
while (j < n) {
52-
val c = qualifiedNameAsText.charAt(j)
53-
val delim = "\'\\:".indexOf(c)
54-
if (isDelimitable && delim > 1) {
55-
if (j + 1 < n && ":". indexOf(qualifiedNameAsText.charAt(j + 1)) == 0) {
56-
segments.add(ElementUtil.unescapeString(qualifiedNameAsText.substring(i, j)));
57-
i = j + 2;
58-
j = i - 1;
59-
}
60-
} else if (delim == 0) {
61-
isDelimitable = !isDelimitable
62-
} else if (delim == 1) {
63-
j++
64-
}
65-
j++
66-
}
67-
if (i < n && j <= n) {
68-
segments.add(ElementUtil.unescapeString(qualifiedNameAsText.substring(i, j)));
69-
}
70-
45+
val segments = ElementUtil.parseQualifiedName(qualifiedNameAsText)
7146
QualifiedName.create(segments)
7247
}
7348

7449
override toString(QualifiedName name) {
75-
if (name === null)
76-
throw new IllegalArgumentException("Qualified name cannot be null")
77-
val segmentCount = name.getSegmentCount
78-
switch (segmentCount) {
79-
case 0: return ""
80-
case 1: return ElementUtil.escapeName(name.getFirstSegment)
81-
default: {
82-
val builder = new StringBuilder;
83-
builder.append(ElementUtil.escapeName(name.getFirstSegment))
84-
for (var i = 1; i < segmentCount; i++) {
85-
builder.append("::")
86-
builder.append(ElementUtil.escapeName(name.getSegment(i)))
87-
}
88-
return builder.toString()
89-
}
90-
}
50+
Preconditions.checkArgument(name !== null, "Qualified name cannot be null")
51+
52+
ElementUtil.toQualifiedNameString(name.segments)
9153
}
9254

9355
}

org.omg.sysml.uml.ecore.importer/src/org/omg/sysml/uml/ecore/importer/CustomUML2EcoreConverter.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
import org.eclipse.emf.ecore.EClassifier;
1111
import org.eclipse.emf.ecore.EModelElement;
1212
import org.eclipse.emf.ecore.EObject;
13+
import org.eclipse.emf.ecore.EOperation;
1314
import org.eclipse.emf.ecore.EReference;
1415
import org.eclipse.emf.ecore.EStructuralFeature;
1516
import org.eclipse.emf.ecore.EcoreFactory;
1617
import org.eclipse.uml2.uml.Element;
18+
import org.eclipse.uml2.uml.NamedElement;
19+
import org.eclipse.uml2.uml.Operation;
1720
import org.eclipse.uml2.uml.Property;
1821
import org.eclipse.uml2.uml.util.UMLUtil.UML2EcoreConverter;
1922

@@ -39,15 +42,13 @@ private void customConvert(DiagnosticChain diagnostics) {
3942
for (Entry<Element, EModelElement> entry : elementToEModelElementMap.entrySet()) {
4043
Element element = entry.getKey();
4144
EModelElement modelElement = entry.getValue();
42-
if (element instanceof Property && modelElement instanceof EStructuralFeature) {
43-
Property property = (Property)element;
44-
if (property.isDerived() && !property.isDerivedUnion()) {
45-
String qualifiedName = property.getQualifiedName();
46-
System.out.println("Add annotation: " + qualifiedName.substring(qualifiedName.indexOf("::") + 2));
47-
EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
48-
annotation.setSource(ANNOTATION_SYSML);
49-
modelElement.getEAnnotations().add(annotation);
50-
}
45+
if (element instanceof Property && ((Property)element).isDerived() && !((Property)element).isDerivedUnion() && modelElement instanceof EStructuralFeature ||
46+
element instanceof Operation && modelElement instanceof EOperation) {
47+
String qualifiedName = ((NamedElement)element).getQualifiedName();
48+
System.out.println("Add annotation: " + qualifiedName.substring(qualifiedName.indexOf("::") + 2));
49+
EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
50+
annotation.setSource(ANNOTATION_SYSML);
51+
modelElement.getEAnnotations().add(annotation);
5152
} else if (element instanceof org.eclipse.uml2.uml.Class && modelElement instanceof EClass) {
5253
String name = ((org.eclipse.uml2.uml.Class)element).getName();
5354
EClass eClass = (EClass)modelElement;

org.omg.sysml.uml.ecore.importer/src/org/omg/sysml/uml/ecore/importer/CustomUMLImporter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public class CustomUMLImporter extends UMLImporter {
6060
private static final String BASE_PACKAGE = "org.omg.sysml.lang";
6161
private static final String TYPES_URI = "https://www.omg.org/spec/UML/20161101/PrimitiveTypes";
6262
private static final String SETTING_DELEGATES_KEY = "settingDelegates";
63+
private static final String INVOCATION_DELEGATES_KEY = "invocationDelegates";
6364

6465
/*
6566
* MOSTLY FORKED FROM org.eclipse.uml2.uml.ecore.importer.UMLImporter except for
@@ -146,6 +147,7 @@ protected void processEcoreTaggedValues(EPackage ePackage, Element element, Map<
146147
EAnnotation annotation = EcoreFactory.eINSTANCE.createEAnnotation();
147148
annotation.setSource(EcorePackage.eNS_URI);
148149
annotation.getDetails().put(SETTING_DELEGATES_KEY, CustomUML2EcoreConverter.ANNOTATION_SYSML);
150+
annotation.getDetails().put(INVOCATION_DELEGATES_KEY, CustomUML2EcoreConverter.ANNOTATION_SYSML);
149151
ePackage.getEAnnotations().add(annotation);
150152
}
151153

org.omg.sysml/META-INF/MANIFEST.MF

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ Require-Bundle: org.eclipse.xtext,
2727
org.eclipse.uml2.uml.resources
2828
Export-Package: org.omg.sysml,
2929
org.omg.sysml.adapter,
30+
org.omg.sysml.api,
31+
org.omg.sysml.delegate.setting,
32+
org.omg.sysml.delegate.invocation,
3033
org.omg.sysml.expressions,
3134
org.omg.sysml.expressions.util,
32-
org.omg.sysml.api,
33-
org.omg.sysml.delegate,
3435
org.omg.sysml.lang.sysml,
3536
org.omg.sysml.lang.sysml.impl,
3637
org.omg.sysml.lang.sysml.util,

0 commit comments

Comments
 (0)