I'm working on a project that must use Eclipse JDT for parsing java methods and generating Abstract Syntax tree for them I wrote the following code :
String method ="\n"+
" public void sayHello() {\n"+
" System.out.println(\"Hello \"+name+\"!\");\n"+
" }\n";
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(method.toCharArray());
parser.setResolveBindings(true);
parser.setBindingsRecovery(true);
CompilationUnit unit = (CompilationUnit)parser.createAST(null);
This snippet just creates AST, but I get stuck!! I'd like to visit AST of any java method and print its path. Can I get print AST for java Method?