node-location | R Documentation |
These functions return information about the location of x
in the document.
The byte, row, and column locations are all 0-indexed.
node_start_byte()
returns the start byte.
node_end_byte()
returns the end byte.
node_start_point()
returns the start point, containing a row and column
location within the document. Use accessors like point_row()
to extract
the row and column positions.
node_end_point()
returns the end point, containing a row and column
location within the document. Use accessors like point_row()
to extract
the row and column positions.
node_range()
returns a range object that contains all of the above
information. Use accessors like range_start_point()
to extract
individual pieces from the range.
node_start_byte(x)
node_end_byte(x)
node_start_point(x)
node_end_point(x)
node_range(x)
x |
A node. |
node_start_byte()
and node_end_byte()
return a single numeric value.
node_start_point()
and node_end_point()
return single points.
node_range()
returns a range.
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_start_byte(node)
node_end_byte(node)
node_start_point(node)
node_end_point(node)
node_range(node)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.