Skip to content

Commit bc105a8

Browse files
committed
[1634] Invalid of export of redefining Attribute with shortName
Bug: #1634 Signed-off-by: Arthur Daussy <arthur.daussy@obeo.fr>
1 parent 6191bc1 commit bc105a8

4 files changed

Lines changed: 60 additions & 1 deletion

File tree

CHANGELOG.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Also introduces new `ServiceMethod` helper class to build AQL service call expre
5757
- https://github.com/eclipse-syson/syson/issues/1618[#1618] [rest-apis] Fix an issue where the _eAnnotations_ reference coming from the Ecore metamodel was taking into account by REST APIs serialization.
5858
- https://github.com/eclipse-syson/syson/issues/1621[#1621] [diagrams] Fix an issue where the creation of a _Package_ inside another _Package_ created the _Package_ at the root of the diagram in addition to the inside of the target _Package_.
5959
- https://github.com/eclipse-syson/syson/issues/1617[#1617] [import] Fix incorrect resolution of _redefined feature_ on `Redefinitions` during textual import.
60+
- https://github.com/eclipse-syson/syson/issues/1634[#1634] [export] Redefining an `AttributeUsage` with a _shortName_ does not properly export to the textual format.
6061

6162
=== Improvements
6263

backend/application/syson-application/src/test/java/org/eclipse/syson/application/export/ImportExportTests.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,29 @@ public void checkFeatureReferenceExpressionWithQualifiedNameDeresolution() throw
863863
this.checker.check(input, input);
864864
}
865865

866+
@Test
867+
@DisplayName("GIVEN a model with an attribute redefining an attribute with a short name, WHEN importing and exporting the model, THEN the redefined attribute should not redefine the shortName")
868+
public void checkRedefineAttributeWithShortName() throws IOException {
869+
var input = """
870+
part p {
871+
attribute <a> anAttribute;
872+
}
873+
874+
part p1 :> p {
875+
attribute :>> a;
876+
}""";
877+
var expected = """
878+
part p {
879+
attribute <a> anAttribute;
880+
}
881+
part p1 :> p {
882+
attribute :>> anAttribute;
883+
}""";
884+
885+
this.checker.check(input, expected);
886+
}
887+
888+
866889
@Test
867890
@DisplayName("GIVEN a model with an AttributeUsage containing a LiteralString, WHEN importing and exporting the model, THEN the exported text file should be the same as the imported one.")
868891
public void checkLiteralString() throws IOException {

backend/metamodel/syson-sysml-metamodel/src/main/java/org/eclipse/syson/sysml/textual/SysMLElementSerializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,7 @@ private String buildImportContextRelativeQualifiedName(Element element, Element
17531753
}
17541754

17551755
private String appendNameWithShortName(Appender builder, Element element) {
1756-
String shortName = element.getShortName();
1756+
String shortName = element.getDeclaredShortName();
17571757
if (!this.isNullOrEmpty(shortName)) {
17581758
builder.appendSpaceIfNeeded().append("<").appendPrintableName(shortName).append(">");
17591759
}

doc/content/modules/user-manual/pages/release-notes/2025.12.0.adoc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,41 @@ metadata def MP :> SemanticMetadata {
6262
}
6363
```
6464

65+
- Fix an issue where a model with a redefining `AttributeUsage` incorrectly redefined a _short name_ during a textual export.
66+
For example with the following model:
67+
68+
```
69+
part p {
70+
attribute <a> anAttribute;
71+
}
72+
73+
part p1 :> p {
74+
attribute :>> anAttribute;
75+
}
76+
```
77+
78+
The export gave :
79+
80+
```
81+
part p {
82+
attribute <a> anAttribute;
83+
}
84+
part p1 :> p {
85+
attribute <a> :>> anAttribute;
86+
}
87+
```
88+
89+
Instead of:
90+
91+
```
92+
part p {
93+
attribute <a> anAttribute;
94+
}
95+
part p1 :> p {
96+
attribute :>> anAttribute;
97+
}
98+
```
99+
65100
== Improvements
66101

67102
- In diagrams, when using direct edit on graphical elements, it's now possible to use _short names_ in the qualified names.

0 commit comments

Comments
 (0)