struct TreeSitter::Node
- TreeSitter::Node
- Struct
- Value
- Object
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.crInstance Method Summary
- #==(other : Node) : Bool
-
#child(index : Int32) : Node
Get the node's child at the given index, where zero represents the first child.
-
#child_count : UInt32
Get the node's number of children
- #descendant(start_byte : UInt32, end_byte : UInt32) : Node | Nil
- #descendant(start_point : Point, end_point : Point) : Node | Nil
-
#end_byte : UInt32
Get the node's end byte.
-
#end_point : Point
Get the node's end position in terms of rows and columns.
-
#extra? : Bool
Check if the node is extra.
-
#has_changes? : Bool
Check if a syntax node has been edited.
-
#has_error? : Bool
Check if the node is a syntax error or contains any syntax errors.
-
#missing? : Bool
Check if the node is missing.
-
#named? : Bool
Check if the node is named.
-
#named_child(index : Int32)
Get the node's named child at the given index.
-
#named_child_count : UInt32
Get the node's number of named children.
-
#parent : Node
Get the node's immediate parent.
-
#start_byte : UInt32
Get the node's start byte.
-
#start_point : Point
Get the node's start position in terms of rows and columns.
-
#to_s(io : IO)
Get an S-expression representing the node as a string.
-
#type : String
Get the node's type as a String.
Instance Method Detail
Get the node's child at the given index, where zero represents the first child.
Raises IndexError
if index is out of bounds.
Check if the node is extra. Extra nodes represent things like comments, which are not required the grammar, but can appear anywhere.
Check if the node is missing. Missing nodes are inserted by the parser in order to recover from certain kinds of syntax errors.
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.