From ce1d8cf20be1570366f91d7c7fb0108094e0ce33 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Wed, 23 Oct 2024 13:26:21 +0000 Subject: [PATCH] feat(traverse): add `BoundIdentifier::from_binding_ident` method (#6814) --- crates/oxc_traverse/src/context/bound_identifier.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/oxc_traverse/src/context/bound_identifier.rs b/crates/oxc_traverse/src/context/bound_identifier.rs index c23bce08581ca..2863a2acb088f 100644 --- a/crates/oxc_traverse/src/context/bound_identifier.rs +++ b/crates/oxc_traverse/src/context/bound_identifier.rs @@ -46,6 +46,12 @@ impl<'a> BoundIdentifier<'a> { Self { name, symbol_id } } + /// Create `BoundIdentifier` from a `BindingIdentifier` + #[expect(clippy::missing_panics_doc)] + pub fn from_binding_ident(ident: &BindingIdentifier<'a>) -> Self { + Self { name: ident.name.clone(), symbol_id: ident.symbol_id.get().unwrap() } + } + /// Create `BindingIdentifier` for this binding pub fn create_binding_identifier(&self, ctx: &TraverseCtx<'a>) -> BindingIdentifier<'a> { ctx.ast.binding_identifier_with_symbol_id(SPAN, self.name.clone(), self.symbol_id)