aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion/presentation.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/completion/presentation.rs')
-rw-r--r--crates/ra_ide_api/src/completion/presentation.rs52
1 files changed, 24 insertions, 28 deletions
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::{
10impl Completions { 10impl Completions {
11 pub(crate) fn add_field( 11 pub(crate) fn add_field(
12 &mut self, 12 &mut self,
13 kind: CompletionKind,
14 ctx: &CompletionContext, 13 ctx: &CompletionContext,
15 field: hir::StructField, 14 field: hir::StructField,
16 substs: &hir::Substs, 15 substs: &hir::Substs,
17 ) { 16 ) {
18 CompletionItem::new(kind, ctx.source_range(), field.name(ctx.db).to_string()) 17 CompletionItem::new(
19 .kind(CompletionItemKind::Field) 18 CompletionKind::Reference,
20 .detail(field.ty(ctx.db).subst(substs).to_string()) 19 ctx.source_range(),
21 .set_documentation(field.docs(ctx.db)) 20 field.name(ctx.db).to_string(),
22 .add_to(self); 21 )
22 .kind(CompletionItemKind::Field)
23 .detail(field.ty(ctx.db).subst(substs).to_string())
24 .set_documentation(field.docs(ctx.db))
25 .add_to(self);
23 } 26 }
24 27
25 pub(crate) fn add_pos_field( 28 pub(crate) fn add_pos_field(&mut self, ctx: &CompletionContext, field: usize, ty: &hir::Ty) {
26 &mut self, 29 CompletionItem::new(CompletionKind::Reference, ctx.source_range(), field.to_string())
27 kind: CompletionKind,
28 ctx: &CompletionContext,
29 field: usize,
30 ty: &hir::Ty,
31 ) {
32 CompletionItem::new(kind, ctx.source_range(), field.to_string())
33 .kind(CompletionItemKind::Field) 30 .kind(CompletionItemKind::Field)
34 .detail(ty.to_string()) 31 .detail(ty.to_string())
35 .add_to(self); 32 .add_to(self);
36 } 33 }
37 34
38 pub(crate) fn add_function( 35 pub(crate) fn add_function(&mut self, ctx: &CompletionContext, func: hir::Function) {
39 &mut self,
40 kind: CompletionKind,
41 ctx: &CompletionContext,
42 func: hir::Function,
43 ) {
44 let sig = func.signature(ctx.db); 36 let sig = func.signature(ctx.db);
45 37
46 let mut builder = CompletionItem::new(kind, ctx.source_range(), sig.name().to_string()) 38 let mut builder = CompletionItem::new(
47 .kind(if sig.has_self_param() { 39 CompletionKind::Reference,
48 CompletionItemKind::Method 40 ctx.source_range(),
49 } else { 41 sig.name().to_string(),
50 CompletionItemKind::Function 42 )
51 }) 43 .kind(if sig.has_self_param() {
52 .set_documentation(func.docs(ctx.db)) 44 CompletionItemKind::Method
53 .set_detail(function_item_label(ctx, func)); 45 } else {
46 CompletionItemKind::Function
47 })
48 .set_documentation(func.docs(ctx.db))
49 .set_detail(function_item_label(ctx, func));
54 // If not an import, add parenthesis automatically. 50 // If not an import, add parenthesis automatically.
55 if ctx.use_item_syntax.is_none() && !ctx.is_call { 51 if ctx.use_item_syntax.is_none() && !ctx.is_call {
56 tested_by!(inserts_parens_for_function_calls); 52 tested_by!(inserts_parens_for_function_calls);