@@ -260,6 +260,7 @@ protected override InitializeResult OnInitialize(InitializeParams parameters)
260260 this . Workspace . ExceptionTriggered += ExceptionTriggered ;
261261 this . Workspace . WarningTrigger += WarningTrigger ;
262262 this . Workspace . MissingCopiesEvent += MissingCopiesDetected ;
263+ this . Workspace . DiagnosticsEvent += DiagnosticsDetected ;
263264 this . Workspace . LoadCustomAnalyzers ( CustomAnalyzerFiles ) ;
264265
265266 // Return language server capabilities
@@ -278,6 +279,9 @@ protected override InitializeResult OnInitialize(InitializeParams parameters)
278279
279280 protected override void OnShutdown ( )
280281 {
282+ this . Workspace . LoadingIssueEvent -= LoadingIssueDetected ;
283+ this . Workspace . ExceptionTriggered -= ExceptionTriggered ;
284+ this . Workspace . WarningTrigger -= WarningTrigger ;
281285 this . Workspace . MissingCopiesEvent -= MissingCopiesDetected ;
282286 this . Workspace . DiagnosticsEvent -= DiagnosticsDetected ;
283287
@@ -307,9 +311,6 @@ protected override void OnDidOpenTextDocument(DidOpenTextDocumentParams paramete
307311 DocumentContext docContext = new DocumentContext ( parameters . textDocument ) ;
308312 if ( docContext . Uri . IsFile && ! this . Workspace . TryGetOpenedDocumentContext ( docContext . Uri , out _ ) )
309313 {
310- //Subscribe to diagnostics event
311- this . Workspace . DiagnosticsEvent += DiagnosticsDetected ;
312-
313314 //Create a ILanguageServer instance for the document.
314315 docContext . LanguageServer = new TypeCobolLanguageServer ( this . RpcServer , parameters . textDocument ) ;
315316 docContext . LanguageServer . UseSyntaxColoring = UseSyntaxColoring ;
@@ -495,7 +496,6 @@ protected override void OnDidCloseTextDocument(DidCloseTextDocumentParams parame
495496 if ( objUri . IsFile )
496497 {
497498 this . Workspace . CloseSourceFile ( objUri ) ;
498- this . Workspace . DiagnosticsEvent -= DiagnosticsDetected ;
499499
500500 // DEBUG information
501501 RemoteConsole . Log ( "Closed source file : " + objUri . LocalPath ) ;
0 commit comments