When refactoring a field, the default behaviour in eclipse is to rename just the field, leaving accessor methods with inconsistent names.
Pressing Alt+Shift+R
twice shows a "Renaming dialog" where I can select if accessors should be renamed as well (as two separate options). This eases the pain of manually renaming the accessors, but is still quite suboptimal, involving pressing 3 more shortcuts than with the in-place renaming, plus my usual forgetfulness... :)
I cannot think of a reason why I would NOT like my refactoring to be consistent, so is there a way to make accessor renaming the default behaviour? I'm OK with tweaking cryptic settings and setting obscure flags as long as it works.
Thank you
To rename all uses of this msg variable, highlight the variable and select Refactor→ Rename, or right-click the variable and select Refactor→ Rename, opening the dialog shown in Figure 4-1.
Highlight and right click on the variable you want to rename. Navigate to Refactor and select Rename.... Type in your new variable name and press Enter.
We can rename variables and methods by following these simple steps: Select the element. Right-click the element. Click the Refactor > Rename option.
Right click file -> Refactor -> Rename. Show activity on this post. You can rename classes or any file by hitting F2 on the filename in Eclipse. It will ask you if you want to update references.
Just tried that in Eclipse 3.6 Helios (but I remember it works in Eclipse 3.4 and 3.5 and probably even earlier)
A single Alt-Shift-R rename in the editor, once ENTER is pressed, will change the method name of corresponding getter and setter. The prerequisite is probably you should have once open the Rename Field dialog by pressing Alt-Shift-R twice, and select options in Rename getter and Rename setter. Subsequent rename actions will remember your choice on this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With