Skip to content

refactor(estree/tokens): add Context methods from different AST nodes#19867

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/03-01-refactor_estree_tokens_make_context_methods_take_ast_nodes
Mar 1, 2026
Merged

refactor(estree/tokens): add Context methods from different AST nodes#19867
graphite-app[bot] merged 1 commit intomainfrom
om/03-01-refactor_estree_tokens_make_context_methods_take_ast_nodes

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Mar 1, 2026

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.

@github-actions github-actions bot added the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label Mar 1, 2026
Copy link
Member Author

overlookmotel commented Mar 1, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@overlookmotel overlookmotel changed the title refactor(estree/tokens): make Context methods take AST nodes refactor(estree/tokens): add Context methods from different AST nodes Mar 1, 2026
@overlookmotel overlookmotel marked this pull request as ready for review March 1, 2026 10:02
Copilot AI review requested due to automatic review settings March 1, 2026 10:02
@overlookmotel overlookmotel self-assigned this Mar 1, 2026
@overlookmotel overlookmotel added A-parser Area - Parser A-linter-plugins Area - Linter JS plugins labels Mar 1, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 1, 2026

Merging this PR will not alter performance

✅ 53 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/03-01-refactor_estree_tokens_make_context_methods_take_ast_nodes (28983f9) with om/03-01-refactor_estree_tokens_rename_updatecontext_to_rawcontext_ (b6f81a4)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-specific Context methods (removing TokenType from the trait).
  • Split handling for StringLiteral vs StringLiteral-as-JSXText vs actual JSXText to make raw-transfer kind overrides explicit.
  • Update Visitor, JsonContext, and RawContext to use the new Context methods.

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.

Copy link
Member Author

overlookmotel commented Mar 1, 2026

Merge activity

@graphite-app graphite-app bot force-pushed the om/03-01-refactor_estree_tokens_rename_updatecontext_to_rawcontext_ branch from b6f81a4 to 73aa87e Compare March 1, 2026 16:46
graphite-app bot pushed a commit that referenced this pull request Mar 1, 2026
…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.
@graphite-app graphite-app bot force-pushed the om/03-01-refactor_estree_tokens_make_context_methods_take_ast_nodes branch from 28983f9 to 43eb95f Compare March 1, 2026 16:46
…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.
@graphite-app graphite-app bot force-pushed the om/03-01-refactor_estree_tokens_rename_updatecontext_to_rawcontext_ branch from 73aa87e to bb87d80 Compare March 1, 2026 16:49
@graphite-app graphite-app bot force-pushed the om/03-01-refactor_estree_tokens_make_context_methods_take_ast_nodes branch from 43eb95f to 1d7adf0 Compare March 1, 2026 16:50
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 1, 2026
Base automatically changed from om/03-01-refactor_estree_tokens_rename_updatecontext_to_rawcontext_ to main March 1, 2026 16:57
@graphite-app graphite-app bot merged commit 1d7adf0 into main Mar 1, 2026
22 checks passed
@graphite-app graphite-app bot deleted the om/03-01-refactor_estree_tokens_make_context_methods_take_ast_nodes branch March 1, 2026 16:57
graphite-app bot pushed a commit that referenced this pull request Mar 1, 2026
…9869)

Pure refactor.

After #19867, `TokenType` is only used in JSON serialization. Create a subdirectory to contain JSON-related code and types, and move `token_type.rs` and `u32_string.rs` into it, since they're not used in raw transfer conversion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter-plugins Area - Linter JS plugins A-parser Area - Parser C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants