refactor(parser): introduce context_add and context_remove functions#14567
Merged
Boshen merged 1 commit intooxc-project:mainfrom Oct 14, 2025
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the parser by introducing two new convenience functions context_add and context_remove to simplify code that only needs to either add or remove context flags, making it more readable than the generic context function.
- Adds
context_addandcontext_removehelper functions to the parser - Replaces calls to the generic
contextfunction with the more specific helpers where appropriate - Removes an unused import in the module file
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_parser/src/cursor.rs | Introduces the new context_add and context_remove helper functions |
| crates/oxc_parser/src/ts/types.rs | Replaces generic context calls with specific context_add/context_remove calls |
| crates/oxc_parser/src/js/statement.rs | Updates context calls to use the new helper functions |
| crates/oxc_parser/src/js/object.rs | Simplifies context usage with the new helper functions |
| crates/oxc_parser/src/js/module.rs | Updates context calls and removes unused Context import |
| crates/oxc_parser/src/js/function.rs | Updates context call to use context_add |
| crates/oxc_parser/src/js/expression.rs | Replaces multiple context calls with the appropriate helper functions |
| crates/oxc_parser/src/js/class.rs | Updates context call to use context_add |
| crates/oxc_parser/src/js/binding.rs | Simplifies context usage with context_add |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
CodSpeed Performance ReportMerging #14567 will not alter performanceComparing Summary
|
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.
This makes code easier to understand that only either adds or removes context flags.