From 5206c6ae06cb67d16ccccfd4c545252cb90434a2 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Thu, 16 Jan 2025 14:55:50 +0000 Subject: [PATCH] refactor(transformer): rename `wrap_in_arrow_function_iife` (#8546) Pure refactor. Rename this function to be more descriptive. --- .../oxc_transformer/src/common/arrow_function_converter.rs | 4 ++-- crates/oxc_transformer/src/es2020/optional_chaining.rs | 6 +++--- crates/oxc_transformer/src/utils/ast_builder.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/oxc_transformer/src/common/arrow_function_converter.rs b/crates/oxc_transformer/src/common/arrow_function_converter.rs index 40326e4ff7af9..5fadd7c2216bb 100644 --- a/crates/oxc_transformer/src/common/arrow_function_converter.rs +++ b/crates/oxc_transformer/src/common/arrow_function_converter.rs @@ -102,7 +102,7 @@ use oxc_syntax::{ }; use oxc_traverse::{Ancestor, BoundIdentifier, Traverse, TraverseCtx}; -use crate::{utils::ast_builder::wrap_arrow_function_iife, EnvOptions}; +use crate::{utils::ast_builder::wrap_expression_in_arrow_function_iife, EnvOptions}; type FxIndexMap = IndexMap; @@ -419,7 +419,7 @@ impl<'a> Traverse<'a> for ArrowFunctionConverter<'a> { // prop = (() => { return async () => {} })(); // } // ``` - Some(wrap_arrow_function_iife(ctx.ast.move_expression(expr), ctx)) + Some(wrap_expression_in_arrow_function_iife(ctx.ast.move_expression(expr), ctx)) } else { return; } diff --git a/crates/oxc_transformer/src/es2020/optional_chaining.rs b/crates/oxc_transformer/src/es2020/optional_chaining.rs index d673efd2ede1f..2ef666e02b681 100644 --- a/crates/oxc_transformer/src/es2020/optional_chaining.rs +++ b/crates/oxc_transformer/src/es2020/optional_chaining.rs @@ -54,7 +54,7 @@ use oxc_ast::{ast::*, NONE}; use oxc_span::SPAN; use oxc_traverse::{Ancestor, BoundIdentifier, MaybeBoundIdentifier, Traverse, TraverseCtx}; -use crate::{utils::ast_builder::wrap_arrow_function_iife, TransformCtx}; +use crate::{utils::ast_builder::wrap_expression_in_arrow_function_iife, TransformCtx}; #[derive(Debug)] enum CallContext<'a> { @@ -283,7 +283,7 @@ impl<'a> OptionalChaining<'a, '_> { // To insert the temp binding in the correct scope, we wrap the expression with // an arrow function. During the chain expression transformation, the temp binding // will be inserted into the arrow function's body. - wrap_arrow_function_iife(ctx.ast.move_expression(expr), ctx) + wrap_expression_in_arrow_function_iife(ctx.ast.move_expression(expr), ctx) } else { self.transform_chain_expression_impl(false, expr, ctx) } @@ -297,7 +297,7 @@ impl<'a> OptionalChaining<'a, '_> { ) { *expr = if self.is_inside_function_parameter { // Same as the above `transform_chain_expression` explanation - wrap_arrow_function_iife(ctx.ast.move_expression(expr), ctx) + wrap_expression_in_arrow_function_iife(ctx.ast.move_expression(expr), ctx) } else { // Unfortunately no way to get compiler to see that this branch is provably unreachable. // We don't want to inline this function, to keep `enter_expression` as small as possible. diff --git a/crates/oxc_transformer/src/utils/ast_builder.rs b/crates/oxc_transformer/src/utils/ast_builder.rs index 079ae29e7000e..df043754b3e49 100644 --- a/crates/oxc_transformer/src/utils/ast_builder.rs +++ b/crates/oxc_transformer/src/utils/ast_builder.rs @@ -41,7 +41,7 @@ pub(crate) fn create_call_call<'a>( /// with a body block. /// /// `expr` -> `(() => { return expr; })()` -pub(crate) fn wrap_arrow_function_iife<'a>( +pub(crate) fn wrap_expression_in_arrow_function_iife<'a>( expr: Expression<'a>, ctx: &mut TraverseCtx<'a>, ) -> Expression<'a> {