Skip to content

refactor(ast_tools): store lists as Vecs not Option<Vec>s#8925

Merged
graphite-app[bot] merged 1 commit intomainfrom
02-06-refactor_ast_tools_store_lists_as_vec_s_not_option_vec_s
Feb 6, 2025
Merged

refactor(ast_tools): store lists as Vecs not Option<Vec>s#8925
graphite-app[bot] merged 1 commit intomainfrom
02-06-refactor_ast_tools_store_lists_as_vec_s_not_option_vec_s

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Feb 6, 2025

In Schema, store lists of name-value pairs from attributes (e.g. #[visit(args(x = 1, y = 2))], #[estree(add_entry(x = 1, y = 2))]) as Vecs, instead of Option<Vec>.

This has 3 effects:

  1. Attribute parsers can append to the Vec. So now these 2 syntaxes are both supported, and equivalent:
#[estree(add_entry(x = 1, y = 2))]
#[estree(add_entry(x = 1))]
#[estree(add_entry(y = 2))]
  1. Make multiple items in #[estree(add_entry(...))] supported. Previously all except the first were ignored.

  2. Shorten code in generators.

Copy link
Member Author

overlookmotel commented Feb 6, 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.

@github-actions github-actions bot added A-ast-tools Area - AST tools C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels Feb 6, 2025
@overlookmotel overlookmotel marked this pull request as ready for review February 6, 2025 12:52
@overlookmotel
Copy link
Member Author

cc @hi-ogawa

@overlookmotel
Copy link
Member Author

overlookmotel commented Feb 6, 2025

Originally I used Option<Vec> for #[visit(args(...))] because this attribute is uncommonly used, and creating a None is slightly cheaper than creating an empty Vec. But oxc_ast_tools is run only occasionally, so an ergonomic API is more important than performance micro-optimization.

@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Feb 6, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Feb 6, 2025

Merge activity

In `Schema`, store lists of name-value pairs from attributes (e.g. `#[visit(args(x = 1, y = 2))]`, `#[estree(add_entry(x = 1, y = 2))]`) as `Vec`s, instead of `Option<Vec>`.

This has 3 effects:

1. Attribute parsers can append to the `Vec`. So now these 2 syntaxes are both supported, and equivalent:

```rs
#[estree(add_entry(x = 1, y = 2))]
```

```rs
#[estree(add_entry(x = 1))]
#[estree(add_entry(y = 2))]
```

2. Make multiple items in `#[estree(add_entry(...))]` supported. Previously all except the first were ignored.

3. Shorten code in generators.
@graphite-app graphite-app bot force-pushed the 02-06-refactor_ast_tools_add_helper_methods_to_attrpartlistelement_ branch from e17ed16 to cc8a311 Compare February 6, 2025 15:14
@graphite-app graphite-app bot force-pushed the 02-06-refactor_ast_tools_store_lists_as_vec_s_not_option_vec_s branch from f4b2acd to ab601a1 Compare February 6, 2025 15:15
Base automatically changed from 02-06-refactor_ast_tools_add_helper_methods_to_attrpartlistelement_ to main February 6, 2025 15:24
@graphite-app graphite-app bot merged commit ab601a1 into main Feb 6, 2025
16 checks passed
@graphite-app graphite-app bot deleted the 02-06-refactor_ast_tools_store_lists_as_vec_s_not_option_vec_s branch February 6, 2025 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0-merge Merge with Graphite Merge Queue 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.

1 participant