From bd8e35f24efac739e365a0bd07975df5f678a42f Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Tue, 16 Jul 2024 15:45:35 +0200 Subject: [PATCH 1/2] Add debug log --- src/LanguageServer.jl | 6 ++++++ src/requests/init.jl | 7 ++++++- src/requests/misc.jl | 1 + src/requests/textdocument.jl | 2 ++ src/requests/workspace.jl | 5 +++++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/LanguageServer.jl b/src/LanguageServer.jl index 0e46f7b9..6c1e306d 100644 --- a/src/LanguageServer.jl +++ b/src/LanguageServer.jl @@ -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") diff --git a/src/requests/init.jl b/src/requests/init.jl index 8491d8b9..2d5a9699 100644 --- a/src/requests/init.jl +++ b/src/requests/init.jl @@ -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 @@ -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)) diff --git a/src/requests/misc.jl b/src/requests/misc.jl index 407d77fe..35a2caef 100644 --- a/src/requests/misc.jl +++ b/src/requests/misc.jl @@ -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 diff --git a/src/requests/textdocument.jl b/src/requests/textdocument.jl index 39aa7ab2..3a2b0e10 100644 --- a/src/requests/textdocument.jl +++ b/src/requests/textdocument.jl @@ -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 @@ -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 diff --git a/src/requests/workspace.jl b/src/requests/workspace.jl index 3da27d42..dc4965a3 100644 --- a/src/requests/workspace.jl +++ b/src/requests/workspace.jl @@ -7,6 +7,7 @@ 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)) + push!(TEMPDEBUG[], "$uri ADDED workspace_didChangeWatchedFiles_notification") elseif change.type == FileChangeTypes.Changed if !haskey(server._open_file_versions, uri) JuliaWorkspaces.update_file_from_disc!(server.workspace, uri2filepath(uri)) @@ -56,6 +57,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 @@ -166,6 +168,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 @@ -183,6 +187,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 From bbbf52a5c308b62956cf62b139d74cd57fde8dd8 Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Wed, 17 Jul 2024 00:20:35 +0200 Subject: [PATCH 2/2] Fix a bug --- src/requests/workspace.jl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/requests/workspace.jl b/src/requests/workspace.jl index dc4965a3..4e1f8cc0 100644 --- a/src/requests/workspace.jl +++ b/src/requests/workspace.jl @@ -6,8 +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)) - push!(TEMPDEBUG[], "$uri ADDED workspace_didChangeWatchedFiles_notification") + 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)) @@ -169,7 +171,7 @@ function gc_files_from_workspace(server::LanguageServerInstance) 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