Skip to content
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

Merged
merged 1 commit into from Apr 6, 2018

Conversation

@rcjsuen
Copy link
Contributor

commented Mar 18, 2018

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.

@dbaeumer

This comment has been minimized.

Copy link
Member

commented Apr 5, 2018

@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.

@rcjsuen

This comment has been minimized.

Copy link
Contributor Author

commented Apr 5, 2018

@dbaeumer Hi Dirk, thanks for the review.

Should I still use NextSignature then? VS Code's Diagnostic does not contain information URI information so I am forced to change...

publishDiagnostics?: NextSignature<PublishDiagnosticsParams, void>;

...to...

publishDiagnostics?: NextSignature<Uri, VDiagnostic[], void>;

But this won't compile because NextSignature only takes two parameters.

Or should I instead write a new function like the following and just introduce a new HandleDiagnosticsSignature interface type?

handleDiagnostics?: (this: void, uri: Uri, diagnostic: VDiagnostics[], next: HandleDiagnosticsSignature) => void;
Add middleware to intercept diagnostics from the server
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>
@dbaeumer

This comment has been minimized.

Copy link
Member

commented Apr 6, 2018

@rcjsuen I would go with the HandleDiagnosticsSignature approach.

@rcjsuen rcjsuen force-pushed the rcjsuen:middleware-tdpd branch from 2a3f054 to 4c78f62 Apr 6, 2018

@rcjsuen

This comment has been minimized.

Copy link
Contributor Author

commented Apr 6, 2018

@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.

@dbaeumer

This comment has been minimized.

Copy link
Member

commented Apr 6, 2018

Thanks for the PR.

@dbaeumer dbaeumer merged commit 15b9900 into microsoft:master Apr 6, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla All CLA requirements met.
Details

@rcjsuen rcjsuen deleted the rcjsuen:middleware-tdpd branch Apr 6, 2018

@thymikee thymikee referenced this pull request May 10, 2018

Open

LSP Umbrella #243

5 of 9 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.