node_parent | R Documentation |
node_parent()
looks up the tree and returns the current node's parent.
node_parent(x)
x |
A node. |
The parent node of x
or NULL
if there is no parent.
language <- treesitter.r::language()
parser <- parser(language)
text <- "fn <- function() { 1 + 1 }"
tree <- parser_parse(parser, text)
node <- tree_root_node(tree)
# Parent of a root node is `NULL`
node_parent(node)
node_function <- node |>
node_child(1) |>
node_child(3)
node_function
node_parent(node_function)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.