我一直在 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/