Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions crates/oxc_transformer/src/common/statement_injector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ impl<'a> StatementInjectorStore<'a> {

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

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

/// Add multiple statements to be inserted immediately before the target statement.
#[expect(dead_code)]
pub fn insert_many_before<S>(&self, target: Address, stmts: S)
pub fn insert_many_before<S>(&self, target: &Statement<'a>, stmts: S)
where
S: IntoIterator<Item = Statement<'a>>,
{
let mut insertions = self.insertions.borrow_mut();
let adjacent_stmts = insertions.entry(target).or_default();
let adjacent_stmts = insertions.entry(target.address()).or_default();
adjacent_stmts.splice(
0..0,
stmts.into_iter().map(|stmt| AdjacentStatement { stmt, direction: Direction::Before }),
);
}

/// Add multiple statements to be inserted immediately after the target statement.
pub fn insert_many_after<S>(&self, target: Address, stmts: S)
pub fn insert_many_after<S>(&self, target: &Statement<'a>, stmts: S)
where
S: IntoIterator<Item = Statement<'a>>,
{
let mut insertions = self.insertions.borrow_mut();
let adjacent_stmts = insertions.entry(target).or_default();
let adjacent_stmts = insertions.entry(target.address()).or_default();
adjacent_stmts.extend(
stmts.into_iter().map(|stmt| AdjacentStatement { stmt, direction: Direction::After }),
);
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_transformer/src/typescript/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::cell::Cell;

use rustc_hash::FxHashSet;

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

// Add assignments after super calls
self.ctx.statement_injector.insert_many_after(
stmt.address(),
stmt,
self.assignments
.iter()
.map(|assignment| assignment.create_this_property_assignment(ctx)),
Expand Down