Skip to content

Commit

Permalink
Merge branch 'RS_foo_finder' into RS_foo_finder
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertASmith authored Jan 30, 2024
2 parents 5e11e4c + 5963845 commit 628e783
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
26 changes: 18 additions & 8 deletions R/cheers_checker.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,26 +118,36 @@ extract_function_name <- function(string) {
#'
extract_function_name2 <- function(string){

foo_def_start <- stringr::str_locate_all(pattern = "(\\s|=|-)function\\s*\\(",
string = string)[[1]][1,1]
string <- stringr::str_replace_all(string,
pattern = c("\n"),
replacement = " ")

assign_operand_locations <- stringr::str_locate_all(pattern = c("=|<-"),
string = string)[[1]][, "start"]
foo_assign_operand_location <- stringr::str_locate_all(pattern = "(\\s|=|<-)function\\s*\\(",
string = string) |>
unlist() |>
head(1)

foo_assign_operand_location <- find_previous_vector_element(value = foo_def_start,
vector = assign_operand_locations)
#assign_operand_locations <- stringr::str_locate_all(pattern = c("=|<-"),
# string = string)[[1]][, "start"]

foo_name <- substr(string, 1, foo_assign_operand_location-1)
foo_name <- stringr::str_replace_all(string = foo_name, pattern = c("\n"), replacement = " ")
foo_name <- strsplit(x = foo_name, split = " ")
foo_name <- unlist(x = foo_name)
foo_name <- utils::tail(x = foo_name, n = 1)

return(foo_name)

}
foo_name <- v_chars[which(!(v_chars %in% c("", "=", "<-")))] |>
utils::tail(n = 1)

# replace any persisting assignment
foo_name <- stringr::str_replace_all(pattern = c("=|<-"),
string = foo_name,
replacement = "")

return(foo_name)

}



Expand Down
2 changes: 1 addition & 1 deletion man/get_file_cheers_classifications.Rd

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

0 comments on commit 628e783

Please sign in to comment.