Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename getter and setter in Eclipse. Shortcut? [duplicate]

Tags:

java

eclipse

Does anyone know a way to rename the getter and setter of a variable when I change the name of it?

The renaming function in eclipse is very useful, but, when I need to rename some variable, after that I need to manually fix the name of the getter and setter.

like image 972
Rafael Avatar asked Sep 27 '13 14:09

Rafael


1 Answers

  1. Right click on the variable
  2. Refactor -> Rename
  3. A prompt should appear asking you for the new field name and whether the accessors be updated. Type the new field name and select the checkboxes for both the setter and getter. Then click OK and you're done.

enter image description here

If the prompt doesn't appear, open Preferences->Java and unselect the Rename in editor without dialog checkbox. Then redo the three steps.

enter image description here

like image 124
Konstantin Yovkov Avatar answered Sep 21 '22 03:09

Konstantin Yovkov