-
Notifications
You must be signed in to change notification settings - Fork 215
add version support to textDocument/publishDiagnostics #1382
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
base: main
Are you sure you want to change the base?
Conversation
kinto0
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing! A few tests for this behavior would make us confident it works really well.
Could you add some tests in the lsp_interaction folder where each version for a diagnostics response is correct?
Thanks!!
pyrefly/lib/lsp/non_wasm/server.rs
Outdated
| } | ||
| self.connection.publish_diagnostics(diags); | ||
| self.connection | ||
| .publish_diagnostics(diags, &*self.version_info.lock()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: by aqcuiring the lock here, we won't be able to make updates to the version info. maybe we should clone it instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cloning the hashtable might be kind of heavy too? I prefer lock. let me know if otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
publish_diagnostics_for_uri takes an i32 so maybe we can change the API to only call these functions with that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I follow you, publish_diagnostics_for_uri takes an Option<i32> as version, also the change API part.
7028101 to
77eb1c0
Compare
I added a small test for this, however I can't figure out why it won't work, might need a little help here. : ( |
50c3750 to
9313fb2
Compare
kinto0
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you paste the test failure? it should show the messages back/forth.
pyrefly/lib/lsp/non_wasm/server.rs
Outdated
| } | ||
| self.connection.publish_diagnostics(diags); | ||
| self.connection | ||
| .publish_diagnostics(diags, &*self.version_info.lock()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
publish_diagnostics_for_uri takes an i32 so maybe we can change the API to only call these functions with that?
|
hmm that test looks like the behavior you want. like the other comments say, you're looking for the publishDiagnostic notification, not the textDocument/diagnostic response. the first one happens because of the type error then the next one happens because of the didChange. you can remove the document diagnostic requests and make a similar method to |
f982a09 to
32c4548
Compare
Now the test always fails with Timeout error, idk why. |
32c4548 to
a201c98
Compare
a201c98 to
3624c06
Compare
|
bumping some old PRs: if you still want a review on this, please re-request review |
3624c06 to
2e27f24
Compare
2e27f24 to
17c375e
Compare
f1bfc8f to
d49f787
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great. just a couple more changes + some conflicts to resolve then i'll import it.
edit: and let's make sure versions never decrease
d49f787 to
1aa1485
Compare
close #794
PS: I know little about LSP or this project