Repository navigation
bnf: fix slow keyword completion in grammars with 20+ rules - #467
Merged
Max Medvedev (maxmedvedev) merged 1 commit intoSep 19, 2026
Merged
Max Medvedev (maxmedvedev) merged 1 commit into
Max Medvedev (maxmedvedev) merged 1 commit into
Conversation
Contributor
Author
|
Merge after #458 |
Andrei Efanov (goto1134)
marked this pull request as draft
August 28, 2026 11:23
Andrei Efanov (goto1134)
force-pushed
the
fix/dummy-block-sibling-walk
branch
2 times, most recently
from
August 29, 2026 10:26
65e9c71 to
cfab6d6
Compare
getDummyAwarePrevSibling has two return paths: one descends into a chunk found as a direct sibling, the other climbs to a non-empty-leading ancestor and returns that ancestor's previous sibling as-is. The second path never unwraps a DUMMY_BLOCK, so once a grammar has two or more chunks in a row, walking backward across the boundary returns a raw chunk node instead of the rule inside it, and stops there. BnfCompletionContributor.suggestKeywords, the one caller, does not recognize DUMMY_BLOCK either, so it gives up and completes from the start of the file instead of resuming after the last rule. Fix: compute prevSibling from whichever branch applies, then run it through the same unwrap loop, so both paths unwrap consistently, including through chunks nested more than one level deep. GrammarUtilTest.testPrevSiblingCrossesChunkBoundaries walks a nested-chunk grammar backward and asserts no rule is skipped; on the old code it stops at the first chunk boundary. There is no completion-level test: the fallback reparses the whole file, but a free top-level position still offers the same keywords, so the regression is not observable through suggestKeywords -- only its cost is.
Andrei Efanov (goto1134)
force-pushed
the
fix/dummy-block-sibling-walk
branch
from
August 29, 2026 10:54
cfab6d6 to
2f5024c
Compare
Andrei Efanov (goto1134)
marked this pull request as ready for review
August 29, 2026 10:55
Max Medvedev (maxmedvedev)
approved these changes
Sep 19, 2026
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.
Keyword completion in
.bnffiles with 20 or more top-level rules re-parsed thefile from the start on every completion request, instead of resuming after the
last preceding rule. Suggestions were still correct, just slower — and
increasingly so as the file grew. Fixed.