diff options
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_path.rs | 7 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/completion_item.rs | 8 | ||||
-rw-r--r-- | crates/ra_ide_api/src/navigation_target.rs | 59 |
3 files changed, 32 insertions, 42 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index bd5484516..e72586e2e 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs | |||
@@ -40,12 +40,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { | |||
40 | .add_to(acc) | 40 | .add_to(acc) |
41 | }); | 41 | }); |
42 | } | 42 | } |
43 | hir::ModuleDef::Function(_) | 43 | _ => return, |
44 | | hir::ModuleDef::Struct(_) | ||
45 | | hir::ModuleDef::Def(_) | ||
46 | | hir::ModuleDef::Const(_) | ||
47 | | hir::ModuleDef::Static(_) | ||
48 | | hir::ModuleDef::EnumVariant(_) => return, | ||
49 | }; | 44 | }; |
50 | } | 45 | } |
51 | 46 | ||
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index 2f8ec41d2..4e679281c 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs | |||
@@ -225,11 +225,9 @@ impl Builder { | |||
225 | hir::ModuleDef::EnumVariant(it) => (CompletionItemKind::EnumVariant, it.docs(ctx.db)), | 225 | hir::ModuleDef::EnumVariant(it) => (CompletionItemKind::EnumVariant, it.docs(ctx.db)), |
226 | hir::ModuleDef::Const(it) => (CompletionItemKind::Const, it.docs(ctx.db)), | 226 | hir::ModuleDef::Const(it) => (CompletionItemKind::Const, it.docs(ctx.db)), |
227 | hir::ModuleDef::Static(it) => (CompletionItemKind::Static, it.docs(ctx.db)), | 227 | hir::ModuleDef::Static(it) => (CompletionItemKind::Static, it.docs(ctx.db)), |
228 | hir::ModuleDef::Def(def_id) => match def_id.resolve(ctx.db) { | 228 | hir::ModuleDef::Trait(it) => (CompletionItemKind::Trait, it.docs(ctx.db)), |
229 | hir::Def::Trait(it) => (CompletionItemKind::Trait, it.docs(ctx.db)), | 229 | hir::ModuleDef::Type(it) => (CompletionItemKind::TypeAlias, it.docs(ctx.db)), |
230 | hir::Def::Type(it) => (CompletionItemKind::TypeAlias, it.docs(ctx.db)), | 230 | hir::ModuleDef::Def(_) => return self, |
231 | _ => return self, | ||
232 | }, | ||
233 | }; | 231 | }; |
234 | self.kind = Some(kind); | 232 | self.kind = Some(kind); |
235 | self.documentation = docs; | 233 | self.documentation = docs; |
diff --git a/crates/ra_ide_api/src/navigation_target.rs b/crates/ra_ide_api/src/navigation_target.rs index 8406fee31..2e11d2de3 100644 --- a/crates/ra_ide_api/src/navigation_target.rs +++ b/crates/ra_ide_api/src/navigation_target.rs | |||
@@ -3,7 +3,7 @@ use ra_syntax::{ | |||
3 | SyntaxNode, AstNode, SmolStr, TextRange, ast, | 3 | SyntaxNode, AstNode, SmolStr, TextRange, ast, |
4 | SyntaxKind::{self, NAME}, | 4 | SyntaxKind::{self, NAME}, |
5 | }; | 5 | }; |
6 | use hir::{Def, ModuleSource}; | 6 | use hir::{ModuleSource}; |
7 | 7 | ||
8 | use crate::{FileSymbol, db::RootDatabase}; | 8 | use crate::{FileSymbol, db::RootDatabase}; |
9 | 9 | ||
@@ -106,63 +106,60 @@ impl NavigationTarget { | |||
106 | db: &RootDatabase, | 106 | db: &RootDatabase, |
107 | module_def: hir::ModuleDef, | 107 | module_def: hir::ModuleDef, |
108 | ) -> Option<NavigationTarget> { | 108 | ) -> Option<NavigationTarget> { |
109 | let def = match module_def { | 109 | match module_def { |
110 | hir::ModuleDef::Def(def_id) => def_id.resolve(db), | 110 | hir::ModuleDef::Def(_) => return None, |
111 | hir::ModuleDef::Module(module) => { | 111 | hir::ModuleDef::Module(module) => Some(NavigationTarget::from_module(db, module)), |
112 | return Some(NavigationTarget::from_module(db, module)); | 112 | hir::ModuleDef::Function(func) => Some(NavigationTarget::from_function(db, func)), |
113 | } | ||
114 | hir::ModuleDef::Function(func) => { | ||
115 | return Some(NavigationTarget::from_function(db, func)); | ||
116 | } | ||
117 | hir::ModuleDef::Struct(s) => { | 113 | hir::ModuleDef::Struct(s) => { |
118 | let (file_id, node) = s.source(db); | 114 | let (file_id, node) = s.source(db); |
119 | return Some(NavigationTarget::from_named( | 115 | Some(NavigationTarget::from_named( |
120 | file_id.original_file(db), | 116 | file_id.original_file(db), |
121 | &*node, | 117 | &*node, |
122 | )); | 118 | )) |
123 | } | 119 | } |
124 | hir::ModuleDef::Const(s) => { | 120 | hir::ModuleDef::Const(s) => { |
125 | let (file_id, node) = s.source(db); | 121 | let (file_id, node) = s.source(db); |
126 | return Some(NavigationTarget::from_named( | 122 | Some(NavigationTarget::from_named( |
127 | file_id.original_file(db), | 123 | file_id.original_file(db), |
128 | &*node, | 124 | &*node, |
129 | )); | 125 | )) |
130 | } | 126 | } |
131 | hir::ModuleDef::Static(s) => { | 127 | hir::ModuleDef::Static(s) => { |
132 | let (file_id, node) = s.source(db); | 128 | let (file_id, node) = s.source(db); |
133 | return Some(NavigationTarget::from_named( | 129 | Some(NavigationTarget::from_named( |
134 | file_id.original_file(db), | 130 | file_id.original_file(db), |
135 | &*node, | 131 | &*node, |
136 | )); | 132 | )) |
137 | } | 133 | } |
138 | hir::ModuleDef::Enum(e) => { | 134 | hir::ModuleDef::Enum(e) => { |
139 | let (file_id, node) = e.source(db); | 135 | let (file_id, node) = e.source(db); |
140 | return Some(NavigationTarget::from_named( | 136 | Some(NavigationTarget::from_named( |
141 | file_id.original_file(db), | 137 | file_id.original_file(db), |
142 | &*node, | 138 | &*node, |
143 | )); | 139 | )) |
144 | } | 140 | } |
145 | hir::ModuleDef::EnumVariant(var) => { | 141 | hir::ModuleDef::EnumVariant(var) => { |
146 | let (file_id, node) = var.source(db); | 142 | let (file_id, node) = var.source(db); |
147 | return Some(NavigationTarget::from_named( | 143 | Some(NavigationTarget::from_named( |
148 | file_id.original_file(db), | 144 | file_id.original_file(db), |
149 | &*node, | 145 | &*node, |
150 | )); | 146 | )) |
151 | } | 147 | } |
152 | }; | 148 | hir::ModuleDef::Trait(e) => { |
153 | 149 | let (file_id, node) = e.source(db); | |
154 | let res = match def { | 150 | Some(NavigationTarget::from_named( |
155 | Def::Trait(f) => { | 151 | file_id.original_file(db), |
156 | let (file_id, node) = f.source(db); | 152 | &*node, |
157 | NavigationTarget::from_named(file_id.original_file(db), &*node) | 153 | )) |
158 | } | 154 | } |
159 | Def::Type(f) => { | 155 | hir::ModuleDef::Type(e) => { |
160 | let (file_id, node) = f.source(db); | 156 | let (file_id, node) = e.source(db); |
161 | NavigationTarget::from_named(file_id.original_file(db), &*node) | 157 | Some(NavigationTarget::from_named( |
158 | file_id.original_file(db), | ||
159 | &*node, | ||
160 | )) | ||
162 | } | 161 | } |
163 | Def::Item => return None, | 162 | } |
164 | }; | ||
165 | Some(res) | ||
166 | } | 163 | } |
167 | 164 | ||
168 | #[cfg(test)] | 165 | #[cfg(test)] |