-
Notifications
You must be signed in to change notification settings - Fork 75
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
Allow using statements to point to live package code #562
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #562 +/- ##
==========================================
- Coverage 28.46% 28.42% -0.05%
==========================================
Files 23 23
Lines 1686 1706 +20
==========================================
+ Hits 480 485 +5
- Misses 1206 1221 +15
Continue to review full report at Codecov.
|
Hm, it seems to me that we generally need to resolve this via the active environment, right? Whereas this just seems to be based on file system structure? So I think if we see a |
This is just the internal handling of this (not the env handling part we discuss the other day) and in particular looks to make available the 'main' package when editing it is being edited - this is not information explicitly held in the Project.toml. I've tightened up the code that decides whether to add a 'live' package to reflect this. |
I think I still don't fully understand this :) Lets say someone opens the root folder for package Inside the For files outside of I think right now I just don't understand the scenario where we should try to resolve this purely pased on file location. |
Unfortunately we do, this seems silly. Keeping with your example above, if I'm editing Foo I think I want all references to Foo within that context (i.e. the package directory) to point to what I'm editing, not a cached version. If, for example, I'm writing tests I'd like to be able to refer to functions/features I've just added. |
Continuing this - isn't this what we discussed, the cache should only be used for code that is outside the current workspace? |
bump @julia-vscode/core I think this could do with some discussion |
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.
We clearly need that kind of thing, but I'm wondering whether a) we should really do this pre Juliacon, and b) whether we should maybe first fix our env handling and then do this? Not sure, to be honest.
@@ -40,6 +40,7 @@ mutable struct LanguageServerInstance | |||
symbol_store::Dict{Symbol,SymbolServer.ModuleStore} | |||
symbol_extends::Dict{SymbolServer.VarRef,Vector{SymbolServer.VarRef}} | |||
symbol_store_ready::Bool | |||
workspacepackages::Dict{String,Document} |
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 should probably have UUIDs as the key, right? I think we are generally not identifying packages by their UUID right now, but probably should to get this right.
# Add possible workspace packages | ||
path = uri2filepath(uri._uri) | ||
for wk_folder in server.workspaceFolders | ||
if startswith(path, wk_folder) && normpath(wk_folder) == normpath(server.env_path) |
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.
I don't fully understand the logic here. Is the idea that only if one has activated the package as the env, will any of this work?
fname = splitext(last(sub_path))[1] | ||
if sub_path[end-1] == "src" && sub_path[end-2] == fname | ||
@info "Setting $path as source of 'live' package" | ||
server.workspacepackages[fname] = doc |
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.
It seems to me that we need to look for a Project.toml
and then at its content to decide whether something is really a package or not.
@@ -414,6 +421,11 @@ function import_completions(doc, offset, rng, ppt, pt, t, is_at_end ,x, CIs, ser | |||
end | |||
end | |||
else | |||
for (n,doc1) in server.workspacepackages | |||
if startswith(n, t.val) && StaticLint.has_workspace_package(server, n) |
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.
I think this is where we need to go via the env info: Say the code has using Foo
, then we need to look in the env what UUID Foo
corresponds to, then we look in the server.workspacepackages
that is indexed by UUID whether there is a package with that UUID. But we probably shouldn't match by name, because the names don't have to be the same if the package is loaded via an env (and not LOAD_PATH
).
@ZacLN I'd say we can try to get that in soon after Juliacon? Is the next step that you resolve merge conflicts, and then we review properly? |
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.
@ZacLN bump, I think next step is to resolve merge conflicts here.
And now we need to get tests to pass :) |
Partner of julia-vscode/StaticLint.jl#103
The key question at this point is what files we will allow/determine to be packages. One approach would be to limit it to workspace folders that have the correct structure (i.e. a folder
X
withsrc/X.jl
within it)