Tree

class Tree(val type: NodeType, children: List<Any>, val positions: List<Int>, val length: Int, propValues: Map<Int, Any?> = emptyMap())

A syntax tree. Immutable, constructed by parsers. Children may be Tree or TreeBuffer instances.

Constructors

Link copied to clipboard
constructor(type: NodeType, children: List<Any>, positions: List<Int>, length: Int, propValues: Map<Int, Any?> = emptyMap())

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
val length: Int
Link copied to clipboard
Link copied to clipboard

The top node of this tree (wraps the tree as a SyntaxNode).

Link copied to clipboard

Functions

Link copied to clipboard
fun balance(config: BalanceConfig = BalanceConfig()): Tree

Balance a tree, making sure no children arrays grow too large for optimal performance.

Link copied to clipboard
fun cursor(mode: Int = 0): TreeCursor

Create a cursor that starts at the top of the tree.

Link copied to clipboard
fun cursorAt(pos: Int, side: Int = 0, mode: Int = 0): TreeCursor

Create a cursor positioned at a given position.

Link copied to clipboard
fun iterate(spec: IterateSpec)

Iterate over all nodes in the tree within a range.

Link copied to clipboard
fun <T> prop(prop: NodeProp<T>): T?

Look up a per-node prop value.

Link copied to clipboard
fun resolve(pos: Int, side: Int = 0): SyntaxNode

Resolve to the innermost node at position pos.

Link copied to clipboard
fun resolveInner(pos: Int, side: Int = 0): SyntaxNode

Like resolve, but enters overlay-mounted trees.

Link copied to clipboard
fun resolveStack(pos: Int, side: Int = 0): NodeIterator

Returns a NodeIterator pointing at the innermost node at pos, with its NodeIterator.next linking to enclosing nodes up to the top.

Link copied to clipboard
open override fun toString(): String