New to JavaScript - External Java Libraries on JavaScript Rhino Scripts

Hello

I'm having some issues getting IntelliJ IDEA 2022.1 (Ultimate) setup to develop simple JavaScript Rhino based scripts/macros for an engineering application.  I typically create these scripts using Groovy or Java but need to create several in JavaScript due to a customer's requirement. My problem is that I'm unsure how to get everything setup so code completion works for the Java libraries required to access the application API's.  While I've developed in JavaScript in the past, I've never done it using IntelliJ IDEA.

I have all the required Jar's added as a library in the project but depending on what JavaScript language version I choose sometimes it recognizes them and sometimes it doesn't.  Regardless of language version, when I use the classes I always an "Unresolved variable or type" error.

Here's an example script that works fine when executed in the engineering application:

Here it is again but with the version set to Nashorn JS:

As you can see, now it seems to recognize the class via JavaImporter but I'm still getting errors and code completion doesn't work.

This particular engineering application no longer supports Nashorn and is requiring all JavaScript code to be in Rhino now: https://docs.nomagic.com/display/MD2021xR1/JavaScript+migration+from+Nashorn+to+Rhino+engine

I feel like my use case is fairly simple since I have no need to compile, run, debug, etc. in the IDE, I just want code completion and error checking.  This all works great when I can create scripts in Groovy, or develop actual plugins for this application in Java.

Any thoughts on what I might be doing wrong?  Any help would be greatly appreciated!!

Thank you,

David

0
2 comments

Rhino is not currently supported (https://youtrack.jetbrains.com/issue/WEB-2884) and unfortunately it is not on our roadmap or being considered as one of our highest priorities.

0

Elena

Thank you for your quick and informative response!

0

Please sign in to leave a comment.