Skip to content

Commit f4d49e1

Browse files
committed
ST6RI-897 Updated custom importer so elementId is not used as an EMF ID.
- This avoids a possible infinite recursion in the construction of elementIds on demand.
1 parent 6102846 commit f4d49e1

6 files changed

Lines changed: 14 additions & 15 deletions

File tree

org.omg.kerml.xtext/src/org/omg/kerml/xtext/scoping/KerMLLinker.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2020-2021, 2024 Model Driven Solutions, Inc.
3+
* Copyright (c) 2020-2021, 2024, 2026 Model Driven Solutions, Inc.
44
* Copyright (c) 2024 Budapest University of Technology and Economics
55
*
66
* This program is free software: you can redistribute it and/or modify
@@ -47,14 +47,6 @@ public class KerMLLinker extends LazyLinker {
4747
@Inject
4848
private OnChangeEvictingCache cache;
4949

50-
@Override
51-
protected void clearReferences(EObject obj) {
52-
super.clearReferences(obj);
53-
if (obj instanceof Element) {
54-
ElementUtil.clean((Element)obj);
55-
}
56-
}
57-
5850
@Override
5951
protected void clearReference(EObject obj, EReference ref) {
6052
if (
@@ -72,10 +64,10 @@ protected void clearReference(EObject obj, EReference ref) {
7264
@Override
7365
protected void doLinkModel(EObject model, IDiagnosticConsumer consumer) {
7466
super.doLinkModel(model, consumer);
75-
postProcessAllCrossReferences(model);
67+
postProcessAll(model);
7668
}
7769

78-
protected void postProcessAllCrossReferences(EObject model) {
70+
protected void postProcessAll(EObject model) {
7971
cache.execWithoutCacheClear(model.eResource(), new IUnitOfWork.Void<Resource>() {
8072
@Override
8173
public void process(Resource state) throws Exception {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,25 @@ private void customConvert(DiagnosticChain diagnostics) {
4747
(((Property)element).isDerived() && !((Property)element).isDerivedUnion() ||
4848
"elementId".equals(((Property)element).getName())) ||
4949
element instanceof Operation && modelElement instanceof EOperation) {
50+
// Add SysML EAnnotation to derived properties (but not derived unions) and all operations
5051
String qualifiedName = ((NamedElement)element).getQualifiedName();
5152
addSysMLAnnotation(qualifiedName.substring(qualifiedName.indexOf("::") + 2), modelElement);
53+
if (element instanceof Property && "elementId".equals(((Property)element).getName())) {
54+
// Since elementId is to be treated as effectively derived, don't use it as an ID
55+
// internally to Eclipse.
56+
((EAttribute)modelElement).setID(false);
57+
}
5258
} else if (element instanceof org.eclipse.uml2.uml.Class && modelElement instanceof EClass) {
5359
String name = ((org.eclipse.uml2.uml.Class)element).getName();
5460
EClass eClass = (EClass)modelElement;
5561
if ("Feature".equals(name)) {
62+
// Add the "isNonunique" attribute as the effective logical inverse of "isUnique".
5663
EClassifier booleanType = eClass.getEStructuralFeature("isUnique").getEType();
5764
EAttribute isNonUniqueAttribute = EcoreFactory.eINSTANCE.createEAttribute();
5865
addStructuralFeature(eClass, isNonUniqueAttribute, "isNonunique", booleanType, 1, 1, "false", false);
5966
addSysMLAnnotation("Feature::isNonUnique", isNonUniqueAttribute);
6067
} else if ("InvocationExpression".equals(name)) {
68+
// Add the "operand" reference as a workaround for parsing operator expression arguments.
6169
EClassifier expressionClass = eClass.getEStructuralFeature("argument").getEType();
6270
EReference operandReference = EcoreFactory.eINSTANCE.createEReference();
6371
addStructuralFeature(eClass, operandReference, "operand", expressionClass, 0, -1, null, true);

org.omg.sysml/model/SysML.ecore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@
977977
<eAnnotations source="http://www.omg.org/spec/SysML"/>
978978
</eStructuralFeatures>
979979
<eStructuralFeatures xsi:type="ecore:EAttribute" name="elementId" ordered="false"
980-
lowerBound="1" eType="ecore:EDataType types.ecore#//String" iD="true">
980+
lowerBound="1" eType="ecore:EDataType types.ecore#//String">
981981
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
982982
<details key="documentation" value="&lt;p>The globally unique identifier for this Element. This is intended to be set by tooling, and it must not change during the lifetime of the Element.&lt;/p>"/>
983983
</eAnnotations>

org.omg.sysml/src/org/omg/sysml/adapter/ElementAdapter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ public boolean isTransformed() {
124124
}
125125

126126
public void clearCaches() {
127-
elementId = null;
128127
}
129128

130129
public void transform() {

org.omg.sysml/syntax-gen/org/omg/sysml/lang/sysml/Element.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public interface Element extends EObject {
210210
* @return the value of the '<em>Element Id</em>' attribute.
211211
* @see #setElementId(String)
212212
* @see org.omg.sysml.lang.sysml.SysMLPackage#getElement_ElementId()
213-
* @model id="true" dataType="org.omg.sysml.lang.types.String" required="true" ordered="false"
213+
* @model dataType="org.omg.sysml.lang.types.String" required="true" ordered="false"
214214
* annotation="http://www.omg.org/spec/SysML"
215215
* @generated
216216
*/

org.omg.sysml/syntax-gen/org/omg/sysml/lang/sysml/impl/SysMLPackageImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9578,7 +9578,7 @@ public void initializePackageContents() {
95789578
initEReference(getElement_OwnedRelationship(), this.getRelationship(), this.getRelationship_OwningRelatedElement(), "ownedRelationship", null, 0, -1, Element.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
95799579
initEReference(getElement_OwningRelationship(), this.getRelationship(), this.getRelationship_OwnedRelatedElement(), "owningRelationship", null, 0, 1, Element.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED);
95809580
initEReference(getElement_OwningNamespace(), this.getNamespace(), this.getNamespace_OwnedMember(), "owningNamespace", null, 0, 1, Element.class, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, !IS_ORDERED);
9581-
initEAttribute(getElement_ElementId(), theTypesPackage.getString(), "elementId", null, 1, 1, Element.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED);
9581+
initEAttribute(getElement_ElementId(), theTypesPackage.getString(), "elementId", null, 1, 1, Element.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED);
95829582
initEReference(getElement_Owner(), this.getElement(), this.getElement_OwnedElement(), "owner", null, 0, 1, Element.class, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, !IS_ORDERED);
95839583
initEReference(getElement_OwnedElement(), this.getElement(), this.getElement_Owner(), "ownedElement", null, 0, -1, Element.class, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED);
95849584
initEReference(getElement_Documentation(), this.getDocumentation(), this.getDocumentation_DocumentedElement(), "documentation", null, 0, -1, Element.class, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED);

0 commit comments

Comments
 (0)