Recent versions of IntelliJ have an "IDE scripting console" option under the tools menu. I've had a hard time finding blog posts about it. Some of these posts pointed out, and the gui proves this, that it has support for javascript. Could someone please point me to an example or blogpost how to use this feature (api docs) with javascript please?
Press Ctrl+Shift+A and type IDE Scripting Console . Once the required option is located, click it to run the console. This opens the IDE Scripting Console tab in the editor, where you can type code and execute it using Ctrl+Enter .
By default, it supports scripts written in JavaScript and Groovy. However, you can use any scripting language that is compliant with JSR 223, for example, Python, Ruby, Clojure, and so on.
Here is how to use it: https://www.jetbrains.com/help/idea/ide-scripting-console.html
Here is the API docs: http://www.jetbrains.org/intellij/sdk/docs/welcome.html
Best/largest(?) set of examples I could find: https://gist.github.com/gregsh/b7ef2e4ebbc4c4c11ee9
Unfortunately for JS there is the least amount of examples. That said, I've tried to implement an Action that starts the first Run Configuration. The code actually works pretty well. I've got stuck, however, on how to extend the Java Action abstract class from JS. Below is the working code:
var result = function run() {
var executor = com.intellij.execution.executors.DefaultDebugExecutor.getDebugExecutorInstance();
var runConfigsSettings = com.intellij.execution.RunManager.getInstance(IDE.project).allSettings;
var a = com.intellij.execution.ProgramRunnerUtil.executeConfiguration(IDE.project, runConfigsSettings[0], executor);
return a;
}()
I found the necessary docs here:
http://www.jetbrains.org/intellij/sdk/docs/basics/run_configurations/run_configuration_execution.html#starting-a-run-configuration-from-code
Hope this could help anyone. Write in the comments if you know how to create an Action in JS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With