node_type | R Documentation |
node_type()
returns the "type" of the current node as a string.
This is a very useful function for making decisions about how to handle the current node.
node_type(x)
x |
A node. |
A single string.
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_type(node)
# The whole `<-` binary operator node
node <- node_child(node, 1)
node
node_type(node)
# Just the literal `<-` operator itself
node <- node_child_by_field_name(node, "operator")
node
node_type(node)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.