R/declared_functions.R

Defines functions declared_s3_generics

declared_s3_generics <- function(x) {
  xpath <- paste0(
    # Top level expression which
    "/exprlist/expr",

    # Assigns to a symbol
    "[./LEFT_ASSIGN|EQ_ASSIGN]",
    "[./expr[FUNCTION or OP-LAMBDA]]",
    "[./expr/SYMBOL]",

    # Is a S3 Generic (contains call to UseMethod)
    "[.//SYMBOL_FUNCTION_CALL[text()='UseMethod']]",

    # Retrieve assigned name of the function
    "/expr/SYMBOL/text()"
  )

  as.character(xml_find_all(x, xpath))
}
jimhester/lintr documentation built on April 24, 2024, 8:21 a.m.