Skip to content

Commit

Permalink
Always show Preview DAG button
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
  • Loading branch information
bentsherman committed Dec 4, 2024
1 parent 7289797 commit 08c2c6f
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -53,7 +54,7 @@ public List<CodeLens> 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<CodeLens>();
Expand All @@ -70,10 +71,10 @@ public List<CodeLens> codeLens(TextDocumentIdentifier textDocument) {
return result;
}

public String previewDag(String documentUri, String name) {
public Map<String,String> 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()
Expand All @@ -86,7 +87,7 @@ public String previewDag(String documentUri, String name) {
var graph = visitor.getGraph(wn.isEntry() ? "<entry>" : wn.getName());
var result = new MermaidRenderer().render(wn.getName(), graph);
log.debug(result);
return result;
return Map.ofEntries(Map.entry("result", result));
})
.orElse(null);
}
Expand Down

0 comments on commit 08c2c6f

Please sign in to comment.