Skip to content

Commit

Permalink
passing flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Aug 14, 2024
1 parent 0b58401 commit 9c00f30
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions crates/oxc_traverse/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,15 @@ impl<'a> TraverseCtx<'a> {
self.scoping.create_reference_in_current_scope(name, flag)
}

/// Clone IdentifierReference based on the original reference's symbol_id, name, and flag.
/// Clone IdentifierReference based on the original reference's SymbolId and name.
///
/// This is a shortcut for `ctx.scoping.clone_identifier_reference`.
pub fn clone_identifier_reference(
&mut self,
ident: &IdentifierReference<'a>,
flag: ReferenceFlag,
) -> IdentifierReference<'a> {
self.scoping.clone_identifier_reference(ident)
self.scoping.clone_identifier_reference(ident, flag)
}
}

Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_traverse/src/context/scoping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,22 +327,22 @@ impl TraverseScoping {
self.create_reference(name, symbol_id, flag)
}

/// Clone `IdentifierReference` based on the original reference's `SymbolId`, name, and flag.
/// Clone `IdentifierReference` based on the original reference's `SymbolId` and name.
///
/// This method makes a lookup of the `SymbolId` for the reference. If you need to create multiple
/// `IdentifierReference`s for the same binding, it is better to look up the `SymbolId` only once,
/// and generate `IdentifierReference`s with `TraverseCtx::create_reference_id`.
pub fn clone_identifier_reference<'a>(
&mut self,
ident: &IdentifierReference<'a>,
flag: ReferenceFlag,
) -> IdentifierReference<'a> {
let reference =
self.symbols().get_reference(ident.reference_id.get().unwrap_or_else(|| {
unreachable!("IdentifierReference must have a reference_id");
}));
let symbol_id = reference.symbol_id();
let flag = reference.flag();
self.create_reference_id(ident.span, ident.name.clone(), symbol_id, *flag)
self.create_reference_id(ident.span, ident.name.clone(), symbol_id, flag)
}
}

Expand Down

0 comments on commit 9c00f30

Please sign in to comment.