1#' Retrieve the path name (filename) for each coverage object 2#' 3#' @param x A coverage object 4#' @keywords internal 5#' @export 6display_name <- function(x) { 7 stopifnot(inherits(x, "coverage")) 8 if (length(x) == 0) { 9 return() 10 } 11 12 filenames <- vcapply(x, function(x) get_source_filename(x$srcref, full.names = TRUE)) 13 if (isTRUE(attr(x, "relative"))) { 14 to_relative_path(filenames, attr(x, "package")$path) 15 } else { 16 filenames 17 } 18} 19 20to_relative_path <- function(path, base) { 21 rex::re_substitutes(path, rex::rex(base, "/"), "") 22} 23 24filter_non_package_files <- function(x) { 25 filenames <- vcapply(x, function(x) get_source_filename(x$srcref, full.names = TRUE)) 26 x[rex::re_matches(filenames, rex::rex(attr(x, "package")$path, "/"), "")] 27} 28