Skip to content

Commit 956f883

Browse files
pcdavidAxelRICHARD
authored andcommitted
[2058] Fix error when importing SysML snippets referencing unknown units
Bug: #2058 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
1 parent 0e18073 commit 956f883

4 files changed

Lines changed: 25 additions & 1 deletion

File tree

CHANGELOG.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ Now the _end_ keyword is not displayed anymore in the label of these graphical n
9898
- https://github.com/eclipse-syson/syson/issues/2054[#2054] [diagrams] Fix an error when invoking the tools _New Start Action_ or _New Done Action_ from inside a package named `Actions`.
9999
- https://github.com/eclipse-syson/syson/issues/2057[#2057] [diagrams] Fix the support for removing the multiplicity using the direct edit.
100100
- https://github.com/eclipse-syson/syson/issues/1938[#1938] [diagrams] Fix an issue where the _New Flow (flow)_ tool between two parameters was broken.
101+
- https://github.com/eclipse-syson/syson/issues/2058[#2058] [diagrams] Fix error when importing SysML snippets referencing unknown units which could make the resluting model inconsistent
101102

102103
=== Improvements
103104

backend/application/syson-application/src/test/java/org/eclipse/syson/application/imports/ImportSysMLModelTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import org.eclipse.emf.common.notify.Notifier;
2929
import org.eclipse.emf.common.util.EList;
30+
import org.eclipse.emf.ecore.InternalEObject;
3031
import org.eclipse.sirius.components.core.api.IEditingContext;
3132
import org.eclipse.sirius.components.core.api.IEditingContextSearchService;
3233
import org.eclipse.sirius.components.core.api.IPayload;
@@ -1283,6 +1284,27 @@ public void checkDoSendPayloadParameterResolution() throws IOException {
12831284
}).check(input);
12841285
}
12851286

1287+
@DisplayName("Given an attribute valued with an unknown unit, WHEN importing the model, THEN then no unresolvable proxies are left")
1288+
@Test
1289+
public void referenceToUnknownUnit() throws IOException {
1290+
var input = """
1291+
part p {
1292+
attribute a = 42 [W]
1293+
}
1294+
""";
1295+
this.checker.checkImportedModel(resource -> {
1296+
var iter = resource.getAllContents();
1297+
while (iter.hasNext()) {
1298+
var current = iter.next();
1299+
for (var target : current.eCrossReferences()) {
1300+
assertThat(target).isNotNull();
1301+
assertThat(((InternalEObject) target).eProxyURI()).isNull();
1302+
assertThat(target.eIsProxy()).isFalse();
1303+
}
1304+
}
1305+
}).check(input);
1306+
}
1307+
12861308
private void assertOperatorExpressionGuard(TransitionUsage t1, String expectedOperator, Class<?> expectedFirstParameterType, Class<?> expectedSecondParameterType) {
12871309
EList<Expression> guardExpression1 = t1.getGuardExpression();
12881310
assertThat(guardExpression1).hasSize(1);

backend/application/syson-sysml-import/src/main/java/org/eclipse/syson/sysml/parser/AstTreeParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public void resolveAllReference(List<ProxiedReference> unresolvedReferences) {
200200
"Non qualified proxy resolution phase", unresolvedAfterRedefinition);
201201

202202
if (!unresolvedProxiesAfterUnqualified.isEmpty()) {
203-
this.handleUnresolvableProxies(unresolvedAfterRedefinition);
203+
this.handleUnresolvableProxies(unresolvedProxiesAfterUnqualified);
204204
}
205205
}
206206

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ package Test {
103103
** Fix the export of `LiteralString` with backslash characters.
104104
** Fix textual import of `LiteralString` containing escaped backslash. In the following example `attribute a1 = "A \\ B";`, the value of "a1" is now "A \ B".
105105
The previous implementation was importing the value "A \\ B".
106+
** Fix error when importing SysML snippets referencing unknown units which could make the resluting model inconsistent
106107

107108
* In _Explorer_ view:
108109

0 commit comments

Comments
 (0)