| Summary: | [Quickfix] Provide quickfix to rename a shadowed variable | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [ECD] Orion | Reporter: | Steve Northover <steve_northover> | ||||
| Component: | JS Tools | Assignee: | 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
Steve Northover
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? 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. 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. Created attachment 258805 [details]
Proposed patch
This is a first draft.
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. New Gerrit change created: https://git.eclipse.org/r/63471 (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. New Gerrit change created: https://git.eclipse.org/r/63481 Michael, can you please evaluate the patch? Thanks. New Gerrit change created: https://git.eclipse.org/r/63571 Gerrit change https://git.eclipse.org/r/63571 was merged to [master]. Commit: http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=033767b4e4923a2a842967f2c253039151138086 Merged. Thanks Olivier! |