This commit is contained in:
Aleksey Kladov 2020-02-25 13:49:34 +01:00
parent 3853a3b643
commit 6542ab89ce
2 changed files with 7 additions and 15 deletions

View file

@ -4,16 +4,11 @@ use indexmap::IndexMap;
use hir::db::AstDatabase; use hir::db::AstDatabase;
use ra_ide_db::RootDatabase; use ra_ide_db::RootDatabase;
use ra_syntax::{ use ra_syntax::{ast, match_ast, AstNode, TextRange};
ast::{self, DocCommentsOwner},
match_ast, AstNode, TextRange,
};
use crate::{ use crate::{
call_info::FnCallNode, call_info::FnCallNode, display::ToNav, expand::descend_into_macros, goto_definition,
display::{ShortLabel, ToNav}, references, FilePosition, NavigationTarget, RangeInfo,
expand::descend_into_macros,
goto_definition, references, FilePosition, NavigationTarget, RangeInfo,
}; };
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -49,6 +44,7 @@ pub(crate) fn incoming_calls(db: &RootDatabase, position: FilePosition) -> Optio
let refs = references::find_all_refs(db, position, None)?; let refs = references::find_all_refs(db, position, None)?;
let mut calls = CallLocations::default(); let mut calls = CallLocations::default();
let mut sb = hir::SourceBinder::new(db);
for reference in refs.info.references() { for reference in refs.info.references() {
let file_id = reference.file_range.file_id; let file_id = reference.file_range.file_id;
@ -62,12 +58,8 @@ pub(crate) fn incoming_calls(db: &RootDatabase, position: FilePosition) -> Optio
match_ast! { match_ast! {
match node { match node {
ast::FnDef(it) => { ast::FnDef(it) => {
Some(NavigationTarget::from_named( let def = sb.to_def(token.with_value(it))?;
db, Some(def.to_nav(sb.db))
token.with_value(&it),
it.doc_comment_text(),
it.short_label(),
))
}, },
_ => { None }, _ => { None },
} }

View file

@ -125,7 +125,7 @@ impl NavigationTarget {
} }
/// Allows `NavigationTarget` to be created from a `NameOwner` /// Allows `NavigationTarget` to be created from a `NameOwner`
pub(crate) fn from_named( fn from_named(
db: &RootDatabase, db: &RootDatabase,
node: InFile<&dyn ast::NameOwner>, node: InFile<&dyn ast::NameOwner>,
docs: Option<String>, docs: Option<String>,