refactor(transformer): import oxc_allocator::Box as ArenaBox (#6999)

Closes #6996.
This commit is contained in:
overlookmotel 2024-10-29 13:00:49 +00:00
parent fc1af2e9da
commit c945fe71b3
4 changed files with 17 additions and 17 deletions

View file

@ -53,7 +53,7 @@
use std::mem;
use oxc_allocator::Box;
use oxc_allocator::Box as ArenaBox;
use oxc_ast::{ast::*, Visit, NONE};
use oxc_semantic::{ReferenceFlags, ScopeFlags, ScopeId, SymbolFlags};
use oxc_span::{Atom, GetSpan, SPAN};
@ -467,8 +467,8 @@ impl<'a, 'ctx> AsyncToGenerator<'a, 'ctx> {
#[inline]
fn create_function(
id: Option<BindingIdentifier<'a>>,
params: Box<'a, FormalParameters<'a>>,
body: Box<'a, FunctionBody<'a>>,
params: ArenaBox<'a, FormalParameters<'a>>,
body: ArenaBox<'a, FunctionBody<'a>>,
scope_id: ScopeId,
ctx: &mut TraverseCtx<'a>,
) -> Function<'a> {
@ -536,8 +536,8 @@ impl<'a, 'ctx> AsyncToGenerator<'a, 'ctx> {
/// ```
fn create_async_to_generator_call(
&self,
params: Box<'a, FormalParameters<'a>>,
body: Box<'a, FunctionBody<'a>>,
params: ArenaBox<'a, FormalParameters<'a>>,
body: ArenaBox<'a, FunctionBody<'a>>,
scope_id: ScopeId,
ctx: &mut TraverseCtx<'a>,
) -> Expression<'a> {
@ -560,8 +560,8 @@ impl<'a, 'ctx> AsyncToGenerator<'a, 'ctx> {
fn create_async_to_generator_declaration(
&self,
bound_ident: &BoundIdentifier<'a>,
params: Box<'a, FormalParameters<'a>>,
body: Box<'a, FunctionBody<'a>>,
params: ArenaBox<'a, FormalParameters<'a>>,
body: ArenaBox<'a, FunctionBody<'a>>,
scope_id: ScopeId,
ctx: &mut TraverseCtx<'a>,
) -> Statement<'a> {
@ -592,8 +592,8 @@ impl<'a, 'ctx> AsyncToGenerator<'a, 'ctx> {
fn create_async_to_generator_assignment(
&self,
bound: &BoundIdentifier<'a>,
params: Box<'a, FormalParameters<'a>>,
body: Box<'a, FunctionBody<'a>>,
params: ArenaBox<'a, FormalParameters<'a>>,
body: ArenaBox<'a, FunctionBody<'a>>,
scope_id: ScopeId,
ctx: &mut TraverseCtx<'a>,
) -> Statement<'a> {
@ -613,7 +613,7 @@ impl<'a, 'ctx> AsyncToGenerator<'a, 'ctx> {
params: &FormalParameters<'a>,
scope_id: ScopeId,
ctx: &mut TraverseCtx<'a>,
) -> Box<'a, FormalParameters<'a>> {
) -> ArenaBox<'a, FormalParameters<'a>> {
let mut parameters = ctx.ast.vec_with_capacity(params.items.len());
for param in &params.items {
if param.pattern.kind.is_assignment_pattern() {
@ -636,7 +636,7 @@ impl<'a, 'ctx> AsyncToGenerator<'a, 'ctx> {
/// Creates an empty [FormalParameters] with [FormalParameterKind::FormalParameter].
#[inline]
fn create_empty_params(ctx: &mut TraverseCtx<'a>) -> Box<'a, FormalParameters<'a>> {
fn create_empty_params(ctx: &mut TraverseCtx<'a>) -> ArenaBox<'a, FormalParameters<'a>> {
ctx.ast.alloc_formal_parameters(
SPAN,
FormalParameterKind::FormalParameter,

View file

@ -45,7 +45,7 @@
//!
//! * Babel plugin implementation: <https://github.com/babel/babel/blob/main/packages/babel-plugin-transform-react-display-name/src/index.ts>
use oxc_allocator::Box;
use oxc_allocator::Box as ArenaBox;
use oxc_ast::ast::*;
use oxc_span::{Atom, SPAN};
use oxc_traverse::{Ancestor, Traverse, TraverseCtx};
@ -133,7 +133,7 @@ impl<'a, 'ctx> ReactDisplayName<'a, 'ctx> {
/// Get the object from `React.createClass({})` or `createReactClass({})`
fn get_object_from_create_class<'b>(
call_expr: &'b mut CallExpression<'a>,
) -> Option<&'b mut Box<'a, ObjectExpression<'a>>> {
) -> Option<&'b mut ArenaBox<'a, ObjectExpression<'a>>> {
if match &call_expr.callee {
callee @ match_member_expression!(Expression) => {
!callee.to_member_expression().is_specific_member_access("React", "createClass")

View file

@ -1,4 +1,4 @@
use oxc_allocator::Box;
use oxc_allocator::Box as ArenaBox;
use oxc_ast::{ast::*, NONE};
use oxc_span::SPAN;
use oxc_syntax::reference::ReferenceFlags;
@ -51,7 +51,7 @@ impl<'a, 'ctx> Traverse<'a> for TypeScriptModule<'a, 'ctx> {
impl<'a, 'ctx> TypeScriptModule<'a, 'ctx> {
fn transform_ts_import_equals(
&self,
decl: &mut Box<'a, TSImportEqualsDeclaration<'a>>,
decl: &mut ArenaBox<'a, TSImportEqualsDeclaration<'a>>,
ctx: &mut TraverseCtx<'a>,
) -> Declaration<'a> {
let kind = VariableDeclarationKind::Var;

View file

@ -1,6 +1,6 @@
use rustc_hash::FxHashSet;
use oxc_allocator::{Box, Vec as ArenaVec};
use oxc_allocator::{Box as ArenaBox, Vec as ArenaVec};
use oxc_ast::{ast::*, NONE};
use oxc_ecmascript::BoundNames;
use oxc_span::{Atom, CompactStr, SPAN};
@ -446,7 +446,7 @@ impl<'a, 'ctx> TypeScriptNamespace<'a, 'ctx> {
/// Convert `export const foo = 1` to `Namespace.foo = 1`;
#[allow(clippy::needless_pass_by_value)]
fn handle_variable_declaration(
mut var_decl: Box<'a, VariableDeclaration<'a>>,
mut var_decl: ArenaBox<'a, VariableDeclaration<'a>>,
name: Atom<'a>,
ctx: &TraverseCtx<'a>,
) -> ArenaVec<'a, Statement<'a>> {