- Notifications
You must be signed in to change notification settings - Fork61
feat(analysis): add diagnostics syntax#457
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
feat(analysis): add diagnostics syntax#457
Uh oh!
There was an error while loading.Please reload this page.
Conversation
I need more cases for the test |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.
This feature is progressing nicely. Thanks a lot for looking into it.
| @@ -0,0 +1,13 @@ | |||
| [{ | |||
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.
There's the question of what to do with parser recovery, see if this is too noisy. Always possible to report only the first thing.
Something to evaluate after hooking this command to the editor inserver.ts.
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.
Can you elaborate a little more? It is related to this PR?
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.
So the parser runs in recovery mode, and keeps on parsing after the first syntax error.
You can see this in your test where 3 things are reported for the same issue.
Now, one could just stop after the first report. Which would take care of the noise in this example.
However, it would be nice to report more than one (syntax) error at once, if possible, when these errors happen in different regions.
Since this PR exposes the syntax errors to users, it's part of this PR to evaluate how those errors look like in practice.
Then based on that, decide how to proceed.
cristianocJun 16, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
It might just be OK the way it is now. But one would need to experiment once this command is hooked up to the extension.
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.
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.
Another related aspect, that also needs to wait, is about making sure there is no double reporting when the compiler is already reporting the syntax error.
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.
E.g.:
1 introduce syntax error
2 compile
3 edit unrelated part of the file
Then you get a file that is unsaved, with syntax errors, but where the syntax error was reported already.
@aspeddro awesome that you're having a look at this! The client upgrade will be merged soon, so this will shortly be unblocked. |
@aspeddro merged! You can go ahead an pull the latest master into this PR, and the client will be upgraded. |
I'm implemented workspace diagnostic to catch syntax error for all files inside a project but dune returns an error: duneexec rescript-editor-analysis workspaceSyntax~/Desktop/learning-rescript/Fatal error: exception Sys_error("Value too large for defined data type") In this directory there is only one file with syntax error. Is it some dune setting, any idea how to get around this error? |
I think we want current file only. |
aspeddro commentedJun 17, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I've made some advances to syntax diagnostics. May be related to#448. I added a second argument to the analysis, this allows capturing diagnostics when the document changes. rescript-editor-analysis diagnosticSyntaxeval"let = 1 + 1.0" Is it a good feature to add to this PR? Testing on vscode client (still need to fix some issues) screencast-2022-06-17_21.05.01.mp4 |
Definitely we want the command to run on unsaved files, in fact that's the only case where the command is needed. Otherwise, the compiler already reports the syntax error. The only thing is: one passes the path to a file containing the current contents of the window, not a string. |
The client side does not merge diagnostics, so there are no duplicates.https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_publishDiagnostics analisys bin is ready. I will open a PR to update |
As long as the diagnostics are identical, true there's no problem. |
aspeddro commentedJun 18, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I did some tests, but the assumption is that the parsing of |
Go for it! |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
cristianoc commentedJun 18, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Noticed this when testing this PR: Now I don't think this change could have caused it. @zth any thoughts about this? |
cristianoc commentedJun 18, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
In general, it seems the reporting logic is very fast, and I was wondering whether this is indeed what we want. |
I'm going to do some thorough testing on TS and Rust, but I'm pretty sure we want to debounce the syntax diagnostics, so that it's only reported once the user "rests"/stops typing. Will get back here with the results. |
Ok, this was a bit surprising. My impression is both Rust and TS has same behavior as we have currently in this PR - everything is reported immediately. However, with TS it's sometimes hard to know whether it's a debounce involved, or if it's just slow. Here are two GIFs showing both experiences: As you can see, both of them push the errors as soon as they can. Two things come to mind knowing this:
What do you think@aspeddro@cristianoc ? |
I also don't find it annoying, as I remember most LSP's I've used report error when typing. Maybe a forum topic to see what users think. |
Other than deciding on the experience itself, what's left before this can be considered complete? |
Given that the experience is the same in other languages, I think that settles it in terms of preferences/opinions. |
@cristianoc yeah it sounds like our time can be better spent on something else than an experiment like that right now. I'm going to run this locally for a while to try things out. |
Ok, after testing some I've noticed a few things:
|
Let's investigate 2. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
0ef4fd6 to39079adCompareThere 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.
This looks great.
Left a few comments.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.
Approving as there are only minor suggestions.
Looking great. Let me know when you're done with the minor things, and we can test and merge. |
Done |


Example:
syntax_error.res: