aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/render
diff options
context:
space:
mode:
authorJosh Mcguigan <[email protected]>2021-03-22 00:30:56 +0000
committerJosh Mcguigan <[email protected]>2021-03-22 00:30:56 +0000
commit8cd94900f7e0806bfdf4e6cb6f0bb868f7673d7d (patch)
tree65bfd1df2f8d192bfb36ae1244354310df7c3c1a /crates/ide_completion/src/render
parent858ad554374a8b1ad67692558a0878391abfdd86 (diff)
implement a temporary workaround for #8058
Diffstat (limited to 'crates/ide_completion/src/render')
-rw-r--r--crates/ide_completion/src/render/function.rs23
1 files changed, 20 insertions, 3 deletions
diff --git a/crates/ide_completion/src/render/function.rs b/crates/ide_completion/src/render/function.rs
index 010303182..b1eba20e8 100644
--- a/crates/ide_completion/src/render/function.rs
+++ b/crates/ide_completion/src/render/function.rs
@@ -20,7 +20,17 @@ pub(crate) fn render_fn<'a>(
20 fn_: hir::Function, 20 fn_: hir::Function,
21) -> Option<CompletionItem> { 21) -> Option<CompletionItem> {
22 let _p = profile::span("render_fn"); 22 let _p = profile::span("render_fn");
23 Some(FunctionRender::new(ctx, local_name, fn_)?.render(import_to_add)) 23 Some(FunctionRender::new(ctx, local_name, fn_, false)?.render(import_to_add))
24}
25
26pub(crate) fn render_method<'a>(
27 ctx: RenderContext<'a>,
28 import_to_add: Option<ImportEdit>,
29 local_name: Option<String>,
30 fn_: hir::Function,
31) -> Option<CompletionItem> {
32 let _p = profile::span("render_method");
33 Some(FunctionRender::new(ctx, local_name, fn_, true)?.render(import_to_add))
24} 34}
25 35
26#[derive(Debug)] 36#[derive(Debug)]
@@ -29,6 +39,7 @@ struct FunctionRender<'a> {
29 name: String, 39 name: String,
30 func: hir::Function, 40 func: hir::Function,
31 ast_node: Fn, 41 ast_node: Fn,
42 is_method: bool,
32} 43}
33 44
34impl<'a> FunctionRender<'a> { 45impl<'a> FunctionRender<'a> {
@@ -36,11 +47,12 @@ impl<'a> FunctionRender<'a> {
36 ctx: RenderContext<'a>, 47 ctx: RenderContext<'a>,
37 local_name: Option<String>, 48 local_name: Option<String>,
38 fn_: hir::Function, 49 fn_: hir::Function,
50 is_method: bool,
39 ) -> Option<FunctionRender<'a>> { 51 ) -> Option<FunctionRender<'a>> {
40 let name = local_name.unwrap_or_else(|| fn_.name(ctx.db()).to_string()); 52 let name = local_name.unwrap_or_else(|| fn_.name(ctx.db()).to_string());
41 let ast_node = fn_.source(ctx.db())?.value; 53 let ast_node = fn_.source(ctx.db())?.value;
42 54
43 Some(FunctionRender { ctx, name, func: fn_, ast_node }) 55 Some(FunctionRender { ctx, name, func: fn_, ast_node, is_method })
44 } 56 }
45 57
46 fn render(self, import_to_add: Option<ImportEdit>) -> CompletionItem { 58 fn render(self, import_to_add: Option<ImportEdit>) -> CompletionItem {
@@ -67,7 +79,12 @@ impl<'a> FunctionRender<'a> {
67 }); 79 });
68 80
69 if let Some(ref_match) = compute_ref_match(self.ctx.completion, &ret_type) { 81 if let Some(ref_match) = compute_ref_match(self.ctx.completion, &ret_type) {
70 item.ref_match(ref_match); 82 // FIXME
83 // For now we don't properly calculate the edits for ref match
84 // completions on methods, so we've disabled them. See #8058.
85 if !self.is_method {
86 item.ref_match(ref_match);
87 }
71 } 88 }
72 89
73 item.build() 90 item.build()