Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: robust way of getting a function signature #24

Merged
merged 3 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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