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

Bug 489873

Summary: [tern] Templates supplied in Tern plugins along with indexes (express, angular), do not show up in content assst
Product: [ECD] Orion Reporter: Curtis Windatt <curtis.windatt.public>
Component: JS ToolsAssignee: Curtis Windatt <curtis.windatt.public>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: Michael_Rennie
Version: 12.0   
Target Milestone: 12.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Curtis Windatt CLA 2016-03-17 13:24:59 EDT
This might have been broken during the move to Tern 0.10.0.  The index plugins (amqp, express, mongodb, etc.) have templates for writing example code.  These templates should only show up when the plugin is started and the eslint-env directive is set.  However, none of the templates ever show up.

It appears we were trying to hook into 'variableCompletion'.  Tern still has a reference to this name, but it does not do a pass for plugin contributions with it (it appears to do nothing with it).  We will likely have to hook into 'completion'
Comment 1 Michael Rennie CLA 2016-03-17 13:59:10 EDT
Looks like this code mysteriously vanished from tern.js:

if (srv.passes[hookname])
      srv.passes[hookname].forEach(function(hook) {hook(file, wordStart, wordEnd, gather);});
Comment 2 Curtis Windatt CLA 2016-03-17 15:20:45 EDT
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=7bcf8ebe1df75d93f7c5581b18232218e87294cd
Fixed in master

I have also created a new test suite for content assist supplied by Tern index plugins.  I had to modify express.js to get the templates working correctly so it seems likely the other index plugins will need work.

The main problem is the removal of srv.passes[hookname].  You can see the old version of it here:
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/tree/bundles/org.eclipse.orion.client.javascript/web/tern/lib/tern.js?h=stable_20150707
The API was modified to use wordStart/wordEnd/gather to match what newer versions of Tern are doing.  Next time we update Tern we might be able to hook into the signal api rather than add our own passes call.
https://github.com/ternjs/tern/blob/master/lib/tern.js#L769