Helper to analyze an AST.

Hierarchy

  • Walker

Properties

ROOT: ASTNode

Root of the AST

current: ASTNode

Current ASTNode.

currentIndex: number

Index of the current node in the parent's children.

parents: ASTNode[]

All parents of the current node.

queryOptions: ComplexQueryOptions

Global query options.

Methods

  • Function to pick the child at a given index.

    Parameters

    • childIndex: number

    Returns undefined | ASTNode

  • Function to pick the child nodes of the current node.

    Returns ASTNode[]

  • Function to get the number of children of the current node.

    Returns number

  • Function to check if the child at a given index exists.

    Parameters

    • childIndex: number

    Returns boolean

  • Function to check if the current node has children.

    Returns boolean

  • Function to check if the next sibling exists.

    Returns boolean

  • Function to check if the current node has a parent.

    Returns boolean

  • Function to check if the previous sibling exists.

    Returns boolean

  • Function to check if a given node is the root of the AST. If no parameter is provided, this function will test if the walker is at the root position of the AST.

    Parameters

    Returns boolean

  • Function to pick the parent of the current node.

    Returns undefined | ASTNode

  • Function to pick a sibling at an offset relative to the current position.

    Parameters

    • offsetFromCurrentPosition: number

    Returns undefined | ASTNode

  • Function to move the walker to an ancestor with given an offset. e.g. 1=direct parent, 2 = grandparent, ...

    Parameters

    • offset: number

    Returns undefined | Walker

  • Function to move the walker to the child at a given index.

    Parameters

    • childIndex: number

    Returns undefined | Walker

  • Function to move the walker to the first child.

    Returns undefined | Walker

  • Function to move the walker to the last child.

    Returns undefined | Walker

  • Function to move the walker to the next sibling.

    Returns undefined | Walker

  • Function to move the walker to the current parent.

    Returns undefined | Walker

  • Function to move the walker to the previous sibling.

    Returns undefined | Walker

  • Function to move the walker to the AST root.

    Returns Walker

  • Function to move the walker to a sibling with an offset relative to the current position.

    Parameters

    • offsetFromCurrentPosition: number

    Returns undefined | Walker

  • Function to walk over the AST. The visitor callback is called twice for every node.

    Parameters

    Returns void

  • Function to walk over all children.

    Parameters

    Returns void

  • Function to walk over the AST. The visitor callback is called once for every node. Parents are visited after the children.

    Parameters

    Returns void

  • Function to walk over the AST. The visitor callback is called once for every node. Parents are visited before the children.

    Parameters

    Returns void

  • Function to create a new walker at the current node position.

    Returns Walker

Generated using TypeDoc