-
Notifications
You must be signed in to change notification settings - Fork 93
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
Provide package symbols before lint in diagnostics #568
Conversation
There are known limitations:
|
I am curious if it would be too slow for large package. (Though lintr is slow anyway). |
I tried
Since the diagnostics runs in reused sessions, the timing might look better after the first time. I tried editing around in lintr package and I don't observe a notable difference in the delay of diagnostics than before. |
Good point. |
I'm seeing this issue as well.
I do have some packages where Edit: also thank you for all the awesome work to provide an R LSP :) |
Does it always take as much time as the first time for each |
@renkun-ken - it does get faster with each call, you're right. I think either way you go with this would be fine, I only mentioned it because it was my first thought when thinking about how to approach this and wanted to make the suggestion in case it simplified things at all. If this feels like the right approach, I totally trust your judgement here. |
@randy3k Do you think we should opt-in or opt-out such behavior? AFAIK, only |
Another approach is that we somehow mimic the behavior of |
There is really no much additional time added. I am happy either way. |
A notable impact of using |
That could be a potential issue of having high CPU and memory usage. Perhaps we should disable it in default and only allow interested users to opt in and test the feature. |
I just switch to a simpler approach by attaching a shim environment of @dgkf Would you like to try it out and see if it works for you? |
Sure - I'll give the brancha go tonight. |
I tried out the branch and performance seemed pretty good. Nice work! I did notice that it will still report the "no visible binding" warnings until the file is saved for the first time, even if the names are found in the local source code. Otherwise it looks great, and having to do a quick save once they pop up is a small inconvenience given how much of an improvement this already is. |
If the document is open before the package R files are parsed, its diagnostics will report In fact, if you edit other files and don't save them, it should still work because language server workspaces work without assuming all files are saved. By constrast, Maybe we could delay the publish of diagnostics until package R files are all parsed on startup. |
@randy3k I think this PR is ready to merge. Let me know if you have any other suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a smart solution. Thank you for working on it. Just a small nitpick.
@@ -362,7 +362,9 @@ parse_expr <- function(content, expr, env, srcref = attr(expr, "srcref")) { | |||
|
|||
if (type == "function") { | |||
env$functs <- c(env$functs, symbol) | |||
env$formals[[symbol]] <- value[[2L]] | |||
fun <- function() NULL | |||
formals(fun) <- value[[2L]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parse_data
now preserves the functions defined in the documents with only formals, which could make it easier to work with. If a future version of lintr checks if function arguments supplied match the function formals, it should be still working as the formals are preserved.
Also, it make it easier to works with match.call(fun, expr)
in the future.
Closes REditorSupport/vscode-R#729.
Also addresses #567 (comment).
pkgload::load_all()
is called beforelintr::lint()
if the workspace root contains a package.