mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(transformer): methods only take &TraverseCtx where possible (#6812)
Methods which only need an immutable ref `&TraverseCtx` take that, instead of unnecessary `&mut TraverseCtx`.
This commit is contained in:
parent
47bc36832c
commit
759710aa66
4 changed files with 6 additions and 6 deletions
|
|
@ -193,7 +193,7 @@ impl<'a> ModuleImportsStore<'a> {
|
|||
fn get_import(
|
||||
source: Atom<'a>,
|
||||
names: Vec<Import<'a>>,
|
||||
ctx: &mut TraverseCtx<'a>,
|
||||
ctx: &TraverseCtx<'a>,
|
||||
) -> Statement<'a> {
|
||||
let specifiers = ctx.ast.vec_from_iter(names.into_iter().map(|import| match import {
|
||||
Import::Named(import) => {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ impl<'a> VarDeclarationsStore<'a> {
|
|||
&self,
|
||||
binding: &BoundIdentifier<'a>,
|
||||
init: Option<Expression<'a>>,
|
||||
ctx: &mut TraverseCtx<'a>,
|
||||
ctx: &TraverseCtx<'a>,
|
||||
) {
|
||||
let ident = binding.create_binding_identifier(ctx);
|
||||
let ident = ctx.ast.binding_pattern_kind_from_binding_identifier(ident);
|
||||
|
|
@ -86,7 +86,7 @@ impl<'a> VarDeclarationsStore<'a> {
|
|||
&self,
|
||||
ident: BindingPattern<'a>,
|
||||
init: Option<Expression<'a>>,
|
||||
ctx: &mut TraverseCtx<'a>,
|
||||
ctx: &TraverseCtx<'a>,
|
||||
) {
|
||||
let declarator =
|
||||
ctx.ast.variable_declarator(SPAN, VariableDeclarationKind::Var, ident, init, false);
|
||||
|
|
@ -94,7 +94,7 @@ impl<'a> VarDeclarationsStore<'a> {
|
|||
}
|
||||
|
||||
/// Add a `VariableDeclarator` to be inserted at top of current enclosing statement block.
|
||||
pub fn insert_declarator(&self, declarator: VariableDeclarator<'a>, ctx: &mut TraverseCtx<'a>) {
|
||||
pub fn insert_declarator(&self, declarator: VariableDeclarator<'a>, ctx: &TraverseCtx<'a>) {
|
||||
let mut stack = self.stack.borrow_mut();
|
||||
stack.last_mut_or_init(|| ctx.ast.vec()).push(declarator);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -407,7 +407,7 @@ impl<'a> ArrowFunctions<'a> {
|
|||
&mut self,
|
||||
statements: &mut Vec<'a, Statement<'a>>,
|
||||
this_var: &BoundIdentifier<'a>,
|
||||
ctx: &mut TraverseCtx<'a>,
|
||||
ctx: &TraverseCtx<'a>,
|
||||
) {
|
||||
let binding_pattern = ctx.ast.binding_pattern(
|
||||
ctx.ast.binding_pattern_kind_from_binding_identifier(
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ impl<'a, 'ctx> ReactJsxSource<'a, 'ctx> {
|
|||
|
||||
pub fn get_filename_var_declarator(
|
||||
&self,
|
||||
ctx: &mut TraverseCtx<'a>,
|
||||
ctx: &TraverseCtx<'a>,
|
||||
) -> Option<VariableDeclarator<'a>> {
|
||||
let filename_var = self.filename_var.as_ref()?;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue