Search code examples
javaeclipserefactoringuimaautomated-refactoring

Refactoring or Renaming Class Imports in Eclipse


In my eclipse project I have dependencies that are imported like this:

import org.uimafit.util.JCasUtil;

However, there has been a namespace change in my dependent project (it moved to apache) such that I need to refactor these imports to look more like this:

import org.apache.uima.fit.JCasUtil;

I am using:

Eclipse Java EE IDE for Web Developers. Version: Mars.2 Release (4.5.2) Build id: 20160218-0600

Is there any way to automatically refactor all instances of imports of this type in Eclipse? Answers that include plugins, upgrading/changing my version of Eclipse are all acceptable.


Solution

  • Go to Search --> File, the search dialog will pop up.

    In the containing text text-field type the string you want to replace: import org.uimafit.util.JCasUtil;

    In the File name patterns type *.java (the files you want to look into).

    Then hit the Replace button. It will find the text and another dialog will pop up, titled Replace text matches. In the With text field, type the new text: import org.apache.uima.fit.JCasUtil; and hit the OK button. It will replace all the matches.