From 6b885fef46f364e441d8e7f0a53bcbc463b07714 Mon Sep 17 00:00:00 2001 From: Dunqing <29533304+Dunqing@users.noreply.github.com> Date: Mon, 19 Aug 2024 17:42:45 +0000 Subject: [PATCH] feat(traverse): expose `generate_uid_based_on_node` and `generate_uid_in_current_scope_based_on_node` from `TraverseCtx` (#4965) Both of these APIs were added in #4940. But they weren't exposed. --- crates/oxc_traverse/src/context/mod.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crates/oxc_traverse/src/context/mod.rs b/crates/oxc_traverse/src/context/mod.rs index d7e748a84..6f4aa3d0c 100644 --- a/crates/oxc_traverse/src/context/mod.rs +++ b/crates/oxc_traverse/src/context/mod.rs @@ -291,6 +291,29 @@ impl<'a> TraverseCtx<'a> { self.scoping.generate_uid_in_root_scope(name, flags) } + /// Generate UID based on node. + /// + /// This is a shortcut for `ctx.scoping.generate_uid_based_on_node`. + pub fn generate_uid_based_on_node( + &mut self, + node: &Expression<'a>, + scope_id: ScopeId, + flags: SymbolFlags, + ) -> SymbolId { + self.scoping.generate_uid_based_on_node(node, scope_id, flags) + } + + /// Generate UID in current scope based on node. + /// + /// This is a shortcut for `ctx.scoping.generate_uid_in_current_scope_based_on_node`. + pub fn generate_uid_in_current_scope_based_on_node( + &mut self, + node: &Expression<'a>, + flags: SymbolFlags, + ) -> SymbolId { + self.scoping.generate_uid_in_current_scope_based_on_node(node, flags) + } + /// Create a reference bound to a `SymbolId`. /// /// This is a shortcut for `ctx.scoping.create_bound_reference`.