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?

0

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
Avatar
Permanently deleted user

Very nice, thanks.

0
Avatar
Permanently deleted user

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

0

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
Avatar
Permanently deleted user

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

0
Avatar
Permanently deleted user

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

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

0

请先登录再写评论。