Skip to contents

Helper for determining whether the current source_expression contains all expressions in the current file, or just a single expression.

Usage

is_lint_level(source_expression, level = c("expression", "file"))

Arguments

source_expression

A parsed expression object, i.e., an element of the object returned by get_source_expressions().

level

Which level of expression is being tested? "expression" means an individual expression, while "file" means all expressions in the current file are available.

Examples

tmp <- withr::local_tempfile(lines = c("x <- 1", "y <- x + 1"))
source_exprs <- get_source_expressions(tmp)
#> Warning: cannot open file '/tmp/RtmpAx0Ma8/file18131fb016d4': No such file or directory
#> Error in file(con, "r"): cannot open the connection
is_lint_level(source_exprs$expressions[[1L]], level = "expression")
#> Error in eval(expr, envir, enclos): object 'source_exprs' not found
is_lint_level(source_exprs$expressions[[1L]], level = "file")
#> Error in eval(expr, envir, enclos): object 'source_exprs' not found
is_lint_level(source_exprs$expressions[[3L]], level = "expression")
#> Error in eval(expr, envir, enclos): object 'source_exprs' not found
is_lint_level(source_exprs$expressions[[3L]], level = "file")
#> Error in eval(expr, envir, enclos): object 'source_exprs' not found