Skip to content

refactor(ast_tools): simplify generating variants of code#17172

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/12-19-refactor_ast_tools_simplify_generating_variants_of_code
Dec 20, 2025
Merged

refactor(ast_tools): simplify generating variants of code#17172
graphite-app[bot] merged 1 commit intomainfrom
om/12-19-refactor_ast_tools_simplify_generating_variants_of_code

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Dec 20, 2025

Pure refactor. Simplify generating multiple variant of code in ast_tools codegen by providing a generate_variants! macro.

Copy link
Member Author

overlookmotel commented Dec 20, 2025


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

This PR refactors the AST tools codegen to simplify generating multiple variants of code by introducing a generate_variants! macro, eliminating boilerplate code when creating code variants with different flag combinations.

  • Introduces a new generate_variants! macro that encapsulates the pattern of generating all permutations of code with different flags
  • Adds a generate_array method to VariantGenerator trait for destructuring variants into multiple variables
  • Simplifies the usage in estree_visit.rs by replacing 8 lines of boilerplate with a single macro call

Reviewed changes

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

File Description
tasks/ast_tools/src/output/javascript.rs Adds generate_array method to VariantGenerator trait and introduces generate_variants! macro with documentation
tasks/ast_tools/src/generators/estree_visit.rs Refactors to use the new generate_variants! macro, replacing manual implementation and removing now-unnecessary clippy attribute

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@overlookmotel overlookmotel self-assigned this Dec 20, 2025
@overlookmotel overlookmotel force-pushed the om/12-19-refactor_ast_tools_simplify_generating_variants_of_code branch from 4e99696 to fff03fc Compare December 20, 2025 13:16
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Dec 20, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 20, 2025

Merge activity

Pure refactor. Simplify generating multiple variant of code in `ast_tools` codegen by providing a `generate_variants!` macro.
@graphite-app graphite-app bot force-pushed the om/12-19-refactor_linter_plugins_add_error_messages_to_debug_assertions branch from 2cf020c to e39deb6 Compare December 20, 2025 13:59
@graphite-app graphite-app bot requested a review from camc314 as a code owner December 20, 2025 13:59
@graphite-app graphite-app bot force-pushed the om/12-19-refactor_ast_tools_simplify_generating_variants_of_code branch from fff03fc to 472c439 Compare December 20, 2025 14:00
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 20, 2025
Base automatically changed from om/12-19-refactor_linter_plugins_add_error_messages_to_debug_assertions to main December 20, 2025 14:06
@graphite-app graphite-app bot merged commit 472c439 into main Dec 20, 2025
19 checks passed
@graphite-app graphite-app bot deleted the om/12-19-refactor_ast_tools_simplify_generating_variants_of_code branch December 20, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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