mirror of
https://github.com/danbulant/oxc
synced 2026-05-21 21:29:01 +00:00
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:
parent
786bf07e45
commit
f88cbcd4ab
2 changed files with 11 additions and 2 deletions
|
|
@ -81,9 +81,8 @@ impl<'a> ArrowFunctions<'a> {
|
||||||
|
|
||||||
fn get_this_name(&mut self, ctx: &mut TraverseCtx<'a>) -> BoundIdentifier<'a> {
|
fn get_this_name(&mut self, ctx: &mut TraverseCtx<'a>) -> BoundIdentifier<'a> {
|
||||||
if self.this_var.is_none() {
|
if self.this_var.is_none() {
|
||||||
self.this_var = Some(BoundIdentifier::new_uid(
|
self.this_var = Some(BoundIdentifier::new_uid_in_current_scope(
|
||||||
"this",
|
"this",
|
||||||
ctx.current_scope_id(),
|
|
||||||
SymbolFlags::FunctionScopedVariable,
|
SymbolFlags::FunctionScopedVariable,
|
||||||
ctx,
|
ctx,
|
||||||
));
|
));
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,16 @@ impl<'a> BoundIdentifier<'a> {
|
||||||
Self::new_uid(name, scope_id, flags, ctx)
|
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
|
/// Create `BindingIdentifier` for this binding
|
||||||
pub fn create_binding_identifier(&self) -> BindingIdentifier<'a> {
|
pub fn create_binding_identifier(&self) -> BindingIdentifier<'a> {
|
||||||
BindingIdentifier {
|
BindingIdentifier {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue