-
Notifications
You must be signed in to change notification settings - Fork 61
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
Ensure expected document state in LSP responses #1334
Conversation
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 like the contribution of this PR, as it provides an explicit way of awaiting the completion of the builder. On the other hand, it's kind of a sugar API based on the build listeners, right, with the additional support for cancelation checking?
Actually, I'm undecided whether it's worth exposing it on the document builder. It could also be added to the LanguageServer
as it's (mainly) used there, couldn't it?
@@ -18,7 +18,7 @@ export default defineConfig({ | |||
interopDefault: true | |||
}, | |||
include: ['**/test/**/*.test.ts'], | |||
exclude: ['**/node_modules/**', '**/dist/**', '**/generated/**', '**/templates/**'], | |||
exclude: ['**/node_modules/**', '**/dist/**', '**/generated/**', '**/templates/**', '**/examples/hello*/**'], |
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.
That's most likely not related to this PR, right?
Is the code examples/hello*/
a left-over of a previous run of generator-langium
tests?
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.
Not necessarily, but I've found that the npm run test
command restarts once the yeoman generator test has passed, since it updates the files. Adding this exclude rule seems to fix it.
e40cde2
to
75828d7
Compare
@sailingKieler I've also thought about the
Also, I wouldn't say it's API sugar. It has two separate use cases:
With that in mind, I believe it's worth to have it's own API. |
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.
Great!
Apart from my additional comment, I'm fine with the contribution.
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.
Good improvement!
4883dc0
to
9d0fefe
Compare
9d0fefe
to
d6ed56a
Compare
Related to #1290
In the discussion in particular, the console warning appears due to the GLSP handler not awaiting the linking phase. However, all of our own LSP handlers haven't been awaiting that phase, instead opting to respond as quickly as possible. This sometimes leads to unexpected behavior in the response or tries to resolve a cross reference before it is ready.
This change attempts to mitigate the risk of this issue appearing by adding a
waitUntil
method to theDocumentBuilder
. We use that method in the language server to wait until the required data is available for the respective service to do their work. This is usually eitherIndexedReferences
(for any service that requires to resolve cross references) andParsed
(for services that operate on the AST/CST directly).The new
waitUntil
method can also be interrupted in case it is no longer required. It will thenreject
(see tests).