Skip to content

Commit

Permalink
fix: robust way of getting a function signature
Browse files Browse the repository at this point in the history
  • Loading branch information
Gotfrid committed Sep 12, 2024
1 parent b8dcbb8 commit 7fe4d21
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion R/box_lsp.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ box_use_parser <- function(expr, action) {

if (this_function != "...") {
namespaced_function <- paste0(as.character(x[[2]]), "::", this_function)
signature <- deparse(eval(parse(text = namespaced_function, keep.source = TRUE)))[[1]]
function_expression <- eval(parse(text = namespaced_function, keep.source = TRUE))
function_signature <- setdiff(
deparse(function_expression),
deparse(body(function_expression))
)
signature <- trimws(gsub("\\s+", " ", x = paste(function_signature, collapse = "")))
sym_name <- ifelse(this_alias == "", this_function, this_alias)

process_module(sym_name, signature, action)
Expand Down

0 comments on commit 7fe4d21

Please sign in to comment.