Skip to content

Commit

Permalink
feat(transformer): add BoundIdentifier::new_uid_in_current_scope me…
Browse files Browse the repository at this point in the history
…thod (#4903)

Add method `BoundIdentifier::new_uid_in_current_scope` as a shortcut.
  • Loading branch information
overlookmotel committed Aug 14, 2024
1 parent 786bf07 commit f88cbcd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 1 addition & 2 deletions crates/oxc_transformer/src/es2015/arrow_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
));
Expand Down
10 changes: 10 additions & 0 deletions crates/oxc_transformer/src/helpers/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f88cbcd

Please sign in to comment.