Skip to content

Comments

feat(semantic): add methods to check if AST contains any/all node types#12227

Closed
camchenry wants to merge 1 commit into07-11-feat_semantic_add_set_of_asttype_that_exist_in_astfrom
07-11-feat_semantic_add_methods_to_check_if_ast_contains_any_all_node_types
Closed

feat(semantic): add methods to check if AST contains any/all node types#12227
camchenry wants to merge 1 commit into07-11-feat_semantic_add_set_of_asttype_that_exist_in_astfrom
07-11-feat_semantic_add_methods_to_check_if_ast_contains_any_all_node_types

Conversation

@camchenry
Copy link
Member

@camchenry camchenry commented Jul 11, 2025

These are not used anywhere yet, but this adds some helper methods to query the AST and see if it contains any nodes of a particular type. Like the previous PR, I'm using the unchecked variants here since it should be safe since the bitset is always sized large enough to contain the biggest value in AstType.

Copy link
Member Author

camchenry commented Jul 11, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


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.

@codspeed-hq
Copy link

codspeed-hq bot commented Jul 11, 2025

CodSpeed Instrumentation Performance Report

Merging #12227 will not alter performance

Comparing 07-11-feat_semantic_add_methods_to_check_if_ast_contains_any_all_node_types (1449a81) with main (242e721)

Summary

✅ 34 untouched benchmarks

@camchenry camchenry force-pushed the 07-11-feat_semantic_add_set_of_asttype_that_exist_in_ast branch from 42a07b3 to 6a10b4d Compare July 11, 2025 16:27
@camchenry camchenry marked this pull request as ready for review July 11, 2025 16:29
@camchenry camchenry requested a review from Dunqing as a code owner July 11, 2025 16:29
@camchenry camchenry force-pushed the 07-11-feat_semantic_add_set_of_asttype_that_exist_in_ast branch from 6a10b4d to 74e03f9 Compare July 11, 2025 16:29
@camchenry camchenry requested a review from overlookmotel as a code owner July 11, 2025 16:29
@camchenry camchenry force-pushed the 07-11-feat_semantic_add_methods_to_check_if_ast_contains_any_all_node_types branch from 09291b4 to cd7d601 Compare July 11, 2025 16:29
@camchenry camchenry force-pushed the 07-11-feat_semantic_add_set_of_asttype_that_exist_in_ast branch from 74e03f9 to 891c8d1 Compare July 11, 2025 17:20
@camchenry camchenry force-pushed the 07-11-feat_semantic_add_methods_to_check_if_ast_contains_any_all_node_types branch from cd7d601 to 1449a81 Compare July 11, 2025 17:20
@overlookmotel
Copy link
Member

overlookmotel commented Jul 11, 2025

You might find that contains_any etc are a little faster if they take a pre-compiled AstTypesBitset instead of &[AstType] and use intersects method or similar (see #12226 (comment)).

@camchenry
Copy link
Member Author

Closing in favor of #13137

@camchenry camchenry closed this Aug 16, 2025
@overlookmotel
Copy link
Member

Is it OK to delete the branches for these 3 closed PRs? I assume so, but I don't feel I should delete other peoples' branches without asking.

@camchenry camchenry deleted the 07-11-feat_semantic_add_methods_to_check_if_ast_contains_any_all_node_types branch August 17, 2025 02:50
graphite-app bot pushed a commit that referenced this pull request Sep 7, 2025
…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.
Copilot AI pushed a commit that referenced this pull request Sep 8, 2025
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-semantic Area - Semantic C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants