Skip to content

Commit 6542ab8

Browse files
committed
Simplify
1 parent 3853a3b commit 6542ab8

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

crates/ra_ide/src/call_hierarchy.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@ use indexmap::IndexMap;
44

55
use hir::db::AstDatabase;
66
use ra_ide_db::RootDatabase;
7-
use ra_syntax::{
8-
ast::{self, DocCommentsOwner},
9-
match_ast, AstNode, TextRange,
10-
};
7+
use ra_syntax::{ast, match_ast, AstNode, TextRange};
118

129
use crate::{
13-
call_info::FnCallNode,
14-
display::{ShortLabel, ToNav},
15-
expand::descend_into_macros,
16-
goto_definition, references, FilePosition, NavigationTarget, RangeInfo,
10+
call_info::FnCallNode, display::ToNav, expand::descend_into_macros, goto_definition,
11+
references, FilePosition, NavigationTarget, RangeInfo,
1712
};
1813

1914
#[derive(Debug, Clone)]
@@ -49,6 +44,7 @@ pub(crate) fn incoming_calls(db: &RootDatabase, position: FilePosition) -> Optio
4944
let refs = references::find_all_refs(db, position, None)?;
5045

5146
let mut calls = CallLocations::default();
47+
let mut sb = hir::SourceBinder::new(db);
5248

5349
for reference in refs.info.references() {
5450
let file_id = reference.file_range.file_id;
@@ -62,12 +58,8 @@ pub(crate) fn incoming_calls(db: &RootDatabase, position: FilePosition) -> Optio
6258
match_ast! {
6359
match node {
6460
ast::FnDef(it) => {
65-
Some(NavigationTarget::from_named(
66-
db,
67-
token.with_value(&it),
68-
it.doc_comment_text(),
69-
it.short_label(),
70-
))
61+
let def = sb.to_def(token.with_value(it))?;
62+
Some(def.to_nav(sb.db))
7163
},
7264
_ => { None },
7365
}

crates/ra_ide/src/display/navigation_target.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl NavigationTarget {
125125
}
126126

127127
/// Allows `NavigationTarget` to be created from a `NameOwner`
128-
pub(crate) fn from_named(
128+
fn from_named(
129129
db: &RootDatabase,
130130
node: InFile<&dyn ast::NameOwner>,
131131
docs: Option<String>,

0 commit comments

Comments
 (0)