diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index b758f4efa..514febb1c 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -52,6 +52,8 @@ This fix ensure that imported models containing, for example, a top-level `Libra - https://github.com/eclipse-syson/syson/issues/1784[#1784] Error while exporting `FeatureValue` using enumeration literals. - https://github.com/eclipse-syson/syson/issues/1838[#1838] [metamodel] Invalid computation of `Usage.getType`: The subsetted features should be taken into account. +- https://github.com/eclipse-syson/syson/issues/1847[#1847] [export] Textual export duplicates "abstract" keyword for `OccurrenceUsage`. + === Improvements - https://github.com/eclipse-syson/syson/issues/1666[#1666] [export] Export `SatisfyRequirementUsage` in textual format. 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 9a4b823b5..e9b88a05c 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 @@ -985,6 +985,17 @@ public void checkReferencingWithShortName() throws IOException { this.checker.check(input, input); } + @Test + @DisplayName("GIVEN an abstract OccurrenceUsage, WHEN importing and exporting the model, THEN the abstract keyword should be correctly exported") + public void checkAbstractOccurrenceUsage() throws IOException { + var input = """ + package root { + abstract occurrence test; + abstract occurrence def Test; + }"""; + this.checker.check(input, input); + } + @Test @DisplayName("GIVEN a model with a references to elements, WHEN importing and exporting the model, THEN the references should privileged short name over declared name when possible") public void checkReferencingIdentifiers() 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 f614eb926..75714f90f 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 @@ -748,7 +748,6 @@ public String caseObjectiveMembership(ObjectiveMembership objective) { @Override public String caseOccurrenceUsage(OccurrenceUsage occurrenceUsage) { Appender builder = new Appender(this.lineSeparator, this.indentation); - this.appendUsagePrefix(builder, occurrenceUsage); this.appendOccurrenceUsagePrefix(builder, occurrenceUsage); if (PortionKind.SNAPSHOT.equals(occurrenceUsage.getPortionKind())) { builder.appendWithSpaceIfNeeded("snapshot"); @@ -2487,7 +2486,7 @@ private void appendPrefixMetadataMember(Appender builder, MetadataUsage metadata } } - + private void appendRequirementConstraintUsage(Appender builder, ConstraintUsage constraintUsage) { if (this.useRequirementConstraintUsageShortHandNotation(constraintUsage)) { this.appendRequirementConstraintUsageShorthandNotation(builder, constraintUsage); @@ -2567,6 +2566,10 @@ private void appendBasicUsagePrefix(Appender builder, Usage usage) { builder.appendSpaceIfNeeded(); builder.append("end"); } + + if (usage.isIsReference() && !this.isImplicitlyReferential(usage)) { + builder.appendWithSpaceIfNeeded(SysMLv2Keywords.REF); + } } private FeatureDirectionKind getDefaultDirection(Usage usage) { diff --git a/doc/content/modules/user-manual/pages/release-notes/2026.1.0.adoc b/doc/content/modules/user-manual/pages/release-notes/2026.1.0.adoc index 15e6b58bc..45ffa61a3 100644 --- a/doc/content/modules/user-manual/pages/release-notes/2026.1.0.adoc +++ b/doc/content/modules/user-manual/pages/release-notes/2026.1.0.adoc @@ -89,6 +89,7 @@ package root { ** New `Expose` elements now have `visibility` set to _protected_ and have `isImportAll` set to _true_, as required by the SysMLv2 specification. ** Correct the computation of a `Feature`'s types to properly account for subsetted features. +** Fix the textual export of `OccurrenceUsage` to avoid duplication of the abstract keyword. == Improvements