From fcbca322d75f27fc8fa9cb0281c33eedbb86db6e Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Sat, 18 Jan 2025 03:59:59 +0000 Subject: [PATCH] refactor(ast): rename `#[estree(with)]` to `#[estree(via)]` (#8564) Follow-on after #8560. Rename `#[estree(with)]` attr introduced in #8560 for struct fields to `#[estree(via)]`. This is to match the attr which does the same thing on struct itself. e.g.: https://github.com/oxc-project/oxc/blob/869bc73e67e46f8b7d4b18dda76d75df499a5d62/crates/oxc_ast/src/ast/literal.rs#L23-L29 --- crates/oxc_ast/src/ast/js.rs | 2 +- tasks/ast_tools/src/derives/estree.rs | 2 +- tasks/ast_tools/src/markers.rs | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index 4fdfd9e8a5699..4a5b775265393 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -2196,7 +2196,7 @@ pub struct ImportExpression<'a> { pub struct ImportDeclaration<'a> { pub span: Span, /// `None` for `import 'foo'`, `Some([])` for `import {} from 'foo'` - #[estree(with = "OptionVecDefault", type = "Array")] + #[estree(via = "OptionVecDefault", type = "Array")] pub specifiers: Option>>, pub source: StringLiteral<'a>, pub phase: Option, diff --git a/tasks/ast_tools/src/derives/estree.rs b/tasks/ast_tools/src/derives/estree.rs index 36079bbb9282b..097cb494f651f 100644 --- a/tasks/ast_tools/src/derives/estree.rs +++ b/tasks/ast_tools/src/derives/estree.rs @@ -142,7 +142,7 @@ fn serialize_struct(def: &StructDef, schema: &Schema) -> TokenStream { } )?; }); - } else if let Some(with) = &field.markers.derive_attributes.estree.with { + } else if let Some(with) = &field.markers.derive_attributes.estree.via { let with_ident = with.to_ident(); fields.push(quote! { map.serialize_entry( diff --git a/tasks/ast_tools/src/markers.rs b/tasks/ast_tools/src/markers.rs index aa1deaaf181ac..b47d3513a2af3 100644 --- a/tasks/ast_tools/src/markers.rs +++ b/tasks/ast_tools/src/markers.rs @@ -227,7 +227,7 @@ pub struct ESTreeFieldAttribute { pub rename: Option, pub typescript_type: Option, pub append_to: Option, - pub with: Option, + pub via: Option, } impl Parse for ESTreeFieldAttribute { @@ -237,7 +237,7 @@ impl Parse for ESTreeFieldAttribute { let mut rename = None; let mut typescript_type = None; let mut append_to = None; - let mut with = None; + let mut via = None; loop { let is_type = input.peek(Token![type]); @@ -283,10 +283,10 @@ impl Parse for ESTreeFieldAttribute { "Duplicate estree(append_to)" ); } - "with" => { + "via" => { input.parse::()?; assert!( - with.replace(input.parse::()?.value()).is_none(), + via.replace(input.parse::()?.value()).is_none(), "Duplicate estree(with)" ); } @@ -299,7 +299,7 @@ impl Parse for ESTreeFieldAttribute { break; } } - Ok(Self { flatten, skip, rename, typescript_type, append_to, with }) + Ok(Self { flatten, skip, rename, typescript_type, append_to, via }) } }