Currently we have two paths leading to textDocument/publishDiagnostic sent to client:
1. Via TDiagnosticsHandler.CheckSyntax() => [ TDiagnosticsHandler.CodeToolsCheckSyntax() => TDiagnosticsHandler.AddCodeToolError() | TDiagnosticsHandler.StrictSyntaxCheck() => Reporter.ReportError() ] => Diagnostics.Add() => Diagnostics.Send()
2. Via PasLS.Diagnostics.PublishCodeToolsError() => TDiagnosticsHandler.SendDiagnosticMessage => TDiagnosticsHandler.AddCodeToolError() => Notification.Add() => Notification.Send()
Where TDiagnosticsHandler.CheckSyntax() being called in PasLS.Synchronization.pas and PasLS.Diagnostics.PublishCodeToolsError() being called by PasLS.*.pas in src/serverprotocol/
LSP spec states that Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens on the client side. so when client got diagnostics from CheckSyntax (after didOpen or didSave message) then client request textDocument/definition for example, client lost previous diagnostics.
This issue try to discuss what should we do?
The options that i can think of are:
- Maintain single
TPublishDiagnostics instance in TDiagnosticsHandler. Then each time new diagnostic added, we also send previous TDiagnosticItems.
The downside of this approach is we must handle duplicates and invalidated (already fixed by user) items. Probably quite complex.
- Prevent
PublishCodetoolsError() maintain and send its own TPublishDiagnostics. Make PublishCodetoolsError() call CheckSyntax() while passing errors from CodeToolBoss and/or UserMessage to be merged inside CheckSyntax()
Downside of this approach is performance hit (?) because each time TDiagnosticItems added, CheckSyntax() also called.
Currently we have two paths leading to
textDocument/publishDiagnosticsent to client:Where
TDiagnosticsHandler.CheckSyntax()being called inPasLS.Synchronization.pasandPasLS.Diagnostics.PublishCodeToolsError()being called byPasLS.*.pasinsrc/serverprotocol/LSP spec states that
Newly pushed diagnostics always replace previously pushed diagnostics. There is no merging that happens on the client side.so when client got diagnostics fromCheckSyntax(afterdidOpenordidSavemessage) then client requesttextDocument/definitionfor example, client lost previous diagnostics.This issue try to discuss what should we do?
The options that i can think of are:
TPublishDiagnosticsinstance inTDiagnosticsHandler. Then each time new diagnostic added, we also send previousTDiagnosticItems.The downside of this approach is we must handle duplicates and invalidated (already fixed by user) items. Probably quite complex.
PublishCodetoolsError()maintain and send its ownTPublishDiagnostics. MakePublishCodetoolsError()callCheckSyntax()while passing errors fromCodeToolBossand/orUserMessageto be merged insideCheckSyntax()Downside of this approach is performance hit (?) because each time
TDiagnosticItemsadded,CheckSyntax()also called.