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

Extract project files tracking into function #1319

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
33 changes: 1 addition & 32 deletions src/requests/init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,38 +245,7 @@
end
end

# Add project files separately in case they are not in a workspace folder
if server.env_path != ""
for file in ["Project.toml", "JuliaProject.toml", "Manifest.toml", "JuliaManifest.toml"]
file_full_path = joinpath(server.env_path, file)
uri = filepath2uri(file_full_path)
if isfile(file_full_path)
@static if Sys.iswindows()
# Normalize drive letter to lowercase
if length(file_full_path) > 1 && isletter(file_full_path[1]) && file_full_path[2] == ':'
file_full_path = lowercasefirst(file_full_path)
end
end
# Only add again if outside of the workspace folders
if all(i->!startswith(file_full_path, i), server.workspaceFolders)
if haskey(server._files_from_disc, uri)
error("This should not happen")
end

text_file = JuliaWorkspaces.read_text_file_from_uri(uri, return_nothing_on_io_error=true)
text_file === nothing && continue

server._files_from_disc[uri] = text_file

if !haskey(server._open_file_versions, uri)
JuliaWorkspaces.add_file!(server.workspace, text_file)
end
end
# But we do want to track, in case the workspace folder is removed
push!(server._extra_tracked_files, filepath2uri(file_full_path))
end
end
end
track_project_files!(server)

Check warning on line 248 in src/requests/init.jl

View check run for this annotation

Codecov / codecov/patch

src/requests/init.jl#L248

Added line #L248 was not covered by tests

JuliaWorkspaces.set_input_fallback_test_project!(server.workspace.runtime, isempty(server.env_path) ? nothing : filepath2uri(server.env_path))

Expand Down
59 changes: 35 additions & 24 deletions src/requests/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,38 +82,49 @@

empty!(server._extra_tracked_files)

# Add project files separately in case they are not in a workspace folder
if server.env_path != ""
for file in ["Project.toml", "JuliaProject.toml", "Manifest.toml", "JuliaManifest.toml"]
file_full_path = joinpath(server.env_path, file)
uri = filepath2uri(file_full_path)
if isfile(file_full_path)
# Only add again if outside of the workspace folders
if all(i->!startswith(file_full_path, i), server.workspaceFolders)
if haskey(server._files_from_disc, uri)
error("This should not happen")
end
track_project_files!(server)

Check warning on line 85 in src/requests/misc.jl

View check run for this annotation

Codecov / codecov/patch

src/requests/misc.jl#L85

Added line #L85 was not covered by tests

text_file = JuliaWorkspaces.read_text_file_from_uri(uri, return_nothing_on_io_error=true)
text_file===nothing || continue
JuliaWorkspaces.set_input_fallback_test_project!(server.workspace.runtime, isempty(server.env_path) ? nothing : filepath2uri(server.env_path))

Check warning on line 87 in src/requests/misc.jl

View check run for this annotation

Codecov / codecov/patch

src/requests/misc.jl#L87

Added line #L87 was not covered by tests

server._files_from_disc[uri] = text_file
# We call this here to remove project and manifest files that were not in the workspace
gc_files_from_workspace(server)

Check warning on line 90 in src/requests/misc.jl

View check run for this annotation

Codecov / codecov/patch

src/requests/misc.jl#L90

Added line #L90 was not covered by tests

if !haskey(server._open_file_versions, uri)
JuliaWorkspaces.add_file!(server.workspace, text_file)
end
trigger_symbolstore_reload(server)

Check warning on line 92 in src/requests/misc.jl

View check run for this annotation

Codecov / codecov/patch

src/requests/misc.jl#L92

Added line #L92 was not covered by tests
end
end

function track_project_files!(server::LanguageServerInstance)

Check warning on line 96 in src/requests/misc.jl

View check run for this annotation

Codecov / codecov/patch

src/requests/misc.jl#L96

Added line #L96 was not covered by tests
# Add project files separately in case they are not in a workspace folder
if server.env_path != ""
for file in ["Project.toml", "JuliaProject.toml", "Manifest.toml", "JuliaManifest.toml"]
file_full_path = joinpath(server.env_path, file)
uri = filepath2uri(file_full_path)
if isfile(file_full_path)
@static if Sys.iswindows()

Check warning on line 103 in src/requests/misc.jl

View check run for this annotation

Codecov / codecov/patch

src/requests/misc.jl#L98-L103

Added lines #L98 - L103 were not covered by tests
# Normalize drive letter to lowercase
if length(file_full_path) > 1 && isletter(file_full_path[1]) && file_full_path[2] == ':'
file_full_path = lowercasefirst(file_full_path)

Check warning on line 106 in src/requests/misc.jl

View check run for this annotation

Codecov / codecov/patch

src/requests/misc.jl#L105-L106

Added lines #L105 - L106 were not covered by tests
end
push!(server._extra_tracked_files, filepath2uri(file_full_path))
end
end
end
# Only add again if outside of the workspace folders
if all(i->!startswith(file_full_path, i), server.workspaceFolders)
if haskey(server._files_from_disc, uri)
error("This should not happen")

Check warning on line 112 in src/requests/misc.jl

View check run for this annotation

Codecov / codecov/patch

src/requests/misc.jl#L110-L112

Added lines #L110 - L112 were not covered by tests
end

JuliaWorkspaces.set_input_fallback_test_project!(server.workspace.runtime, isempty(server.env_path) ? nothing : filepath2uri(server.env_path))
text_file = JuliaWorkspaces.read_text_file_from_uri(uri, return_nothing_on_io_error=true)
text_file === nothing && continue

Check warning on line 116 in src/requests/misc.jl

View check run for this annotation

Codecov / codecov/patch

src/requests/misc.jl#L115-L116

Added lines #L115 - L116 were not covered by tests

# We call this here to remove project and manifest files that were not in the workspace
gc_files_from_workspace(server)
server._files_from_disc[uri] = text_file

Check warning on line 118 in src/requests/misc.jl

View check run for this annotation

Codecov / codecov/patch

src/requests/misc.jl#L118

Added line #L118 was not covered by tests

trigger_symbolstore_reload(server)
if !haskey(server._open_file_versions, uri)
JuliaWorkspaces.add_file!(server.workspace, text_file)

Check warning on line 121 in src/requests/misc.jl

View check run for this annotation

Codecov / codecov/patch

src/requests/misc.jl#L120-L121

Added lines #L120 - L121 were not covered by tests
end
end
# But we do want to track, in case the workspace folder is removed
push!(server._extra_tracked_files, filepath2uri(file_full_path))

Check warning on line 125 in src/requests/misc.jl

View check run for this annotation

Codecov / codecov/patch

src/requests/misc.jl#L125

Added line #L125 was not covered by tests
end
end

Check warning on line 127 in src/requests/misc.jl

View check run for this annotation

Codecov / codecov/patch

src/requests/misc.jl#L127

Added line #L127 was not covered by tests
end
end

Expand Down
Loading