Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ It is now _Become nested Concern_ instead of _Become nested Requirement_.
- https://github.com/eclipse-syson/syson/issues/2397[#2397] [metamodel] Fix the resolution of the ends of a connector so the ends declared with the `end` keyword inside a connection body are taken into account.
Following KerML, where `endFeature` is defined as the owned features having `isEnd = true`, the ends owned through a plain `FeatureMembership` are now collected as well, and not only those owned through an `EndFeatureMembership`.
This also fixes `relatedFeature`, `sourceFeature` and `targetFeature`, which were all empty for such connections.
- https://github.com/eclipse-syson/syson/issues/2226[#2226] [import] Fix textual import of annotations on relationships so their `annotatedElement` is set and they are returned by `Element#getOwnedAnnotation()`.

=== Improvements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.eclipse.syson.services.UtilService;
import org.eclipse.syson.sysml.ActionDefinition;
import org.eclipse.syson.sysml.ActionUsage;
import org.eclipse.syson.sysml.Annotation;
import org.eclipse.syson.sysml.AttributeUsage;
import org.eclipse.syson.sysml.BindingConnectorAsUsage;
import org.eclipse.syson.sysml.ConjugatedPortDefinition;
Expand Down Expand Up @@ -208,7 +209,7 @@ public void removeExtraBacklash() throws IOException {
}).check(input);
}

@DisplayName("GIVEN an MetadataUsage annotating a ExposeMembership, WHEN importing the model, THEN the Annotation holding the MetadataUsage should be stored in ownedRelationships.")
@DisplayName("GIVEN a MetadataUsage annotating an ExposeMembership, WHEN importing the model, THEN the Annotation targets and is owned by the ExposeMembership.")
@Test
public void metadataUsageOnExposeMembership() throws IOException {
var input = """
Expand All @@ -228,6 +229,9 @@ public void metadataUsageOnExposeMembership() throws IOException {
List<MembershipExpose> membershipExposes = EMFUtils.allContainedObjectOfType(resource, MembershipExpose.class).toList();
assertThat(membershipExposes).hasSize(1);
assertThat(membershipExposes.get(0).getOwnedRelationship()).hasSize(1);
Annotation annotation = (Annotation) membershipExposes.get(0).getOwnedRelationship().get(0);
assertThat(annotation.getAnnotatedElement()).isEqualTo(membershipExposes.get(0));
assertThat(membershipExposes.get(0).getOwnedAnnotation()).containsExactly(annotation);
}).check(input);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.syson.sysml.Annotation;
import org.eclipse.syson.sysml.Element;
import org.eclipse.syson.sysml.Expression;
import org.eclipse.syson.sysml.Feature;
import org.eclipse.syson.sysml.FeatureDirectionKind;
Expand Down Expand Up @@ -99,6 +101,17 @@ private void setValue(final EObject eObject, EReference ref, EObject value) {
}
}

/**
* Adds a parsed object to its containing reference and completes containment-derived relationships.
*
* @param owner
* the object that contains the parsed object
* @param owned
* the parsed object to add
* @param referenceName
* the AST containment reference name
* @return {@code true} when the containment has been handled
*/
private boolean addChildIn(final EObject owner, final EObject owned, String referenceName) {

if ("operands".equals(referenceName) && owned instanceof Expression ownedExpression && owner instanceof InvocationExpression invocationExpression) {
Expand All @@ -115,10 +128,12 @@ private boolean addChildIn(final EObject owner, final EObject owned, String refe
featureValue.getOwnedRelatedElement().add(ownedExpression);
invocationExpression.getOwnedRelationship().add(paramMembership);
} else {

Optional<EReference> optContainementReference = this.referenceTranslator.getContainmentReference(owner, owned.eClass(), referenceName);
if (optContainementReference.isPresent()) {
this.setValue(owner, optContainementReference.get(), owned);
if (owned instanceof Annotation annotation && owner instanceof Element element) {
annotation.setAnnotatedElement(element);
}
}
}

Expand Down
Loading