Skip to content

Commit 93d9e44

Browse files
authoredJul 18, 2024··
fix(es/quote): Fix macro (#9270)
1 parent 5f91339 commit 93d9e44

File tree

7 files changed

+23
-13
lines changed

7 files changed

+23
-13
lines changed
 

‎crates/swc_ecma_quote_macros/src/ast/class.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ impl_struct!(
44
Class,
55
[
66
span,
7+
ctxt,
78
decorators,
89
body,
910
super_class,
@@ -16,7 +17,7 @@ impl_struct!(
1617

1718
impl_struct!(
1819
Constructor,
19-
[span, key, params, body, accessibility, is_optional]
20+
[span, ctxt, key, params, body, accessibility, is_optional]
2021
);
2122

2223
impl_struct!(
@@ -74,6 +75,9 @@ impl_struct!(
7475
AutoAccessor,
7576
[
7677
span,
78+
is_abstract,
79+
is_override,
80+
definite,
7781
key,
7882
value,
7983
type_ann,

‎crates/swc_ecma_quote_macros/src/ast/decl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ impl_enum!(
1414
]
1515
);
1616

17-
impl_struct!(ClassDecl, [ident, class]);
18-
impl_struct!(FnDecl, [ident, function]);
17+
impl_struct!(ClassDecl, [ident, declare, class]);
18+
impl_struct!(FnDecl, [ident, declare, function]);
1919
impl_struct!(VarDecl, [span, ctxt, kind, declare, decls]);
2020
impl_struct!(VarDeclarator, [span, name, init, definite]);
2121
impl_struct!(UsingDecl, [span, is_await, decls]);

‎crates/swc_ecma_quote_macros/src/ast/expr.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ impl_struct!(
7171
ArrowExpr,
7272
[
7373
span,
74+
ctxt,
7475
params,
7576
body,
7677
is_async,
@@ -89,19 +90,19 @@ impl_struct!(MemberExpr, [span, obj, prop]);
8990
impl_struct!(SuperPropExpr, [span, obj, prop]);
9091
impl_struct!(CondExpr, [span, test, cons, alt]);
9192

92-
impl_struct!(CallExpr, [span, callee, args, type_args]);
93+
impl_struct!(CallExpr, [span, ctxt, callee, args, type_args]);
9394
impl_struct!(ExprOrSpread, [spread, expr]);
9495
impl_struct!(Super, [span]);
9596
impl_struct!(Import, [span, phase]);
96-
impl_struct!(NewExpr, [span, callee, args, type_args]);
97+
impl_struct!(NewExpr, [span, ctxt, callee, args, type_args]);
9798
impl_struct!(SeqExpr, [span, exprs]);
9899

99-
impl_struct!(TaggedTpl, [span, tag, type_params, tpl]);
100+
impl_struct!(TaggedTpl, [span, ctxt, tag, type_params, tpl]);
100101
impl_struct!(YieldExpr, [span, arg, delegate]);
101102
impl_struct!(MetaPropExpr, [span, kind]);
102103
impl_struct!(AwaitExpr, [span, arg]);
103-
impl_struct!(JSXMemberExpr, [obj, prop]);
104-
impl_struct!(JSXNamespacedName, [ns, name]);
104+
impl_struct!(JSXMemberExpr, [span, obj, prop]);
105+
impl_struct!(JSXNamespacedName, [span, ns, name]);
105106
impl_struct!(JSXEmptyExpr, [span]);
106107
impl_struct!(JSXElement, [span, opening, closing, children]);
107108
impl_struct!(JSXFragment, [span, opening, closing, children]);
@@ -111,6 +112,7 @@ impl_struct!(ParenExpr, [span, expr]);
111112
impl_struct!(
112113
Function,
113114
[
115+
ctxt,
114116
params,
115117
decorators,
116118
span,
@@ -150,6 +152,6 @@ impl_enum!(JSXAttrName, [Ident, JSXNamespacedName]);
150152

151153
impl_enum!(JSXExpr, [Expr, JSXEmptyExpr]);
152154

153-
impl_struct!(OptCall, [span, callee, args, type_args]);
155+
impl_struct!(OptCall, [span, ctxt, callee, args, type_args]);
154156

155157
impl_enum!(Callee, [Super, Import, Expr]);

‎crates/swc_ecma_quote_macros/src/ast/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ macro_rules! impl_struct {
6565
fn to_code(&self, cx: &crate::ctxt::Ctx) -> syn::Expr {
6666
let mut builder = crate::builder::Builder::new(stringify!($name));
6767

68+
let Self { $($v,)* } = self;
69+
6870
$(
6971
builder.add(
7072
stringify!($v),
71-
crate::ast::ToCode::to_code(&self.$v, cx),
73+
crate::ast::ToCode::to_code($v, cx),
7274
);
7375
)*
7476

‎crates/swc_ecma_quote_macros/src/ast/module_decl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl_struct!(ImportDecl, [span, specifiers, src, type_only, with, phase]);
1919
impl_struct!(ExportDecl, [span, decl]);
2020
impl_struct!(ExportDefaultDecl, [span, decl]);
2121
impl_struct!(ExportDefaultExpr, [span, expr]);
22-
impl_struct!(ExportAll, [span, src, with]);
22+
impl_struct!(ExportAll, [span, type_only, src, with]);
2323
impl_struct!(NamedExport, [span, specifiers, src, type_only, with]);
2424

2525
impl_enum!(ImportSpecifier, [Named, Default, Namespace]);

‎crates/swc_ecma_quote_macros/src/ast/prop.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ impl_struct!(
66
PrivateProp,
77
[
88
span,
9+
ctxt,
10+
definite,
911
key,
1012
value,
1113
type_ann,
@@ -20,7 +22,7 @@ impl_struct!(
2022

2123
impl_struct!(KeyValueProp, [key, value]);
2224

23-
impl_struct!(AssignProp, [key, value]);
25+
impl_struct!(AssignProp, [span, key, value]);
2426

2527
impl_struct!(GetterProp, [span, key, type_ann, body]);
2628
impl_struct!(SetterProp, [span, key, param, this_param, body]);

‎crates/swc_ecma_quote_macros/src/ast/stmt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ impl_enum!(
99
);
1010

1111
impl_struct!(EmptyStmt, [span]);
12-
impl_struct!(BlockStmt, [span, stmts]);
12+
impl_struct!(BlockStmt, [span, ctxt, stmts]);
1313
impl_struct!(DebuggerStmt, [span]);
1414
impl_struct!(WithStmt, [span, obj, body]);
1515
impl_struct!(LabeledStmt, [span, label, body]);

0 commit comments

Comments
 (0)
Please sign in to comment.