From 55744fd9775a032ea83215dadc77a6bff3e2a87d Mon Sep 17 00:00:00 2001 From: Max Stoumen Date: Sun, 29 Dec 2024 23:27:30 -0800 Subject: [PATCH] feat(semantic): allow getting mutable reference to symbols table (#8189) Seems like the only way to get a mutable reference to the `SymbolTable` inside `Semantic` right now is with `into_symbol_table_and_scope_tree`, but that drops other useful info. Since `scopes_mut` exists I figure this would be reasonable too? Reason I'm requesting this is I have a project where I need to fill in some symbols `oxc_semantic` doesn't yet pick up on (like function overloads, `declare`'d symbols) and this would be the cleanest way to do it. --- crates/oxc_semantic/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/oxc_semantic/src/lib.rs b/crates/oxc_semantic/src/lib.rs index 8dabf4e32..42b624429 100644 --- a/crates/oxc_semantic/src/lib.rs +++ b/crates/oxc_semantic/src/lib.rs @@ -163,6 +163,11 @@ impl<'a> Semantic<'a> { &self.symbols } + /// Get a mutable reference to the [`SymbolTable`]. + pub fn symbols_mut(&mut self) -> &mut SymbolTable { + &mut self.symbols + } + pub fn unused_labels(&self) -> &Vec { &self.unused_labels }