struct

TreeSitter::Node

Inherits Struct / Value / Object

A Node represents a single node in the syntax tree. It tracks its start and end positions in the source code, as well as its relation to other nodes like its parent, siblings and children.

Instance methods

==(other : Node) : Bool
Source
child(index : Int32) : Node

Get the node's child at the given index, where zero represents the first child.

Raises IndexError if index is out of bounds.

Source
child_count

Get the node's number of children

Source
descendant(start_byte : UInt32, end_byte : UInt32) : Node | Nil
Source
descendant(start_point : Point, end_point : Point) : Node | Nil
Source
end_byte

Get the node's end byte.

Source
end_point

Get the node's end position in terms of rows and columns.

Source
extra?

Check if the node is extra. Extra nodes represent things like comments, which are not required the grammar, but can appear anywhere.

Source
has_changes?

Check if a syntax node has been edited.

Source
has_error?

Check if the node is a syntax error or contains any syntax errors.

Source
missing?

Check if the node is missing. Missing nodes are inserted by the parser in order to recover from certain kinds of syntax errors.

Source
named?

Check if the node is named. Named nodes correspond to named rules in the grammar, whereas anonymous nodes correspond to string literals in the grammar.

Source
named_child(index : Int32)

Get the node's named child at the given index.

See also #named?

Source
named_child_count

Get the node's number of named children.

See also #named?

Source
parent

Get the node's immediate parent.

Source
start_byte

Get the node's start byte.

Source
start_point

Get the node's start position in terms of rows and columns.

Source
text(source : String) : String
Source
to_s(io : IO)

Get an S-expression representing the node as a string.

Source
type

Get the node's type as a String.

Source