Fully remove old macro descension API

This commit is contained in:
Lukas Wirth 2024-08-22 16:18:01 +02:00
parent 495118015e
commit 64064907ce
13 changed files with 66 additions and 103 deletions

View file

@ -3,7 +3,7 @@
use std::collections::VecDeque;
use base_db::SourceRootDatabase;
use hir::{Crate, DescendPreference, ItemInNs, ModuleDef, Name, Semantics};
use hir::{Crate, ItemInNs, ModuleDef, Name, Semantics};
use span::{Edition, FileId};
use syntax::{
ast::{self, make},
@ -112,11 +112,12 @@ pub fn is_editable_crate(krate: Crate, db: &RootDatabase) -> bool {
!db.source_root(source_root_id).is_library
}
// FIXME: This is a weird function
pub fn get_definition(
sema: &Semantics<'_, RootDatabase>,
token: SyntaxToken,
) -> Option<Definition> {
for token in sema.descend_into_macros(DescendPreference::None, token) {
for token in sema.descend_into_macros_exact(token) {
let def = IdentClass::classify_token(sema, &token).map(IdentClass::definitions_no_ops);
if let Some(&[x]) = def.as_deref() {
return Some(x);