aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion/complete_struct_literal.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-02-24 15:51:38 +0000
committerAleksey Kladov <[email protected]>2019-02-24 15:51:38 +0000
commitd0a261468e67be9213a3fae20f1511e303cac064 (patch)
tree2169423b7b9472e51b870f2ade7f5fb1df9fc6d9 /crates/ra_ide_api/src/completion/complete_struct_literal.rs
parent67528c4b3943a2027839a25770d079132a9ea130 (diff)
introduce completion presentation
This module should remove completion rendering boilerplate from the "brains" of completion engine.
Diffstat (limited to 'crates/ra_ide_api/src/completion/complete_struct_literal.rs')
-rw-r--r--crates/ra_ide_api/src/completion/complete_struct_literal.rs15
1 files changed, 3 insertions, 12 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_struct_literal.rs b/crates/ra_ide_api/src/completion/complete_struct_literal.rs
index f8dd2baad..c617bff5f 100644
--- a/crates/ra_ide_api/src/completion/complete_struct_literal.rs
+++ b/crates/ra_ide_api/src/completion/complete_struct_literal.rs
@@ -1,7 +1,6 @@
1use hir::{Ty, AdtDef, Docs}; 1use hir::{Ty, AdtDef};
2 2
3use crate::completion::{CompletionContext, Completions, CompletionItem, CompletionItemKind}; 3use crate::completion::{CompletionContext, Completions, CompletionKind};
4use crate::completion::completion_item::CompletionKind;
5 4
6/// Complete fields in fields literals. 5/// Complete fields in fields literals.
7pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionContext) { 6pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionContext) {
@@ -23,15 +22,7 @@ pub(super) fn complete_struct_literal(acc: &mut Completions, ctx: &CompletionCon
23 match adt { 22 match adt {
24 AdtDef::Struct(s) => { 23 AdtDef::Struct(s) => {
25 for field in s.fields(ctx.db) { 24 for field in s.fields(ctx.db) {
26 CompletionItem::new( 25 acc.add_field(CompletionKind::Reference, ctx, field, substs);
27 CompletionKind::Reference,
28 ctx.source_range(),
29 field.name(ctx.db).to_string(),
30 )
31 .kind(CompletionItemKind::Field)
32 .detail(field.ty(ctx.db).subst(substs).to_string())
33 .set_documentation(field.docs(ctx.db))
34 .add_to(acc);
35 } 26 }
36 } 27 }
37 28