Problem with ASTVisitor [message #509845] |
Mon, 25 January 2010 10:24  |
Eclipse User |
|
|
|
I'm trying to find all ReturnStatement-s in a given MethodDeclaration:
MethodDeclaration decl = ...
System.out.println("decl = " + decl);
final List<ReturnStatement> returnStmts = new ArrayList<ReturnStatement>();
ASTVisitor visitor = new ASTVisitor() {
@Override
public boolean visit(ReturnStatement node) {
System.out.println("visiting " + node);
returnStmts.add(node);
return true;
}
@Override
public void preVisit(ASTNode node) {
System.out.println("visiting " + node);
}
};
visitor.visit(decl);
I get empty list and only following output:
decl = static String getWhereClause(){
return "where 1=2";
}
this shows that "decl" is OK, and it has a ReturnStatement.
Any idea what's wrong here?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03308 seconds