Skip to content

Commit 255713d

Browse files
committed
[2105] Display textual representation of expressions in the Explorer
Bug: #2105 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
1 parent ec39d4c commit 255713d

7 files changed

Lines changed: 118 additions & 40 deletions

File tree

CHANGELOG.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ As a result, the following GraphQL mutations have been removed `exposeRequiremen
3232

3333
=== Improvements
3434

35+
- https://github.com/eclipse-syson/syson/issues/2105[#2105] [explorer] In the _Explorer_ view, `Expression` elements now display their full textual representation
3536

3637
=== New features
3738

backend/application/syson-application/src/test/java/org/eclipse/syson/application/controller/explorer/view/SysONExplorerTests.java

Lines changed: 82 additions & 38 deletions
Large diffs are not rendered by default.

backend/application/syson-application/src/test/java/org/eclipse/syson/application/data/ActionTransitionUsagesProjectData.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2025 Obeo.
2+
* Copyright (c) 2025, 2026 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -42,6 +42,8 @@ public static final class GraphicalIds {
4242
*/
4343
public static final class SemanticIds {
4444

45+
public static final String DOCUMENT_ID = "26a78eef-bfa1-4de0-9d0a-c1f86a1b97d5";
46+
4547
public static final String PACKAGE_1_ID = "2264f62c-b223-4b9b-ae41-96dc2ba0070e";
4648

4749
public static final String A0_ID = "82a2fa10-e736-4c3e-b27a-e94f76d7456d";

backend/metamodel/syson-sysml-metamodel/src/main/java/org/eclipse/syson/sysml/helper/EMFUtils.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ public static <T extends EObject> List<T> getAncestors(Class<T> type, EObject ob
282282
*/
283283
public static <T extends EObject> Optional<T> getFirstAncestor(Class<T> type, EObject object, Predicate<EObject> ancestorPredicate) {
284284
var current = object;
285-
List<T> results = new ArrayList<>();
286285
while (current != null) {
287286
if (type.isInstance(current) && (ancestorPredicate == null || ancestorPredicate.test(current))) {
288287
return Optional.of((T) current);

backend/services/syson-tree-services/src/main/java/org/eclipse/syson/tree/explorer/services/SysONDefaultExplorerServices.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,13 @@
3838
import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata;
3939
import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.services.api.IRepresentationMetadataSearchService;
4040
import org.eclipse.syson.sysml.Element;
41+
import org.eclipse.syson.sysml.Expression;
4142
import org.eclipse.syson.sysml.Type;
43+
import org.eclipse.syson.sysml.Usage;
4244
import org.eclipse.syson.sysml.ViewUsage;
45+
import org.eclipse.syson.sysml.textual.SysMLElementSerializer;
46+
import org.eclipse.syson.sysml.textual.SysMLSerializingOptions;
47+
import org.eclipse.syson.sysml.textual.utils.FileNameDeresolver;
4348
import org.eclipse.syson.sysml.util.ElementUtil;
4449
import org.eclipse.syson.tree.explorer.fragments.KerMLStandardLibraryDirectory;
4550
import org.eclipse.syson.tree.explorer.fragments.LibrariesDirectory;
@@ -148,6 +153,8 @@ public String getLabel(Object self) {
148153
String label = "";
149154
if (self instanceof ISysONExplorerFragment fragment) {
150155
label = fragment.getLabel();
156+
} else if (self instanceof Expression expression && !(self instanceof Usage)) {
157+
label = this.getValueExpressionTextualRepresentation(expression);
151158
} else if (self instanceof Type type) {
152159
String name = type.getName();
153160
if (name != null) {
@@ -159,6 +166,25 @@ public String getLabel(Object self) {
159166
return label;
160167
}
161168

169+
private String getValueExpressionTextualRepresentation(Expression value) {
170+
String result = "";
171+
if (value != null) {
172+
SysMLSerializingOptions options = new SysMLSerializingOptions.Builder()
173+
.lineSeparator("\n")
174+
.nameDeresolver(new FileNameDeresolver())
175+
.indentation("\t")
176+
.needEscapeCharacter(false)
177+
.build();
178+
String textualFormat = new SysMLElementSerializer(options, s -> {
179+
// Do nothing for now
180+
}).doSwitch(value);
181+
if (textualFormat != null) {
182+
result = textualFormat;
183+
}
184+
}
185+
return result;
186+
}
187+
162188
private String getFallbackLabel(Object self) {
163189
StyledString styledLabel = this.labelService.getStyledLabel(self);
164190
if (styledLabel != null) {
76.6 KB
Loading

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
** Add tools to create timeslices and snapshots, available on `OccurrenceUsage`, `ItemUsage`, and `PartUsage` graphical nodes.
2626
These tools leverage a selection dialog to either create a specific timeslice/snapshot graphical node or, if no selection is made, default to a timeslice/snapshot `OccurrenceUsage` graphical node.
2727

28+
* In the _Explorer_ view:
29+
30+
** `Expression` elements now display their full textual representation:
31+
32+
image::explorer-expression-text.png[Expression textual representation]
33+
2834
== Technical details
2935

3036
* For technical details on this {product} release (including breaking changes), please refer to https://github.com/eclipse-syson/syson/blob/main/CHANGELOG.adoc[changelog].

0 commit comments

Comments
 (0)