LanguageServer.jl
LanguageServer.jl copied to clipboard
support for @reexport using SomePackage
Is it possible to specially parse the reexport using statement?
using Reexport
@reexport using SomePackage
so that it is parsed as without the @reexport macro. Now all the functions from SomePackage are marked as unknowns.
I guess we could special case this, but maybe we should just be looking for a more generic solution? Not sure.
Just to note, the Reexport package has added support for syntax like the following on the master branch, but it has not been released yet:
using Reexport: @reexport
@reexport using SomePackage: a, b
I would also greatly appreciate these special cases being added, as currently the plugin tells me all of the functions from other Modules inside of my package are unavailable.
This is quite tricky to handle in a neat way. In the meantime, while I think about a solution, I've added a codeAction that provides the same functionality: https://github.com/julia-vscode/LanguageServer.jl/pull/463
FWIW, it seems that Pluto recently fixed a similar issue by expanding macros for analysis. I don't know enough about the internals of either of these packages to judge whether this fix could be applied here but maybe it is a helpful data point:
https://github.com/fonsp/Pluto.jl/issues/196#issuecomment-800485127 https://github.com/fonsp/Pluto.jl/pull/1032
@lassepe I believe they just run the macros. We can't do that (at least easily) because we have a policy to never run user code in the LS process. Maybe we need to think about a two process solution for this at some point, not sure...
Or, maybe just treat @reexport lexicographically and special-case for it. It is really a widely used syntax sugar. On the other hand, having macros actions visible would be such a huge benefit. But I have no idea how to combine this with the LS safety/stability. Have their execution have sandboxed + interpreted? Is this possible with current interpreter? And, does it require interpreting the whole project code in order to do this?
- I see, this is really tricky topic. My personal feeling is, that I'd rather like to sacrifice macros than have the unpredictably broken environments of Juno's time.
This is quite tricky to handle in a neat way. In the meantime, while I think about a solution, I've added a codeAction that provides the same functionality: #463
where to find documentation about how to use the codeAction?