fix(core): apply a project descriptor edit in the build it starts - #238
Merged
Merged
Conversation
- Re-parse a descriptor still at Changed before reading it, since the onUpdate listeners run before the build's parse phase and otherwise see the previous edit's AST - Restore the document state afterwards so the build still runs and notifies its own parse phase, without parsing the text twice - Say the cascade reset joins the build of the descriptor's update, not a later one - Cover removing and re-adding a requires clause, and creating a new descriptor, in order-flow Fixes #221
martin-fleck-at
force-pushed
the
fix/descriptor-edit-lag
branch
from
September 30, 2026 09:37
bc17214 to
9f42e47
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Editing a project descriptor changed the project registry only on the descriptor's next edit.
AbstractProjectManagerreads descriptors from aDocumentBuilder.onUpdatelistener, and Langium calls those listeners after it resets the changed documents but before the build parses them, soparseProjectDescriptorsaw the previous edit's AST. This change hasloadDescriptorre-parse a descriptor that has not been parsed since the edit, from the same text the build reads, and then restore the document's state. The build still runs its own parse phase and fires its phase notification, and the factory skips the second parse because the text is unchanged. The change event is still emitted from the listener, and Langium awaits the listeners before it collects the documents to rebuild, so the dependent documents join that same build rather than a second one. The same guard fixes a descriptor created by an update: Langium holds it as an unparsedINVALIDplaceholder until the build's parse phase, so its project was not registered until the file's next edit.The three doc comments that said the cascade reset is picked up by "the next build cycle" now say it joins the build of the update that changed the descriptor. Discovery emits with no affected documents, so that update's build is the only one a reset can land in.
What it leaves alone
The re-parse runs with
CancellationToken.None, because Langium passes its update listeners no token, so a newer edit cannot cancel a descriptor parse already under way. AnonUpdatelistener registered after the project manager now sees the descriptor's new AST rather than the old one.How I know it works
requires commerce-corefromorders.domain, runs one update, and expectsordersto have no dependencies andOrder.totalto be unresolved; then it restores the line and expects both back after one more update. With the core change stashed and core rebuilt it fails withexpected [ 'commerce-core' ] to be undefined, the stale registry from the issue.refunds/refunds.domaincarryingproject refunds requires commerce-core, runs one update, and expects the project registered and itsMoneyfield resolved. With the core change stashed it fails withexpected undefined to deeply equal [ 'commerce-core' ]: the project is not registered until the file's next edit.onUpdatelistener, deleted afterwards, logged the descriptor at stateChangedwith its AST still containingrequires commerce-coreat the moment the project manager reads it.Fixes #221.