From ea9cefb5c365e9b53ec7160eeef08c46048f8bec Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Wed, 8 Jan 2025 01:52:43 +0000 Subject: [PATCH] refactor(transformer/arrow-functions): reorder visitor methods (#8320) Follow-on after #8024. Pure refactor. Re-order the methods of the `ConstructorBodyThisAfterSuperInserter` visitor. Intent is that the call path flows from top to bottom, so the "story" makes sense when you read the code starting from the top. --- .../src/common/arrow_function_converter.rs | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/crates/oxc_transformer/src/common/arrow_function_converter.rs b/crates/oxc_transformer/src/common/arrow_function_converter.rs index c5a45f2fe4294..dbb57506c6027 100644 --- a/crates/oxc_transformer/src/common/arrow_function_converter.rs +++ b/crates/oxc_transformer/src/common/arrow_function_converter.rs @@ -1128,21 +1128,6 @@ impl<'a, 'v> ConstructorBodyThisAfterSuperInserter<'a, 'v> { fn new(this_var_binding: &'v BoundIdentifier<'a>, ctx: &'v mut TraverseCtx<'a>) -> Self { Self { this_var_binding, ctx } } - - #[inline] - fn transform_super_call_expression(&mut self, expr: &Expression<'a>) -> Option> { - if expr.is_super_call_expression() { - let assignment = self.ctx.ast.expression_assignment( - SPAN, - AssignmentOperator::Assign, - self.this_var_binding.create_write_target(self.ctx), - self.ctx.ast.expression_this(SPAN), - ); - Some(assignment) - } else { - None - } - } } impl<'a> VisitMut<'a> for ConstructorBodyThisAfterSuperInserter<'a, '_> { @@ -1188,3 +1173,20 @@ impl<'a> VisitMut<'a> for ConstructorBodyThisAfterSuperInserter<'a, '_> { } } } + +impl<'a> ConstructorBodyThisAfterSuperInserter<'a, '_> { + #[inline] + fn transform_super_call_expression(&mut self, expr: &Expression<'a>) -> Option> { + if expr.is_super_call_expression() { + let assignment = self.ctx.ast.expression_assignment( + SPAN, + AssignmentOperator::Assign, + self.this_var_binding.create_write_target(self.ctx), + self.ctx.ast.expression_this(SPAN), + ); + Some(assignment) + } else { + None + } + } +}