Skip to content

Commit d075552

Browse files
authored
WI #2009 Bad assign DiagnosticsDetected elsewhere (#2010)
* WI #2009 Bad assign DiagnosticsDetected elsewhere * WI #2009 use events
1 parent 5d990e8 commit d075552

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

TypeCobol.LanguageServer/TypeCobolServer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

TypeCobol.LanguageServer/Workspace.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ public class Workspace
4747

4848
private List<FileCompiler> _fileCompilerWaittingForNodePhase;
4949
public TypeCobolConfiguration Configuration { get; private set; }
50-
public EventHandler<DiagnosticEvent> DiagnosticsEvent { get; set; }
51-
public EventHandler<EventArgs> DocumentModifiedEvent { get; set; }
52-
public EventHandler<MissingCopiesEvent> MissingCopiesEvent { get; set; }
53-
public EventHandler<LoadingIssueEvent> LoadingIssueEvent { get; set; }
54-
public EventHandler<ThreadExceptionEventArgs> ExceptionTriggered { get; set; }
55-
public EventHandler<string> WarningTrigger { get; set; }
50+
public event EventHandler<DiagnosticEvent> DiagnosticsEvent;
51+
public event EventHandler<EventArgs> DocumentModifiedEvent;
52+
public event EventHandler<MissingCopiesEvent> MissingCopiesEvent;
53+
public event EventHandler<LoadingIssueEvent> LoadingIssueEvent;
54+
public event EventHandler<ThreadExceptionEventArgs> ExceptionTriggered;
55+
public event EventHandler<string> WarningTrigger;
5656
public Queue<MessageActionWrapper> MessagesActionsQueue { get; private set; }
5757
private Func<string, Uri, bool> _Logger;
5858
/// <summary>

0 commit comments

Comments
 (0)