Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 425054

Summary: Contribute Tern index files for JS content assist
Product: [ECD] Orion Reporter: Mark Macdonald <mamacdon>
Component: ClientAssignee: Mark Macdonald <mamacdon>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: m.sridharan
Version: 5.0   
Target Milestone: 5.0 M2   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Mark Macdonald CLA 2014-01-07 17:43:40 EST
The esprima JS content assist provider can parse type information from Tern indexes (see bug 413585). We ship with 3 indexes:
 - ecma5 built-ins
 - browser (enabled by /*jslint browser:true*/
 - Node    (enabled by /*jslint node:true*/

Orion should allow extensions to contribute additional Tern index files. 

At some point a decision will have to be made about which indexes are active for a given invocation of content assist. For now this can be the JS content assist provider's job, based on a simple understanding of node require()s -- eg. the presence of  require("express") would activate the Express index. (Later on we will of course have to deal with dependencies expressed in AMD and local files too, which will require more support from the Orion core.)
Comment 1 Mark Macdonald CLA 2014-01-10 18:12:51 EST
Here's the commits that added the basic support:
> * b244079 2014-01-10 | [Bug 425054] register index files for redis, postgres, mysql
> * 7cd5537 2014-01-10 | [Bug 425054] Add TypeDefs support to editorView and contentAssist
> * 314371f 2014-01-09 | [Bug 425054] Add service API for contributing type definitions: orion.core.typedef 
>                        -Add TypeDefRegistry
>                        -Expose typeDefRegistry to Editor Context
> * a78ab50 2014-01-10 | JS content assist: load built-in Type Defs as modules, not XHR
> * 4c1561f 2014-01-09 | Bugfix in serviceTracker "onServiceAdded", unit tests

I'm still working on getting the JS content assist provider to load the indexes and activate them when require()d.
Comment 2 Mark Macdonald CLA 2014-01-15 18:36:39 EST
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=dd22aae

Sort of working. At the moment you still need the /*jslint node:true*/ flag enabled for it to use the available indexes. For example:

> /*jslint node:true*/
> require("mysql").
>                  ^ put caret here and hit ctrl+space for content assist on the library

You also have to reload your plugins to pick up the index metadata.
Comment 3 Mark Macdonald CLA 2014-01-16 11:24:14 EST
Resolving this bug. We can open targeted bugs for remaining problems in the index files, type inferencer, etc etc etc etc etc etc