Skip to content

Commit

Permalink
Merge pull request #12 from flowr-analysis/11-support-for-analyzing-m…
Browse files Browse the repository at this point in the history
…ultiple-files-at-once

Support for analyzing multiple files at once
  • Loading branch information
LukasPietzschmann authored Aug 5, 2024
2 parents 43757d1 + 0773540 commit 66b636e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 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
2 changes: 1 addition & 1 deletion man/request_file_analysis.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 66b636e

Please sign in to comment.