Namespace refactoring tool for Eclipse?
I'm doing some housekeeping on some files, and I need to move some classes to a new namespace. Currently I have to manually edit the files, but I was wondering i开发者_开发问答f there's a more efficient way of doing this?
I heard about ReSharper for Visual Studio does what I need, but is there a similar tool for Eclipse?
is there a similar tool for Eclipse?
Nope.
The is no such capability in eclipse until today MARS 8.1 . However, what on can do is to manually search for occurrences of the classes.
- Select the class name that you want to refactor and to a File Search within the enclosing project.
- From the tabs select "File Search" and then press "Replace ..." , it will find all occurences and let you fill in the replacement text.
- Click "Preview" to see what is going to be applied and remove those actions that you do not wish that they be applied by unchecking them.
This should be sufficient. If you are using git
you can always do git checkout -b _refactorme
to feel safe and then merge your changes. In that manner if something went wrong you can always track the problem e.g. using git blame
.
I'm not really sure if Eclipse does that but IntelliJ IDEA (from the same vendor as ReSharper) does have a refactoring to move classes between packages. It is available from Refactor > Migrate menu if I remember correctly.
精彩评论