< p >ASTNode 的 < code >accept 方法是做什么用的(javadoc 没有提供太多帮助...)?什么时候会调用 < code >visit(Expression node) 方法呢?下面是一个需要使用它的示例代码:
final List<Expression> listi = new ArrayList<Expression>();
String stringi = opi.generate(entryContract, true_false_maybe);
// stringi representes an expression, for example "g!=h".
parser.setSource(stringi.toCharArray());
unit = (CompilationUnit) parser.createAST(null);
ASTNode astRoot = unit.getRoot();
astRoot.accept(new ASTVisitor() {
public boolean visit(Expression node) {
listi.add(node);
return true;
}
});
Thank you