find_node_indices: Find Node Indices in an RStatic Object

Description Usage Arguments Details Value See Also Examples

View source: R/find_nodes.R

Description

This function traverses the given RStatic object and returns a list of indices for all descendants that satisfy the given test function.

Usage

1
2
find_node_indices(node, test, ..., recursive = TRUE, initial = list(),
  index = integer(0))

Arguments

node

(ASTNode) The RStatic object to search.

test

(function) The test function, which should accept an rstatic object to check as its first argument and return a scalar logical.

...

Additional arguments to the test function.

recursive

(logical) Search recursively in matching nodes?

initial

(list) Initial list of indices for matching nodes.

index

(integer) The index of node.

Details

All indices are relative to node, unless index is supplied.

Note that node itself is not tested.

Value

A list of indices for matching nodes.

See Also

find_nodes()

Examples

1
2
3
4
5
6
7
8
9
ast = quote_ast(
  function(x, y) {
    x = x + y
    function() x
  })

find_node_indices(ast, is, "Function")

find_node_indices(ast, is_symbol, "x")

nick-ulle/ast documentation built on Oct. 18, 2019, 4:37 a.m.