@@ -82,6 +82,7 @@ def __init__(self, protocol: LanguageServerProtocol) -> None:
8282 super ().__init__ (protocol )
8383
8484 self .workspace_loaded_event = Event ()
85+
8586 self ._workspace_load_lock = Lock ()
8687 self ._workspace_loaded = False
8788
@@ -92,7 +93,6 @@ def __init__(self, protocol: LanguageServerProtocol) -> None:
9293 self ._current_workspace_task : Optional [asyncio .Task [WorkspaceDiagnosticReport ]] = None
9394
9495 self .in_get_workspace_diagnostics = Event (True )
95- self ._collect_full_diagnostics = False
9696
9797 def extend_capabilities (self , capabilities : ServerCapabilities ) -> None :
9898 if (
@@ -107,15 +107,6 @@ def extend_capabilities(self, capabilities: ServerCapabilities) -> None:
107107 work_done_progress = True ,
108108 )
109109
110- @property
111- def collect_full_diagnostics (self ) -> bool :
112- return self ._collect_full_diagnostics
113-
114- async def set_collect_full_diagnostics (self , value : bool ) -> None :
115- if self ._collect_full_diagnostics != value :
116- self ._collect_full_diagnostics = value
117- await self .refresh ()
118-
119110 @async_tasking_event_iterator
120111 async def collect (sender , document : TextDocument , full : bool ) -> DiagnosticsResult : # NOSONAR
121112 ...
@@ -216,8 +207,6 @@ async def _text_document_diagnostic(
216207 self ._logger .debug (lambda : f"textDocument/diagnostic for { text_document } " )
217208
218209 try :
219- # await self.ensure_workspace_loaded()
220-
221210 document = await self .parent .documents .get (text_document .uri )
222211 if document is None :
223212 raise JsonRPCErrorException (ErrorCodes .INVALID_PARAMS , f"Document { text_document !r} not found" )
@@ -274,13 +263,6 @@ async def _get_diagnostics() -> WorkspaceDiagnosticReport:
274263 result : List [WorkspaceDocumentDiagnosticReport ] = []
275264
276265 for doc in self .parent .documents .documents :
277- if self ._current_workspace_task is None :
278- raise JsonRPCErrorException (
279- ErrorCodes .SERVER_CANCELLED ,
280- "ServerCancelled" ,
281- data = DiagnosticServerCancellationData (True ),
282- )
283-
284266 doc_result = await self .get_document_diagnostics (doc )
285267
286268 if doc_result .result_id is not None and any (
@@ -301,7 +283,7 @@ async def _get_diagnostics() -> WorkspaceDiagnosticReport:
301283
302284 async def _get_partial_diagnostics () -> WorkspaceDiagnosticReport :
303285 async with self .parent .window .progress (
304- f "Analyse { 'full ' if self . collect_full_diagnostics else '' } Workspace" ,
286+ "Analyse Workspace" ,
305287 progress_token = work_done_token ,
306288 cancellable = False ,
307289 ) as progress :
@@ -315,7 +297,7 @@ async def _task(doc: TextDocument) -> None:
315297 else :
316298 name = path .relative_to (folder .uri .to_path ())
317299
318- progress .report (f"Analyse { 'full ' if self . collect_full_diagnostics else '' } { name } " )
300+ progress .report (f"Analyse { name } " )
319301
320302 doc_result = await self .get_document_diagnostics (doc )
321303
@@ -349,12 +331,6 @@ async def _task(doc: TextDocument) -> None:
349331 for doc in self .parent .documents .documents :
350332 if await self .get_diagnostics_mode (doc .uri ) == DiagnosticsMode .WORKSPACE :
351333 await _task (doc )
352- if self ._current_workspace_task is None :
353- raise JsonRPCErrorException (
354- ErrorCodes .SERVER_CANCELLED ,
355- "ServerCancelled" ,
356- data = DiagnosticServerCancellationData (True ),
357- )
358334
359335 return WorkspaceDiagnosticReport (items = [])
360336
@@ -368,11 +344,15 @@ async def _task(doc: TextDocument) -> None:
368344 task = create_sub_task (_get_diagnostics () if partial_result_token is None else _get_partial_diagnostics ())
369345 self ._current_workspace_task = task
370346 try :
371- result = await task
372- await self .set_collect_full_diagnostics (True )
373- return result
347+ return await task
374348 except asyncio .CancelledError :
375349 self ._logger .debug ("workspace/diagnostic canceled" )
350+ if self ._current_workspace_task is None :
351+ raise JsonRPCErrorException (
352+ ErrorCodes .SERVER_CANCELLED ,
353+ "ServerCancelled" ,
354+ data = DiagnosticServerCancellationData (True ),
355+ )
376356 raise
377357 finally :
378358 if self ._current_workspace_task == task :
0 commit comments