In pure Java or pure JavaScript I am able to use Ctrl+B to jump to a declaration. But when I'm invoking Java from within a JavaScript file, IntelliJ cannot resolve my Java references.
These 3 lines execute no problem, but I cannot press "Ctrl+B" on the "out" or "println" parts of these lines. I want Ctrl+B to jump to the java.lang.System class in my editor like it does when I do the same in a Java file.
// test.js
Java.type("java.lang.System").out.println("howdy");
Packages.java.lang.System.out.println("doody");
java.lang.System.out.println("mister");
I use the following Java to invoke my script:
ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
FileReader myScript = new FileReader("test.js");
engine.eval(myScript);
And the output is:
howdy
doody
mister
Does anyone know how to get Ctrl+B (Go To Declaration) to work with IntelliJ in this context?
Out of the box, IntelliJ IDEA has no support for resolving references between JavaScript and Java. Someone from the community was working on a plugin which supported that, but as far as I know the plugin wasn't released.