Skip to content

Add pull diagnostic support#1534

Closed
MariaSolOs wants to merge 10 commits intomicrosoft:mainfrom
MariaSolOs:pull-diagnostics
Closed

Add pull diagnostic support#1534
MariaSolOs wants to merge 10 commits intomicrosoft:mainfrom
MariaSolOs:pull-diagnostics

Conversation

@MariaSolOs
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.


// 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
Copy Markdown
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.

const notebooks = new NotebookDocuments(documents);

// This makes loading work in a plain NodeJS and a WebPacked environment
class DiagnosticVersions {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

and thanks a lot for doing this. Highly appreciated.

Comment on lines +219 to +220
if (refreshDiagnostics) {
connection.languages.diagnostics.refresh();
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@dbaeumer
Copy link
Copy Markdown
Member

Pull support got added.

@dbaeumer dbaeumer closed this Dec 18, 2024
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