From d0a261468e67be9213a3fae20f1511e303cac064 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 24 Feb 2019 18:51:38 +0300 Subject: introduce completion presentation This module should remove completion rendering boilerplate from the "brains" of completion engine. --- .../ra_ide_api/src/completion/complete_struct_literal.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'crates/ra_ide_api/src/completion/complete_struct_literal.rs') 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 @@ -use hir::{Ty, AdtDef, Docs}; +use hir::{Ty, AdtDef}; -use crate::completion::{CompletionContext, Completions, CompletionItem, CompletionItemKind}; -use crate::completion::completion_item::CompletionKind; +use crate::completion::{CompletionContext, Completions, CompletionKind}; /// Complete fields in fields literals. pub(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 match adt { AdtDef::Struct(s) => { for field in s.fields(ctx.db) { - CompletionItem::new( - CompletionKind::Reference, - ctx.source_range(), - field.name(ctx.db).to_string(), - ) - .kind(CompletionItemKind::Field) - .detail(field.ty(ctx.db).subst(substs).to_string()) - .set_documentation(field.docs(ctx.db)) - .add_to(acc); + acc.add_field(CompletionKind::Reference, ctx, field, substs); } } -- cgit v1.2.3