public class SpliceASTWalker extends java.lang.Object implements ASTVisitor
Modifier and Type | Field and Description |
---|---|
java.util.Map<CompilationPhase,java.util.List<java.lang.Class<? extends ISpliceVisitor>>> |
visitorClasses |
Constructor and Description |
---|
SpliceASTWalker(java.util.List<java.lang.Class<? extends ISpliceVisitor>> afterParseClasses,
java.util.List<java.lang.Class<? extends ISpliceVisitor>> afterBindClasses,
java.util.List<java.lang.Class<? extends ISpliceVisitor>> afterOptimizeClasses) |
Modifier and Type | Method and Description |
---|---|
void |
begin(java.lang.String statementText,
CompilationPhase phase)
The compiler calls this method just before walking a query tree.
|
void |
end(CompilationPhase phase)
The compiler calls this method when it's done walking a tree.
|
void |
initializeVisitor()
Initialize the Visitor before processing any trees.
|
boolean |
skipChildren(Visitable node)
Method that is called to indicate whether
we should skip all nodes below this node
for traversal.
|
boolean |
stopTraversal()
Method that is called to see
if query tree traversal should be
stopped before visiting all nodes.
|
void |
teardownVisitor()
Final call to the Visitor.
|
Visitable |
visit(Visitable node,
QueryTreeNode parent)
This is the default visit operation on a
QueryTreeNode.
|
boolean |
visitChildrenFirst(Visitable node)
Method that is called to see if
visit() should be called on
the children of node before it is called on node itself. |
public final java.util.Map<CompilationPhase,java.util.List<java.lang.Class<? extends ISpliceVisitor>>> visitorClasses
public SpliceASTWalker(java.util.List<java.lang.Class<? extends ISpliceVisitor>> afterParseClasses, java.util.List<java.lang.Class<? extends ISpliceVisitor>> afterBindClasses, java.util.List<java.lang.Class<? extends ISpliceVisitor>> afterOptimizeClasses)
public void begin(java.lang.String statementText, CompilationPhase phase) throws StandardException
ASTVisitor
begin
in interface ASTVisitor
statementText
- Text used to create the tree.phase
- of compilation (AFTER_PARSE, AFTER_BIND, or AFTER_OPTIMIZE).StandardException
public void end(CompilationPhase phase) throws StandardException
ASTVisitor
end
in interface ASTVisitor
phase
- of compilation (AFTER_PARSE, AFTER_BIND, or AFTER_OPTIMIZE).StandardException
public Visitable visit(Visitable node, QueryTreeNode parent) throws StandardException
Visitor
Visitors will overload this method by implementing a version with a signature that matches a specific type of node. For example, if I want to do something special with aggregate nodes, then that Visitor will implement a visit(AggregateNode node) method which does the aggregate specific processing.
visit
in interface Visitor
node
- the node to processparent
- the parent of the node being visited, or, more generally, the node that contains a reference to
the node being visited.StandardException
- may be throw an error
as needed by the visitor (i.e. may be a normal error
if a particular node is found, e.g. if checking
a group by, we don't expect to find any ColumnReferences
that aren't under an AggregateNode -- the easiest
thing to do is just throw an error when we find the
questionable node).public boolean visitChildrenFirst(Visitable node)
Visitor
visit()
should be called on
the children of node
before it is called on node
itself.
If this method always returns true
, the visitor will walk the
tree bottom-up. If it always returns false
, the tree is visited
top-down.visitChildrenFirst
in interface Visitor
node
- the top node of a sub-tree about to be visitedtrue
if node
's children should be visited
before node
, false
otherwisepublic boolean stopTraversal()
Visitor
stopTraversal
in interface Visitor
public boolean skipChildren(Visitable node) throws StandardException
Visitor
Differs from stopTraversal() in that it only affects subtrees, rather than the entire traversal.
skipChildren
in interface Visitor
node
- the node to processStandardException
public void initializeVisitor() throws StandardException
ASTVisitor
initializeVisitor
in interface ASTVisitor
StandardException
public void teardownVisitor() throws StandardException
ASTVisitor
teardownVisitor
in interface ASTVisitor
StandardException