map.apps Bundle APIs 4.20.0
    Preparing search index...

    Helper to analyze an AST.

    interface Walker {
        child(childIndex: number): undefined | ASTNode;
        children(): ASTNode[];
        childrenCount(): number;
        current: ASTNode;
        currentIndex: number;
        hasChild(childIndex: number): boolean;
        hasChildren(): boolean;
        hasNextSibling(): boolean;
        hasParent(): boolean;
        hasPrevSibling(): boolean;
        isROOT(node?: ASTNode): boolean;
        parent(): undefined | ASTNode;
        parents: ASTNode[];
        queryOptions: ComplexQueryOptions;
        ROOT: ASTNode;
        sibling(offsetFromCurrentPosition: number): undefined | ASTNode;
        toAncestor(offset: number): undefined | Walker;
        toChild(childIndex: number): undefined | Walker;
        toFirstChild(): undefined | Walker;
        toLastChild(): undefined | Walker;
        toNextSibling(): undefined | Walker;
        toParent(): undefined | Walker;
        toPrevSibling(): undefined | Walker;
        toROOT(): Walker;
        toSibling(offsetFromCurrentPosition: number): undefined | Walker;
        walk(cb: VisitCallback, scope?: any): void;
        walkChildren(cb: ChildVisitCallback, scope?: any): void;
        walker(): Walker;
        walkPostOrder(cb: VisitCallback, scope?: any): void;
        walkPreOrder(cb: VisitCallback, scope?: any): void;
    }
    Index

    Properties

    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.

    ROOT: ASTNode

    Root of the AST

    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 create a new walker at the current node position.

      Returns Walker

    • 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