fling
fling copied to clipboard
Improve the structure of generated AST visitors
AST visitor generation was producing visitors that were hardly useful:
-
visitmethods were final which prevented implementations from controlling the descending behaviour -
whileVisitingmethods were hardly useful due to point 1
Consider the task of wrapping a parent AST node in parentheses, including its children. This could not be achieved using previous AST visitors.
This change makes visitors be generated in the fashion of
javax.lang.model.util.ElementScanner. It allows implementations to
control the descent like so:
void visit(ParentNode node) {
print("("); // before visiting children
Visitor.super.visit(node); // descend
print(")"); // after having visited children
}