feat(traverse): add BoundIdentifier::from_binding_ident method (#6814)

This commit is contained in:
overlookmotel 2024-10-23 13:26:21 +00:00
parent b8dfa191be
commit ce1d8cf20b

View file

@ -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)