Construct a new tree. See also Tree.build.
The type of the top node.
This node's child nodes.
The positions (offsets relative to the start of this tree) of the children.
The total length of this tree
Optionalprops: readonly [number | NodeProp<any>, any][]Per-node node props to associate with this node.
ReadonlychildrenThis node's child nodes.
ReadonlylengthThe total length of this tree
ReadonlypositionsThe positions (offsets relative to the start of this tree) of the children.
ReadonlytypeThe type of the top node.
StaticemptyThe empty tree
Returns the node's per-node props in a
format that can be passed to the Tree
constructor.
Get a syntax node object for the top of the tree.
Balance the direct children of this tree, producing a copy of
which may have children grouped into subtrees with type
NodeType.none.
Optionalconfig: {OptionalmakeTree?: (Function to create the newly balanced subtrees.
Get a tree cursor positioned at the top of the tree. Mode can be used to control which nodes the cursor visits.
Optionalmode: IterModeGet a tree cursor pointing into this tree
at the given position and side (see
moveTo.
Optionalside: -1 | 0 | 1Optionalmode: IterModeIterate over the tree and its children, calling enter for any
node that touches the from/to region (if given) before
running over such a node's children, and leave (if given) when
leaving the node. When enter returns false, that node will
not have its children iterated over (or leave called).
Get the syntax node at the given position.
If side is -1, this will move into nodes that end at the
position. If 1, it'll move into nodes that start at the
position. With 0, it'll only enter nodes that cover the position
from both sides.
Note that this will not enter
overlays, and you often want
resolveInner instead.
Optionalside: -1 | 0 | 1Like resolve, but will enter
overlaid nodes, producing a syntax node
pointing into the innermost overlaid tree at the given position
(with parent links going through all parent structure, including
the host trees).
Optionalside: -1 | 0 | 1In some situations, it can be useful to iterate through all nodes around a position, including those in overlays that don't directly cover the position. This method gives you an iterator that will produce all nodes, from small to big, around the given position.
Optionalside: -1 | 0 | 1Staticbuild
A piece of syntax tree. There are two ways to approach these trees: the way they are actually stored in memory, and the convenient way.
Syntax trees are stored as a tree of
TreeandTreeBufferobjects. By packing detail information intoTreeBufferleaf nodes, the representation is made a lot more memory-efficient.However, when you want to actually work with tree nodes, this representation is very awkward, so most client code will want to use the
TreeCursororSyntaxNodeinterface instead, which provides a view on some part of this data structure, and can be used to move around to adjacent nodes.