GP-1035: Python interpreter code completion now works prior to executing

any python statements
This commit is contained in:
Ryan Kurtz 2022-12-30 05:36:14 -05:00
parent 432e5252d6
commit 21d8d18134
2 changed files with 8 additions and 2 deletions

View file

@ -332,7 +332,7 @@ public class GhidraPythonInterpreter extends InteractiveInterpreter {
* *
* @param script The script whose class hierarchy is to be used for injection. * @param script The script whose class hierarchy is to be used for injection.
*/ */
private void injectScriptHierarchy(PythonScript script) { void injectScriptHierarchy(PythonScript script) {
if (script == null) { if (script == null) {
return; return;

View file

@ -226,8 +226,14 @@ public class PythonPlugin extends ProgramPlugin
// Setup the PythonScript describing the state of the interactive prompt. // Setup the PythonScript describing the state of the interactive prompt.
// This allows things like currentProgram and currentAddress to dynamically reflect // This allows things like currentProgram and currentAddress to dynamically reflect
// what's happening in the listing. // what's happening in the listing. Injecting the script hierarchy early here allows
// code completion to work before commands are entered.
interactiveScript = new PythonScript(); interactiveScript = new PythonScript();
interactiveScript.set(
new GhidraState(tool, tool.getProject(), getCurrentProgram(), getProgramLocation(),
getProgramSelection(), getProgramHighlight()),
interactiveTaskMonitor, new PrintWriter(getConsole().getStdOut()));
interpreter.injectScriptHierarchy(interactiveScript);
interactiveTaskMonitor = new PythonInteractiveTaskMonitor(console.getStdOut()); interactiveTaskMonitor = new PythonInteractiveTaskMonitor(console.getStdOut());
// Start the input thread that receives python commands to execute. // Start the input thread that receives python commands to execute.