From 6542ab89ceb32d6ec108a28ad9d938d24762c029 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 25 Feb 2020 13:49:34 +0100 Subject: Simplify --- crates/ra_ide/src/call_hierarchy.rs | 20 ++++++-------------- crates/ra_ide/src/display/navigation_target.rs | 2 +- 2 files changed, 7 insertions(+), 15 deletions(-) (limited to 'crates/ra_ide') diff --git a/crates/ra_ide/src/call_hierarchy.rs b/crates/ra_ide/src/call_hierarchy.rs index f984f40ad..51ac59a71 100644 --- a/crates/ra_ide/src/call_hierarchy.rs +++ b/crates/ra_ide/src/call_hierarchy.rs @@ -4,16 +4,11 @@ use indexmap::IndexMap; use hir::db::AstDatabase; use ra_ide_db::RootDatabase; -use ra_syntax::{ - ast::{self, DocCommentsOwner}, - match_ast, AstNode, TextRange, -}; +use ra_syntax::{ast, match_ast, AstNode, TextRange}; use crate::{ - call_info::FnCallNode, - display::{ShortLabel, ToNav}, - expand::descend_into_macros, - goto_definition, references, FilePosition, NavigationTarget, RangeInfo, + call_info::FnCallNode, display::ToNav, expand::descend_into_macros, goto_definition, + references, FilePosition, NavigationTarget, RangeInfo, }; #[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 mut calls = CallLocations::default(); + let mut sb = hir::SourceBinder::new(db); for reference in refs.info.references() { 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 node { ast::FnDef(it) => { - Some(NavigationTarget::from_named( - db, - token.with_value(&it), - it.doc_comment_text(), - it.short_label(), - )) + let def = sb.to_def(token.with_value(it))?; + Some(def.to_nav(sb.db)) }, _ => { None }, } diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index b42cb477e..c9d0058a6 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs @@ -125,7 +125,7 @@ impl NavigationTarget { } /// Allows `NavigationTarget` to be created from a `NameOwner` - pub(crate) fn from_named( + fn from_named( db: &RootDatabase, node: InFile<&dyn ast::NameOwner>, docs: Option, -- cgit v1.2.3