Montag, 15. Juli 2013

Fixing multiple errors with search/replace in Eclipse

This is just a short post about a nice trick which I just found out while doing big changes to several projects in eclipse.

I had some problems refactoring a class due to too many previous errors and ended up having more errors due to a method which I moved elsewhere. Replacing the method call wasn't a problem, but I needed to add the import to the new Class too.

Applying a quick fix for adding the import to all these files at the same time in the Problems view didn't work out (seems like a small bug in eclipse). But when I did a right click on the problems view table I had the 'Show In' option and selected 'Project Explorer'. This resulted in a selection of all affected files in the explorer. Next I did go to the Search->File menu and hit 'Search In: Selected Resources'.

Now it was easy to search via regular expression for 'package (.*);' and replace with '\0\R\Rimport MyNewClass;'