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

R (I think): Functions from imported packages reported as problem in package development #999

Closed
Tracked by #1087
juliasilge opened this issue Aug 9, 2023 · 6 comments
Assignees
Labels
Milestone

Comments

@juliasilge
Copy link
Contributor

juliasilge commented Aug 9, 2023

This function inform() is from rlang, which is imported in its entirety in the package I am working on. However, the function is marked as a 🚨 problem 🚨 here in this file:

Screenshot 2023-08-09 at 11 17 23 AM

@kevinushey
Copy link
Contributor

I suspect this just hasn't been implemented yet (symbol resolution from Imported packages). Does the issue go away if rlang is explicitly loaded in the session?

Related code: https://github.com/posit-dev/amalthea/blob/f9e8d17178049c7914352fe7e7d2f31a0c1b98bc/crates/ark/src/lsp/diagnostics.rs#L62-L84

We'd probably need some notion of imported_symbols for a package that gets synchronized whenever the DESCRIPTION file changes.

@DavisVaughan
Copy link
Contributor

I think this actually should be working as is, i just think that diagnostics for R documents aren't being updated because we use a global VERSION that is common across all documents rather than being tied to a specific document

https://github.com/posit-dev/amalthea/blob/d89be6169e46cfd731a39af4060ed607e49e3909/crates/ark/src/lsp/diagnostics.rs#L38

i.e. I can see that typing in the Console produces a "document" version of 243, which is greater than the current VERSION of 242, so we apply diagnostics in that case, but when I type in an R file I see a much lower document version of say, 64, and since that is lower than the global VERSION we just bail and never apply diagnostics
https://github.com/posit-dev/amalthea/blob/d89be6169e46cfd731a39af4060ed607e49e3909/crates/ark/src/lsp/diagnostics.rs#L89

So we probably apply diagnostics to the document 1 time at the very beginning or something, and then things get out of sync so running load_all() doesn't get recognized as bringing import() into scope

@DavisVaughan
Copy link
Contributor

DavisVaughan commented Aug 9, 2023

Yea if I manually remove that VERSION bail out check, load_all(), and click around in the document, then the diagnostic goes away

Screenshot 2023-08-09 at 2 11 56 PM

Since Julia does @import rlang, the rlang namespace functions are included in the namespace vetiver environment that is on the search path, so R_lsInternal() lists them as we iterate over that namespace and append the session variables

@juliasilge
Copy link
Contributor Author

The way this works now for me is if I open my package in Positron totally fresh like I have never opened it before, I see the problems pop up after I start editing the file:

Screenshot 2023-08-18 at 10 02 46 AM

After I do devtools::load_all() and then edit the file more, the problems resolve:

Screenshot 2023-08-18 at 10 05 02 AM

Doing devtools::load_all() only does not seem to trigger the diagnostics to re-run until I go back into the file and start editing it again.

Is this all as expected? This is the behavior we plan for Private Alpha? It is certainly an improvement but still not an ideal end state IMO.

@DavisVaughan
Copy link
Contributor

DavisVaughan commented Aug 18, 2023

That is the "expected" behavior (currently). What you are describing is captured by #1005 which is not currently a Private Alpha issue but we could talk about that with the group. But I'd say that is separate from this issue

@juliasilge
Copy link
Contributor Author

Yes, let's collect further refinements needed in #1005. So great to have these improvements already! 🚀

@wesm wesm added the lang: r label Feb 29, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants