我正在学习使用 ASTParser 解析 Java 项目的教程:
http://www.programcreek.com/2011/08/code-to-parse-a-java-project/
但我想要的是,使用 ASTPArser 来解析 Java 项目的战争或 jar 文件。可能吗?如果是,你能告诉我怎么做吗?
提前致谢!
我正在学习使用 ASTParser 解析 Java 项目的教程:
http://www.programcreek.com/2011/08/code-to-parse-a-java-project/
但我想要的是,使用 ASTPArser 来解析 Java 项目的战争或 jar 文件。可能吗?如果是,你能告诉我怎么做吗?
提前致谢!
Do you understand what these technologies are?
An AST is an Abstract Syntax Tree. An AST is generated when a single compilation file is parsed. WAR and EAR are archive files, basically fancy ZIPs with some metadata files that tell special applications that read them (e.g. a compliant EJB server) how to handle them.
The Abstract Syntax Tree of an archive makes no sense. That's like the AST of a folder, or document. But the algorithm should be clear.
Tools like Checkstyle do similar work under the covers to analyze projects. If you're stuck, or feeling brave, you may want to trace through that code to get an understanding of how they do it.