Learn R Programming

treesitter (version 0.3.0)

node-children: Get a node's children

Description

These functions return the children of x within a list.

  • node_children() considers both named and anonymous children.

  • node_named_children() considers only named children.

Usage

node_children(x)

node_named_children(x)

Value

The children of x as a list.

Arguments

x

[tree_sitter_node]

A node.

Examples

Run this code
if (FALSE) { # rlang::is_installed("treesitter.r")
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

# Note how the named variant doesn't include the anonymous operator node
node_children(node)
node_named_children(node)
}

Run the code above in your browser using DataLab