Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Showing analysis result via code actions #9

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/GoblintAnalysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class GoblintAnalysis implements ToolAnalysis {

public GoblintAnalysis(MagpieServer server) {
this.magpieServer = server;
magpieServer.addCommand("showresult", new ShowResultCommand());
}

/**
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/GoblintAnalysisResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -97,5 +99,10 @@ public String code() {
}
return code;
}


@Override
public Iterable<Command> command() {
Command command = new Command("show result", "showresult", Collections.singletonList(position().getFirstLine()));
return Collections.singleton(command);
}
}
16 changes: 16 additions & 0 deletions src/main/java/ShowResultCommand.java
Original file line number Diff line number Diff line change
@@ -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));
}
}