支持注解的 Java 源代码解析器 [英] Java source code parser which supports annotations
问题描述
我需要一个用于 Java 的 Java 源代码解析库,以便以编程方式提取方法定义和注释.
I need a Java source code parsing library for Java to programmatically extract method definitions and annotations.
具体来说,给定的代码如下:
Specifically, given code like :
@WebMethod(operationName = "MyOperation")
public String myOperation(String param1,int param2) { ....
}
我有以下要求:
1.提取方法参数的名称、返回类型和名称和类型
2.提取与方法相关的注解
3.最后,通过删除注释创建一个新的源文件
I have the following requirements:
1. Extract the name, return type and names and types of the method parameters
2. Extract the annotations associated with the method
3. Finally, create a new source file by removing the annotations
我目前正在使用 JaxMeJS http://ws.apache.org/jaxme/js/jparser.html 满足 1. 但不满足 2. 或 3.
I am currently using JaxMeJS http://ws.apache.org/jaxme/js/jparser.html which satisfies 1. but not 2. or 3.
你能推荐一个可以满足所有 3 个要求的解析库吗?
Could you recommended a parsing library that can fulfill all 3 requirements ?
推荐答案
JavaCC 带有一个 1.5 解析器.
JavaCC comes with a 1.5 parser.
这篇关于支持注解的 Java 源代码解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!