mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
feat(ast): update arrow_expression to arrow_function_expression (#2496)
This commit is contained in:
parent
fba66dcc75
commit
70295a5552
5 changed files with 52 additions and 40 deletions
|
|
@ -402,7 +402,7 @@ impl<'a> AstBuilder<'a> {
|
||||||
Expression::ArrayExpression(self.alloc(ArrayExpression { span, elements, trailing_comma }))
|
Expression::ArrayExpression(self.alloc(ArrayExpression { span, elements, trailing_comma }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn arrow_expression(
|
pub fn arrow_function_expression(
|
||||||
&self,
|
&self,
|
||||||
span: Span,
|
span: Span,
|
||||||
expression: bool,
|
expression: bool,
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,7 @@ impl<'a> ParserImpl<'a> {
|
||||||
};
|
};
|
||||||
self.ctx = self.ctx.and_await(has_await).and_yield(has_yield);
|
self.ctx = self.ctx.and_await(has_await).and_yield(has_yield);
|
||||||
|
|
||||||
Ok(self.ast.arrow_expression(
|
Ok(self.ast.arrow_function_expression(
|
||||||
self.end_span(span),
|
self.end_span(span),
|
||||||
expression,
|
expression,
|
||||||
r#async,
|
r#async,
|
||||||
|
|
@ -515,7 +515,7 @@ impl<'a> ParserImpl<'a> {
|
||||||
|
|
||||||
self.ctx = self.ctx.and_await(has_await).and_yield(has_yield);
|
self.ctx = self.ctx.and_await(has_await).and_yield(has_yield);
|
||||||
|
|
||||||
Ok(self.ast.arrow_expression(
|
Ok(self.ast.arrow_function_expression(
|
||||||
self.end_span(span),
|
self.end_span(span),
|
||||||
expression,
|
expression,
|
||||||
r#async,
|
r#async,
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ impl<'a> ClassStaticBlock<'a> {
|
||||||
let function_body =
|
let function_body =
|
||||||
self.ast.function_body(SPAN, self.ast.new_vec(), statements);
|
self.ast.function_body(SPAN, self.ast.new_vec(), statements);
|
||||||
|
|
||||||
let callee = self.ast.arrow_expression(
|
let callee = self.ast.arrow_function_expression(
|
||||||
SPAN,
|
SPAN,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
|
|
||||||
|
|
@ -452,48 +452,59 @@ impl<'a> Decorators<'a> {
|
||||||
{
|
{
|
||||||
if flag.is_setter() && !flag.is_static() {
|
if flag.is_setter() && !flag.is_static() {
|
||||||
// _ => #a in _;
|
// _ => #a in _;
|
||||||
private_in_expressions.push(self.ast.arrow_expression(
|
private_in_expressions.push(
|
||||||
SPAN,
|
self.ast.arrow_function_expression(
|
||||||
true,
|
|
||||||
false,
|
|
||||||
self.ast.formal_parameters(
|
|
||||||
SPAN,
|
SPAN,
|
||||||
FormalParameterKind::ArrowFormalParameters,
|
true,
|
||||||
self.ast.new_vec_single(self.ast.formal_parameter(
|
false,
|
||||||
|
self.ast.formal_parameters(
|
||||||
SPAN,
|
SPAN,
|
||||||
self.ast.binding_pattern(
|
FormalParameterKind::ArrowFormalParameters,
|
||||||
self.ast.binding_pattern_identifier(
|
self.ast.new_vec_single(self.ast.formal_parameter(
|
||||||
BindingIdentifier::new(SPAN, "_".into()),
|
SPAN,
|
||||||
|
self.ast.binding_pattern(
|
||||||
|
self.ast.binding_pattern_identifier(
|
||||||
|
BindingIdentifier::new(
|
||||||
|
SPAN,
|
||||||
|
"_".into(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
None,
|
||||||
|
false,
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
false,
|
false,
|
||||||
),
|
self.ast.new_vec(),
|
||||||
|
)),
|
||||||
None,
|
None,
|
||||||
false,
|
),
|
||||||
|
self.ast.function_body(
|
||||||
|
SPAN,
|
||||||
self.ast.new_vec(),
|
self.ast.new_vec(),
|
||||||
)),
|
self.ast.new_vec_single(
|
||||||
|
self.ast.expression_statement(
|
||||||
|
SPAN,
|
||||||
|
self.ast.private_in_expression(
|
||||||
|
SPAN,
|
||||||
|
PrivateIdentifier::new(
|
||||||
|
SPAN,
|
||||||
|
def.key.private_name().unwrap(),
|
||||||
|
),
|
||||||
|
self.ast
|
||||||
|
.identifier_reference_expression(
|
||||||
|
IdentifierReference::new(
|
||||||
|
SPAN,
|
||||||
|
"_".into(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
None,
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
self.ast.function_body(
|
);
|
||||||
SPAN,
|
|
||||||
self.ast.new_vec(),
|
|
||||||
self.ast.new_vec_single(self.ast.expression_statement(
|
|
||||||
SPAN,
|
|
||||||
self.ast.private_in_expression(
|
|
||||||
SPAN,
|
|
||||||
PrivateIdentifier::new(
|
|
||||||
SPAN,
|
|
||||||
def.key.private_name().unwrap(),
|
|
||||||
),
|
|
||||||
self.ast.identifier_reference_expression(
|
|
||||||
IdentifierReference::new(SPAN, "_".into()),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -906,7 +917,7 @@ impl<'a> Decorators<'a> {
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
decorator_elements.push(ArrayExpressionElement::Expression(
|
decorator_elements.push(ArrayExpressionElement::Expression(
|
||||||
self.ast.arrow_expression(
|
self.ast.arrow_function_expression(
|
||||||
SPAN,
|
SPAN,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
|
|
@ -949,7 +960,7 @@ impl<'a> Decorators<'a> {
|
||||||
);
|
);
|
||||||
|
|
||||||
decorator_elements.push(ArrayExpressionElement::Expression(
|
decorator_elements.push(ArrayExpressionElement::Expression(
|
||||||
self.ast.arrow_expression(
|
self.ast.arrow_function_expression(
|
||||||
SPAN,
|
SPAN,
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
|
|
|
||||||
|
|
@ -535,7 +535,8 @@ impl<'a> TypeScript<'a> {
|
||||||
let statements = self.transform_ts_enum_members(&mut decl.body.members, &enum_name);
|
let statements = self.transform_ts_enum_members(&mut decl.body.members, &enum_name);
|
||||||
let body = self.ast.function_body(decl.body.span, self.ast.new_vec(), statements);
|
let body = self.ast.function_body(decl.body.span, self.ast.new_vec(), statements);
|
||||||
|
|
||||||
let callee = self.ast.arrow_expression(SPAN, false, false, params, body, None, None);
|
let callee =
|
||||||
|
self.ast.arrow_function_expression(SPAN, false, false, params, body, None, None);
|
||||||
|
|
||||||
// })(Foo || {});
|
// })(Foo || {});
|
||||||
let mut arguments = self.ast.new_vec();
|
let mut arguments = self.ast.new_vec();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue