0

I have a problem that I changed the class name in java class using javaParser and now I want to change all references from the old name to the new name. For example, if I have a java class like this

class A{
 private static final Logger log4j = LoggerFactory.getLogger(A.class);
}

and I changed the name of A to B

class B{
     private static final Logger log4j = LoggerFactory.getLogger(A.class);
}

then I also want to scan all the files to change A to B using javaParser and I don't know how anybody here can help?

Rans
  • 422
  • 2
  • 8
Eslam Ashour
  • 113
  • 12

2 Answers2

1

You can refactor class name

This operation will automatically change all usages

enter image description here

kaan bobac
  • 729
  • 4
  • 8
  • What about not using IntelliJ Idea? – aydinugur Oct 08 '18 at 13:42
  • same for eclipse as well... http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Ftasks%2Fcdt_t_rename.htm – kaan bobac Oct 08 '18 at 13:44
  • but i have a lot of projects and i want to change a lot of things like variale name not only class name and i want to make this automatically by JavaParser so refactor will not help me – Eslam Ashour Oct 08 '18 at 13:55
0

In Eclipse, for classes just right click on the class in the project explorer and select "Refactor->Rename". That it is is under the "Refactor" submenu. Shift + alt + r (Right click file ->refactor ->rename) when cursor is on class name. For Variables 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.

John
  • 258
  • 1
  • 5
  • 21
  • but i have a lot of projects and i want to change a lot of things like variale name not only class name and i want to make this automatically by JavaParser so refactor will not help me – Eslam Ashour Oct 09 '18 at 07:31