R/node.R
node_get_root.Rd
Recover the tree root from a node
node_get_root(x)
A node, either from tree_root() or from another node_*() function.
tree_root()
node_*()
src <- " print('hi') fn <- function() { print('hello') } " root <- src |> tree_new() |> tree_root() root |> node_find(ast_rule(pattern = "print($A)")) |> node_get_root() |> tree_root() |> node_text() #> [[1]] #> [1] "print('hi')\nfn <- function() {\n print('hello')\n}\n" #>