diff options
Diffstat (limited to 'crates/ra_ide/src/references/classify.rs')
-rw-r--r-- | crates/ra_ide/src/references/classify.rs | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/crates/ra_ide/src/references/classify.rs b/crates/ra_ide/src/references/classify.rs index d0f03d8a8..2394e68d1 100644 --- a/crates/ra_ide/src/references/classify.rs +++ b/crates/ra_ide/src/references/classify.rs | |||
@@ -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_module_def(sb.db, func.into(), None)); | 25 | return Some(from_module_def(sb.db, func.into())); |
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 | ||
@@ -43,7 +43,6 @@ pub(crate) fn classify_name_ref( | |||
43 | 43 | ||
44 | // FIXME: find correct container and visibility for each case | 44 | // FIXME: find correct container and visibility for each case |
45 | let visibility = None; | 45 | let visibility = None; |
46 | let container = sb.to_module_def(name_ref.file_id.original_file(sb.db))?; | ||
47 | 46 | ||
48 | if let Some(macro_call) = parent.ancestors().find_map(ast::MacroCall::cast) { | 47 | if let Some(macro_call) = parent.ancestors().find_map(ast::MacroCall::cast) { |
49 | tested_by!(goto_def_for_macros); | 48 | tested_by!(goto_def_for_macros); |
@@ -51,40 +50,37 @@ pub(crate) fn classify_name_ref( | |||
51 | analyzer.resolve_macro_call(sb.db, name_ref.with_value(¯o_call)) | 50 | analyzer.resolve_macro_call(sb.db, name_ref.with_value(¯o_call)) |
52 | { | 51 | { |
53 | let kind = NameKind::Macro(macro_def); | 52 | let kind = NameKind::Macro(macro_def); |
54 | return Some(NameDefinition { kind, container, visibility }); | 53 | return Some(NameDefinition { kind, visibility }); |
55 | } | 54 | } |
56 | } | 55 | } |
57 | 56 | ||
58 | let path = name_ref.value.syntax().ancestors().find_map(ast::Path::cast)?; | 57 | let path = name_ref.value.syntax().ancestors().find_map(ast::Path::cast)?; |
59 | let resolved = analyzer.resolve_path(sb.db, &path)?; | 58 | let resolved = analyzer.resolve_path(sb.db, &path)?; |
60 | let res = match resolved { | 59 | let res = match resolved { |
61 | PathResolution::Def(def) => from_module_def(sb.db, def, Some(container)), | 60 | PathResolution::Def(def) => from_module_def(sb.db, def), |
62 | PathResolution::AssocItem(item) => { | 61 | PathResolution::AssocItem(item) => { |
63 | let def = match item { | 62 | let def = match item { |
64 | hir::AssocItem::Function(it) => it.into(), | 63 | hir::AssocItem::Function(it) => it.into(), |
65 | hir::AssocItem::Const(it) => it.into(), | 64 | hir::AssocItem::Const(it) => it.into(), |
66 | hir::AssocItem::TypeAlias(it) => it.into(), | 65 | hir::AssocItem::TypeAlias(it) => it.into(), |
67 | }; | 66 | }; |
68 | from_module_def(sb.db, def, Some(container)) | 67 | from_module_def(sb.db, def) |
69 | } | 68 | } |
70 | PathResolution::Local(local) => { | 69 | PathResolution::Local(local) => { |
71 | let kind = NameKind::Local(local); | 70 | let kind = NameKind::Local(local); |
72 | let container = local.module(sb.db); | 71 | NameDefinition { kind, visibility: None } |
73 | NameDefinition { kind, container, visibility: None } | ||
74 | } | 72 | } |
75 | PathResolution::TypeParam(par) => { | 73 | PathResolution::TypeParam(par) => { |
76 | let kind = NameKind::TypeParam(par); | 74 | let kind = NameKind::TypeParam(par); |
77 | let container = par.module(sb.db); | 75 | NameDefinition { kind, visibility } |
78 | NameDefinition { kind, container, visibility } | ||
79 | } | 76 | } |
80 | PathResolution::Macro(def) => { | 77 | PathResolution::Macro(def) => { |
81 | let kind = NameKind::Macro(def); | 78 | let kind = NameKind::Macro(def); |
82 | NameDefinition { kind, container, visibility } | 79 | NameDefinition { kind, visibility } |
83 | } | 80 | } |
84 | PathResolution::SelfType(impl_block) => { | 81 | PathResolution::SelfType(impl_block) => { |
85 | let kind = NameKind::SelfType(impl_block); | 82 | let kind = NameKind::SelfType(impl_block); |
86 | let container = impl_block.module(sb.db); | 83 | NameDefinition { kind, visibility } |
87 | NameDefinition { kind, container, visibility } | ||
88 | } | 84 | } |
89 | }; | 85 | }; |
90 | Some(res) | 86 | Some(res) |