Package net.sourceforge.pmd.lang.ast
Interface AstVisitor<P,R>
- Type Parameters:
P- Parameter type of the visit methodR- Return type of the visit method
- All Known Implementing Classes:
AstVisitorBase
public interface AstVisitor<P,R>
Root interface for AST visitors. Language modules publish a subinterface
with one separate visit method for each type of node in the language,
eg JavaVisitor.
Usually you never want to call visit methods manually, instead
calling Node::acceptVisitor,
which then dispatches to the most specific method of the visitor instance.
Use Void as a type parameter if you don't want a parameter type
or a return type.
-
Method Summary
-
Method Details
-
cannotVisit
Called by a node when it detects that the visitor is not of the language it is used to visiting. If a visitor wants to visit nodes for several languages, it should provide a useful implementation of this method. The default implementation throws- Parameters:
node- Node calling back this methodparam- Parameter of the visit- Returns:
- A value (or may throw)
-
visitNode
Visit a node. This method is dispatched statically, you should useNode.acceptVisitor(AstVisitor, Object)if you want to call the most specific method instead.- Parameters:
node- Node to visitparam- Parameter- Returns:
- Some result
-