refactor(ast): repurpose CommentNodeId code in AstBuilder codegen for NodeId#21680
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
Refactors ast_tools’ AstBuilder 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_idfields by comparingTypeIdtoCell<NodeId>(via schema container IDs) instead of string-matching the field name. - Emit
Default::default()fornode_idinitialization and remove the now-unneededNodeIdimport 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. |
07ea9a4 to
aa172b8
Compare
c37f302 to
9636056
Compare
Merge activity
|
`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).
9636056 to
fe2844f
Compare
… 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.
aa172b8 to
8a2ad95
Compare
`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).
fe2844f to
bd8bd58
Compare
… 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.
8a2ad95 to
b26c4a4
Compare
`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).
bd8bd58 to
ff5c7f9
Compare
… 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.
b26c4a4 to
cf6da3e
Compare
… 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.
`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).
ff5c7f9 to
c5b3deb
Compare
cf6da3e to
eccbdfa
Compare

#21679 remove
CommentNodeId. Repurpose code inast_toolscodegen which was designed forCommentNodeId, using it forNodeIdinstead.Notably:
Cell<NodeId>with a quickTypeIdcomparison, instead of string comparison on field name (more reliable, and faster).AstBuilderby utilizing existing logic for default fields forNodeIdfields.