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

Bug 475952

Summary: [Quickfix] Provide quickfix to rename a shadowed variable
Product: [ECD] Orion Reporter: Steve Northover <steve_northover>
Component: JS ToolsAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P2 CC: Michael_Rennie, Olivier_Thomann
Version: unspecified   
Target Milestone: 11.0   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/63571
https://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=033767b4e4923a2a842967f2c253039151138086
Whiteboard:
Attachments:
Description Flags
Proposed patch none

Description Steve Northover CLA 2015-08-26 12:25:57 EDT
Now that we have rename variable, a quick fix that allows you to rename the shadowed variable seems like a good idea.
Comment 1 Steve Northover CLA 2015-11-23 13:03:43 EST
Eric isn't able to look at this right now.  Curtis, is this an easy quick fix to implement?  When a variable is shadowed, the fix it to rename it, no?
Comment 2 Curtis Windatt CLA 2015-11-23 13:21:33 EST
This should be pretty easy to do something for.  ESLint is identifying the variable that is shadowing so we can use the same logic as the rename command to modify all local references.  However, we would probably want to let the user choose a new name, which means putting the editor in linked mode like rename command does.  I wonder if we could actually use the rename command as a quickfix directly, as quickfixes are implemented using commands.

cc'ing Oliver as he is already looking at some ESLint rules and fixes.
Comment 3 Olivier Thomann CLA 2015-12-18 12:12:54 EST
The rename command relies on the editor's offset to know what variable should be renamed. When used as a quickfix, the "right" offset doesn't come from the editor, but from the passed in annotation. I modified the rename command to use the annotations from the options's argument if available.
I have code that works fine, but the way I retrieve the offset might not be optimal. After the rename, the offset in the editor is moved to the renamed variable declaration's offset.
Steve, would this be ok for you? I can show you how it works on my machine if you want. Just stop by when you have time.
Comment 4 Olivier Thomann CLA 2015-12-18 12:14:45 EST
Created attachment 258805 [details]
Proposed patch

This is a first draft.
Comment 5 Steve Northover CLA 2015-12-18 13:00:13 EST
If there is an offset that is "wrong", then SSQ will need to understand why it is wrong so he should review the patch.  Having said that, I'd like a demo.
Comment 6 Eclipse Genie CLA 2016-01-04 10:32:27 EST
New Gerrit change created: https://git.eclipse.org/r/63471
Comment 7 Olivier Thomann CLA 2016-01-04 10:33:22 EST
(In reply to Eclipse Genie from comment #6)
> New Gerrit change created: https://git.eclipse.org/r/63471
This is too early. I abandonned it.
Comment 8 Eclipse Genie CLA 2016-01-04 12:16:07 EST
New Gerrit change created: https://git.eclipse.org/r/63481
Comment 9 Steve Northover CLA 2016-01-04 18:39:19 EST
Michael, can you please evaluate the patch?  Thanks.
Comment 10 Eclipse Genie CLA 2016-01-05 10:52:15 EST
New Gerrit change created: https://git.eclipse.org/r/63571
Comment 12 Michael Rennie CLA 2016-01-05 16:31:44 EST
Merged. Thanks Olivier!