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

Bug 496955

Summary: [tern] Weird ordering problem for plugins and content assist
Product: [ECD] Orion Reporter: Michael Rennie <Michael_Rennie>
Component: JS ToolsAssignee: Michael Rennie <Michael_Rennie>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: curtis.windatt.public
Version: 12.0   
Target Milestone: 13.0   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description Michael Rennie CLA 2016-06-28 15:14:24 EDT
Have a .tern-project file with the following contents:

{
	"plugins": {
		"node": {},
		"mysql": {}
	},
	"libs": ["ecma5", "ecma6"]
}

then make a source file with the following:

/*eslint-env mysql*/ require('mysql').createQuery(null,null,null).star

Invoking assist will give you two proposals, one from node (from EventEmitter) and one from ecma6. But the one from mysql is not given.

If you swap the order of the node and mysql plugins in the .tern-project file, you get the mysql proposal and not the node one??
Comment 1 Michael Rennie CLA 2016-06-28 15:22:41 EDT
Looks like the problem is in tern.js while trying to gather proposals.

line 791 in tern.js has the following:

for (var prop in srv.cx.props) gather(prop, srv.cx.props[prop][0], 0);

since props are inferred and added as an array (srv.cx.props[prop] can be an array of undetermined length), we should be gathering all of the props from that contest, not just the first one.
Comment 3 Michael Rennie CLA 2016-06-29 14:52:19 EDT
Upstream Tern bug and pull request:

https://github.com/ternjs/tern/issues/797
Comment 4 Curtis Windatt CLA 2016-06-29 15:57:45 EDT
This causes a test failure for me locally

Tern Content Assist Tests
MySQl Index Tests
test mysql index 4 ‣
AssertionError: Invalid proposal description: expected 'node' to equal 'mysql'

The returned proposals are in a different order than expected.  This works in the editor because we run our own sorting function, but the tests are looking at what Tern is returning.