mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
refactor(transformer): add StatementInjectorStore::insert_many_before method (#6857)
This method is not used yet, but it seems natural to provide it as a counterpart to `insert_many_after`.
This commit is contained in:
parent
7339dde473
commit
c19996c2e7
1 changed files with 14 additions and 0 deletions
|
|
@ -85,6 +85,20 @@ impl<'a> StatementInjectorStore<'a> {
|
|||
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)
|
||||
where
|
||||
S: IntoIterator<Item = Statement<'a>>,
|
||||
{
|
||||
let mut insertions = self.insertions.borrow_mut();
|
||||
let adjacent_stmts = insertions.entry(target).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)
|
||||
where
|
||||
|
|
|
|||
Loading…
Reference in a new issue