@@ -82,6 +82,7 @@ def __init__(self, protocol: LanguageServerProtocol) -> None:
82
82
super ().__init__ (protocol )
83
83
84
84
self .workspace_loaded_event = Event ()
85
+
85
86
self ._workspace_load_lock = Lock ()
86
87
self ._workspace_loaded = False
87
88
@@ -92,7 +93,6 @@ def __init__(self, protocol: LanguageServerProtocol) -> None:
92
93
self ._current_workspace_task : Optional [asyncio .Task [WorkspaceDiagnosticReport ]] = None
93
94
94
95
self .in_get_workspace_diagnostics = Event (True )
95
- self ._collect_full_diagnostics = False
96
96
97
97
def extend_capabilities (self , capabilities : ServerCapabilities ) -> None :
98
98
if (
@@ -107,15 +107,6 @@ def extend_capabilities(self, capabilities: ServerCapabilities) -> None:
107
107
work_done_progress = True ,
108
108
)
109
109
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
-
119
110
@async_tasking_event_iterator
120
111
async def collect (sender , document : TextDocument , full : bool ) -> DiagnosticsResult : # NOSONAR
121
112
...
@@ -216,8 +207,6 @@ async def _text_document_diagnostic(
216
207
self ._logger .debug (lambda : f"textDocument/diagnostic for { text_document } " )
217
208
218
209
try :
219
- # await self.ensure_workspace_loaded()
220
-
221
210
document = await self .parent .documents .get (text_document .uri )
222
211
if document is None :
223
212
raise JsonRPCErrorException (ErrorCodes .INVALID_PARAMS , f"Document { text_document !r} not found" )
@@ -274,13 +263,6 @@ async def _get_diagnostics() -> WorkspaceDiagnosticReport:
274
263
result : List [WorkspaceDocumentDiagnosticReport ] = []
275
264
276
265
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
-
284
266
doc_result = await self .get_document_diagnostics (doc )
285
267
286
268
if doc_result .result_id is not None and any (
@@ -301,7 +283,7 @@ async def _get_diagnostics() -> WorkspaceDiagnosticReport:
301
283
302
284
async def _get_partial_diagnostics () -> WorkspaceDiagnosticReport :
303
285
async with self .parent .window .progress (
304
- f "Analyse { 'full ' if self . collect_full_diagnostics else '' } Workspace" ,
286
+ "Analyse Workspace" ,
305
287
progress_token = work_done_token ,
306
288
cancellable = False ,
307
289
) as progress :
@@ -315,7 +297,7 @@ async def _task(doc: TextDocument) -> None:
315
297
else :
316
298
name = path .relative_to (folder .uri .to_path ())
317
299
318
- progress .report (f"Analyse { 'full ' if self . collect_full_diagnostics else '' } { name } " )
300
+ progress .report (f"Analyse { name } " )
319
301
320
302
doc_result = await self .get_document_diagnostics (doc )
321
303
@@ -349,12 +331,6 @@ async def _task(doc: TextDocument) -> None:
349
331
for doc in self .parent .documents .documents :
350
332
if await self .get_diagnostics_mode (doc .uri ) == DiagnosticsMode .WORKSPACE :
351
333
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
- )
358
334
359
335
return WorkspaceDiagnosticReport (items = [])
360
336
@@ -368,11 +344,15 @@ async def _task(doc: TextDocument) -> None:
368
344
task = create_sub_task (_get_diagnostics () if partial_result_token is None else _get_partial_diagnostics ())
369
345
self ._current_workspace_task = task
370
346
try :
371
- result = await task
372
- await self .set_collect_full_diagnostics (True )
373
- return result
347
+ return await task
374
348
except asyncio .CancelledError :
375
349
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
+ )
376
356
raise
377
357
finally :
378
358
if self ._current_workspace_task == task :
0 commit comments