Learn R Programming

treesitter (version 0.3.0)

node_descendant_count: Node descendant count

Description

Returns the number of descendants of this node, including this node in the count.

Usage

node_descendant_count(x)

Value

A single double.

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)

# Top level program node
node_descendant_count(node)

# The whole `<-` binary operator node
node <- node_child(node, 1)
node_descendant_count(node)

# Just the literal `<-` operator itself
node <- node_child_by_field_name(node, "operator")
node_descendant_count(node)
}

Run the code above in your browser using DataLab