Remove lossy Definition::from_token/Definition::from_node methods

This commit is contained in:
Lukas Wirth 2022-01-04 18:29:20 +01:00
parent 68bc12c3b8
commit c5a9985fc5
6 changed files with 91 additions and 92 deletions

View file

@ -6,7 +6,7 @@ use std::collections::HashMap;
use hir::{db::HirDatabase, Crate, Module, Semantics};
use ide_db::{
base_db::{FileId, FileRange, SourceDatabaseExt},
defs::Definition,
defs::{Definition, IdentClass},
RootDatabase,
};
use rustc_hash::FxHashSet;
@ -195,9 +195,9 @@ impl StaticIndex<'_> {
fn get_definition(sema: &Semantics<RootDatabase>, token: SyntaxToken) -> Option<Definition> {
for token in sema.descend_into_macros(token) {
let def = Definition::from_token(sema, &token);
if let [x] = def.as_slice() {
return Some(*x);
let def = IdentClass::classify_token(sema, &token).map(IdentClass::definitions);
if let Some(&[x]) = def.as_deref() {
return Some(x);
} else {
continue;
};