Skip to content

refactor(ast): repurpose CommentNodeId code in AstBuilder codegen for NodeId#21680

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/02-14-refactor_ast_repurpose_commentnodeid_code_in_astbuilder_codegen_for_nodeid_
Apr 23, 2026
Merged

refactor(ast): repurpose CommentNodeId code in AstBuilder codegen for NodeId#21680
graphite-app[bot] merged 1 commit intomainfrom
om/02-14-refactor_ast_repurpose_commentnodeid_code_in_astbuilder_codegen_for_nodeid_

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Apr 23, 2026

#21679 remove CommentNodeId. Repurpose code in ast_tools codegen which was designed for CommentNodeId, using it for NodeId instead.

Notably:

  1. Check if fields are Cell<NodeId> with a quick TypeId comparison, instead of string comparison on field name (more reliable, and faster).
  2. Simplify generator for AstBuilder by utilizing existing logic for default fields for NodeId fields.

Copy link
Copy Markdown
Member Author

overlookmotel commented Apr 23, 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 changes, fast-track this PR to the front of 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.

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

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 23, 2026

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/02-14-refactor_ast_repurpose_commentnodeid_code_in_astbuilder_codegen_for_nodeid_ (eccbdfa) with om/02-14-feat_syntax_remove_commentnodeid_ (c5b3deb)2

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.

  2. No successful run was found on om/02-14-feat_syntax_remove_commentnodeid_ (c5b3deb) during the generation of this report, so 1cda531 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel overlookmotel self-assigned this Apr 23, 2026
@overlookmotel overlookmotel marked this pull request as ready for review April 23, 2026 13:10
Copilot AI review requested due to automatic review settings April 23, 2026 13:10
Copy link
Copy Markdown
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 ast_toolsAstBuilder codegen to repurpose the previous CommentNodeId-oriented logic for NodeId, using a schema TypeId check for Cell<NodeId> and simplifying default initialization of node_id fields.

Changes:

  • Detect node_id fields by comparing TypeId to Cell<NodeId> (via schema container IDs) instead of string-matching the field name.
  • Emit Default::default() for node_id initialization and remove the now-unneeded NodeId import from the generated builder.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 3 comments.

File Description
tasks/ast_tools/src/generators/ast_builder.rs Updates codegen logic to identify Cell<NodeId> fields by TypeId and to default-initialize them consistently.
crates/oxc_ast/src/generated/ast_builder.rs Regenerated output reflecting node_id: Default::default() and removed NodeId import.

Comment thread tasks/ast_tools/src/generators/ast_builder.rs
Comment thread tasks/ast_tools/src/generators/ast_builder.rs
Comment thread tasks/ast_tools/src/generators/ast_builder.rs
@overlookmotel overlookmotel added C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior A-ast Area - AST A-ast-tools Area - AST tools labels Apr 23, 2026
@overlookmotel overlookmotel force-pushed the om/02-14-refactor_ast_repurpose_commentnodeid_code_in_astbuilder_codegen_for_nodeid_ branch from 07ea9a4 to aa172b8 Compare April 23, 2026 13:56
@overlookmotel overlookmotel force-pushed the om/02-14-feat_syntax_remove_commentnodeid_ branch from c37f302 to 9636056 Compare April 23, 2026 13:56
@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app Bot commented Apr 23, 2026

Merge activity

graphite-app Bot pushed a commit that referenced this pull request Apr 23, 2026
`CommentNodeId` is a type we added some time ago, but never used. We now have `NodeId`s stored in all AST structs, so we can use that for comment attachment if we choose.

Remove `CommentNodeId` type, and all code referencing it.

Only code remaining that references it is in `ast_tools` codegen. I've left that code so that it can be repurposed for `NodeId` in next PR (#21680).
@graphite-app graphite-app Bot force-pushed the om/02-14-feat_syntax_remove_commentnodeid_ branch from 9636056 to fe2844f Compare April 23, 2026 15:38
graphite-app Bot pushed a commit that referenced this pull request Apr 23, 2026
… for `NodeId` (#21680)

#21679 remove `CommentNodeId`. Repurpose code in `ast_tools` codegen which was designed for `CommentNodeId`, using it for `NodeId` instead.

Notably:

1. Check if fields are `Cell<NodeId>` with a quick `TypeId` comparison, instead of string comparison on field name (more reliable, and faster).
2. Simplify generator for `AstBuilder` by utilizing existing logic for default fields for `NodeId` fields.
@graphite-app graphite-app Bot force-pushed the om/02-14-refactor_ast_repurpose_commentnodeid_code_in_astbuilder_codegen_for_nodeid_ branch from aa172b8 to 8a2ad95 Compare April 23, 2026 15:38
graphite-app Bot pushed a commit that referenced this pull request Apr 23, 2026
`CommentNodeId` is a type we added some time ago, but never used. We now have `NodeId`s stored in all AST structs, so we can use that for comment attachment if we choose.

Remove `CommentNodeId` type, and all code referencing it.

Only code remaining that references it is in `ast_tools` codegen. I've left that code so that it can be repurposed for `NodeId` in next PR (#21680).
@graphite-app graphite-app Bot force-pushed the om/02-14-feat_syntax_remove_commentnodeid_ branch from fe2844f to bd8bd58 Compare April 23, 2026 15:48
graphite-app Bot pushed a commit that referenced this pull request Apr 23, 2026
… for `NodeId` (#21680)

#21679 remove `CommentNodeId`. Repurpose code in `ast_tools` codegen which was designed for `CommentNodeId`, using it for `NodeId` instead.

Notably:

1. Check if fields are `Cell<NodeId>` with a quick `TypeId` comparison, instead of string comparison on field name (more reliable, and faster).
2. Simplify generator for `AstBuilder` by utilizing existing logic for default fields for `NodeId` fields.
@graphite-app graphite-app Bot force-pushed the om/02-14-refactor_ast_repurpose_commentnodeid_code_in_astbuilder_codegen_for_nodeid_ branch from 8a2ad95 to b26c4a4 Compare April 23, 2026 15:49
graphite-app Bot pushed a commit that referenced this pull request Apr 23, 2026
`CommentNodeId` is a type we added some time ago, but never used. We now have `NodeId`s stored in all AST structs, so we can use that for comment attachment if we choose.

Remove `CommentNodeId` type, and all code referencing it.

Only code remaining that references it is in `ast_tools` codegen. I've left that code so that it can be repurposed for `NodeId` in next PR (#21680).
@graphite-app graphite-app Bot force-pushed the om/02-14-feat_syntax_remove_commentnodeid_ branch from bd8bd58 to ff5c7f9 Compare April 23, 2026 17:22
graphite-app Bot pushed a commit that referenced this pull request Apr 23, 2026
… for `NodeId` (#21680)

#21679 remove `CommentNodeId`. Repurpose code in `ast_tools` codegen which was designed for `CommentNodeId`, using it for `NodeId` instead.

Notably:

1. Check if fields are `Cell<NodeId>` with a quick `TypeId` comparison, instead of string comparison on field name (more reliable, and faster).
2. Simplify generator for `AstBuilder` by utilizing existing logic for default fields for `NodeId` fields.
@graphite-app graphite-app Bot force-pushed the om/02-14-refactor_ast_repurpose_commentnodeid_code_in_astbuilder_codegen_for_nodeid_ branch from b26c4a4 to cf6da3e Compare April 23, 2026 17:23
… for `NodeId` (#21680)

#21679 remove `CommentNodeId`. Repurpose code in `ast_tools` codegen which was designed for `CommentNodeId`, using it for `NodeId` instead.

Notably:

1. Check if fields are `Cell<NodeId>` with a quick `TypeId` comparison, instead of string comparison on field name (more reliable, and faster).
2. Simplify generator for `AstBuilder` by utilizing existing logic for default fields for `NodeId` fields.
graphite-app Bot pushed a commit that referenced this pull request Apr 23, 2026
`CommentNodeId` is a type we added some time ago, but never used. We now have `NodeId`s stored in all AST structs, so we can use that for comment attachment if we choose.

Remove `CommentNodeId` type, and all code referencing it.

Only code remaining that references it is in `ast_tools` codegen. I've left that code so that it can be repurposed for `NodeId` in next PR (#21680).
@graphite-app graphite-app Bot force-pushed the om/02-14-feat_syntax_remove_commentnodeid_ branch from ff5c7f9 to c5b3deb Compare April 23, 2026 17:31
@graphite-app graphite-app Bot force-pushed the om/02-14-refactor_ast_repurpose_commentnodeid_code_in_astbuilder_codegen_for_nodeid_ branch from cf6da3e to eccbdfa Compare April 23, 2026 17:31
Base automatically changed from om/02-14-feat_syntax_remove_commentnodeid_ to main April 23, 2026 18:45
@graphite-app graphite-app Bot merged commit eccbdfa into main Apr 23, 2026
37 checks passed
@graphite-app graphite-app Bot deleted the om/02-14-refactor_ast_repurpose_commentnodeid_code_in_astbuilder_codegen_for_nodeid_ branch April 23, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST A-ast-tools Area - AST tools 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