Skip to content

Commit

Permalink
refactor(transformer/arrow-functions): reorder visitor methods (#8320)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
overlookmotel committed Jan 8, 2025
1 parent 37199a4 commit ea9cefb
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions crates/oxc_transformer/src/common/arrow_function_converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Expression<'a>> {
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, '_> {
Expand Down Expand Up @@ -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<Expression<'a>> {
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
}
}
}

0 comments on commit ea9cefb

Please sign in to comment.