Skip to content

Commit

Permalink
Support for analyzing multiple files at once
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasPietzschmann committed Aug 4, 2024
1 parent 43757d1 commit 3af13e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions R/file_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' Note that either `filepath` or `content` must be provided, but never both.
#'
#' @param con The connection to the server
#' @param filepath The path to the file (must be visible to the server)
#' @param filepath A single or multiple file paths (must be visible to the server)
#' @param content The R code to be analyzed
#' @param cfg Weather to include the control flow graph in the response
#' @param id The id of the request
Expand All @@ -22,7 +22,7 @@ request_file_analysis <- function(con,
stopifnot(rlang::is_missing(filepath) || rlang::is_missing(content), !rlang::is_missing(filepath) || !rlang::is_missing(content))

if (!rlang::is_missing(filepath)) {
stopifnot(is.character(filepath))
stopifnot(is.character(filepath) || is.vector(filepath))
filepath <- normalizePath(filepath, mustWork = FALSE)
filetoken <- get_filetoken(filepath)
request <- list(
Expand Down
7 changes: 5 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ get_new_id <- make_id_provider()
#' @return The token
get_filetoken <- function(filepath = rlang::missing_arg(), content = rlang::missing_arg()) {
if (!rlang::is_missing(filepath)) {
stopifnot(is.character(filepath), file.exists(filepath))
token <- digest::digest(readLines(filepath))
stopifnot(is.character(filepath) || is.vector(filepath))
# sort to ensure that a different order will result in the same token
filepath <- sort(c(filepath))
stopifnot(file.exists(filepath))
token <- digest::digest(lapply(filepath, readLines))
} else if (!rlang::is_missing(content)) {
stopifnot(is.character(content))
token <- digest::digest(content)
Expand Down

0 comments on commit 3af13e2

Please sign in to comment.