Reddy
Reddy

Reputation: 8911

auto-import of packages across project in eclipse

I have used file search functionality in eclipse to replace a specific occurrence of text with a replace text which contains a java method name in all files across the workspace.

But now in all those files I have to add the import statement (for the method name to resolve).

Is there an automatic way of doing this instead of manually searching and importing the package myself in all files?

P.S.: I can't use java refactoring since the text I have changed is not a java element and Organize import option will make changes to lot of files (re-ordering imports) which will be problematic when I need to commit, I again have to manually check differences to see which files have actual changes instead of just organize import statements.

Upvotes: 4

Views: 2649

Answers (1)

Omry Yadan
Omry Yadan

Reputation: 33596

Instead of doing this with search and replace, try to use Refactor->rename which will do it correctly. another options is to use organize imports, you can do it for an entire project as well (source -> organize imports).

Upvotes: 6

Related Questions