JavaClassReferenceSet in javascript

Hello,

I've been trying to use JavaClassReferenceSet with JSReferenceExpression but without any success. I'd like to implement that for the specific case of referencing java class in Packages namespace in rhino-js / nashorn (e.g. var runtime = Packages.java.lang.Runtime;). I cannot add reference to JSReferenceExpression, while it is reference itself. Only thing to override here is probably doResolve in custom reference expression resolver. If I did that there would be only ctrl+click to package / java class, but no autocompletion. I find it very problematic because of cascade of JSReferenceExpressions. I'd like to have public static method / fields autocompletion as well. Only way I can actually think of is language injection, but I haven't used it yet. Any ideas?

8 comments
Comment actions Permalink

Hello Peter.

Currently I don't know any feasible way to do this. You can reference java class without Packages prefix now. I've created a ticket to implement it myself as this might be helpful for other users too. Feel free to vote/watch it.

0
Comment actions Permalink

Very nice, thanks.

0
Comment actions Permalink

I see it was solved in 140.2576. Could you provide some hints regarding it's usage please?

0
Comment actions Permalink

What usage are you talking about? At least such references are resolved to java classes and packages, classes and packages are in completion list after e.g. Packages.java.lang. qualifier,

var Vector = Packages.java.util.Vector;
  var v = new Vector(); v.<caret> lists java Vector members etc.
0
Comment actions Permalink

In my template js I didn't set DialectOptionHolder.NASHORN. Now it works very well even for public static stuff, thanks a lot!

0
Comment actions Permalink

Glad to hear that!

0
Comment actions Permalink

One more question - I've done some testing and find usages and refactoring doesn't seem to work at all. So basically nashorn dialect just provides references for ctrl+click or am I missing something?

0
Comment actions Permalink

Yep, unfortunately find usages are not working now. Please watch issues WEB-15592 and WEB-15594.

0

Please sign in to leave a comment.