refactor(parser): Remove Lexer peeking for js/class#11243
Merged
graphite-app[bot] merged 1 commit intomainfrom May 23, 2025
Merged
refactor(parser): Remove Lexer peeking for js/class#11243graphite-app[bot] merged 1 commit intomainfrom
graphite-app[bot] merged 1 commit intomainfrom
Conversation
Contributor
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors parser peeking logic by replacing direct lexer peeking (peek_at) with lookahead callbacks, mirroring the TypeScript parser approach.
- Exposed
next_token_is_open_braceto enable lookahead. - Swapped out
peek_atforlookahead(Self::next_token_is_open_brace)in the static block check. - Introduced an inline lookahead closure for string‐constructor call detection.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/oxc_parser/src/modifiers.rs | Made next_token_is_open_brace pub(crate) for lookahead use. |
| crates/oxc_parser/src/js/class.rs | Replaced peek_at calls with lookahead for two parsing cases. |
Comments suppressed due to low confidence (1)
crates/oxc_parser/src/js/class.rs:202
- Ensure there are unit tests covering the static block parsing path after switching to
lookahead, to verify no behavior regression.
if self.at(Kind::Static) && self.lookahead(Self::next_token_is_open_brace) {
CodSpeed Instrumentation Performance ReportMerging #11243 will not alter performanceComparing Summary
|
Member
Merge activity
|
Part of #11194 Just replace, TS does the same thing this time. > https://github.com/microsoft/TypeScript/blob/b504a1eed45e35b5f54694a1e0a09f35d0a5663c/src/compiler/parser.ts#L7730 > https://github.com/microsoft/TypeScript/blob/b504a1eed45e35b5f54694a1e0a09f35d0a5663c/src/compiler/parser.ts#L8050
9388a6b to
4e12796
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.
Part of #11194
Just replace, TS does the same thing this time.