-
Notifications
You must be signed in to change notification settings - Fork 21
Description
Hey together,
trying to get context-assist working in RSTA for my JavaScripts:
Im using the JavaScriptLanguageSupport together with the Rhino Engine and adding my java project-jar with JarManager::addClassFileSource, so that it gets to know my classes.
Everything works so far, I can use importPackage() in the script to load one of my packages and then get context-assist in the editor for my own classes.
My problem is the following: The scripts im writing are not self-contained, instead I am using them in different contexts in my application. In the application I add specific Java-objects to the Rhino runtime with ScriptEngine::put().
Of course, the editor does not know about these runtime-only objects that are added to the global scope in execution.
In this scenario i have a class "MyRuntime" in my jar, from which I create an instance "runtime" and add it to the Rhino execution with
ScriptEngine.put("runtime", new MyRuntime());
Now to make the editor recognize the object, I was thinking about the following (which should work in theory):
- Get the class MyRuntime from the JarManager
- Get the VariableResolver from the JavaScript SourceCompletionProvider
- Tell it to add a variable (named runtime of type MyRuntime) to the system scope
Im not sure however how to do the last step, VariableResolver::addSystemVariable requires a JavaScriptVariableDeclaration instance, which needs a codeblock or AstNode. Maybe someone can guide me in the right direction how to continue from there.
Im very thankful to any help in this issue