private class FunctionRewriter.ReductionGatherer extends java.lang.Object implements NodeTraversal.Callback
Modifier and Type | Field and Description |
---|---|
private java.util.List<FunctionRewriter.Reducer> |
reducers |
private com.google.common.collect.Multimap<FunctionRewriter.Reducer,FunctionRewriter.Reduction> |
reductions |
Constructor and Description |
---|
ReductionGatherer(java.util.List<FunctionRewriter.Reducer> reducers,
com.google.common.collect.Multimap<FunctionRewriter.Reducer,FunctionRewriter.Reduction> reductions) |
Modifier and Type | Method and Description |
---|---|
boolean |
shouldTraverse(NodeTraversal raversal,
Node node,
Node parent)
Visits a node in pre order (before visiting its children) and decides
whether this node's children should be traversed.
|
void |
visit(NodeTraversal traversal,
Node node,
Node parent)
Visits a node in postorder (after its children have been visited).
|
private final java.util.List<FunctionRewriter.Reducer> reducers
private final com.google.common.collect.Multimap<FunctionRewriter.Reducer,FunctionRewriter.Reduction> reductions
ReductionGatherer(java.util.List<FunctionRewriter.Reducer> reducers, com.google.common.collect.Multimap<FunctionRewriter.Reducer,FunctionRewriter.Reduction> reductions)
reducers
- List of reducers to apply during traversal.reductions
- Reducer -> Reduction multimap,
populated during traversal.public boolean shouldTraverse(NodeTraversal raversal, Node node, Node parent)
NodeTraversal.Callback
Visits a node in pre order (before visiting its children) and decides
whether this node's children should be traversed. If children are
traversed, they will be visited by
NodeTraversal.Callback.visit(NodeTraversal, Node, Node)
in postorder.
Implementations can have side effects (e.g. modifying the parse tree).
shouldTraverse
in interface NodeTraversal.Callback
public void visit(NodeTraversal traversal, Node node, Node parent)
NodeTraversal.Callback
Visits a node in postorder (after its children have been visited).
A node is visited only if all its parents should be traversed
(NodeTraversal.Callback.shouldTraverse(NodeTraversal, Node, Node)
).
Implementations can have side effects (e.g. modifying the parse tree).
visit
in interface NodeTraversal.Callback