mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
feat(semantic): add move_binding API in ScopeTree (#6808)
Part of #6658 This API is useful when we want to move a scope to another scope
This commit is contained in:
parent
e7e60dab68
commit
5928f043b5
1 changed files with 8 additions and 0 deletions
|
|
@ -328,6 +328,14 @@ impl ScopeTree {
|
|||
self.bindings[scope_id].shift_remove(name);
|
||||
}
|
||||
|
||||
/// Move a binding from one scope to another.
|
||||
pub fn move_binding(&mut self, from: ScopeId, to: ScopeId, name: &str) {
|
||||
let from_map = &mut self.bindings[from];
|
||||
if let Some((name, symbol_id)) = from_map.swap_remove_entry(name) {
|
||||
self.bindings[to].insert(name, symbol_id);
|
||||
}
|
||||
}
|
||||
|
||||
/// Reserve memory for an `additional` number of scopes.
|
||||
pub fn reserve(&mut self, additional: usize) {
|
||||
self.parent_ids.reserve(additional);
|
||||
|
|
|
|||
Loading…
Reference in a new issue