Skip to content

Commit

Permalink
refactor(semantic): methods take Span as param, not &Span
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Jul 25, 2024
1 parent eeb0b99 commit 6b39374
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/rules/import/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl Rule for Namespace {
}

let Some(symbol_id) =
ctx.semantic().symbols().get_symbol_id_from_span(&entry.local_name.span())
ctx.semantic().symbols().get_symbol_id_from_span(entry.local_name.span())
else {
return;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl Rule for NoNamedAsDefaultMember {

if !remote_module_record_ref.exported_bindings.is_empty() {
has_members_map.insert(
ctx.symbols().get_symbol_id_from_span(&import_entry.local_name.span()).unwrap(),
ctx.symbols().get_symbol_id_from_span(import_entry.local_name.span()).unwrap(),
(remote_module_record_ref, import_entry.module_request.name().clone()),
);
}
Expand Down
6 changes: 3 additions & 3 deletions crates/oxc_semantic/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ impl SymbolTable {
self.spans.iter_enumerated().rev().map(|(symbol_id, _)| symbol_id)
}

pub fn get_symbol_id_from_span(&self, span: &Span) -> Option<SymbolId> {
pub fn get_symbol_id_from_span(&self, span: Span) -> Option<SymbolId> {
self.spans
.iter_enumerated()
.find_map(|(symbol, inner_span)| if inner_span == span { Some(symbol) } else { None })
.find_map(|(symbol, &inner_span)| if inner_span == span { Some(symbol) } else { None })
}

pub fn get_symbol_id_from_name(&self, name: &str) -> Option<SymbolId> {
Expand Down Expand Up @@ -113,7 +113,7 @@ impl SymbolTable {
self.scope_ids[symbol_id]
}

pub fn get_scope_id_from_span(&self, span: &Span) -> Option<ScopeId> {
pub fn get_scope_id_from_span(&self, span: Span) -> Option<ScopeId> {
self.get_symbol_id_from_span(span).map(|symbol_id| self.get_scope_id(symbol_id))
}

Expand Down

0 comments on commit 6b39374

Please sign in to comment.