Skip to content

Commit

Permalink
refactor(traverse): use symbol_id etc methods
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Nov 4, 2024
1 parent fd3b442 commit d219e50
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
3 changes: 1 addition & 2 deletions crates/oxc_traverse/src/context/bound_identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ impl<'a> BoundIdentifier<'a> {
}

/// Create `BoundIdentifier` from a `BindingIdentifier`
#[expect(clippy::missing_panics_doc)]
pub fn from_binding_ident(ident: &BindingIdentifier<'a>) -> Self {
Self { name: ident.name.clone(), symbol_id: ident.symbol_id.get().unwrap() }
Self { name: ident.name.clone(), symbol_id: ident.symbol_id() }
}

/// Create `BindingIdentifier` for this binding
Expand Down
5 changes: 1 addition & 4 deletions crates/oxc_traverse/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,7 @@ impl<'a> TraverseCtx<'a> {
ident: &IdentifierReference<'a>,
flags: ReferenceFlags,
) -> IdentifierReference<'a> {
let reference =
self.symbols().get_reference(ident.reference_id.get().unwrap_or_else(|| {
unreachable!("IdentifierReference must have a reference_id");
}));
let reference = self.symbols().get_reference(ident.reference_id());
let symbol_id = reference.symbol_id();
self.create_reference_id(ident.span, ident.name.clone(), symbol_id, flags)
}
Expand Down
14 changes: 7 additions & 7 deletions crates/oxc_traverse/src/context/scoping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,13 @@ impl TraverseScoping {
pub fn is_static(&self, expr: &Expression) -> bool {
match expr {
Expression::ThisExpression(_) | Expression::Super(_) => true,
Expression::Identifier(ident) => self
.symbols
.get_reference(ident.reference_id.get().unwrap())
.symbol_id()
.is_some_and(|symbol_id| {
self.symbols.get_resolved_references(symbol_id).all(|r| !r.is_write())
}),
Expression::Identifier(ident) => {
self.symbols.get_reference(ident.reference_id()).symbol_id().is_some_and(
|symbol_id| {
self.symbols.get_resolved_references(symbol_id).all(|r| !r.is_write())
},
)
}
_ => false,
}
}
Expand Down

0 comments on commit d219e50

Please sign in to comment.