Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refactoring a field in eclipse

Tags:

java

eclipse

When i rename a variable in eclipse using Ctrl+1 it doesnt rename the getter/setter methods. Is there any way to rename the methods as well.

like image 500
mangala shenoy Avatar asked Sep 11 '12 06:09

mangala shenoy


2 Answers

Use Alt+Shift+R on the required field. In the dialog that appears select 'Open Rename Dialog' and check the corresponding checkboxes

like image 80
pankar Avatar answered Sep 28 '22 10:09

pankar


Rename the field using Refactor > Rename and choose "open rename dialog" in the tooltip. Or, simpler, press Ctrl+R twice.

In the rename dialog you can then choose to rename the getter and the setter of the field as well.

The setting you apply there is persistent, so after checking Rename getter and Rename setter, the next inline-rename will honor the setting as well and rename the getters and setters.

Rename dialog in Eclipse 3.7

like image 33
nd. Avatar answered Sep 28 '22 09:09

nd.