如何将所有已弃用的类列出到文件中?

时间:2017-01-16 09:28:02

标签: java intellij-idea deprecated

我知道Intellij can scan就是这个 - 而且似乎有一个名为Scannotation的古老项目。这些似乎都不符合我的要求。

我想列出代码库中标记为@Deprecated的类的完整包名。

我的问题是:如何将所有已弃用的类列出到文件中?

3 个答案:

答案 0 :(得分:1)

您可以使用Structural Search

CTRL + SHIFT + A - > Search Structurally

使用它来查找所有已弃用的类:

@Deprecated
class $class$ {
}

答案 1 :(得分:0)

在unix / linux系统上,您可以使用find . -name *.java -regex "@Deprecated"

这将给出一个包含绝对路径的文件列表,这些路径可以使用sed或任何其他文本编辑器更改为包符号。

在Windows上,您可以考虑安装 git ,它会带来一个bash,您可以在其中运行此命令。

答案 2 :(得分:0)

这是你可以使用的:

    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();
        }

    }
相关问题