Use "Run Tools Window" from Plugin in IntelliJ

已回答

I am programming an IntelliJ plugin and want to run a node command in the "run tools window".

So far I have the following code:


        Project project = event.getProject();
        GeneralCommandLine commandLine = new GeneralCommandLine();
        commandLine.setExePath("node");
        commandLine.addParameter(pathToJSFile);
        commandLine.setWorkDirectory(startingPath);

        ProcessHandler processHandler = new OSProcessHandler(commandLine);

        RunContentDescriptor contentDescriptor = new RunContentDescriptor(processHandler, null);
        RunContentManager.getInstance(project).showRunContent(contentDescriptor);

But I get the following error:

error: no suitable constructor found for RunContentDescriptor(ProcessHandler,<null>)
      RunContentDescriptor contentDescriptor = new RunContentDescriptor(processHandler, null);

So I tried to add this line to the dependencies, but it seems I cannot figure out which version to add.

implementation("com.intellij.execution.runners:213.7172.25")

What I want to archive is, to run a node command in the background, and the user should be able to find the process in the run tools window. That way the user has the control when to stop it and it runs in the background.

Any ideas how to solve this?

0

This extra dependency is wrong and not needed.

Please try using com.intellij.execution.process.ScriptRunnerUtil instead of above manual setup.

0

请先登录再写评论。