[Nashorn Javascript files]: "Unresolved variable or type Packages": Java types not recognized

DESCRIPTION

I have no problems running .js files using Nashorn, which makes sense because it's done by the JVM not by IntelliJ.

What I was hoping to get out of IntelliJ is autocompletion and runtime verification, like Java code.  e.g., dropdown menus for methods, "red squigglies", etc.  I think some folks call this "Intellisense".

But, alas, as you can see above, this doesn't seem to be happening.

From a technical perspective, this shouldn't be that difficult, at least for a Phase 1, because it's very similar to Java.

For a Phase 2, Nashorn "injects" some extra variables/functions into the context:

  • Packages
  • arguments
  • Java (Java.type, Java.extend, etc.)
  • JavaImporter
  • loadWithNewGlobal
  • debugger

More info at:

Or, perhaps, I'm doing something wrong.

 

SPECIFICATIONS

IntelliJ IDEA 2016.2.4
Build #IU-162.2032.8, built on September 9, 2016
JRE: 1.8.0_91-b14 x86_64
JVM: Java HotSpot(TM) 64-Bit Server VM by Oracle Corporation

0
3 comments

Works fine for me - types are recognized and suggested by completion:

 

did you select 'Nashorn JS' as JavaScript Language version in Settings (Preferences) | Languages & Frameworks | JavaScript?

0
Avatar
Permanently deleted user

Thanks, @Elena.

Everything worked fine after I closed the project, deleted all .iml files and .idea directories, and re-imported the project.

0

Please sign in to leave a comment.