Skip to content

Commit

Permalink
move code2list to teal.data
Browse files Browse the repository at this point in the history
  • Loading branch information
m7pr committed Nov 6, 2024
1 parent 76b0dd8 commit 839fca6
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions R/utils-get_code_dependency.R
Original file line number Diff line number Diff line change
Expand Up @@ -463,31 +463,6 @@ split_code <- function(code) {
gsub("^([[:space:]])*;(.+)$", "\\1\\2", new_code, perl = TRUE)
}


#' Reshape code to the list
#'
#' List will be divided by the calls. Each element of the list contains `id` and `dependency` attributes.
#'
#' @param code `character` with the code.
#'
#' @return list of `character`s of the length equal to the number of calls in `code`.
#'
#' @keywords internal
#' @noRd
code2list <- function(code) {
checkmate::assert_character(code, null.ok = TRUE)
if (length(code)) {
lapply(split_code(code), function(current_code) {
attr(current_code, "id") <- sample.int(.Machine$integer.max, 1)
parsed_code <- parse(text = trimws(current_code), keep.source = TRUE)
attr(current_code, "dependency") <- extract_dependency(parsed_code)
current_code
})
} else {
list(character(0))
}
}

#' @param parsed_code results of `parse(text = code, keep.source = TRUE` (parsed text)
#' @keywords internal
#' @noRd
Expand Down

0 comments on commit 839fca6

Please sign in to comment.