[英]How to list all deprecated classes to a file?
I'm aware that Intellij can scan for this - and there seems to be an ancient project called Scannotation .我知道 Intellij 可以对此进行扫描- 似乎有一个名为Scannotation的古老项目。 Neither of these seems to do what I want.
这些似乎都没有做我想要的。
I want to list the full package names of classes in my codebase that are marked @Deprecated
.我想列出我的代码库中标记为
@Deprecated
的类的完整包名称。
My question is: How to list all deprecated classes to a file?我的问题是:如何将所有已弃用的类列出到文件中?
You can use Structural Search .您可以使用结构搜索。
CTRL
+ SHIFT
+ A
--> Search Structurally
CTRL
+ SHIFT
+ A
--> Search Structurally
Use this to find all deprecated classes:使用它来查找所有已弃用的类:
@Deprecated
class $class$ {
}
On a unix/linux system you could use find . -name *.java -regex "@Deprecated"
在 unix/linux 系统上,您可以使用
find . -name *.java -regex "@Deprecated"
find . -name *.java -regex "@Deprecated"
This would give a list of files with absolute paths that could be changed to package notation with sed
or any other text editor.这将给出具有绝对路径的文件列表,可以使用
sed
或任何其他文本编辑器将其更改为包表示法。
On Windows you might consider installing git which brings a bash where you can run this command.在 Windows 上,您可能会考虑安装git ,它会带来一个 bash,您可以在其中运行此命令。
This is what you can use:这是您可以使用的:
package util;
import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner;
import io.github.lukehutch.fastclasspathscanner.matchprocessor.ClassAnnotationMatchProcessor;
public class AnnotationScanTest {
public static void main(String args[]) throws ClassNotFoundException {
new FastClasspathScanner("com")
// Optional, in case you want to debug any issues with scanning.
// Add this right after the constructor to maximize the amount of log info.
.verbose()
// Add a MatchProcessor ("Mechanism 1")
.matchClassesWithAnnotation(Deprecated.class, new ClassAnnotationMatchProcessor() {
@Override
public void processMatch(Class<?> matchingClass) {
System.out.println("Matching annotation: " + matchingClass);
}
})
// Actually perform the scan (nothing will happen without this call)
.scan();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.