aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/render/function.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/render/function.rs')
-rw-r--r--crates/ide_completion/src/render/function.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ide_completion/src/render/function.rs b/crates/ide_completion/src/render/function.rs
index d681e2c91..63bd66926 100644
--- a/crates/ide_completion/src/render/function.rs
+++ b/crates/ide_completion/src/render/function.rs
@@ -1,6 +1,6 @@
1//! Renderer for function calls. 1//! Renderer for function calls.
2 2
3use hir::{HasSource, HirDisplay, Type}; 3use hir::{HasSource, HirDisplay};
4use ide_db::SymbolKind; 4use ide_db::SymbolKind;
5use itertools::Itertools; 5use itertools::Itertools;
6use syntax::ast::Fn; 6use syntax::ast::Fn;
@@ -16,7 +16,7 @@ use crate::{
16pub(crate) fn render_fn<'a>( 16pub(crate) fn render_fn<'a>(
17 ctx: RenderContext<'a>, 17 ctx: RenderContext<'a>,
18 import_to_add: Option<ImportEdit>, 18 import_to_add: Option<ImportEdit>,
19 local_name: Option<String>, 19 local_name: Option<hir::Name>,
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");
@@ -26,7 +26,7 @@ pub(crate) fn render_fn<'a>(
26pub(crate) fn render_method<'a>( 26pub(crate) fn render_method<'a>(
27 ctx: RenderContext<'a>, 27 ctx: RenderContext<'a>,
28 import_to_add: Option<ImportEdit>, 28 import_to_add: Option<ImportEdit>,
29 local_name: Option<String>, 29 local_name: Option<hir::Name>,
30 fn_: hir::Function, 30 fn_: hir::Function,
31) -> Option<CompletionItem> { 31) -> Option<CompletionItem> {
32 let _p = profile::span("render_method"); 32 let _p = profile::span("render_method");
@@ -45,11 +45,11 @@ struct FunctionRender<'a> {
45impl<'a> FunctionRender<'a> { 45impl<'a> FunctionRender<'a> {
46 fn new( 46 fn new(
47 ctx: RenderContext<'a>, 47 ctx: RenderContext<'a>,
48 local_name: Option<String>, 48 local_name: Option<hir::Name>,
49 fn_: hir::Function, 49 fn_: hir::Function,
50 is_method: bool, 50 is_method: bool,
51 ) -> Option<FunctionRender<'a>> { 51 ) -> Option<FunctionRender<'a>> {
52 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();
53 let ast_node = fn_.source(ctx.db())?.value; 53 let ast_node = fn_.source(ctx.db())?.value;
54 54
55 Some(FunctionRender { ctx, name, func: fn_, ast_node, is_method }) 55 Some(FunctionRender { ctx, name, func: fn_, ast_node, is_method })
@@ -74,7 +74,7 @@ impl<'a> FunctionRender<'a> {
74 let ret_type = self.func.ret_type(self.ctx.db()); 74 let ret_type = self.func.ret_type(self.ctx.db());
75 item.set_relevance(CompletionRelevance { 75 item.set_relevance(CompletionRelevance {
76 type_match: compute_type_match(self.ctx.completion, &ret_type), 76 type_match: compute_type_match(self.ctx.completion, &ret_type),
77 exact_name_match: compute_exact_name_match(self.ctx.completion, self.name.clone()), 77 exact_name_match: compute_exact_name_match(self.ctx.completion, &self.name),
78 ..CompletionRelevance::default() 78 ..CompletionRelevance::default()
79 }); 79 });
80 80
@@ -129,7 +129,7 @@ impl<'a> FunctionRender<'a> {
129 format!("-> {}", ret_ty.display(self.ctx.db())) 129 format!("-> {}", ret_ty.display(self.ctx.db()))
130 } 130 }
131 131
132 fn add_arg(&self, arg: &str, ty: &Type) -> String { 132 fn add_arg(&self, arg: &str, ty: &hir::Type) -> String {
133 if let Some(derefed_ty) = ty.remove_ref() { 133 if let Some(derefed_ty) = ty.remove_ref() {
134 for (name, local) in self.ctx.completion.locals.iter() { 134 for (name, local) in self.ctx.completion.locals.iter() {
135 if name == arg && local.ty(self.ctx.db()) == derefed_ty { 135 if name == arg && local.ty(self.ctx.db()) == derefed_ty {