Community
Participate
Working Groups
In our application we have projects (mobile applications created with HTML+JS) configured as following: 1. "org.eclipse.wst.jsdt.core.jsNature" nature 2. "org.eclipse.wst.jsdt.core.javascriptValidator" builder. 3. HTML files and other assets are located in project root and subfolders (i.e. our "WebContent" folder is our project root) We have an action that adds a library. Essentially all it does is copies JS files and other resources as needed and adds references to the JS file. The idea is to rely on JSDT to pick types and other APIs (though we had to introduce our InferEngine). What happens is that types and other APIs are not always immediately available in the content assist. There is race condition so the behavior depends on environment. Extended investigation had shown the following: 1. Project is created. For the project named "a" index file ".metadata\.plugins\org.eclipse.wst.jsdt.core\indexes\1835159913.index" is created and used to lookup types. 2. Library is added. Files are indexed and added to the project index located in "../org.eclipse.wst.jsdt.core/..". 3. In another thread index ".metadata\.plugins\org.eclipse.wst.jsdt.web.core\jssearch\1835159913.index" is created. It does not contain any types from the library. It is created when indexing HTML file in the project root. 3. Content assist does not show proposals from the library. 4. If I touch JS file from the library it gets reindexed and properly added to the new index (located in "../org.eclipse.wst.jsdt.web.core/.."). Proposals from the library will appear in the popup. Note: this problem goes away if I diable org.eclipse.wst.jsdt.web.* plugins.
Seems like the core issue was that JsIndexManager did not index HTML files as it relies on resource listener to be notified of the resource changes. It adds resource change listener after the project is created and is not notified of the project files. As a workaround I added "JsIndexManager.getInstance();" to our bundle activator "start()" method.