diff --git a/src/main/java/GoblintAnalysis.java b/src/main/java/GoblintAnalysis.java index 04eede9..363b2d3 100644 --- a/src/main/java/GoblintAnalysis.java +++ b/src/main/java/GoblintAnalysis.java @@ -36,6 +36,7 @@ public class GoblintAnalysis implements ToolAnalysis { public GoblintAnalysis(MagpieServer server) { this.magpieServer = server; + magpieServer.addCommand("showresult", new ShowResultCommand()); } /** diff --git a/src/main/java/GoblintAnalysisResult.java b/src/main/java/GoblintAnalysisResult.java index 3f572a0..1604ee9 100644 --- a/src/main/java/GoblintAnalysisResult.java +++ b/src/main/java/GoblintAnalysisResult.java @@ -2,11 +2,13 @@ import com.ibm.wala.util.collections.Pair; import java.util.ArrayList; +import java.util.Collections; import magpiebridge.core.AnalysisResult; import magpiebridge.core.Kind; import magpiebridge.util.SourceCodeReader; +import org.eclipse.lsp4j.Command; import org.eclipse.lsp4j.DiagnosticSeverity; public class GoblintAnalysisResult implements AnalysisResult { @@ -97,5 +99,10 @@ public String code() { } return code; } - + + @Override + public Iterable command() { + Command command = new Command("show result", "showresult", Collections.singletonList(position().getFirstLine())); + return Collections.singleton(command); + } } diff --git a/src/main/java/ShowResultCommand.java b/src/main/java/ShowResultCommand.java new file mode 100644 index 0000000..85d1c1c --- /dev/null +++ b/src/main/java/ShowResultCommand.java @@ -0,0 +1,16 @@ +import com.google.gson.JsonPrimitive; +import magpiebridge.core.MagpieServer; +import magpiebridge.core.WorkspaceCommand; +import org.eclipse.lsp4j.ExecuteCommandParams; +import org.eclipse.lsp4j.Location; +import org.eclipse.lsp4j.MessageParams; +import org.eclipse.lsp4j.MessageType; +import org.eclipse.lsp4j.services.LanguageClient; + +public class ShowResultCommand implements WorkspaceCommand { + @Override + public void execute(ExecuteCommandParams params, MagpieServer server, LanguageClient client) { + JsonPrimitive line = (JsonPrimitive) params.getArguments().get(0); + server.forwardMessageToClient(new MessageParams(MessageType.Info, "Showing result for position: " + line)); + } +}