diff options
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r-- | crates/ra_ide_api/src/completion/presentation.rs | 5 | ||||
-rw-r--r-- | crates/ra_ide_api/src/display/navigation_target.rs | 20 | ||||
-rw-r--r-- | crates/ra_ide_api/src/hover.rs | 18 |
3 files changed, 10 insertions, 33 deletions
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index 8c4d7127b..495899262 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs | |||
@@ -141,13 +141,12 @@ impl Completions { | |||
141 | } | 141 | } |
142 | 142 | ||
143 | pub(crate) fn add_type_alias(&mut self, ctx: &CompletionContext, type_alias: hir::TypeAlias) { | 143 | pub(crate) fn add_type_alias(&mut self, ctx: &CompletionContext, type_alias: hir::TypeAlias) { |
144 | let (_file_id, type_def) = type_alias.source(ctx.db); | 144 | let type_def = type_alias.source(ctx.db).ast; |
145 | let name = match type_def.name() { | 145 | let name = match type_def.name() { |
146 | Some(name) => name, | 146 | Some(name) => name, |
147 | _ => return, | 147 | _ => return, |
148 | }; | 148 | }; |
149 | let (_, ast_node) = type_alias.source(ctx.db); | 149 | let detail = type_label(&type_def); |
150 | let detail = type_label(&ast_node); | ||
151 | 150 | ||
152 | CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.text().to_string()) | 151 | CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.text().to_string()) |
153 | .kind(CompletionItemKind::TypeAlias) | 152 | .kind(CompletionItemKind::TypeAlias) |
diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs index a036a3b36..19a64f300 100644 --- a/crates/ra_ide_api/src/display/navigation_target.rs +++ b/crates/ra_ide_api/src/display/navigation_target.rs | |||
@@ -232,15 +232,7 @@ impl NavigationTarget { | |||
232 | node.short_label(), | 232 | node.short_label(), |
233 | ) | 233 | ) |
234 | } | 234 | } |
235 | hir::ModuleDef::TypeAlias(e) => { | 235 | hir::ModuleDef::TypeAlias(it) => NavigationTarget::from_def_source(db, it), |
236 | let (file_id, node) = e.source(db); | ||
237 | NavigationTarget::from_named( | ||
238 | file_id.original_file(db), | ||
239 | &*node, | ||
240 | node.doc_comment_text(), | ||
241 | node.short_label(), | ||
242 | ) | ||
243 | } | ||
244 | hir::ModuleDef::BuiltinType(..) => { | 236 | hir::ModuleDef::BuiltinType(..) => { |
245 | return None; | 237 | return None; |
246 | } | 238 | } |
@@ -267,15 +259,7 @@ impl NavigationTarget { | |||
267 | match impl_item { | 259 | match impl_item { |
268 | ImplItem::Method(it) => NavigationTarget::from_function(db, it), | 260 | ImplItem::Method(it) => NavigationTarget::from_function(db, it), |
269 | ImplItem::Const(it) => NavigationTarget::from_def_source(db, it), | 261 | ImplItem::Const(it) => NavigationTarget::from_def_source(db, it), |
270 | ImplItem::TypeAlias(a) => { | 262 | ImplItem::TypeAlias(it) => NavigationTarget::from_def_source(db, it), |
271 | let (file_id, node) = a.source(db); | ||
272 | NavigationTarget::from_named( | ||
273 | file_id.original_file(db), | ||
274 | &*node, | ||
275 | node.doc_comment_text(), | ||
276 | node.short_label(), | ||
277 | ) | ||
278 | } | ||
279 | } | 263 | } |
280 | } | 264 | } |
281 | 265 | ||
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs index 0f68cacca..c4826e515 100644 --- a/crates/ra_ide_api/src/hover.rs +++ b/crates/ra_ide_api/src/hover.rs | |||
@@ -107,14 +107,11 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn | |||
107 | res.extend(hover_text(it.doc_comment_text(), it.short_label())); | 107 | res.extend(hover_text(it.doc_comment_text(), it.short_label())); |
108 | } | 108 | } |
109 | } | 109 | } |
110 | Some(AssocItem(it)) => match it { | 110 | Some(AssocItem(it)) => res.extend(match it { |
111 | hir::ImplItem::Method(it) => res.extend(from_def_source(db, it)), | 111 | hir::ImplItem::Method(it) => from_def_source(db, it), |
112 | hir::ImplItem::Const(it) => res.extend(from_def_source(db, it)), | 112 | hir::ImplItem::Const(it) => from_def_source(db, it), |
113 | hir::ImplItem::TypeAlias(it) => { | 113 | hir::ImplItem::TypeAlias(it) => from_def_source(db, it), |
114 | let it = it.source(db).1; | 114 | }), |
115 | res.extend(hover_text(it.doc_comment_text(), it.short_label())) | ||
116 | } | ||
117 | }, | ||
118 | Some(Def(it)) => { | 115 | Some(Def(it)) => { |
119 | match it { | 116 | match it { |
120 | hir::ModuleDef::Module(it) => { | 117 | hir::ModuleDef::Module(it) => { |
@@ -137,10 +134,7 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn | |||
137 | let it = it.source(db).1; | 134 | let it = it.source(db).1; |
138 | res.extend(hover_text(it.doc_comment_text(), it.short_label())) | 135 | res.extend(hover_text(it.doc_comment_text(), it.short_label())) |
139 | } | 136 | } |
140 | hir::ModuleDef::TypeAlias(it) => { | 137 | hir::ModuleDef::TypeAlias(it) => res.extend(from_def_source(db, it)), |
141 | let it = it.source(db).1; | ||
142 | res.extend(hover_text(it.doc_comment_text(), it.short_label())) | ||
143 | } | ||
144 | hir::ModuleDef::BuiltinType(_) => { | 138 | hir::ModuleDef::BuiltinType(_) => { |
145 | // FIXME: hover for builtin Type ? | 139 | // FIXME: hover for builtin Type ? |
146 | } | 140 | } |