aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/render
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/render')
-rw-r--r--crates/ide_completion/src/render/enum_variant.rs11
-rw-r--r--crates/ide_completion/src/render/function.rs7
-rw-r--r--crates/ide_completion/src/render/macro_.rs13
-rw-r--r--crates/ide_completion/src/render/pattern.rs17
4 files changed, 22 insertions, 26 deletions
diff --git a/crates/ide_completion/src/render/enum_variant.rs b/crates/ide_completion/src/render/enum_variant.rs
index 23c43496e..e8cfcc0c7 100644
--- a/crates/ide_completion/src/render/enum_variant.rs
+++ b/crates/ide_completion/src/render/enum_variant.rs
@@ -55,13 +55,12 @@ impl<'a> EnumRender<'a> {
55 } 55 }
56 56
57 fn render(self, import_to_add: Option<ImportEdit>) -> CompletionItem { 57 fn render(self, import_to_add: Option<ImportEdit>) -> CompletionItem {
58 let mut builder = CompletionItem::new( 58 let mut item = CompletionItem::new(
59 CompletionKind::Reference, 59 CompletionKind::Reference,
60 self.ctx.source_range(), 60 self.ctx.source_range(),
61 self.qualified_name.clone(), 61 self.qualified_name.clone(),
62 ); 62 );
63 builder 63 item.kind(SymbolKind::Variant)
64 .kind(SymbolKind::Variant)
65 .set_documentation(self.variant.docs(self.ctx.db())) 64 .set_documentation(self.variant.docs(self.ctx.db()))
66 .set_deprecated(self.ctx.is_deprecated(self.variant)) 65 .set_deprecated(self.ctx.is_deprecated(self.variant))
67 .add_import(import_to_add) 66 .add_import(import_to_add)
@@ -70,12 +69,12 @@ impl<'a> EnumRender<'a> {
70 if self.variant_kind == StructKind::Tuple { 69 if self.variant_kind == StructKind::Tuple {
71 cov_mark::hit!(inserts_parens_for_tuple_enums); 70 cov_mark::hit!(inserts_parens_for_tuple_enums);
72 let params = Params::Anonymous(self.variant.fields(self.ctx.db()).len()); 71 let params = Params::Anonymous(self.variant.fields(self.ctx.db()).len());
73 builder.add_call_parens(self.ctx.completion, self.short_qualified_name, params); 72 item.add_call_parens(self.ctx.completion, self.short_qualified_name, params);
74 } else if self.path.is_some() { 73 } else if self.path.is_some() {
75 builder.lookup_by(self.short_qualified_name); 74 item.lookup_by(self.short_qualified_name);
76 } 75 }
77 76
78 builder.build() 77 item.build()
79 } 78 }
80 79
81 fn detail(&self) -> String { 80 fn detail(&self) -> String {
diff --git a/crates/ide_completion/src/render/function.rs b/crates/ide_completion/src/render/function.rs
index 1e2f45f14..f4dabe3d1 100644
--- a/crates/ide_completion/src/render/function.rs
+++ b/crates/ide_completion/src/render/function.rs
@@ -41,13 +41,12 @@ impl<'a> FunctionRender<'a> {
41 41
42 fn render(self, import_to_add: Option<ImportEdit>) -> CompletionItem { 42 fn render(self, import_to_add: Option<ImportEdit>) -> CompletionItem {
43 let params = self.params(); 43 let params = self.params();
44 let mut builder = CompletionItem::new( 44 let mut item = CompletionItem::new(
45 CompletionKind::Reference, 45 CompletionKind::Reference,
46 self.ctx.source_range(), 46 self.ctx.source_range(),
47 self.name.clone(), 47 self.name.clone(),
48 ); 48 );
49 builder 49 item.kind(self.kind())
50 .kind(self.kind())
51 .set_documentation(self.ctx.docs(self.func)) 50 .set_documentation(self.ctx.docs(self.func))
52 .set_deprecated( 51 .set_deprecated(
53 self.ctx.is_deprecated(self.func) || self.ctx.is_deprecated_assoc_item(self.func), 52 self.ctx.is_deprecated(self.func) || self.ctx.is_deprecated_assoc_item(self.func),
@@ -56,7 +55,7 @@ impl<'a> FunctionRender<'a> {
56 .add_call_parens(self.ctx.completion, self.name, params) 55 .add_call_parens(self.ctx.completion, self.name, params)
57 .add_import(import_to_add); 56 .add_import(import_to_add);
58 57
59 builder.build() 58 item.build()
60 } 59 }
61 60
62 fn detail(&self) -> String { 61 fn detail(&self) -> String {
diff --git a/crates/ide_completion/src/render/macro_.rs b/crates/ide_completion/src/render/macro_.rs
index 727f5e02e..3fa21ba7c 100644
--- a/crates/ide_completion/src/render/macro_.rs
+++ b/crates/ide_completion/src/render/macro_.rs
@@ -39,10 +39,9 @@ impl<'a> MacroRender<'a> {
39 } 39 }
40 40
41 fn render(&self, import_to_add: Option<ImportEdit>) -> Option<CompletionItem> { 41 fn render(&self, import_to_add: Option<ImportEdit>) -> Option<CompletionItem> {
42 let mut builder = 42 let mut item =
43 CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), &self.label()); 43 CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), &self.label());
44 builder 44 item.kind(SymbolKind::Macro)
45 .kind(SymbolKind::Macro)
46 .set_documentation(self.docs.clone()) 45 .set_documentation(self.docs.clone())
47 .set_deprecated(self.ctx.is_deprecated(self.macro_)) 46 .set_deprecated(self.ctx.is_deprecated(self.macro_))
48 .add_import(import_to_add) 47 .add_import(import_to_add)
@@ -53,18 +52,18 @@ impl<'a> MacroRender<'a> {
53 Some(cap) if needs_bang => { 52 Some(cap) if needs_bang => {
54 let snippet = self.snippet(); 53 let snippet = self.snippet();
55 let lookup = self.lookup(); 54 let lookup = self.lookup();
56 builder.insert_snippet(cap, snippet).lookup_by(lookup); 55 item.insert_snippet(cap, snippet).lookup_by(lookup);
57 } 56 }
58 None if needs_bang => { 57 None if needs_bang => {
59 builder.insert_text(self.banged_name()); 58 item.insert_text(self.banged_name());
60 } 59 }
61 _ => { 60 _ => {
62 cov_mark::hit!(dont_insert_macro_call_parens_unncessary); 61 cov_mark::hit!(dont_insert_macro_call_parens_unncessary);
63 builder.insert_text(&self.name); 62 item.insert_text(&self.name);
64 } 63 }
65 }; 64 };
66 65
67 Some(builder.build()) 66 Some(item.build())
68 } 67 }
69 68
70 fn needs_bang(&self) -> bool { 69 fn needs_bang(&self) -> bool {
diff --git a/crates/ide_completion/src/render/pattern.rs b/crates/ide_completion/src/render/pattern.rs
index 4d8f2b17d..ca2926125 100644
--- a/crates/ide_completion/src/render/pattern.rs
+++ b/crates/ide_completion/src/render/pattern.rs
@@ -69,20 +69,19 @@ fn build_completion(
69 ctx: RenderContext<'_>, 69 ctx: RenderContext<'_>,
70 name: String, 70 name: String,
71 pat: String, 71 pat: String,
72 item: impl HasAttrs + Copy, 72 def: impl HasAttrs + Copy,
73) -> CompletionItem { 73) -> CompletionItem {
74 let mut completion = CompletionItem::new(CompletionKind::Snippet, ctx.source_range(), name); 74 let mut item = CompletionItem::new(CompletionKind::Snippet, ctx.source_range(), name);
75 completion 75 item.kind(CompletionItemKind::Binding)
76 .kind(CompletionItemKind::Binding) 76 .set_documentation(ctx.docs(def))
77 .set_documentation(ctx.docs(item)) 77 .set_deprecated(ctx.is_deprecated(def))
78 .set_deprecated(ctx.is_deprecated(item))
79 .detail(&pat); 78 .detail(&pat);
80 if let Some(snippet_cap) = ctx.snippet_cap() { 79 if let Some(snippet_cap) = ctx.snippet_cap() {
81 completion.insert_snippet(snippet_cap, pat); 80 item.insert_snippet(snippet_cap, pat);
82 } else { 81 } else {
83 completion.insert_text(pat); 82 item.insert_text(pat);
84 }; 83 };
85 completion.build() 84 item.build()
86} 85}
87 86
88fn render_pat( 87fn render_pat(