mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
cleanup + docs + tests
This commit is contained in:
parent
c43cfefdd8
commit
4d5c66986e
7 changed files with 320 additions and 60 deletions
|
@ -3,13 +3,14 @@
|
|||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use hir::{db::HirDatabase, Crate, Module, Semantics};
|
||||
use hir::{db::HirDatabase, Crate, Module};
|
||||
use ide_db::helpers::get_definition;
|
||||
use ide_db::{
|
||||
base_db::{FileId, FileRange, SourceDatabaseExt},
|
||||
defs::{Definition, IdentClass},
|
||||
defs::Definition,
|
||||
FxHashSet, RootDatabase,
|
||||
};
|
||||
use syntax::{AstNode, SyntaxKind::*, SyntaxToken, TextRange, T};
|
||||
use syntax::{AstNode, SyntaxKind::*, TextRange, T};
|
||||
|
||||
use crate::{
|
||||
hover::hover_for_definition,
|
||||
|
@ -214,16 +215,6 @@ impl StaticIndex<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_definition(sema: &Semantics<'_, RootDatabase>, token: SyntaxToken) -> Option<Definition> {
|
||||
for token in sema.descend_into_macros(token) {
|
||||
let def = IdentClass::classify_token(sema, &token).map(IdentClass::definitions_no_ops);
|
||||
if let Some(&[it]) = def.as_deref() {
|
||||
return Some(it);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{fixture, StaticIndex};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue