-
Notifications
You must be signed in to change notification settings - Fork 321
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
Add middleware to intercept textDocument/publishDiagnostics #322
Conversation
@rcjsuen thanks for the PR. There is one thing I am not sure of how we should do it: the middleware API currently uses VS Code API types only. With this PR it will surface LSP types. Although this allows to intercept the notification as early as possible I would nevertheless change the types to VS Code API types. In the implementation that means we first convert the LSP data into VS Code data and then call the middleware. |
@dbaeumer Hi Dirk, thanks for the review. Should I still use publishDiagnostics?: NextSignature<PublishDiagnosticsParams, void>; ...to... publishDiagnostics?: NextSignature<Uri, VDiagnostic[], void>; But this won't compile because Or should I instead write a new function like the following and just introduce a new handleDiagnostics?: (this: void, uri: Uri, diagnostic: VDiagnostics[], next: HandleDiagnosticsSignature) => void; |
Clients may want to inspect diagnostics received from the server before letting VS Code handle and display them. It is not possible to use onNotification because the existing handler will be replaced. Thus, we need to introduce a new middleware for the language client to route the server's textDocument/publishDiagnostics notification to. This will allow the client can do what it needs to do before then forwarding it off to VS Code. Signed-off-by: Remy Suen <remy.suen@gmail.com>
@rcjsuen I would go with the |
@dbaeumer Thank you. I've force pushed a new change to my branch. Feel free to take a look whenever you have the time. I'm sure you're a busy man. |
Thanks for the PR. |
It is currently not possible for a client to inspect the contents of the
textDocument/publishDiagnostics
notifications from the server before letting VS Code handle them. This pull request introduces a middleware function to allow clients to intercept the contents of the notification before passing them off to VS Code.