diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-12 08:41:16 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-12 08:41:16 +0000 |
commit | c01ef6eabab1fa70d3fdfed9c565fadec9f0a5ed (patch) | |
tree | 37160de8384855fd5fadce3ca4a3de4dacdf98b8 /crates/ide_completion/src/render/macro_.rs | |
parent | db6364fecc2b0e9a95d9aaece820a86265b4cb4f (diff) | |
parent | 99c4a41cd1a9f9ef0ee4f067f0069a23123b949a (diff) |
Merge #7974
7974: use references in CompletionItem's builder r=matklad a=yonip23
@matklad
This is a follow up to [this pr](https://github.com/rust-analyzer/rust-analyzer/pull/7973)
Co-authored-by: yonip23 <[email protected]>
Diffstat (limited to 'crates/ide_completion/src/render/macro_.rs')
-rw-r--r-- | crates/ide_completion/src/render/macro_.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/crates/ide_completion/src/render/macro_.rs b/crates/ide_completion/src/render/macro_.rs index a6cf3e479..727f5e02e 100644 --- a/crates/ide_completion/src/render/macro_.rs +++ b/crates/ide_completion/src/render/macro_.rs | |||
@@ -40,24 +40,27 @@ impl<'a> MacroRender<'a> { | |||
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 builder = |
43 | CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), &self.label()) | 43 | CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), &self.label()); |
44 | .kind(SymbolKind::Macro) | 44 | builder |
45 | .set_documentation(self.docs.clone()) | 45 | .kind(SymbolKind::Macro) |
46 | .set_deprecated(self.ctx.is_deprecated(self.macro_)) | 46 | .set_documentation(self.docs.clone()) |
47 | .add_import(import_to_add) | 47 | .set_deprecated(self.ctx.is_deprecated(self.macro_)) |
48 | .set_detail(self.detail()); | 48 | .add_import(import_to_add) |
49 | .set_detail(self.detail()); | ||
49 | 50 | ||
50 | let needs_bang = self.needs_bang(); | 51 | let needs_bang = self.needs_bang(); |
51 | builder = match self.ctx.snippet_cap() { | 52 | match self.ctx.snippet_cap() { |
52 | Some(cap) if needs_bang => { | 53 | Some(cap) if needs_bang => { |
53 | let snippet = self.snippet(); | 54 | let snippet = self.snippet(); |
54 | let lookup = self.lookup(); | 55 | let lookup = self.lookup(); |
55 | builder.insert_snippet(cap, snippet).lookup_by(lookup) | 56 | builder.insert_snippet(cap, snippet).lookup_by(lookup); |
57 | } | ||
58 | None if needs_bang => { | ||
59 | builder.insert_text(self.banged_name()); | ||
56 | } | 60 | } |
57 | None if needs_bang => builder.insert_text(self.banged_name()), | ||
58 | _ => { | 61 | _ => { |
59 | cov_mark::hit!(dont_insert_macro_call_parens_unncessary); | 62 | cov_mark::hit!(dont_insert_macro_call_parens_unncessary); |
60 | builder.insert_text(&self.name) | 63 | builder.insert_text(&self.name); |
61 | } | 64 | } |
62 | }; | 65 | }; |
63 | 66 | ||