mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
refactor(transformer): use identifier_reference_with_reference_id builder method (#7056)
Similar to #7055. In transformer, use `AstBuilder::identifier_reference_with_reference_id` function, instead of creating an `IdentifierReference` and then setting the `reference_id` on it afterwards.
This commit is contained in:
parent
4688a061ae
commit
9d384ad6db
1 changed files with 12 additions and 6 deletions
|
|
@ -63,20 +63,26 @@ impl<'a> RefreshIdentifierResolver<'a> {
|
|||
pub fn to_expression(&self, ctx: &mut TraverseCtx<'a>) -> Expression<'a> {
|
||||
match self {
|
||||
Self::Identifier(ident) => {
|
||||
let ident = ident.clone();
|
||||
let reference_id =
|
||||
ctx.create_unbound_reference(ident.name.to_compact_str(), ReferenceFlags::Read);
|
||||
ident.reference_id.set(Some(reference_id));
|
||||
ctx.ast.expression_from_identifier_reference(ident)
|
||||
Expression::Identifier(ctx.ast.alloc_identifier_reference_with_reference_id(
|
||||
ident.span,
|
||||
ident.name.clone(),
|
||||
reference_id,
|
||||
))
|
||||
}
|
||||
Self::Member((ident, property)) => {
|
||||
let ident = ident.clone();
|
||||
let reference_id =
|
||||
ctx.create_unbound_reference(ident.name.to_compact_str(), ReferenceFlags::Read);
|
||||
ident.reference_id.set(Some(reference_id));
|
||||
let ident =
|
||||
Expression::Identifier(ctx.ast.alloc_identifier_reference_with_reference_id(
|
||||
ident.span,
|
||||
ident.name.clone(),
|
||||
reference_id,
|
||||
));
|
||||
Expression::from(ctx.ast.member_expression_static(
|
||||
SPAN,
|
||||
ctx.ast.expression_from_identifier_reference(ident),
|
||||
ident,
|
||||
property.clone(),
|
||||
false,
|
||||
))
|
||||
|
|
|
|||
Loading…
Reference in a new issue