struct TreeSitter::Node

Overview

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.

Defined in:

tree_sitter/node.cr

Instance Method Summary

Instance Method Detail

def ==(other : Node) : Bool #

[View source]
def 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.


[View source]
def child_count : UInt32 #

Get the node's number of children


[View source]
def descendant(start_byte : UInt32, end_byte : UInt32) : Node | Nil #

[View source]
def descendant(start_point : Point, end_point : Point) : Node | Nil #

[View source]
def end_byte : UInt32 #

Get the node's end byte.


[View source]
def end_point : Point #

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


[View source]
def extra? : Bool #

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


[View source]
def has_changes? : Bool #

Check if a syntax node has been edited.


[View source]
def has_error? : Bool #

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


[View source]
def missing? : Bool #

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


[View source]
def named? : Bool #

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.


[View source]
def named_child(index : Int32) #

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

See also #named?


[View source]
def named_child_count : UInt32 #

Get the node's number of named children.

See also #named?


[View source]
def parent : Node #

Get the node's immediate parent.


[View source]
def start_byte : UInt32 #

Get the node's start byte.


[View source]
def start_point : Point #

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


[View source]
def to_s(io : IO) #

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


[View source]
def type : String #

Get the node's type as a String.


[View source]