node-first-child-byte: Get the first child that extends beyond the given byte offset

node-first-child-byteR Documentation

Get the first child that extends beyond the given byte offset

Description

These functions return the first child of x that extends beyond the given byte offset. Note that byte is a 0-indexed offset.

  • node_first_child_for_byte() considers both named and anonymous nodes.

  • node_first_named_child_for_byte() considers only named nodes.

Usage

node_first_child_for_byte(x, byte)

node_first_named_child_for_byte(x, byte)

Arguments

x

⁠[tree_sitter_node]⁠

A node.

byte

⁠[integer(1)]⁠

The byte to start the search from.

Note that byte is 0-indexed!

Value

A new node, or NULL if there is no node past the byte offset.

Examples


language <- treesitter.r::language()
parser <- parser(language)

text <- "fn <- function() { 1 + 1 }"
tree <- parser_parse(parser, text)
node <- tree_root_node(tree)

# Navigate to first child
node <- node_child(node, 1)
node

# `fn {here}<- function()`
node_first_child_for_byte(node, 3)
node_first_named_child_for_byte(node, 3)

# Past any node
node_first_child_for_byte(node, 100)


treesitter documentation built on June 24, 2024, 5:07 p.m.