Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mark all from java packages as @Depracated in eclipse

Is it a way to automatically mark the whole content of java package (subpackages, classes, methods, members) as @Depracated using eclipse (preferably) or any other tool if there is too many files to make it manually.

like image 217
Łukasz Rzeszotarski Avatar asked Mar 22 '13 09:03

Łukasz Rzeszotarski


1 Answers

You could use sed to mark all classes in the current directory and below (tested in Cygwin). Navigate to the desired folder and run:

for file in $(find . -name *.java); do sed -i 's/\(public class\)/@Deprecated\n\1/g' $file; done

To also mark interfaces just add it like this:

for file in $(find . -name *.java); do sed -i 's/\(\(public class\|interface\)\)/@Deprecated\n\1/g' $file; done

EDIT

As @ŁukaszRzeszotarski points out, you can do this in Eclipse with the Search/Replace tool. Just mark the resources where you want to perform the operations, then press Ctrl + h. Fill it out like this:

Search Then, press Replace, and fill it out like this:

Replace
All done!

like image 72
Keppil Avatar answered Sep 21 '22 02:09

Keppil