Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » JSDT: Dynamic Code Completion
JSDT: Dynamic Code Completion [message #989775] Fri, 07 December 2012 12:05 Go to next message
Christoph Hausmann is currently offline 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 11:26 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2238
Registered: July 2009
Senior Member
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 WTP, IBM
Re: JSDT: Dynamic Code Completion [message #990053 is a reply to message #990048] Mon, 10 December 2012 11:35 Go to previous message
Christoph Hausmann is currently offline Christoph Hausmann
Messages: 3
Registered: December 2012
Junior Member
Okay, thank you for the advice. I'll try that.
Previous Topic:Configure Jboss WS as Web Service Runtime
Next Topic:JavaTOWS Fail to load class error
Goto Forum:
  


Current Time: Fri Aug 01 12:05:06 EDT 2014

Powered by FUDForum. Page generated in 0.02639 seconds