From af0ddc0db7800af328c7a0c7ec7843e2a4219132 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sat, 4 Jan 2025 18:55:40 +0000 Subject: [PATCH] refactor(transformer/async-to-generator): pass `TraverseCtx` to function not `AstBuilder` --- .../oxc_transformer/src/es2017/async_to_generator.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/oxc_transformer/src/es2017/async_to_generator.rs b/crates/oxc_transformer/src/es2017/async_to_generator.rs index 8ecd6981bfc072..8d18098c72a586 100644 --- a/crates/oxc_transformer/src/es2017/async_to_generator.rs +++ b/crates/oxc_transformer/src/es2017/async_to_generator.rs @@ -54,7 +54,7 @@ use std::{borrow::Cow, mem}; use oxc_allocator::{Box as ArenaBox, String as ArenaString}; -use oxc_ast::{ast::*, AstBuilder, Visit, NONE}; +use oxc_ast::{ast::*, Visit, NONE}; use oxc_semantic::{ReferenceFlags, ScopeFlags, ScopeId, SymbolFlags}; use oxc_span::{Atom, GetSpan, SPAN}; use oxc_syntax::{ @@ -517,7 +517,7 @@ impl<'a, 'ctx> AsyncGeneratorExecutor<'a, 'ctx> { } // infer `foo` from `({ foo: async function() {} })` Ancestor::ObjectPropertyValue(property) if !*property.method() => { - property.key().static_name().map(|key| Self::normalize_function_name(&key, ctx.ast)) + property.key().static_name().map(|key| Self::normalize_function_name(&key, ctx)) } _ => None, } @@ -534,13 +534,13 @@ impl<'a, 'ctx> AsyncGeneratorExecutor<'a, 'ctx> { /// // Reserved keyword /// * `this` -> `_this` /// * `arguments` -> `_arguments` - fn normalize_function_name(input: &Cow<'a, str>, ast: AstBuilder<'a>) -> Atom<'a> { + fn normalize_function_name(input: &Cow<'a, str>, ctx: &TraverseCtx<'a>) -> Atom<'a> { let input_str = input.as_ref(); if !is_reserved_keyword(input_str) && is_identifier_name(input_str) { - return ast.atom_from_cow(input); + return ctx.ast.atom_from_cow(input); } - let mut name = ArenaString::with_capacity_in(input_str.len() + 1, ast.allocator); + let mut name = ArenaString::with_capacity_in(input_str.len() + 1, ctx.ast.allocator); let mut capitalize_next = false; let mut chars = input_str.chars();