refactor(estree/tokens): add Context methods from different AST nodes#19867
Conversation
Context methods take AST nodesContext methods from different AST nodes
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
Refactors oxc_estree_tokens’ internal Context interface to provide node-specific emission methods (e.g., PrivateIdentifier, StringLiteral, JSXText), improving clarity around when token kinds need mutation in raw-transfer mode versus when JSON serialization needs JSON-escaping.
Changes:
- Replace
*_at(start, …, TokenType)-style APIs with node-specificContextmethods (removingTokenTypefrom the trait). - Split handling for
StringLiteralvsStringLiteral-as-JSXTextvs actualJSXTextto make raw-transfer kind overrides explicit. - Update
Visitor,JsonContext, andRawContextto use the newContextmethods.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/oxc_estree_tokens/src/visitor.rs | Updates AST visitor to call the new node-specific Context emission methods. |
| crates/oxc_estree_tokens/src/raw_transfer.rs | Adapts raw-transfer context to new APIs; keeps no-op behavior where token kinds already match, and sets Kind::JSXText only for JSX-attribute string literals. |
| crates/oxc_estree_tokens/src/json.rs | Moves TokenType usage fully into JSON serialization; adds small internal helpers and implements new Context methods. |
| crates/oxc_estree_tokens/src/context.rs | Refactors the Context trait signatures and documentation to match the new node-specific emission approach. |
c919ce9 to
28983f9
Compare
ce89e1d to
b6f81a4
Compare
Merge activity
|
b6f81a4 to
73aa87e
Compare
…es (#19867) Refactor. Create individual `Context` methods for different AST node types. * Clarifies the logic around `JSXText` tokens - when they need updating and when they don't. * Removes `TokenType` from `Context` methods' signatures. `TokenType` is now specific to JSON serialization.
28983f9 to
43eb95f
Compare
…es (#19867) Refactor. Create individual `Context` methods for different AST node types. * Clarifies the logic around `JSXText` tokens - when they need updating and when they don't. * Removes `TokenType` from `Context` methods' signatures. `TokenType` is now specific to JSON serialization.
73aa87e to
bb87d80
Compare
43eb95f to
1d7adf0
Compare

Refactor. Create individual
Contextmethods for different AST node types.JSXTexttokens - when they need updating and when they don't.TokenTypefromContextmethods' signatures.TokenTypeis now specific to JSON serialization.