eclipse-typescript
eclipse-typescript copied to clipboard
Feature: Quick Rename occurrences inline with ctrl+2 r
There is a neat feature in JavaScript Eclipse (also in PyDev):
- Go to name, and let the occurrences highlight.
- Click ctrl+2 and then r
It goes to rename occurrences inline, that is the editor edits all occurrence places without dialog. I find this very useful feature, it gives me instant feedback what it renames.
I know there is refactor rename, but it seems a bit overkill at times.
That would be cool :)
Looking around how it's done in PyDev:
It starts from here, it opens a quick shortcut dialog when pressing ctrl+2, which allows to hit R, it's here:
edit.addOfflineActionListener("r", new PyRenameInFileAction(edit), "Rename occurrences in file", false);
ActionCreatorPyEditListener.java
And the renaming action is here PyRenameInFileAction.java
Yet to figure out how it's done though, seems a lot of code for replacing already highlighted occurrences.
Yeah, I considered implementing the find/replace this way but it seemed overly complex so I did the dialog approach instead. I strongly agree this design would be better but I don't have the time to implement it.
Eclipse plugin API seems depressingly convoluted. I think I'll still try to take stab at this at later time, this would be useful.
Ideally this should be like few lines of code if Eclipse provided some higher level functions, for e.g. multi edit locations. Loop all marked annotations, set multiple edit location around each.
Ah yeah, I don't think there is a helper for inline renaming in the same way that there was for modal renaming.
I'll put this as a reference (and a reminder for myself) here also:
I suspect this file is JavaScript Eclipse (JSDT) equivalent: LinkedNamesAssistProposal.java