Skip to content

Commit

Permalink
feat(semantic): allow getting mutable reference to symbols table (#8189)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mxsdev authored Dec 30, 2024
1 parent 11e598e commit 55744fd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/oxc_semantic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<NodeId> {
&self.unused_labels
}
Expand Down

0 comments on commit 55744fd

Please sign in to comment.