Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Nov 14, 2024
1 parent 86f0560 commit e0d5c1c
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions crates/oxc_transformer/src/es2020/optional_chaining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,49 +159,49 @@ impl<'a, 'ctx> OptionalChaining<'a, 'ctx> {
ctx: &mut OptionalChainingTransformContext<'a, 't>,
) -> Option<Expression<'a>> {
// Go deeper into the member expression and transform it and return the result
let (result, optional_expr) = match expr {
let (left, optional_expr) = match expr {
Expression::ComputedMemberExpression(m) => {
let deep = self.transform_optional_expression_recursion(&mut m.object, ctx);
let left = self.transform_optional_expression_recursion(&mut m.object, ctx);
if m.optional {
m.optional = false;
(deep, &mut m.object)
(left, &mut m.object)
} else {
return deep;
return left;
}
}
Expression::StaticMemberExpression(m) => {
let deep = self.transform_optional_expression_recursion(&mut m.object, ctx);
let left = self.transform_optional_expression_recursion(&mut m.object, ctx);
if m.optional {
m.optional = false;
(deep, &mut m.object)
(left, &mut m.object)
} else {
return deep;
return left;
}
}
Expression::PrivateFieldExpression(m) => {
let deep = self.transform_optional_expression_recursion(&mut m.object, ctx);
let left = self.transform_optional_expression_recursion(&mut m.object, ctx);
if m.optional {
m.optional = false;
(deep, &mut m.object)
(left, &mut m.object)
} else {
return deep;
return left;
}
}
Expression::CallExpression(c) => {
let deep = self.transform_optional_expression_recursion(&mut c.callee, ctx);
let left = self.transform_optional_expression_recursion(&mut c.callee, ctx);
if c.optional {
c.optional = false;
(deep, &mut c.callee)
(left, &mut c.callee)
} else {
return deep;
return left;
}
}
_ => return None,
};

let result = match (result, optional_expr) {
(Some(result), expr) => {
self.generate_memoised_and_assign_to_it_and_check(result, expr, ctx)
let combined_expr = match (left, optional_expr) {
(Some(left), expr) => {
self.generate_memoised_and_assign_to_it_and_check(left, expr, ctx)
}
(None, Expression::Identifier(ident)) => {
let binding =
Expand All @@ -221,7 +221,7 @@ impl<'a, 'ctx> OptionalChaining<'a, 'ctx> {
}
};

Some(result)
Some(combined_expr)
}

fn maybe_generate_memoised<'t>(
Expand Down

0 comments on commit e0d5c1c

Please sign in to comment.