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 pull diagnostic support #1534

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

MariaSolOs
Copy link
Contributor

This PR updates the server and client to use the pull diagnostics model.

Before completing this, there are a couple of places where I'm unsure if a change is needed (I marked those as TODOs in the code):

@rchl
Copy link
Contributor

rchl commented Oct 9, 2022

Am I correctly assuming that this would somewhat degrade the functionality or performance in editors that don't support pull diagnostics model since some code related to canceling validation requests is removed?

I know this server is made by Microsoft employee and you are working for Microsoft too but it is used by many editors outside of VSCode and it would be nice to consider that.

@dbaeumer
Copy link
Member

@rchl this is correct. However, keeping both implementations is not a good path forward either. I therefore suggest that we move the version number to 3.x. Then other editors can still use 2.x.

@@ -34,6 +34,7 @@ import LanguageDefaults from './languageDefaults';

// The connection to use. Code action requests get removed from the queue if
// canceled.
// TODO: Not sure if this changes with pull diagnostics.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to stay like this.

@@ -57,7 +58,43 @@ const documents: TextDocuments<TextDocument> = new TextDocuments(TextDocument);
// So all validating will work out of the box since normal document events will fire.
const notebooks = new NotebookDocuments(documents);

// This makes loading work in a plain NodeJS and a WebPacked environment
class DiagnosticVersions {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if it is worth doing this. The unchanged support is for languages that have inter file dependencies. Since we don't handle these in ESLint right now (ESLint doesn't either) I think it is fair to awlays return the diagnostics since we re-validate a file when the user types. So diagnostic positions changeanyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reasoning behind doing this is because not all editors offer this kind of client configuration for indicating which events should trigger a pull. By having this we can ensure that diagnostics are updated based on the value of the eslint.run setting.

async function validateSingle(document: TextDocument, publishDiagnostics: boolean = true): Promise<void> {
// We validate document in a queue but open / close documents directly. So we need to deal with the
async function validateSingle(params: DocumentDiagnosticParams): Promise<FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport> {
// TODO: Not sure if this comment still applies.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't happen anymore.

Copy link
Member

@dbaeumer dbaeumer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some comments for the todos

@dbaeumer
Copy link
Member

and thanks a lot for doing this. Highly appreciated.

Comment on lines 219 to 220
if (refreshDiagnostics) {
connection.languages.diagnostics.refresh();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be called if client doesn't support pull.
Node libraries don't check client capabilities so this will trigger crash.

Copy link
Contributor

@rchl rchl Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, unless the intention is to completely stop supporting non-pull model...
Not sure if that's @dbaeumer meant in another comment.

Copy link
Contributor Author

@MariaSolOs MariaSolOs Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To agree with the LSP specs, I'll add the capability check before sending the request @rchl. Thanks for catching that!

@dbaeumer
Copy link
Member

My proposal is to only support pull model from 3.x on forward. It allows us to remove quite some code and makes the overall processing easier on the server side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants