Renaming accessor/mutator methods in Eclipse?
Asked Answered
H

2

10

Is there any way to automatically rename accessor/mutator when a variable they get/set gets refactored -> renamed (Eclipse 3.4)?

Heads answered 13/10, 2008 at 9:41 Comment(0)
B
19

1 - When you select Refactor->Rename on a variable, Eclipse prompts you to enter the new name in an "in-line" box. Directly below it, there is a help message and next to it a small icon (an arrow going down).Click on that arrow and then select "Open Rename Dialog". A new pop-up appears with the checkboxes you need.

2 - Alternatively, select the variable you want to change and press twice Alt+Shift+R. Again check the getter/setter checkboxes.

Boob answered 13/10, 2008 at 10:20 Comment(1)
Nice. Pity that it doesn't rename the argument to the setter, though.Eriha
L
0

By default eclipse will not rename getters and setters when using 'inline' renaming of a variable. However you can change this behaviour by using the 'Rename Field' dialog for a rename once, and selecting 'Rename getter' and 'Rename setter'. (see the answer by idrosid for details only how to open this window).

After this the 'inline' renames will also update the getter and setter for that field (but not the parameter in the setter).

Note, I have tested this with Eclipse 4.5

Lorilee answered 12/8, 2016 at 11:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.