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

Bug 493463

Summary: [tern18] Tern doesn't recognize global properties when node plugin is running
Product: [ECD] Orion Reporter: Curtis Windatt <curtis.windatt.public>
Component: JS ToolsAssignee: Curtis Windatt <curtis.windatt.public>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 12.0   
Target Milestone: 12.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on: 493276    
Bug Blocks:    

Description Curtis Windatt CLA 2016-05-11 16:13:56 EDT
1) In Minesweeper project
2) Ensure .tern-project will load the node plugin (or all plugins)
3) Ensure .tern-project will loadEagerly index.html
4) Open main.js
Result
Counter cannot be found.

Counter is a global scope function from counter.js which is loaded by index.html.  This still fails even if you navigate to the file directly.  Everything works if the node plugin isn't running.
Comment 1 Curtis Windatt CLA 2016-05-11 16:17:57 EDT
This is caused by the modules plugin adding a wrapping scope to every single file.  Globals no longer show up in the top level scope.  Workaround is to not run node plugin when not using node for dependencies.  Fix is only modify the scope when we are using node in that specific file.

Same problem will occur for es_modules plugin and commonJS.
Comment 2 Curtis Windatt CLA 2016-05-11 17:01:01 EDT
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=83fe8bfc3b98d99d1c2fef25c88f06e6dee46652
This fixes the problem by explicitly checking that the current file is using a node environment.

However, this check will cause problems for es_modules support which also uses modules.js.
Comment 3 Curtis Windatt CLA 2016-05-12 13:02:36 EDT
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=09838adac94db342e7c05c2222a93183917e9b4b
This substantially expands our cross file tests to check node, HTML global and es import dependencies.
The es import tests are skipped because the current fix in modules.js only checks for node usage.
Comment 4 Curtis Windatt CLA 2016-05-12 17:08:09 EDT
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=f80018ef1c5b8d2edb93af1279bfbee02db91d13
This allows es_modules plugin to run whenever there is an import declaration.

I can't re-enable the es_modules tests because we can't set the Tern server to sourceType: module mode in the tests yet. See Bug 493276
Comment 5 Curtis Windatt CLA 2016-05-17 17:41:04 EDT
Tests were added as part of Bug 493611.  Marking this as FIXED.