node-first-child-byte {treesitter}R 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.

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)


[Package treesitter version 0.1.0 Index]