From 08c2c6f36d669073038e648ac865ac4115023f1f Mon Sep 17 00:00:00 2001 From: Ben Sherman Date: Wed, 4 Dec 2024 17:24:05 -0600 Subject: [PATCH] Always show Preview DAG button Signed-off-by: Ben Sherman --- .../lsp/services/script/ScriptCodeLensProvider.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptCodeLensProvider.java b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptCodeLensProvider.java index 08154e6..bcd73eb 100644 --- a/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptCodeLensProvider.java +++ b/modules/language-server/src/main/java/nextflow/lsp/services/script/ScriptCodeLensProvider.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Map; import com.google.gson.JsonNull; import com.google.gson.JsonPrimitive; @@ -53,7 +54,7 @@ public List codeLens(TextDocumentIdentifier textDocument) { } var uri = URI.create(textDocument.getUri()); - if( !ast.hasAST(uri) || ast.hasErrors(uri) ) + if( !ast.hasAST(uri) ) return Collections.emptyList(); var result = new ArrayList(); @@ -70,10 +71,10 @@ public List codeLens(TextDocumentIdentifier textDocument) { return result; } - public String previewDag(String documentUri, String name) { + public Map previewDag(String documentUri, String name) { var uri = URI.create(documentUri); if( !ast.hasAST(uri) || ast.hasErrors(uri) ) - return null; + return Map.ofEntries(Map.entry("error", "DAG preview cannot be shown because the script has errors.")); var sourceUnit = ast.getSourceUnit(uri); return ast.getWorkflowNodes(uri).stream() @@ -86,7 +87,7 @@ public String previewDag(String documentUri, String name) { var graph = visitor.getGraph(wn.isEntry() ? "" : wn.getName()); var result = new MermaidRenderer().render(wn.getName(), graph); log.debug(result); - return result; + return Map.ofEntries(Map.entry("result", result)); }) .orElse(null); }