A visitor which handles a node visited by a TreeWalker.

interface Visitor<NodeType extends Node> {
    getChildren(
        node: NodeType,
        context: Context<NodeType>,
    ): undefined | void | NodeType[] | Iterable<NodeType>;
    postVisit(node: NodeType, context: Context<NodeType>): void | VisitCodes;
    preVisit(node: NodeType, context: Context<NodeType>): void | VisitCodes;
}

Type Parameters

  • NodeType extends Node

Methods

  • Retrieves all children at a given node. HINT: This not necessarily have to be the children of the current node. An implementation may give the visitor a chance to return an arbitrary list of child nodes. By default, the node's children are considered to walk deeper the tree.

    Parameters

    Returns undefined | void | NodeType[] | Iterable<NodeType>

    Indicates how the walker shall proceed, the default is VisitCodes.CONTINUE.

  • Node handle to do something after visiting the node's children.

    Parameters

    Returns void | VisitCodes

    Indicates how the walker shall proceed, the default is VisitCodes.CONTINUE.

  • Node handle to do something before visiting the node's children.

    Parameters

    Returns void | VisitCodes

    Indicates how the walker shall proceed, the default is VisitCodes.CONTINUE.