From cfb3ec5391e0897be78fe59e5e5fba4c655a5e28 Mon Sep 17 00:00:00 2001 From: Tobias Ortmayr Date: Mon, 24 Jun 2024 12:10:44 +0200 Subject: [PATCH] Fix workflow documentation navigation example (#238) Update the NodeDocumentationNavigationTargetProvider to not rely on the tasks name which is currently unreliable (see https://github.com/eclipse-glsp/glsp/issues/1351) and instead relies on the `text` property of the tasks label. --- .../workflow/model/WorkflowNavigationTargetResolver.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/org.eclipse.glsp.example.workflow/src/org/eclipse/glsp/example/workflow/model/WorkflowNavigationTargetResolver.java b/examples/org.eclipse.glsp.example.workflow/src/org/eclipse/glsp/example/workflow/model/WorkflowNavigationTargetResolver.java index c683705c..f20cd9ff 100644 --- a/examples/org.eclipse.glsp.example.workflow/src/org/eclipse/glsp/example/workflow/model/WorkflowNavigationTargetResolver.java +++ b/examples/org.eclipse.glsp.example.workflow/src/org/eclipse/glsp/example/workflow/model/WorkflowNavigationTargetResolver.java @@ -20,6 +20,7 @@ import java.util.Set; import org.eclipse.glsp.example.workflow.wfgraph.TaskNode; +import org.eclipse.glsp.graph.GLabel; import org.eclipse.glsp.server.features.navigation.NavigationTarget; import org.eclipse.glsp.server.features.navigation.NavigationTargetResolution; import org.eclipse.glsp.server.features.navigation.NavigationTargetResolver; @@ -36,7 +37,8 @@ public NavigationTargetResolution resolve(final NavigationTarget navigationTarge if (navigationTarget.getArgs().containsKey("name")) { String name = navigationTarget.getArgs().get("name"); Set taskNodes = modelState.getIndex().findAll(modelState.getRoot(), TaskNode.class); - Optional element = taskNodes.stream().filter(node -> name.equals(node.getName())).findFirst(); + Optional element = taskNodes.stream().filter(node -> node.getChildren().stream() + .anyMatch(child -> child instanceof GLabel && ((GLabel) child).getText().equals("Push"))).findFirst(); if (element.isPresent()) { return new NavigationTargetResolution(Arrays.asList(element.get().getId())); }