Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse how to refactor variable names?

In my 15 years old java project, Standard Java Conventions are not respected, and first letter of variable names is often capitalized.

I would like to refactor my project to lower case first letter of variables names, especially in method signatures :

public void creerProfil(String CodeProfil, Profil ProfilACreer) throws Exception {
...
}

should be :

public void creerProfil(String codeProfil, Profil profilACreer) throws Exception {
...
}

If you have any idea of plugin which could do that, I would be glad to hear it :)

like image 428
Ben Avatar asked Apr 01 '15 10:04

Ben


People also ask

How do I Refactor a name in Eclipse?

Refactoring a method name is just as easy. For example, select the printem method and then select Refactor→ Rename, or right-click the variable and select Refactor→ Rename.

How do I change all variable names in Eclipse?

Select the variable you with to change, right click, and select Refactor->Rename. This will highlight all instances of the variable. Changing the variable name is automatically propagated to all of the instances.

How do you Refactor a variable name in Java?

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. Verify that occurrences of the variable are updating as you type.


3 Answers

You can Also Press Alt+Shift+R in Eclipse to refactor on variable.

like image 125
MrDumb Avatar answered Oct 16 '22 12:10

MrDumb


If you are on windows/ubuntu platform use alt+shift+R or on mac use command+option+r. It will refactor all the occurences where that variable is used.

To get the list of shortcuts available in eclipse, use ctrl+shift+L in windows/ubuntu and command+shift+l in mac.

like image 22
Vivek Singh Avatar answered Oct 16 '22 13:10

Vivek Singh


No plugins needed, rightclick on the variable name, then "refactor" -> "rename". However, never tried before, I don't know how reliable it is among the whole project.

like image 4
Luigi Cortese Avatar answered Oct 16 '22 14:10

Luigi Cortese