Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to refactor field names in eclipse which should change getters/setters as well

Tags:

java

eclipse

I need to do lot of refactoring (actually need to change field names) in eclipse. It is changing all occurrences, references of fields. But one thing is it is not changing getter/setter names which have been generated based on previous name.

Do we have any plugin to do this or any configuration change needed to be done?

like image 775
Reddy Avatar asked May 10 '10 19:05

Reddy


People also ask

How do I change my getters and setters in Eclipse?

Select "Javadoc -> Generate Getter/Setter Javadocs from Field Javadocs..." in the main menu of Eclipse or the context menu of the editor, and a dialog opens. The shortcut key is Ctrl+Shift+D. In the dialog select getters and setters for which you want to generate Javadocs and click "OK" button.

How do I refactor a name in Eclipse?

We can rename variables and methods by following these simple steps: Select the element. Right-click the element. Click the Refactor > Rename option.

What does refactor do in Eclipse?

AutoRefactor is an Eclipse plugin to automatically refactor Java code bases. The aim is to fix language/API usage in order to deliver smaller, more maintainable and more expressive code bases.

How do I refactor a method in Eclipse?

Refactoring using EclipseRight clicking on a Java element in the Package Explorer view and selecting Refactor menu item. Right clicking on a Java element in the Java editor and selecting Refactor menu item. Selecting a Java element in either the Package Explorer view or Java Editor and clicking Shift + Alt + T.


1 Answers

Yes, in Galileo the "rename" dialog has an option for changing the setters and getters of a field - see here. (Alternatively, you can use ALT + SHIFT + R twice after selecting the field)

Before Galileo, you'd have to do 3 actions instead of one (not that bad)

like image 120
Bozho Avatar answered Sep 18 '22 18:09

Bozho