diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index f045a0d72..ffeb656e9 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -58,6 +58,7 @@ Also introduces new `ServiceMethod` helper class to build AQL service call expre - 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_. - https://github.com/eclipse-syson/syson/issues/1617[#1617] [import] Fix incorrect resolution of _redefined feature_ on `Redefinitions` during textual import. - https://github.com/eclipse-syson/syson/issues/1627[#1627] [import] [export] Fix invalid textual import/export of `LiteralRational`. +- https://github.com/eclipse-syson/syson/issues/1634[#1634] [export] Redefining an `AttributeUsage` with a _shortName_ does not properly export to the textual format. === Improvements diff --git a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/export/ImportExportTests.java b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/export/ImportExportTests.java index ed787caf1..f57739e08 100644 --- a/backend/application/syson-application/src/test/java/org/eclipse/syson/application/export/ImportExportTests.java +++ b/backend/application/syson-application/src/test/java/org/eclipse/syson/application/export/ImportExportTests.java @@ -888,6 +888,29 @@ public void checkFeatureReferenceExpressionWithQualifiedNameDeresolution() throw this.checker.check(input, input); } + @Test + @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") + public void checkRedefineAttributeWithShortName() throws IOException { + var input = """ + part p { + attribute anAttribute; + } + + part p1 :> p { + attribute :>> a; + }"""; + var expected = """ + part p { + attribute anAttribute; + } + part p1 :> p { + attribute :>> anAttribute; + }"""; + + this.checker.check(input, expected); + } + + @Test @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.") public void checkLiteralString() throws IOException { diff --git a/backend/metamodel/syson-sysml-metamodel/src/main/java/org/eclipse/syson/sysml/textual/SysMLElementSerializer.java b/backend/metamodel/syson-sysml-metamodel/src/main/java/org/eclipse/syson/sysml/textual/SysMLElementSerializer.java index 5783dbba6..bd8d417ec 100644 --- a/backend/metamodel/syson-sysml-metamodel/src/main/java/org/eclipse/syson/sysml/textual/SysMLElementSerializer.java +++ b/backend/metamodel/syson-sysml-metamodel/src/main/java/org/eclipse/syson/sysml/textual/SysMLElementSerializer.java @@ -1874,7 +1874,7 @@ private String buildImportContextRelativeQualifiedName(Element element, Element } private String appendNameWithShortName(Appender builder, Element element) { - String shortName = element.getShortName(); + String shortName = element.getDeclaredShortName(); if (!this.isNullOrEmpty(shortName)) { builder.appendSpaceIfNeeded().append("<").appendPrintableName(shortName).append(">"); } diff --git a/doc/content/modules/user-manual/pages/release-notes/2025.12.0.adoc b/doc/content/modules/user-manual/pages/release-notes/2025.12.0.adoc index 01acf3934..add7a0dec 100644 --- a/doc/content/modules/user-manual/pages/release-notes/2025.12.0.adoc +++ b/doc/content/modules/user-manual/pages/release-notes/2025.12.0.adoc @@ -62,7 +62,8 @@ metadata def MP :> SemanticMetadata { } ``` -- Fix an issue during import and export of rational numbers. +- Fix an issue during texual import and export of rational numbers. + The following model is now properly imported: ``` @@ -99,6 +100,41 @@ package Occurrences { } ``` +- Fix an issue where a model with a redefining `AttributeUsage` incorrectly redefined a _short name_ during a textual export. +For example with the following model: + +``` +part p { + attribute anAttribute; +} + +part p1 :> p { + attribute :>> anAttribute; +} +``` + +The export gave : + +``` +part p { + attribute anAttribute; +} +part p1 :> p { + attribute :>> anAttribute; +} +``` + +Instead, it now exports: + +``` +part p { + attribute anAttribute; +} +part p1 :> p { + attribute :>> anAttribute; +} +``` + == Improvements - In diagrams, when using direct edit on graphical elements, it's now possible to use _short names_ in the qualified names.