feat(transformer): add BoundIdentifier::new_uid_in_current_scope method (#4903)

Add method `BoundIdentifier::new_uid_in_current_scope` as a shortcut.
This commit is contained in:
overlookmotel 2024-08-14 18:55:27 +00:00
parent 786bf07e45
commit f88cbcd4ab
2 changed files with 11 additions and 2 deletions

View file

@ -81,9 +81,8 @@ impl<'a> ArrowFunctions<'a> {
fn get_this_name(&mut self, ctx: &mut TraverseCtx<'a>) -> BoundIdentifier<'a> {
if self.this_var.is_none() {
self.this_var = Some(BoundIdentifier::new_uid(
self.this_var = Some(BoundIdentifier::new_uid_in_current_scope(
"this",
ctx.current_scope_id(),
SymbolFlags::FunctionScopedVariable,
ctx,
));

View file

@ -65,6 +65,16 @@ impl<'a> BoundIdentifier<'a> {
Self::new_uid(name, scope_id, flags, ctx)
}
/// Create `BoundIdentifier` for new binding in current scope
pub fn new_uid_in_current_scope(
name: &str,
flags: SymbolFlags,
ctx: &mut TraverseCtx<'a>,
) -> Self {
let scope_id = ctx.current_scope_id();
Self::new_uid(name, scope_id, flags, ctx)
}
/// Create `BindingIdentifier` for this binding
pub fn create_binding_identifier(&self) -> BindingIdentifier<'a> {
BindingIdentifier {