Skip to content
Draft
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
6 changes: 6 additions & 0 deletions src/LanguageServer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ using PrecompileTools

export LanguageServerInstance, runserver

const TEMPDEBUG = Ref{Vector{String}}()

function __init__()
TEMPDEBUG[] = String[]
end

JSON.lower(uri::URI) = string(uri)

include("exception_types.jl")
Expand Down
7 changes: 6 additions & 1 deletion src/requests/init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ function initialized_notification(params::InitializedParams, server::LanguageSer

if server.workspaceFolders !== nothing
for i in server.workspaceFolders
JuliaWorkspaces.add_folder_from_disc!(server.workspace, i)
diag_files = JuliaWorkspaces.add_folder_from_disc!(server.workspace, i)

for i in diag_files
push!(TEMPDEBUG[], "$(i.uri) ADDED initialized_notification loop")
end
end

# Add project files separately in case they are not in a workspace folder
Expand All @@ -209,6 +213,7 @@ function initialized_notification(params::InitializedParams, server::LanguageSer
# Only add again if outside of the workspace folders
if all(i->!startswith(file_full_path, i), server.workspaceFolders)
JuliaWorkspaces.add_file_from_disc!(server.workspace, file_full_path)
push!(TEMPDEBUG[], "$(filepath2uri(file_full_path)) ADDED initialized_notification project handling")
end
# But we do want to track, in case the workspace folder is removed
push!(server._extra_tracked_files, filepath2uri(file_full_path))
Expand Down
1 change: 1 addition & 0 deletions src/requests/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function julia_activateenvironment_notification(params::NamedTuple{(:envPath,),T
# Only add again if outside of the workspace folders
if all(i->!startswith(file_full_path, i), server.workspaceFolders)
JuliaWorkspaces.add_file_from_disc!(server.workspace, file_full_path)
push!(TEMPDEBUG[], "$(filepath2uri(file_full_path)) ADDED julia_activateenvironment_notification")
end
push!(server._extra_tracked_files, filepath2uri(file_full_path))
end
Expand Down
2 changes: 2 additions & 0 deletions src/requests/textdocument.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function textDocument_didOpen_notification(params::DidOpenTextDocumentParams, se
JuliaWorkspaces.update_file!(server.workspace, new_text_file)
else
JuliaWorkspaces.add_file!(server.workspace, new_text_file)
push!(TEMPDEBUG[], "$uri ADDED textDocument_didOpen_notification")
end
server._open_file_versions[uri] = params.textDocument.version

Expand Down Expand Up @@ -63,6 +64,7 @@ function textDocument_didClose_notification(params::DidCloseTextDocumentParams,
file_path = uri2filepath(uri)
if file_path===nothing || !isfile(file_path)
JuliaWorkspaces.remove_file!(server.workspace, uri)
push!(TEMPDEBUG[], "$uri REMOVED textDocument_didClose_notification")
if !ismissing(server.initialization_options) && get(server.initialization_options, "julialangTestItemIdentification", false)
JSONRPC.send(conn, textDocument_publishTests_notification_type, PublishTestsParams(uri, missing, TestItemDetail[], TestSetupDetail[], TestErrorDetail[]))
end
Expand Down
9 changes: 8 additions & 1 deletion src/requests/workspace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ function workspace_didChangeWatchedFiles_notification(params::DidChangeWatchedFi

if change.type == FileChangeTypes.Created || change.type == FileChangeTypes.Changed
if change.type == FileChangeTypes.Created
JuliaWorkspaces.add_file_from_disc!(server.workspace, uri2filepath(uri))
if !haskey(server._open_file_versions, uri)
JuliaWorkspaces.add_file_from_disc!(server.workspace, uri2filepath(uri))
push!(TEMPDEBUG[], "$uri ADDED workspace_didChangeWatchedFiles_notification")
end
elseif change.type == FileChangeTypes.Changed
if !haskey(server._open_file_versions, uri)
JuliaWorkspaces.update_file_from_disc!(server.workspace, uri2filepath(uri))
Expand Down Expand Up @@ -56,6 +59,7 @@ function workspace_didChangeWatchedFiles_notification(params::DidChangeWatchedFi
elseif change.type == FileChangeTypes.Deleted
if !haskey(server._open_file_versions, uri)
JuliaWorkspaces.remove_file!(server.workspace, uri)
push!(TEMPDEBUG[], "$uri REMOVED workspace_didChangeWatchedFiles_notification")
if !ismissing(server.initialization_options) && get(server.initialization_options, "julialangTestItemIdentification", false)
JSONRPC.send(conn, textDocument_publishTests_notification_type, PublishTestsParams(uri, missing, TestItemDetail[], TestSetupDetail[], TestErrorDetail[]))
end
Expand Down Expand Up @@ -166,6 +170,8 @@ function gc_files_from_workspace(server::LanguageServerInstance)
end

JuliaWorkspaces.remove_file!(server.workspace, uri)
push!(TEMPDEBUG[], "$uri REMOVED gc_files_from_workspace")

if !ismissing(server.initialization_options) && get(server.initialization_options, "julialangTestItemIdentification", false)
JSONRPC.send(server.jr_endpoint, textDocument_publishTests_notification_type, PublishTestsParams(uri, missing, TestItemDetail[], TestSetupDetail[], TestErrorDetail[]))
end
Expand All @@ -183,6 +189,7 @@ function workspace_didChangeWorkspaceFolders_notification(params::DidChangeWorks
for i in files
if !haskey(server._open_file_versions, i.uri)
JuliaWorkspaces.add_file!(server.workspace, i)
push!(TEMPDEBUG[], "$(i.uri) ADDED workspace_didChangeWorkspaceFolders_notification")
end
end
end
Expand Down