-
-
Notifications
You must be signed in to change notification settings - Fork 718
feat(semantic): add ability to lookup if AST contains any node kinds #13137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(semantic): add ability to lookup if AST contains any node kinds #13137
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via 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 Instrumentation Performance ReportMerging #13137 will not alter performanceComparing Summary
Benchmarks breakdown
|
55ccbf2 to
8e31c70
Compare
camc314
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks really nice, should definetly help optimizing linter perf
4649cd4 to
af12449
Compare
af12449 to
f6b3a21
Compare
f6b3a21 to
99956af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new AstTypesBitset data structure to efficiently track which AST node types are present in a semantic analysis tree. The bitset enables fast "contains" queries without iterating through the entire AST.
- Introduces
AstTypesBitsetstruct with bitwise operations for AST type tracking - Adds
AST_TYPE_MAXconstant for compile-time bitset sizing - Integrates bitset into
AstNodeswith automatic population during node creation
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tasks/ast_tools/src/generators/ast_kind.rs | Generates AST_TYPE_MAX constant for bitset sizing |
| crates/oxc_semantic/src/node.rs | Integrates bitset into AstNodes and adds query methods |
| crates/oxc_semantic/src/lib.rs | Adds new module declaration |
| crates/oxc_semantic/src/ast_types_bitset.rs | Implements the core bitset data structure and operations |
Comments suppressed due to low confidence (1)
crates/oxc_semantic/src/ast_types_bitset.rs:1
- The
containsmethod can short-circuit early when a mismatch is found. Consider returningfalseimmediately whenmismatch != 0instead of accumulating all mismatches.
use oxc_ast::{AstType, ast_kind::AST_TYPE_MAX};
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
589a962 to
f03068b
Compare
overlookmotel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to correct the comment in a later PR, rather than having to restack this whole stack.
6948775 to
9c9a1c9
Compare
Merge activity
|
…13137) I decided to revive this stack: #12227 and merge all of the changes into one PR for slightly easier review and changes. This PR adds a new `AstTypesBitset` struct which is a set of bits that has a fixed size known at compile time and can be used to store AST types as a set. The aim of this structure is to making checks like "does this file have a for statement?" possible to answer without doing any additional iterations over the AST.
9c9a1c9 to
f00adbe
Compare
Follow-on after #13137. Correct a comment, as per #13137 (comment).
…13137) I decided to revive this stack: #12227 and merge all of the changes into one PR for slightly easier review and changes. This PR adds a new `AstTypesBitset` struct which is a set of bits that has a fixed size known at compile time and can be used to store AST types as a set. The aim of this structure is to making checks like "does this file have a for statement?" possible to answer without doing any additional iterations over the AST.
Follow-on after #13137. Correct a comment, as per #13137 (comment).

I decided to revive this stack: #12227 and merge all of the changes into one PR for slightly easier review and changes.
This PR adds a new
AstTypesBitsetstruct which is a set of bits that has a fixed size known at compile time and can be used to store AST types as a set. The aim of this structure is to making checks like "does this file have a for statement?" possible to answer without doing any additional iterations over the AST.