Skip to content

Commit

Permalink
feat(semantic): add SymbolTable::delete_resolved_reference method
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Sep 6, 2024
1 parent 1f45a15 commit 875c498
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/oxc_semantic/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,16 @@ impl SymbolTable {
.map(|reference_id| &self.references[*reference_id])
}

/// Delete a reference to a symbol.
///
/// # Panics
/// Panics if provided `reference_id` is not a resolved reference for `symbol_id`.
pub fn delete_resolved_reference(&mut self, symbol_id: SymbolId, reference_id: ReferenceId) {
let reference_ids = &mut self.resolved_references[symbol_id];
let index = reference_ids.iter().position(|&id| id == reference_id).unwrap();
reference_ids.swap_remove(index);
}

pub fn reserve(&mut self, additional_symbols: usize, additional_references: usize) {
self.spans.reserve(additional_symbols);
self.names.reserve(additional_symbols);
Expand Down

0 comments on commit 875c498

Please sign in to comment.