Interface AstVisitor<P,​R>

  • Type Parameters:
    P - Parameter type of the visit method
    R - Return type of the visit method
    All Known Implementing Classes:

    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 Detail

      • cannotVisit

        default R cannotVisit​(Node node,
                              P param)
        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
        node - Node calling back this method
        param - Parameter of the visit
        A value (or may throw)
      • visitNode

        R visitNode​(Node node,
                    P param)
        Visit a node. This method is dispatched statically, you should use Node.acceptVisitor(AstVisitor, Object) if you want to call the most specific method instead.
        node - Node to visit
        param - Parameter
        Some result