JSDT: Dynamic Code Completion [message #989775] |
Fri, 07 December 2012 17:05 |
Christoph Hausmann Messages: 3 Registered: December 2012 |
Junior Member |
|
|
Hi everyone,
I have a question regarding the JSDT code completion. Basically, I want to have full control over the objects and methods offered in the code completion dialog. These objects and methods are not static, they are dynamically generated at runtime and should immediately appear within the code completion dialog.
Here is what I already tried:
(1) Using the 'org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer' extension point I added a custom library that contains the API, which should be available via code completion. However, this approach does not work for a "dynamic" API - if I change the library file at runtime, the changes are not reflected in the code completion.
(2) I used the 'org.eclipse.wst.jsdt.core.inferrenceSupport' extension point and implemented a custom InferenceProvider which returns an extension of the InferEngine that dynamically modifies the given CompilationUnitDeclaration and, e.g., adds an additional type. This type then afterwards appears in the code completion dialog, so it is basically working. However, there seems to be no API for adding additional variables. There is just CompilationUnitDeclaration.addType(...) and CompilationUnitDeclaration.addImport(...). And this approach also seems more like a hack to me.
(3) The last thing I tried was using the 'org.eclipse.wst.jsdt.ui.javaCompletionProposalComputer' extension point to provide a custom CompletionProposalComputer. But so far I am a bit lost there, so if this is the correct approach, I need some more hints on how to do this.
So in conclusion my question is: what is the preferred way to dynamically influence code completion in the JSDT JavaScript editor?
|
|
|
Re: JSDT: Dynamic Code Completion [message #990048 is a reply to message #989775] |
Mon, 10 December 2012 16:26 |
|
1) changes to libraries aren't automatically detected unless they're also resources in the workspace (the resource delta then triggers a reindexing), which is unusual for containers. You need to call org.eclipse.wst.jsdt.core.JavaScriptCore#setJsGlobalScopeContainer() to make JSDT aware that the contents of your container have changed.
2) If you mean adding properties to those types, you call one of the add...() methods on the InferredType objects.
_
Nitin Dahyabhai
Eclipse Web Tools Platform
|
|
|
|
Powered by
FUDForum. Page generated in 0.03241 seconds