diff options
Diffstat (limited to 'crates/ra_ide_api/src/completion/completion_item.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion/completion_item.rs | 41 |
1 files changed, 2 insertions, 39 deletions
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index cb880d92c..f515fcc14 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs | |||
@@ -1,14 +1,8 @@ | |||
1 | use std::fmt; | 1 | use std::fmt; |
2 | 2 | ||
3 | use hir::{Docs, Documentation}; | 3 | use hir::Documentation; |
4 | use ra_syntax::TextRange; | 4 | use ra_syntax::TextRange; |
5 | use ra_text_edit::{ TextEditBuilder, TextEdit}; | 5 | use ra_text_edit::{TextEditBuilder, TextEdit}; |
6 | |||
7 | use crate::completion::{ | ||
8 | completion_context::CompletionContext, | ||
9 | const_label, | ||
10 | type_label | ||
11 | }; | ||
12 | 6 | ||
13 | /// `CompletionItem` describes a single completion variant in the editor pop-up. | 7 | /// `CompletionItem` describes a single completion variant in the editor pop-up. |
14 | /// It is basically a POD with various properties. To construct a | 8 | /// It is basically a POD with various properties. To construct a |
@@ -253,27 +247,6 @@ impl Builder { | |||
253 | self.documentation = docs.map(Into::into); | 247 | self.documentation = docs.map(Into::into); |
254 | self | 248 | self |
255 | } | 249 | } |
256 | pub(super) fn from_const(mut self, ctx: &CompletionContext, ct: hir::Const) -> Builder { | ||
257 | if let Some(docs) = ct.docs(ctx.db) { | ||
258 | self.documentation = Some(docs); | ||
259 | } | ||
260 | |||
261 | self.detail = Some(const_item_label(ctx, ct)); | ||
262 | self.kind = Some(CompletionItemKind::Const); | ||
263 | |||
264 | self | ||
265 | } | ||
266 | |||
267 | pub(super) fn from_type(mut self, ctx: &CompletionContext, ty: hir::Type) -> Builder { | ||
268 | if let Some(docs) = ty.docs(ctx.db) { | ||
269 | self.documentation = Some(docs); | ||
270 | } | ||
271 | |||
272 | self.detail = Some(type_item_label(ctx, ty)); | ||
273 | self.kind = Some(CompletionItemKind::TypeAlias); | ||
274 | |||
275 | self | ||
276 | } | ||
277 | } | 250 | } |
278 | 251 | ||
279 | impl<'a> Into<CompletionItem> for Builder { | 252 | impl<'a> Into<CompletionItem> for Builder { |
@@ -307,16 +280,6 @@ impl Into<Vec<CompletionItem>> for Completions { | |||
307 | } | 280 | } |
308 | } | 281 | } |
309 | 282 | ||
310 | fn const_item_label(ctx: &CompletionContext, ct: hir::Const) -> String { | ||
311 | let node = ct.source(ctx.db).1; | ||
312 | const_label(&node) | ||
313 | } | ||
314 | |||
315 | fn type_item_label(ctx: &CompletionContext, ty: hir::Type) -> String { | ||
316 | let node = ty.source(ctx.db).1; | ||
317 | type_label(&node) | ||
318 | } | ||
319 | |||
320 | #[cfg(test)] | 283 | #[cfg(test)] |
321 | pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> { | 284 | pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> { |
322 | use crate::mock_analysis::{single_file_with_position, analysis_and_position}; | 285 | use crate::mock_analysis::{single_file_with_position, analysis_and_position}; |