-
Notifications
You must be signed in to change notification settings - Fork 30.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate a diagnostic pull model #112501
Comments
I think the most important reason for this being push, not pull hasn't been listed and that's that there is no way to know what files to ask diagnostics for. Typing a file A can introduce errors in file Z and that file might not be active and not be an open tab, however I still wanna see its errors in the error list. |
This is what I meant with the statement that VS Code pushed for a workspace diagnostic model. But I will clarify this by adding the file dependency example as well.
The reason for this is that even if we have an open editor tab model I think it will not be enough. If we consistently decorate file with their errors in the UI how would an extension (e.g. a linter) decide to compute the errors and push them if a file is for example presented in a reference result list? So I thought that a pull model would benefit VS Code as well and not only LSP. And I think that on an LSP layer I can't promise to implement a pull model correctly in all cases. |
Update the description with the inter file dependency example. |
I like the proposal. We need this for vscode.d.ts as well
I would suggest to try first without a |
That's not correct. The existing push-API will remain forever and therefore you will always have diagnostics being reported for virtual documents. |
A pull model would be useful for embedded languages, which is a use-case I have right now. |
Will close the issue. A new next version of the LSP libraries containing a pull model implementation got published |
Introduction
Diagnostics are currently the only data objects in the languages space that an extension pushed to VS Code. The reasoning behind that architecture is as follows:
A
can result in problems in a fileB
. In addition in a workspace diagnostic model the extension (e.g. LSP server) can decide when it is a good time to compute the diagnostics and to push them to the server.However the approach has also some downsides:
Pull Model
Instead of letting the server push diagnostics a client could pull them. Such a model would be analogous to the other language features which are usually pull also (for example semantic tokens). However a pull model has some drawbacks as well:
Requesting Diagnostics
Pulling for document scoped diagnostics should be done analogous to other providers that are document scoped. A good blueprint could be document symbols for which the pull frequency is adopted to computation time, file size, user typing, ... However it is unclear if the client should pull for all open visible documents or only for the focused one. If the client pulls for all visible documents the pull frequency should be higher for the active document.
Pulling for workspace diagnostics needs to address the following issues:
These characteristics are addressed as follows (see API proposal below):
WorkspaceDiagnosticResult
to which the extension can add values later on. The result is consider to be open until the extension callsdone
on it.provideWorkspaceDiagnostics
and (b)provideWorkspaceDiagnosticsEdits
to pull the delta. An item in a result is identified using theresource
property of aDiagnosticResultItem
. This means a result item with a resourceX
replace one from a previous result with the same resource. Items are cleared for a specific resource by using aDiagnosticResultItem
with the resource's uri and an empty diagnostics array.done
on aWorkspaceDiagnosticResult
. The result items delivered are consider to be valid. However the extension can pass in a flag to ask the client to immediately re-trigger a diagnostic pull. Please note that such a re-trigger is even possible if no result items have been add. This allows an extension to signal a busy case indicating that it is not a good time right now to ask for workspace diagnostics.API Proposal
A diagnostic pull model should be align with the current API design. A possible API could look like this:
Open questions
X
from a document provider will shadow diagnostics for a resourceX
from a workspace provider.The text was updated successfully, but these errors were encountered: