node_kind: Find the kind of a node

View source: R/node.R

node_kindR Documentation

Find the kind of a node

Description

Find the kind of a node

Usage

node_kind(x)

Arguments

x

A node, either from tree_root() or from another ⁠node_*()⁠ function.

Value

A list with as many elements as in the input. Each element is a character value.

Examples

src <- "x <- rnorm(100, mean = 2)
    any(duplicated(y))
    x <- z + 1
    any(duplicated(x))"

root <- src |>
  tree_new() |>
  tree_root()

root |>
  node_find(ast_rule(pattern = "any(duplicated($VAR))")) |>
  node_kind()

root |>
  node_find(ast_rule(pattern = "$X + $VALUE")) |>
  node_kind()

astgrepr documentation built on June 8, 2025, 11:05 a.m.