public final void accept(ASTVisitor visitor) { if (visitor == null) { throw new IllegalArgumentException(); } // begin with the generic pre-visit if (visitor.preVisit2(this)) { // dynamic dispatch to internal method for type-specific visit/endVisit accept0(visitor); } // end with the generic post-visit visitor.postVisit(this); }
abstract void accept0( visitor);
void accept0(ASTVisitor visitor) { boolean visitChildren = visitor.visit(this); if (visitChildren) { // visit children in normal left to right reading order acceptChild(visitor, getException()); acceptChild(visitor, getBody()); } visitor.endVisit(this); }
final void acceptChild(ASTVisitor visitor, ASTNode child) { if (child == null) { return; } child.accept(visitor); }