Package net.sourceforge.pmd.lang.ast
Class AstVisitorBase<P,R>
- java.lang.Object
-
- net.sourceforge.pmd.lang.ast.AstVisitorBase<P,R>
-
- All Implemented Interfaces:
AstVisitor<P,R>
public abstract class AstVisitorBase<P,R> extends Object implements AstVisitor<P,R>
Base implementation ofAstVisitor
, that performs a top-down (preorder) visit and may accumulate a result.Note that if you care about the result (
<R>
), then you need to overridevisitChildren
to implement the logic that combines values from children, if any.
-
-
Constructor Summary
Constructors Constructor Description AstVisitorBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected R
visitChildren(Node node, P data)
Visit the children.R
visitNode(Node node, P param)
Visit a node.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.AstVisitor
cannotVisit
-
-
-
-
Method Detail
-
visitChildren
protected R visitChildren(Node node, P data)
Visit the children. By default the data parameter is passed unchanged to all descendants, and null is returned. Override this method to customize this behavior.- Parameters:
node
- Node whose children should be visiteddata
- Parameter of the visit- Returns:
- Some value for the children
-
visitNode
public R visitNode(Node node, P param)
Description copied from interface:AstVisitor
Visit a node. This method is dispatched statically, you should useNode.acceptVisitor(AstVisitor, Object)
if you want to call the most specific method instead.- Specified by:
visitNode
in interfaceAstVisitor<P,R>
- Parameters:
node
- Node to visitparam
- Parameter- Returns:
- Some result
-
-