<分区>
这段Java代码很难理解。这个 DirExplorer 是如何创建的?类 DirExplorer 链接是 https://github.com/ftomassetti/analyze-java-code-examples/blob/master/src/main/java/me/tomassetti/support/DirExplorer.java 干杯, 代码如下:
new DirExplorer((level, path, file) -> path.endsWith(".java"), (level, path, file) -> {
System.out.println(path);
System.out.println(Strings.repeat("=", path.length()));
try {
new VoidVisitorAdapter<Object>() {
@Override
public void visit(ClassOrInterfaceDeclaration n, Object arg) {
super.visit(n, arg);
System.out.println(" * " + n.getName());
}
}.visit(JavaParser.parse(file), null);
System.out.println(); // empty line
} catch (ParseException | IOException e) {
new RuntimeException(e);
}
}).explore(projectDir);