java - ASTVisitor 类定义节点

标签 java eclipse abstract-syntax-tree

我一直在 Eclipse 中使用 ASTVisitor 类,以便在方法声明和方法调用节点获取数据。我现在还想在类声明节点获取数据,但我在 ASTVisitor 的 API 中找不到任何允许我执行此操作的内容。我错过了什么吗?什么是做到这一点的好方法?

最佳答案

如果你想获得ClassDeclaration,你应该寻找TypeDeclaration对象因为:

A type declaration is the union of a class declaration and an interface declaration.

一旦找到它,您只需使用 isInterface()方法,如果返回 false 则为 ClassDeclaration

关于java - ASTVisitor 类定义节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23414957/

相关文章:

java - MAC 上的 Eclipse,将当前目录设置为 Documents 文件夹而不是 APP BUNDLE

javascript - 如何以编程方式更改 CSS 以限制其范围?

java - 如何使用 ASTRewrite 将特定的 SimpleType 替换为 PrimitiveType?

java - Android源码,Java trace,抽象类

java - Function Java 将 arity-2 函数 (F2) 绑定(bind)到选项

java - 如何更改 LayerDrawable 中一张图像的大小

java - Hibernate postgresql 通知功能

php - eclipse PHP : variable undefined evenif it is defined in an require_once php file

android - 如何让Eclipse Android 布局编辑器扩展高度?

python - ast.literal_eval() 格式错误的节点或字符串,同时使用 array()s 列表转换字符串