node-sibling | R Documentation |
These functions return siblings of the current node, i.e. if you looked "left" or "right" from the current node rather "up" (parent) or "down" (child).
node_next_sibling()
and node_next_named_sibling()
return the next
sibling.
node_previous_sibling()
and node_previous_named_sibling()
return the
previous sibling.
node_next_sibling(x)
node_next_named_sibling(x)
node_previous_sibling(x)
node_previous_named_sibling(x)
x |
A node. |
A sibling node, or NULL
if there is no sibling node.
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)
# Navigate to function definition node
node <- node_child(node, 3)
node
node_previous_sibling(node)
# Skip anonymous operator node
node_previous_named_sibling(node)
# There isn't one!
node_next_sibling(node)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.