mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-07-30 07:18:37 -09:00
Merge branch 'GP-0_ryanmkurtz_vscode'
This commit is contained in:
@@ -37,10 +37,26 @@
|
||||
<TD valign="top" align="left">Path to a Visual Studio Code executable file. It defaults
|
||||
to the most commonly used location on your specific platform.</TD>
|
||||
</TR>
|
||||
<TR valign="middle">
|
||||
<TD valign="top" width="200" align="left">Visual Studio Code Argument 1 (optional)</TD>
|
||||
<TD valign="top" align="left">An optional argument to pass to the Visual Studio Code
|
||||
executable.</TD>
|
||||
</TR>
|
||||
<TR valign="middle">
|
||||
<TD valign="top" width="200" align="left">Visual Studio Code Argument 2 (optional)</TD>
|
||||
<TD valign="top" align="left">An optional argument to pass to the Visual Studio Code
|
||||
executable.</TD>
|
||||
</TR>
|
||||
</TBODY>
|
||||
</TABLE>
|
||||
</CENTER>
|
||||
|
||||
<P>
|
||||
<IMG src="help/shared/note.yellow.png" alt="">One use of the optional argument fields is to
|
||||
launch a Flatpak installation of Visual Studio Code. In this case, the executable path might be
|
||||
"/usr/bin/flatpak", and the two optional arguments might be "run" and "com.visualstudio.code".
|
||||
</P>
|
||||
|
||||
<H2><A name="VSCodeModuleProject"></A>Create Visual Studio Code Module Project</H2>
|
||||
<P>This action creates a new Visual Studio Code project folder which can be used as a convenient
|
||||
starting point to develop a new Ghidra module. The new project will be linked against the
|
||||
|
||||
@@ -44,9 +44,21 @@ public class VSCodeIntegrationOptionsPlugin extends Plugin implements Applicatio
|
||||
public static final String PLUGIN_OPTIONS_NAME = "Visual Studio Code Integration";
|
||||
|
||||
public static final String VSCODE_EXE_PATH_OPTION = "Visual Studio Code Executable Path";
|
||||
private static final String VSCODE_EXE_PATH_DESC = "Path to Visual Studio Code executable";
|
||||
private static final String VSCODE_EXE_PATH_DESC = "Full path to Visual Studio Code executable";
|
||||
private static final File VSCODE_EXE_PATH_DEFAULT = getDefaultVSCodeExecutable();
|
||||
|
||||
public static final String VSCODE_ARG1_OPTION =
|
||||
"Visual Studio Code Launch Argument 1 (optional)";
|
||||
private static final String VSCODE_ARG1_DESC =
|
||||
"Optional argument 1 for Visual Studio Code executable";
|
||||
private static final String VSCODE_ARG1_DEFAULT = null;
|
||||
|
||||
public static final String VSCODE_ARG2_OPTION =
|
||||
"Visual Studio Code Launch Argument 2 (optional)";
|
||||
private static final String VSCODE_ARG2_DESC =
|
||||
"Optional argument 2 for Visual Studio Code executable";
|
||||
private static final String VSCODE_ARG2_DEFAULT = null;
|
||||
|
||||
public VSCodeIntegrationOptionsPlugin(PluginTool tool) {
|
||||
super(tool);
|
||||
}
|
||||
@@ -57,6 +69,10 @@ public class VSCodeIntegrationOptionsPlugin extends Plugin implements Applicatio
|
||||
ToolOptions options = tool.getOptions(PLUGIN_OPTIONS_NAME);
|
||||
options.registerOption(VSCODE_EXE_PATH_OPTION, OptionType.FILE_TYPE,
|
||||
VSCODE_EXE_PATH_DEFAULT, null, VSCODE_EXE_PATH_DESC);
|
||||
options.registerOption(VSCODE_ARG1_OPTION, OptionType.STRING_TYPE,
|
||||
VSCODE_ARG1_DEFAULT, null, VSCODE_ARG1_DESC);
|
||||
options.registerOption(VSCODE_ARG2_OPTION, OptionType.STRING_TYPE,
|
||||
VSCODE_ARG2_DEFAULT, null, VSCODE_ARG2_DESC);
|
||||
options.setOptionsHelpLocation(
|
||||
new HelpLocation("VSCodeIntegration", "VSCodeIntegrationOptions"));
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.io.*;
|
||||
|
||||
import com.google.gson.*;
|
||||
@@ -153,6 +154,16 @@ public class VSCodeIntegrationPlugin extends ProgramPlugin implements VSCodeInte
|
||||
return vscodeExecutableFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVSCodeArguments() {
|
||||
List<String> args = new ArrayList<>();
|
||||
CollectionUtils.addIgnoreNull(args,
|
||||
options.getString(VSCodeIntegrationOptionsPlugin.VSCODE_ARG1_OPTION, null));
|
||||
CollectionUtils.addIgnoreNull(args,
|
||||
options.getString(VSCodeIntegrationOptionsPlugin.VSCODE_ARG2_OPTION, null));
|
||||
return args;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void launchVSCode(File file) {
|
||||
TaskLauncher.launch(new VSCodeLauncherTask(this, file));
|
||||
|
||||
@@ -59,6 +59,7 @@ class VSCodeLauncherTask extends Task {
|
||||
// location present the user with the options window, and when they close that window, try
|
||||
// again.
|
||||
File vscodeExecutableFile;
|
||||
List<String> vscodeArgs = vscodeService.getVSCodeArguments();
|
||||
try {
|
||||
vscodeExecutableFile = vscodeService.getVSCodeExecutableFile();
|
||||
}
|
||||
@@ -93,6 +94,7 @@ class VSCodeLauncherTask extends Task {
|
||||
try {
|
||||
List<String> args = new ArrayList<>();
|
||||
args.add(vscodeExecutableFile.getAbsolutePath());
|
||||
args.addAll(vscodeArgs);
|
||||
args.add("-a");
|
||||
args.add(workspaceFile.getAbsolutePath());
|
||||
args.add(file.getAbsolutePath());
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package ghidra.app.services;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
|
||||
@@ -36,6 +37,11 @@ public interface VSCodeIntegrationService {
|
||||
*/
|
||||
public File getVSCodeExecutableFile() throws FileNotFoundException;
|
||||
|
||||
/**
|
||||
* {@return the Visual Studio Code executable arguments}
|
||||
*/
|
||||
public List<String> getVSCodeArguments();
|
||||
|
||||
/**
|
||||
* Launches Visual Studio Code
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user