gopls commands use a gopls/diagnoseFiles "non standard request" to implement file diagnostics for commands and testing. Unfortunately, this still publishes diagnostics asynchronously, and so suffers from syncronization problems (e.g. #59475).
There is now a textDocument/diagnostic LSP method that does exactly what we want: return diagnostics for a requested file. We should implement this method and use it instead.
Furthermore, we should remove support for non-standard requests. workspace/executeCommand is a better extensibility mechanism.
Implementing textDocument/diagnostic should be done with some care: if we advertise this capability, some clients may start requesting diagnostics rather than letting gopls compute them asynchronously. This may have lifecycle and performance implications.
CC @adonovan
gopls commands use a
gopls/diagnoseFiles"non standard request" to implement file diagnostics for commands and testing. Unfortunately, this still publishes diagnostics asynchronously, and so suffers from syncronization problems (e.g. #59475).There is now a
textDocument/diagnosticLSP method that does exactly what we want: return diagnostics for a requested file. We should implement this method and use it instead.Furthermore, we should remove support for non-standard requests.
workspace/executeCommandis a better extensibility mechanism.Implementing
textDocument/diagnosticshould be done with some care: if we advertise this capability, some clients may start requesting diagnostics rather than letting gopls compute them asynchronously. This may have lifecycle and performance implications.CC @adonovan