简体   繁体   中英

Mark all from java packages as @Depracated in eclipse

它是一种自动标记java包(子包,类,方法,成员)的整个内容为@Depracated使用eclipse(最好)或任何其他工具(如果有太多文件来手动创建它)的方法。

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:

搜索 Then, press Replace , and fill it out like this:

更换
All done!

Try creating a file called package-info.java and deprecate the package.

@Deprecated
package foo;

Deprecating foo and will not deprecate foo.bar .

Tested on Java 7; Eclipse.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM