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

Bug 492470

Summary: All JS code completions are available inside of string literals
Product: [ECD] Orion Reporter: Curtis Windatt <curtis.windatt.public>
Component: JS ToolsAssignee: Michael Rennie <Michael_Rennie>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Michael_Rennie, Olivier_Thomann
Version: 12.0   
Target Milestone: 12.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Screenshot
none
Remove templates from string completions none

Description Curtis Windatt CLA 2016-04-26 12:48:35 EDT
Created attachment 261263 [details]
Screenshot

1) Open JS file
2) Type "fo" (including the quotes)
3) Ctrl+Space to complete
Result:
See screenshot, for loop completions are offered.
Comment 1 Curtis Windatt CLA 2016-04-26 14:48:36 EDT
This appears to be the expected behaviour of Tern.  It checks the word end for a prefix.

Two things make this worse for Orion
1) We have a lot of templates that fill the completions list
2) We don't run the string completions plugin

This will be a problem for module name completion in Tern 18.
Comment 2 Curtis Windatt CLA 2016-04-26 16:45:05 EDT
Created attachment 261272 [details]
Remove templates from string completions
Comment 3 Curtis Windatt CLA 2016-04-26 16:47:16 EDT
The patch fixes (1)
Running the string completions plugin by default would fix (2).

This would result in the same behaviour as the Tern demo.  If we are concerned about performance of that plug-in we'll have to add our own plug-in (or modification to Tern) to skip calculating proposals as usual.
Comment 4 Michael Rennie CLA 2016-04-27 11:46:25 EDT
I pushed a different patch for not showing the templates in literals:

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=b3e0a5f8fdea1f80faf08aef9b10ffb18ea3e0fb

The patch avoids wrapping the code in an if, and treats literals differently depending on their kind, where to allow a template. 

For example:

1. var foo = /f*/<-- assist here should not show a template since thats where modifiers for the regex literal go

2. var foo = "f"<-- assist here should show a template, the literal is complete

3. var foo = 333<-- assist here should not show a template

4. var foo = true<-- assist here should not show a template
Comment 5 Michael Rennie CLA 2016-05-19 12:18:02 EDT
After wasting time trying to get the complete_strings plugin up and running - which has the negative effect of stomping on the module name completion - I ended up modifying the Tern code.

Fixed in:

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=1e91d96d41295054f125bf7a4825e762ae1b35b3

Related Tern bug (and pull request):

https://github.com/ternjs/tern/issues/780