tree-sitter - v0.25.1
    Preparing search index...

    Interface Tree

    A tree that represents the syntactic structure of a source code file.

    interface Tree {
        rootNode: SyntaxNode;
        edit(edit: Edit): Tree;
        getChangedRanges(other: Tree): Range[];
        getEditedRange(): Range;
        getIncludedRanges(): Range[];
        getText(node: SyntaxNode): string;
        printDotGraph(fd?: number): void;
        rootNodeWithOffset(offsetBytes: number, offsetExtent: Point): SyntaxNode;
        walk(): TreeCursor;
    }
    Index

    Properties

    rootNode: SyntaxNode

    The root node of the syntax tree

    Methods

    • Edit the syntax tree to keep it in sync with source code that has been edited. The edit must be described both in terms of byte offsets and in terms of row/column coordinates.

      Parameters

      • edit: Edit

        The edit to apply to the tree

      Returns Tree

      The edited tree

    • Compare this edited syntax tree to a new syntax tree representing the same document, returning ranges whose syntactic structure has changed.

      For this to work correctly, this tree must have been edited to match the new tree's ranges. Generally, you'll want to call this right after parsing, using the old tree that was passed to parse and the new tree that was returned.

      Parameters

      • other: Tree

        The new tree to compare against

      Returns Range[]

      Array of ranges that have changed

    • Get the ranges that were included when parsing this syntax tree

      Returns Range[]

      Array of included ranges

    • Get the text for a node within this tree

      Parameters

      Returns string

      The source text for the node

    • Print a graph of the tree in the DOT language. You may want to pipe this to a 'dot' process to generate SVG output.

      Parameters

      • Optionalfd: number

        Optional file descriptor for the output

      Returns void

    • Get the root node of the syntax tree, but with its position shifted forward by the given offset.

      Parameters

      • offsetBytes: number

        The number of bytes to shift by

      • offsetExtent: Point

        The number of rows/columns to shift by

      Returns SyntaxNode

      The root node with its position offset