Skip to content

Commit cced347

Browse files
committed
refactor(transformer): StatementInjectorStore methods take &Statement as target
1 parent 7bbedb6 commit cced347

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

crates/oxc_transformer/src/common/statement_injector.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ impl<'a> StatementInjectorStore<'a> {
6767

6868
/// Add a statement to be inserted immediately before the target statement.
6969
#[expect(dead_code)]
70-
pub fn insert_before(&self, target: Address, stmt: Statement<'a>) {
70+
pub fn insert_before(&self, target: &Statement<'a>, stmt: Statement<'a>) {
7171
let mut insertions = self.insertions.borrow_mut();
72-
let adjacent_stmts = insertions.entry(target).or_default();
72+
let adjacent_stmts = insertions.entry(target.address()).or_default();
7373
let index = adjacent_stmts
7474
.iter()
7575
.position(|s| matches!(s.direction, Direction::After))
@@ -79,33 +79,33 @@ impl<'a> StatementInjectorStore<'a> {
7979

8080
/// Add a statement to be inserted immediately after the target statement.
8181
#[expect(dead_code)]
82-
pub fn insert_after(&self, target: Address, stmt: Statement<'a>) {
82+
pub fn insert_after(&self, target: &Statement<'a>, stmt: Statement<'a>) {
8383
let mut insertions = self.insertions.borrow_mut();
84-
let adjacent_stmts = insertions.entry(target).or_default();
84+
let adjacent_stmts = insertions.entry(target.address()).or_default();
8585
adjacent_stmts.push(AdjacentStatement { stmt, direction: Direction::After });
8686
}
8787

8888
/// Add multiple statements to be inserted immediately before the target statement.
8989
#[expect(dead_code)]
90-
pub fn insert_many_before<S>(&self, target: Address, stmts: S)
90+
pub fn insert_many_before<S>(&self, target: &Statement<'a>, stmts: S)
9191
where
9292
S: IntoIterator<Item = Statement<'a>>,
9393
{
9494
let mut insertions = self.insertions.borrow_mut();
95-
let adjacent_stmts = insertions.entry(target).or_default();
95+
let adjacent_stmts = insertions.entry(target.address()).or_default();
9696
adjacent_stmts.splice(
9797
0..0,
9898
stmts.into_iter().map(|stmt| AdjacentStatement { stmt, direction: Direction::Before }),
9999
);
100100
}
101101

102102
/// Add multiple statements to be inserted immediately after the target statement.
103-
pub fn insert_many_after<S>(&self, target: Address, stmts: S)
103+
pub fn insert_many_after<S>(&self, target: &Statement<'a>, stmts: S)
104104
where
105105
S: IntoIterator<Item = Statement<'a>>,
106106
{
107107
let mut insertions = self.insertions.borrow_mut();
108-
let adjacent_stmts = insertions.entry(target).or_default();
108+
let adjacent_stmts = insertions.entry(target.address()).or_default();
109109
adjacent_stmts.extend(
110110
stmts.into_iter().map(|stmt| AdjacentStatement { stmt, direction: Direction::After }),
111111
);

crates/oxc_transformer/src/typescript/annotations.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::cell::Cell;
44

55
use rustc_hash::FxHashSet;
66

7-
use oxc_allocator::{GetAddress, Vec as ArenaVec};
7+
use oxc_allocator::Vec as ArenaVec;
88
use oxc_ast::ast::*;
99
use oxc_diagnostics::OxcDiagnostic;
1010
use oxc_semantic::SymbolFlags;
@@ -414,7 +414,7 @@ impl<'a, 'ctx> Traverse<'a> for TypeScriptAnnotations<'a, 'ctx> {
414414

415415
// Add assignments after super calls
416416
self.ctx.statement_injector.insert_many_after(
417-
stmt.address(),
417+
stmt,
418418
self.assignments
419419
.iter()
420420
.map(|assignment| assignment.create_this_property_assignment(ctx)),

0 commit comments

Comments
 (0)