From c91ffbcb01dcc0b8a69a3ffc0cbb439f1cff6192 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Wed, 23 Oct 2024 03:36:30 +0000 Subject: [PATCH] refactor(ast, transformer)!: remove `IdentifierName::new` method (#6784) --- crates/oxc_ast/src/ast_impl/js.rs | 7 ------- crates/oxc_transformer/src/common/module_imports.rs | 4 +++- crates/oxc_transformer/src/react/jsx.rs | 2 +- crates/oxc_transformer/src/typescript/namespace.rs | 4 ++-- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/crates/oxc_ast/src/ast_impl/js.rs b/crates/oxc_ast/src/ast_impl/js.rs index 4e82cf665..06134c8df 100644 --- a/crates/oxc_ast/src/ast_impl/js.rs +++ b/crates/oxc_ast/src/ast_impl/js.rs @@ -299,13 +299,6 @@ impl<'a> Expression<'a> { } } -impl<'a> IdentifierName<'a> { - #[allow(missing_docs)] - pub fn new(span: Span, name: Atom<'a>) -> Self { - Self { span, name } - } -} - impl<'a> fmt::Display for IdentifierName<'a> { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/crates/oxc_transformer/src/common/module_imports.rs b/crates/oxc_transformer/src/common/module_imports.rs index 0c5fda9eb..4918a79d2 100644 --- a/crates/oxc_transformer/src/common/module_imports.rs +++ b/crates/oxc_transformer/src/common/module_imports.rs @@ -199,7 +199,9 @@ impl<'a> ModuleImportsStore<'a> { Import::Named(import) => { ImportDeclarationSpecifier::ImportSpecifier(ctx.ast.alloc_import_specifier( SPAN, - ModuleExportName::IdentifierName(IdentifierName::new(SPAN, import.imported)), + ModuleExportName::IdentifierName( + ctx.ast.identifier_name(SPAN, import.imported), + ), import.local.create_binding_identifier(), ImportOrExportKind::Value, )) diff --git a/crates/oxc_transformer/src/react/jsx.rs b/crates/oxc_transformer/src/react/jsx.rs index a236579eb..593be8e76 100644 --- a/crates/oxc_transformer/src/react/jsx.rs +++ b/crates/oxc_transformer/src/react/jsx.rs @@ -800,7 +800,7 @@ impl<'a, 'ctx> ReactJsx<'a, 'ctx> { } JSXMemberExpressionObject::ThisExpression(expr) => ctx.ast.expression_this(expr.span), }; - let property = IdentifierName::new(expr.property.span, expr.property.name.clone()); + let property = ctx.ast.identifier_name(expr.property.span, expr.property.name.clone()); ctx.ast.member_expression_static(expr.span, object, property, false).into() } diff --git a/crates/oxc_transformer/src/typescript/namespace.rs b/crates/oxc_transformer/src/typescript/namespace.rs index 4153f255a..69e4a49e9 100644 --- a/crates/oxc_transformer/src/typescript/namespace.rs +++ b/crates/oxc_transformer/src/typescript/namespace.rs @@ -362,7 +362,7 @@ impl<'a, 'ctx> TypeScriptNamespace<'a, 'ctx> { ctx.ast.member_expression_static( SPAN, parent_export, - IdentifierName::new(SPAN, real_name.clone()), + ctx.ast.identifier_name(SPAN, real_name.clone()), false, ), ) @@ -387,7 +387,7 @@ impl<'a, 'ctx> TypeScriptNamespace<'a, 'ctx> { let assign_left = ctx.ast.simple_assignment_target_identifier_reference(SPAN, &real_name); let assign_right = { - let property = IdentifierName::new(SPAN, real_name.clone()); + let property = ctx.ast.identifier_name(SPAN, real_name.clone()); let logical_left = ctx.ast.member_expression_static(SPAN, parent_export, property, false); let op = LogicalOperator::Or;