Skip to content

Commit

Permalink
refactor(transformer/async-to-generator): pass TraverseCtx to funct…
Browse files Browse the repository at this point in the history
…ion not `AstBuilder`
  • Loading branch information
overlookmotel committed Jan 6, 2025
1 parent 2e7207f commit af0ddc0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions crates/oxc_transformer/src/es2017/async_to_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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,
}
Expand All @@ -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();
Expand Down

0 comments on commit af0ddc0

Please sign in to comment.