Skip to content

Commit

Permalink
fix: robust way of getting a function signature (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gotfrid authored Sep 12, 2024
1 parent ec1c515 commit 0215531
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: box.lsp
Title: Provides 'box' Compatibility for 'languageserver'
Version: 0.1.1
Version: 0.1.1.9001
Authors@R:
c(
person("Ricardo Rodrigo", "Basa", role = c("aut", "cre"), email = "[email protected]"),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# box.lsp (development version)

* Handle long function signatures spanning across multiple lines.

# box.lsp 0.1.1

* Fixed one unit test on Windows that returns a different length of values.
Expand Down
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 0215531

Please sign in to comment.