@@ -375,50 +375,58 @@ function try_to_load_parents(child_path, server)
375375 end
376376end
377377
378- const our_count = Ref {Int} (0 )
379-
380378function publish_diagnostics (uris:: Vector{URI} , server, conn, source)
381- our_count[] = our_count[] + 1
382379 jw_diagnostics_updated, jw_diagnostics_deleted = JuliaWorkspaces. get_files_with_updated_diagnostics (server. workspace)
383380
384- diagnostics = Dict {URI,Vector{Diagnostic} } ()
381+ all_uris_with_updates = Set {URI} ()
385382
386383 for uri in uris
387- push! (jw_diagnostics_updated , uri)
384+ push! (all_uris_with_updates , uri)
388385 end
389386
390- for uri in uris
391- diags = get! (diagnostics, uri, Diagnostic[])
392- doc = getdocument (server, uri)
387+ for uri in jw_diagnostics_updated
388+ push! (all_uris_with_updates, uri)
389+ end
390+
391+ diagnostics = Dict {URI,Vector{Diagnostic}} ()
393392
394- if server. runlinter && (is_workspace_file (doc) || isunsavedfile (doc))
395- pkgpath = getpath (doc)
396- if any (is_in_target_dir_of_package .(Ref (pkgpath), server. lint_disableddirs))
397- filter! (! is_diag_dependent_on_env, doc. diagnostics)
393+ for uri in all_uris_with_updates
394+ diags = Diagnostic[]
395+ diagnostics[uri] = diags
396+
397+ if hasdocument (server, uri)
398+ doc = getdocument (server, uri)
399+
400+ if server. runlinter && (is_workspace_file (doc) || isunsavedfile (doc))
401+ pkgpath = getpath (doc)
402+ if any (is_in_target_dir_of_package .(Ref (pkgpath), server. lint_disableddirs))
403+ filter! (! is_diag_dependent_on_env, doc. diagnostics)
404+ end
405+ append! (diags, doc. diagnostics)
398406 end
399- append! (diags, doc. diagnostics)
400407 end
401408
402- st = JuliaWorkspaces. get_text_file (server. workspace, uri). content
403-
404- append! (diags, Diagnostic (
405- Range (st, i. range),
406- if i. severity== :error
407- DiagnosticSeverities. Error
408- elseif i. severity== :warning
409- DiagnosticSeverities. Warning
410- elseif i. severity== :info
411- DiagnosticSeverities. Information
412- else
413- error (" Unknown severity $(i. severity) " )
414- end ,
415- missing ,
416- missing ,
417- i. source,
418- i. message,
419- missing ,
420- missing
421- ) for i in JuliaWorkspaces. get_diagnostic (server. workspace, uri))
409+ if JuliaWorkspaces. has_file (server. workspace, uri)
410+ st = JuliaWorkspaces. get_text_file (server. workspace, uri). content
411+ append! (diags, Diagnostic (
412+ Range (st, i. range),
413+ if i. severity== :error
414+ DiagnosticSeverities. Error
415+ elseif i. severity== :warning
416+ DiagnosticSeverities. Warning
417+ elseif i. severity== :info
418+ DiagnosticSeverities. Information
419+ else
420+ error (" Unknown severity $(i. severity) " )
421+ end ,
422+ missing ,
423+ missing ,
424+ i. source,
425+ i. message,
426+ missing ,
427+ missing
428+ ) for i in JuliaWorkspaces. get_diagnostic (server. workspace, uri))
429+ end
422430 end
423431
424432 for (uri,diags) in diagnostics
@@ -429,7 +437,6 @@ function publish_diagnostics(uris::Vector{URI}, server, conn, source)
429437end
430438
431439function publish_tests (server:: LanguageServerInstance )
432- our_count[] = our_count[] + 1
433440 if ! ismissing (server. initialization_options) && get (server. initialization_options, " julialangTestItemIdentification" , false )
434441 updated_files, deleted_files = JuliaWorkspaces. get_files_with_updated_testitems (server. workspace)
435442
0 commit comments