From 9af525dbd69bb22c968ba42d758657b2ad9bdd37 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 24 Feb 2019 20:49:55 +0300 Subject: simplify --- crates/ra_ide_api/src/completion/presentation.rs | 52 +++++++++++------------- 1 file changed, 24 insertions(+), 28 deletions(-) (limited to 'crates/ra_ide_api/src/completion/presentation.rs') diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index 057dbc21a..514f3b539 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs @@ -10,47 +10,43 @@ use crate::completion::{ impl Completions { pub(crate) fn add_field( &mut self, - kind: CompletionKind, ctx: &CompletionContext, field: hir::StructField, substs: &hir::Substs, ) { - CompletionItem::new(kind, 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(self); + 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(self); } - pub(crate) fn add_pos_field( - &mut self, - kind: CompletionKind, - ctx: &CompletionContext, - field: usize, - ty: &hir::Ty, - ) { - CompletionItem::new(kind, ctx.source_range(), field.to_string()) + pub(crate) fn add_pos_field(&mut self, ctx: &CompletionContext, field: usize, ty: &hir::Ty) { + CompletionItem::new(CompletionKind::Reference, ctx.source_range(), field.to_string()) .kind(CompletionItemKind::Field) .detail(ty.to_string()) .add_to(self); } - pub(crate) fn add_function( - &mut self, - kind: CompletionKind, - ctx: &CompletionContext, - func: hir::Function, - ) { + pub(crate) fn add_function(&mut self, ctx: &CompletionContext, func: hir::Function) { let sig = func.signature(ctx.db); - let mut builder = CompletionItem::new(kind, ctx.source_range(), sig.name().to_string()) - .kind(if sig.has_self_param() { - CompletionItemKind::Method - } else { - CompletionItemKind::Function - }) - .set_documentation(func.docs(ctx.db)) - .set_detail(function_item_label(ctx, func)); + let mut builder = CompletionItem::new( + CompletionKind::Reference, + ctx.source_range(), + sig.name().to_string(), + ) + .kind(if sig.has_self_param() { + CompletionItemKind::Method + } else { + CompletionItemKind::Function + }) + .set_documentation(func.docs(ctx.db)) + .set_detail(function_item_label(ctx, func)); // If not an import, add parenthesis automatically. if ctx.use_item_syntax.is_none() && !ctx.is_call { tested_by!(inserts_parens_for_function_calls); -- cgit v1.2.3