Skip to content

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

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

Open
wants to merge 1 commit into
base: 07-11-feat_semantic_add_set_of_asttype_that_exist_in_ast
Choose a base branch
from

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.

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
Contributor

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)).

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