diff options
Diffstat (limited to 'crates/ra_ide_api/src/completion/presentation.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion/presentation.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index d405161d6..f4ff4404b 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! This modules takes care of rendering various defenitions as completion items. | 1 | //! This modules takes care of rendering various defenitions as completion items. |
2 | use join_to_string::join; | 2 | use join_to_string::join; |
3 | use test_utils::tested_by; | 3 | use test_utils::tested_by; |
4 | use hir::{Docs, PerNs, Resolution, HirDisplay}; | 4 | use hir::{Docs, PerNs, Resolution, HirDisplay, HasSource}; |
5 | use ra_syntax::ast::NameOwner; | 5 | use ra_syntax::ast::NameOwner; |
6 | 6 | ||
7 | use crate::completion::{ | 7 | use crate::completion::{ |
@@ -100,7 +100,7 @@ impl Completions { | |||
100 | ) { | 100 | ) { |
101 | let sig = func.signature(ctx.db); | 101 | let sig = func.signature(ctx.db); |
102 | let name = name.unwrap_or_else(|| sig.name().to_string()); | 102 | let name = name.unwrap_or_else(|| sig.name().to_string()); |
103 | let (_, ast_node) = func.source(ctx.db); | 103 | let ast_node = func.source(ctx.db).ast; |
104 | let detail = function_label(&ast_node); | 104 | let detail = function_label(&ast_node); |
105 | 105 | ||
106 | let mut builder = CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name) | 106 | let mut builder = CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name) |
@@ -126,12 +126,11 @@ impl Completions { | |||
126 | } | 126 | } |
127 | 127 | ||
128 | pub(crate) fn add_const(&mut self, ctx: &CompletionContext, constant: hir::Const) { | 128 | pub(crate) fn add_const(&mut self, ctx: &CompletionContext, constant: hir::Const) { |
129 | let (_file_id, ast_node) = constant.source(ctx.db); | 129 | let ast_node = constant.source(ctx.db).ast; |
130 | let name = match ast_node.name() { | 130 | let name = match ast_node.name() { |
131 | Some(name) => name, | 131 | Some(name) => name, |
132 | _ => return, | 132 | _ => return, |
133 | }; | 133 | }; |
134 | let (_, ast_node) = constant.source(ctx.db); | ||
135 | let detail = const_label(&ast_node); | 134 | let detail = const_label(&ast_node); |
136 | 135 | ||
137 | CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.text().to_string()) | 136 | CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.text().to_string()) |
@@ -142,13 +141,12 @@ impl Completions { | |||
142 | } | 141 | } |
143 | 142 | ||
144 | 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) { |
145 | let (_file_id, type_def) = type_alias.source(ctx.db); | 144 | let type_def = type_alias.source(ctx.db).ast; |
146 | let name = match type_def.name() { | 145 | let name = match type_def.name() { |
147 | Some(name) => name, | 146 | Some(name) => name, |
148 | _ => return, | 147 | _ => return, |
149 | }; | 148 | }; |
150 | let (_, ast_node) = type_alias.source(ctx.db); | 149 | let detail = type_label(&type_def); |
151 | let detail = type_label(&ast_node); | ||
152 | 150 | ||
153 | CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.text().to_string()) | 151 | CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.text().to_string()) |
154 | .kind(CompletionItemKind::TypeAlias) | 152 | .kind(CompletionItemKind::TypeAlias) |