diff options
author | Florian Diebold <[email protected]> | 2019-09-14 15:26:03 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-09-17 18:47:45 +0100 |
commit | 828d60574f8ecbc33fe4987913c6f713e41af1ae (patch) | |
tree | cd51badc345665f6d1ea5eb09cb9a00ff4093b73 /crates/ra_ide_api/src | |
parent | 913ab1ec0ad10873134ca429c1496806a9261206 (diff) |
Refactor a bit to prepare for resolving trait assoc items
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/display/navigation_target.rs | 15 | ||||
-rw-r--r-- | crates/ra_ide_api/src/goto_definition.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/hover.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide_api/src/name_ref_kind.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/syntax_highlighting.rs | 6 |
5 files changed, 17 insertions, 14 deletions
diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs index 03382ab3c..11f73ccfd 100644 --- a/crates/ra_ide_api/src/display/navigation_target.rs +++ b/crates/ra_ide_api/src/display/navigation_target.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use hir::{FieldSource, HasSource, ImplItem, ModuleSource}; | 1 | use hir::{AssocItem, FieldSource, HasSource, ModuleSource}; |
2 | use ra_db::{FileId, SourceDatabase}; | 2 | use ra_db::{FileId, SourceDatabase}; |
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | algo::visit::{visitor, Visitor}, | 4 | algo::visit::{visitor, Visitor}, |
@@ -221,11 +221,14 @@ impl NavigationTarget { | |||
221 | ) | 221 | ) |
222 | } | 222 | } |
223 | 223 | ||
224 | pub(crate) fn from_impl_item(db: &RootDatabase, impl_item: hir::ImplItem) -> NavigationTarget { | 224 | pub(crate) fn from_assoc_item( |
225 | match impl_item { | 225 | db: &RootDatabase, |
226 | ImplItem::Method(it) => NavigationTarget::from_def_source(db, it), | 226 | assoc_item: hir::AssocItem, |
227 | ImplItem::Const(it) => NavigationTarget::from_def_source(db, it), | 227 | ) -> NavigationTarget { |
228 | ImplItem::TypeAlias(it) => NavigationTarget::from_def_source(db, it), | 228 | match assoc_item { |
229 | AssocItem::Function(it) => NavigationTarget::from_def_source(db, it), | ||
230 | AssocItem::Const(it) => NavigationTarget::from_def_source(db, it), | ||
231 | AssocItem::TypeAlias(it) => NavigationTarget::from_def_source(db, it), | ||
229 | } | 232 | } |
230 | } | 233 | } |
231 | 234 | ||
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index 28529a2de..503dcacff 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs | |||
@@ -60,7 +60,7 @@ pub(crate) fn reference_definition( | |||
60 | match classify_name_ref(db, &analyzer, name_ref) { | 60 | match classify_name_ref(db, &analyzer, name_ref) { |
61 | Some(Macro(mac)) => return Exact(NavigationTarget::from_macro_def(db, mac)), | 61 | Some(Macro(mac)) => return Exact(NavigationTarget::from_macro_def(db, mac)), |
62 | Some(FieldAccess(field)) => return Exact(NavigationTarget::from_field(db, field)), | 62 | Some(FieldAccess(field)) => return Exact(NavigationTarget::from_field(db, field)), |
63 | Some(AssocItem(assoc)) => return Exact(NavigationTarget::from_impl_item(db, assoc)), | 63 | Some(AssocItem(assoc)) => return Exact(NavigationTarget::from_assoc_item(db, assoc)), |
64 | Some(Method(func)) => return Exact(NavigationTarget::from_def_source(db, func)), | 64 | Some(Method(func)) => return Exact(NavigationTarget::from_def_source(db, func)), |
65 | Some(Def(def)) => match NavigationTarget::from_def(db, def) { | 65 | Some(Def(def)) => match NavigationTarget::from_def(db, def) { |
66 | Some(nav) => return Exact(nav), | 66 | Some(nav) => return Exact(nav), |
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs index 28a6bef12..655bcdb16 100644 --- a/crates/ra_ide_api/src/hover.rs +++ b/crates/ra_ide_api/src/hover.rs | |||
@@ -117,9 +117,9 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn | |||
117 | } | 117 | } |
118 | } | 118 | } |
119 | Some(AssocItem(it)) => res.extend(match it { | 119 | Some(AssocItem(it)) => res.extend(match it { |
120 | hir::ImplItem::Method(it) => from_def_source(db, it), | 120 | hir::AssocItem::Function(it) => from_def_source(db, it), |
121 | hir::ImplItem::Const(it) => from_def_source(db, it), | 121 | hir::AssocItem::Const(it) => from_def_source(db, it), |
122 | hir::ImplItem::TypeAlias(it) => from_def_source(db, it), | 122 | hir::AssocItem::TypeAlias(it) => from_def_source(db, it), |
123 | }), | 123 | }), |
124 | Some(Def(it)) => { | 124 | Some(Def(it)) => { |
125 | match it { | 125 | match it { |
diff --git a/crates/ra_ide_api/src/name_ref_kind.rs b/crates/ra_ide_api/src/name_ref_kind.rs index 6c2a7b260..aff03464a 100644 --- a/crates/ra_ide_api/src/name_ref_kind.rs +++ b/crates/ra_ide_api/src/name_ref_kind.rs | |||
@@ -8,7 +8,7 @@ pub enum NameRefKind { | |||
8 | Method(hir::Function), | 8 | Method(hir::Function), |
9 | Macro(hir::MacroDef), | 9 | Macro(hir::MacroDef), |
10 | FieldAccess(hir::StructField), | 10 | FieldAccess(hir::StructField), |
11 | AssocItem(hir::ImplItem), | 11 | AssocItem(hir::AssocItem), |
12 | Def(hir::ModuleDef), | 12 | Def(hir::ModuleDef), |
13 | SelfType(hir::Ty), | 13 | SelfType(hir::Ty), |
14 | Pat(AstPtr<ast::BindPat>), | 14 | Pat(AstPtr<ast::BindPat>), |
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs index 86ab3a260..3d7f91c1d 100644 --- a/crates/ra_ide_api/src/syntax_highlighting.rs +++ b/crates/ra_ide_api/src/syntax_highlighting.rs | |||
@@ -102,9 +102,9 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa | |||
102 | Some(Method(_)) => "function", | 102 | Some(Method(_)) => "function", |
103 | Some(Macro(_)) => "macro", | 103 | Some(Macro(_)) => "macro", |
104 | Some(FieldAccess(_)) => "field", | 104 | Some(FieldAccess(_)) => "field", |
105 | Some(AssocItem(hir::ImplItem::Method(_))) => "function", | 105 | Some(AssocItem(hir::AssocItem::Function(_))) => "function", |
106 | Some(AssocItem(hir::ImplItem::Const(_))) => "constant", | 106 | Some(AssocItem(hir::AssocItem::Const(_))) => "constant", |
107 | Some(AssocItem(hir::ImplItem::TypeAlias(_))) => "type", | 107 | Some(AssocItem(hir::AssocItem::TypeAlias(_))) => "type", |
108 | Some(Def(hir::ModuleDef::Module(_))) => "module", | 108 | Some(Def(hir::ModuleDef::Module(_))) => "module", |
109 | Some(Def(hir::ModuleDef::Function(_))) => "function", | 109 | Some(Def(hir::ModuleDef::Function(_))) => "function", |
110 | Some(Def(hir::ModuleDef::Adt(_))) => "type", | 110 | Some(Def(hir::ModuleDef::Adt(_))) => "type", |