| 1 |
#' Determine whether an non-evaluated call is parenthesized |
| 2 |
#' |
| 3 |
#' @param a non-evaluated expression |
| 4 |
#' @return logical - TRUE if expression is parenthesized, FALSE otherwise. |
| 5 |
#' @noRd |
| 6 |
is_parenthesized <- function(expr) { |
| 7 |
is.call(expr) && identical(expr[[1L]], quote(`(`)) |
| 8 |
} |
| 9 |
|
| 10 |
|
| 11 |
#' Check whether expression is enclosed in curly braces. |
| 12 |
#' |
| 13 |
#' @param expr An expression to be tested. |
| 14 |
#' @return logical - TRUE if expr is enclosed in `{`, FALSE otherwise. |
| 15 |
#' @noRd |
| 16 |
is_funexpr <- function(expr) { |
| 17 |
is.call(expr) && identical(expr[[1L]], quote(`{`)) |
| 18 |
} |
| 19 |
|
| 20 |
#' Check whether expression has double or triple colons |
| 21 |
#' |
| 22 |
#' @param expr An expression to be tested. |
| 23 |
#' @return logical - TRUE if expr contains `::` or `:::`, FALSE otherwise. |
| 24 |
#' @noRd |
| 25 |
is_colexpr <- function(expr) { |
| 26 |
is.call(expr) && |
| 27 |
(identical(expr[[1L]], quote(`::`)) || identical(expr[[1L]], quote(`:::`))) |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
#' Determine whether an expression counts as a function in a magrittr chain. |
| 32 |
#' |
| 33 |
#' @param a non-evaluated expression. |
| 34 |
#' @return logical - TRUE if expr represents a function, FALSE otherwise. |
| 35 |
#' @noRd |
| 36 |
is_function <- function(expr) { |
| 37 |
is.symbol(expr) || is.function(expr) |
| 38 |
} |
| 39 |
|
| 40 |
is_lambda <- function(expr) { |
| 41 |
is.call(expr) && identical(expr[[1L]], quote(`function`)) |
| 42 |
} |