eclipse-typescript icon indicating copy to clipboard operation
eclipse-typescript copied to clipboard

Feature: Quick Rename occurrences inline with ctrl+2 r

Open Ciantic opened this issue 10 years ago • 6 comments

There is a neat feature in JavaScript Eclipse (also in PyDev):

  1. Go to name, and let the occurrences highlight.
  2. 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.

Ciantic avatar Jul 14 '14 13:07 Ciantic

That would be cool :)

derekcicerone-zz avatar Jul 14 '14 13:07 derekcicerone-zz

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.

Ciantic avatar Jul 14 '14 21:07 Ciantic

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.

derekcicerone-zz avatar Jul 14 '14 21:07 derekcicerone-zz

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.

Ciantic avatar Jul 14 '14 22:07 Ciantic

Ah yeah, I don't think there is a helper for inline renaming in the same way that there was for modal renaming.

derekcicerone-zz avatar Jul 14 '14 22:07 derekcicerone-zz

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

Ciantic avatar Jul 15 '14 10:07 Ciantic