Class Tree

A syntax tree.

Analogous to TSTree.

Methods

Tree:copy () Create a shallow copy of the syntax tree.
Tree:root_node () Get the root node of the syntax tree.
Tree:root_node (byte_offset, point_offset) Get the root node of the syntax tree, with its position shifted forward by the given offset.
Tree:language () Get the language that was used to parse the syntax tree.
Tree:included_ranges () Get the array of included ranges that was used to parse the syntax tree.
Tree:edit (start_byte, old_end_byte, new_end_byte, start_point, old_end_point, new_end_point) Edit the syntax tree to keep it in sync with source code that has been edited.

Metamethods

Tree:__eq (other) Check equality of two trees by their root node.


Methods

Tree:copy ()
Create a shallow copy of the syntax tree.

You need to copy a syntax tree in order to use it on more than one thread at a time, as syntax trees are not thread safe.

Returns:

    Tree
Tree:root_node ()
Get the root node of the syntax tree.

Returns:

    Node
Tree:root_node (byte_offset, point_offset)
Get the root node of the syntax tree, with its position shifted forward by the given offset.

Parameters:

  • byte_offset integer
  • point_offset Point

Returns:

    Node
Tree:language ()
Get the language that was used to parse the syntax tree.

Returns:

    Language

See also:

Tree:included_ranges ()
Get the array of included ranges that was used to parse the syntax tree.

Returns:

    Range.Array

See also:

Tree:edit (start_byte, old_end_byte, new_end_byte, start_point, old_end_point, new_end_point)
Edit the syntax tree to keep it in sync with source code that has been edited.

The edits have to be described in both byte offsets and Points.

Parameters:

  • start_byte integer
  • old_end_byte integer
  • new_end_byte integer
  • start_point Point
  • old_end_point Point
  • new_end_point Point

Metamethods

Tree:__eq (other)
Check equality of two trees by their root node.

Equivalent to calling Node:__eq on the two root nodes.

Parameters:

Returns:

    boolean

See also:

generated by LDoc 1.5.0 Last updated 2024-04-16 14:22:44