aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/references
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-07 13:35:02 +0000
committerGitHub <[email protected]>2020-02-07 13:35:02 +0000
commit1996762b1f2b9cb196cc879f0ce26d28a3c450c8 (patch)
treee17cb26eb6da4c1832f4ae4fca10c57f100b546b /crates/ra_ide/src/references
parent8337dcd9e277feac8e9cff621c752a3e86ba19e6 (diff)
parentae70d072374f3c4d14abdccbe61661cf02b41b33 (diff)
Merge #3048
3048: Remove irrelevant distinction r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/references')
-rw-r--r--crates/ra_ide/src/references/classify.rs28
1 files changed, 18 insertions, 10 deletions
diff --git a/crates/ra_ide/src/references/classify.rs b/crates/ra_ide/src/references/classify.rs
index 0326fd379..d0f03d8a8 100644
--- a/crates/ra_ide/src/references/classify.rs
+++ b/crates/ra_ide/src/references/classify.rs
@@ -8,7 +8,7 @@ use test_utils::tested_by;
8use super::{NameDefinition, NameKind}; 8use super::{NameDefinition, NameKind};
9use ra_ide_db::RootDatabase; 9use ra_ide_db::RootDatabase;
10 10
11pub use ra_ide_db::defs::{classify_name, from_assoc_item, from_module_def, from_struct_field}; 11pub use ra_ide_db::defs::{classify_name, from_module_def, from_struct_field};
12 12
13pub(crate) fn classify_name_ref( 13pub(crate) fn classify_name_ref(
14 sb: &mut SourceBinder<RootDatabase>, 14 sb: &mut SourceBinder<RootDatabase>,
@@ -22,7 +22,7 @@ pub(crate) fn classify_name_ref(
22 if let Some(method_call) = ast::MethodCallExpr::cast(parent.clone()) { 22 if let Some(method_call) = ast::MethodCallExpr::cast(parent.clone()) {
23 tested_by!(goto_def_for_methods); 23 tested_by!(goto_def_for_methods);
24 if let Some(func) = analyzer.resolve_method_call(&method_call) { 24 if let Some(func) = analyzer.resolve_method_call(&method_call) {
25 return Some(from_assoc_item(sb.db, func.into())); 25 return Some(from_module_def(sb.db, func.into(), None));
26 } 26 }
27 } 27 }
28 28
@@ -57,27 +57,35 @@ pub(crate) fn classify_name_ref(
57 57
58 let path = name_ref.value.syntax().ancestors().find_map(ast::Path::cast)?; 58 let path = name_ref.value.syntax().ancestors().find_map(ast::Path::cast)?;
59 let resolved = analyzer.resolve_path(sb.db, &path)?; 59 let resolved = analyzer.resolve_path(sb.db, &path)?;
60 match resolved { 60 let res = match resolved {
61 PathResolution::Def(def) => Some(from_module_def(sb.db, def, Some(container))), 61 PathResolution::Def(def) => from_module_def(sb.db, def, Some(container)),
62 PathResolution::AssocItem(item) => Some(from_assoc_item(sb.db, item)), 62 PathResolution::AssocItem(item) => {
63 let def = match item {
64 hir::AssocItem::Function(it) => it.into(),
65 hir::AssocItem::Const(it) => it.into(),
66 hir::AssocItem::TypeAlias(it) => it.into(),
67 };
68 from_module_def(sb.db, def, Some(container))
69 }
63 PathResolution::Local(local) => { 70 PathResolution::Local(local) => {
64 let kind = NameKind::Local(local); 71 let kind = NameKind::Local(local);
65 let container = local.module(sb.db); 72 let container = local.module(sb.db);
66 Some(NameDefinition { kind, container, visibility: None }) 73 NameDefinition { kind, container, visibility: None }
67 } 74 }
68 PathResolution::TypeParam(par) => { 75 PathResolution::TypeParam(par) => {
69 let kind = NameKind::TypeParam(par); 76 let kind = NameKind::TypeParam(par);
70 let container = par.module(sb.db); 77 let container = par.module(sb.db);
71 Some(NameDefinition { kind, container, visibility }) 78 NameDefinition { kind, container, visibility }
72 } 79 }
73 PathResolution::Macro(def) => { 80 PathResolution::Macro(def) => {
74 let kind = NameKind::Macro(def); 81 let kind = NameKind::Macro(def);
75 Some(NameDefinition { kind, container, visibility }) 82 NameDefinition { kind, container, visibility }
76 } 83 }
77 PathResolution::SelfType(impl_block) => { 84 PathResolution::SelfType(impl_block) => {
78 let kind = NameKind::SelfType(impl_block); 85 let kind = NameKind::SelfType(impl_block);
79 let container = impl_block.module(sb.db); 86 let container = impl_block.module(sb.db);
80 Some(NameDefinition { kind, container, visibility }) 87 NameDefinition { kind, container, visibility }
81 } 88 }
82 } 89 };
90 Some(res)
83} 91}