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

Bug 496739

Summary: Nativation not working for Brackets source code for EventDispatcher.makeEventDispatcher
Product: [ECD] Orion Reporter: Steve Northover <steve_northover>
Component: JS ToolsAssignee: Michael Rennie <Michael_Rennie>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P2 CC: curtis.windatt.public, kuschel, Michael_Rennie
Version: 12.0   
Target Milestone: 14.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Steve Northover CLA 2016-06-24 10:57:37 EDT
1) get Brackets
2) drill into CommandManager.js
3) click on EventDispatcher.makeEventDispatcher(exports);
4) References->Project
5) BUG:  There is only one declaration, why can't we find it?

If you do References->Project, you can see this
Comment 1 Curtis Windatt CLA 2016-06-29 11:01:04 EDT
1) Follow the steps in comment #0
Result:
The declaration is found in EventDispatcher.js marked with ?

2) Run open decl / open impl from CommandManager.js
Result:
The correct decl/impl in EventDispatcher.js is opened

3) Run find references again
Result:
The declaration is found in EventDispatcher.js marked with a check

This behaviour appears correct for me.  We always find the declaration, but on the initial pass find references isn't 100% certain that they are referencing the same function.  Once you run open declaration Tern is certain that EventDispatcher is the correct declaration.

I'm closing this as WORKSFORME.  Reopen if you think I missed something.  cc'ing Mike in case I'm wrong about when find refs should be 100% confident about the declaration.
Comment 2 Steve Northover CLA 2016-07-14 19:29:10 EDT
Step 4 is wrong.  It should say "4) Tools->Open Declaration"

I get "No implementation was found"
Comment 3 Steve Northover CLA 2016-07-14 19:31:13 EDT
If you run Reference->Project and then Tools->Open Declaration you get different behavior.  You get a bogus potential mat.

Potential matches:

EventDispatcher.js - src/utils/EventDispatcher.js (start: 13552, end: 13571)
Comment 4 Steve Northover CLA 2016-07-14 19:32:42 EDT
To be 100% clear, 

"2) Run open decl / open impl from CommandManager.js
Result:
The correct decl/impl in EventDispatcher.js is opened"

is not working for me.  I am doing this on orion.eclipse.org.
Comment 5 Steve Northover CLA 2017-01-04 14:51:30 EST
Closed accidently
Comment 6 Steve Northover CLA 2017-01-25 13:10:33 EST
This still fails.  There is only one declaration of this method in the project.  Why can't we find it?

    var EventDispatcher = require("utils/EventDispatcher");
    EventDispatcher.makeEventDispatcher(Command.prototype);
Comment 7 Steve Northover CLA 2017-01-26 17:01:16 EST
Works in Sublime, fails in VS code, fails in Atom ...
Comment 8 Steve Northover CLA 2017-01-26 17:05:18 EST
Works in Sublime, fails in VS code, fails in Atom ...
Comment 9 Michael Rennie CLA 2017-01-27 13:58:34 EST
(In reply to Steve Northover from comment #8)
> Works in Sublime, fails in VS code, fails in Atom ...

The problem in our case is that the commonjs plugin is not loaded / not being called, so none of the type information is being propagated correctly (why we can't find the decl).

I also noticed that our linting rule does not nag about the plugin not being loaded (when it should be)
Comment 10 Michael Rennie CLA 2017-01-27 15:27:56 EST
Adding this simple .tern-project file makes it all work as expected:

{
	"plugins": {
		"commonjs": {}
	},
	"libs": ["ecma5", "ecma6"],
	"ecmaVersion": 6,
	"loadEagerly": []
}

I pushed a fix in bug 511235 that prevents core rules from being turned off. So without the above mentioned .tern-project file, you get alerted that the plugin is not running.
Comment 11 Michael Rennie CLA 2017-01-27 15:51:16 EST
(In reply to Michael Rennie from comment #10)

> I pushed a fix in bug 511235 that prevents core rules from being turned off.
> So without the above mentioned .tern-project file, you get alerted that the
> plugin is not running.

I'm going to close this one worksforme, since it was a configuration issue, that is now properly reported via the fix to bug 511235.