Reputation: 17810
I am building a prototype of a static analysis tool, for which I intend to use eclipse to do the heavy lifting. How can I check what annotations are applied on a method when I visit the declaration using the ASTVisitor. I am interested in only certain methods of the class under analysis, and I am thinking of marking them using annotations
Upvotes: 3
Views: 1783
Reputation: 1
I got the annotations successfully by using MethodDeclaration.modifiers() . https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fjdt%2Fcore%2Fdom%2FBodyDeclaration.html&anchor=modifiers()
I hope this will help you.
Upvotes: 0
Reputation: 7923
Try ASTView plugin (http://www.eclipse.org/jdt/ui/astview/index.php), this helps to visualize the AST of a source file and also helps to figure out which nodes to visit.
You would probably want to override the following in ASTVisitor
Or you may visit only method declarations and get the annotations via MethodDeclaration.MODIFIERS2_PROPERTY.
Upvotes: 7