diff options
Diffstat (limited to 'crates/completion/src/render/function.rs')
-rw-r--r-- | crates/completion/src/render/function.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/crates/completion/src/render/function.rs b/crates/completion/src/render/function.rs index 9dd5cd18c..542383d7e 100644 --- a/crates/completion/src/render/function.rs +++ b/crates/completion/src/render/function.rs | |||
@@ -1,21 +1,21 @@ | |||
1 | //! Renderer for function calls. | 1 | //! Renderer for function calls. |
2 | 2 | ||
3 | use assists::utils::{ImportScope, MergeBehaviour}; | 3 | use hir::{HasSource, Type}; |
4 | use hir::{HasSource, ModPath, Type}; | ||
5 | use syntax::{ast::Fn, display::function_declaration}; | 4 | use syntax::{ast::Fn, display::function_declaration}; |
6 | 5 | ||
7 | use crate::{ | 6 | use crate::{ |
8 | item::{CompletionItem, CompletionItemKind, CompletionKind}, | 7 | item::{CompletionItem, CompletionItemKind, CompletionKind, ImportToAdd}, |
9 | render::{builder_ext::Params, RenderContext}, | 8 | render::{builder_ext::Params, RenderContext}, |
10 | }; | 9 | }; |
11 | 10 | ||
12 | pub(crate) fn render_fn<'a>( | 11 | pub(crate) fn render_fn<'a>( |
13 | ctx: RenderContext<'a>, | 12 | ctx: RenderContext<'a>, |
14 | import_data: Option<(ModPath, ImportScope, Option<MergeBehaviour>)>, | 13 | import_to_add: Option<ImportToAdd>, |
15 | local_name: Option<String>, | 14 | local_name: Option<String>, |
16 | fn_: hir::Function, | 15 | fn_: hir::Function, |
17 | ) -> CompletionItem { | 16 | ) -> CompletionItem { |
18 | FunctionRender::new(ctx, local_name, fn_).render(import_data) | 17 | let _p = profile::span("render_fn"); |
18 | FunctionRender::new(ctx, local_name, fn_).render(import_to_add) | ||
19 | } | 19 | } |
20 | 20 | ||
21 | #[derive(Debug)] | 21 | #[derive(Debug)] |
@@ -38,10 +38,7 @@ impl<'a> FunctionRender<'a> { | |||
38 | FunctionRender { ctx, name, fn_, ast_node } | 38 | FunctionRender { ctx, name, fn_, ast_node } |
39 | } | 39 | } |
40 | 40 | ||
41 | fn render( | 41 | fn render(self, import_to_add: Option<ImportToAdd>) -> CompletionItem { |
42 | self, | ||
43 | import_data: Option<(ModPath, ImportScope, Option<MergeBehaviour>)>, | ||
44 | ) -> CompletionItem { | ||
45 | let params = self.params(); | 42 | let params = self.params(); |
46 | CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), self.name.clone()) | 43 | CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), self.name.clone()) |
47 | .kind(self.kind()) | 44 | .kind(self.kind()) |
@@ -49,7 +46,7 @@ impl<'a> FunctionRender<'a> { | |||
49 | .set_deprecated(self.ctx.is_deprecated(self.fn_)) | 46 | .set_deprecated(self.ctx.is_deprecated(self.fn_)) |
50 | .detail(self.detail()) | 47 | .detail(self.detail()) |
51 | .add_call_parens(self.ctx.completion, self.name, params) | 48 | .add_call_parens(self.ctx.completion, self.name, params) |
52 | .import_data(import_data) | 49 | .add_import(import_to_add) |
53 | .build() | 50 | .build() |
54 | } | 51 | } |
55 | 52 | ||