diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-11-28 14:33:57 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-11-28 14:33:57 +0000 |
commit | b7ece77af49ce59762fc3246a4c721411efe637e (patch) | |
tree | 81c617c2df781e27b0c16c10515ebcf588cb376e /crates/completion/src/render/function.rs | |
parent | fe2ac4480bd71c9cf25d2c21bda82b33558d27a4 (diff) | |
parent | 3f612d37c68a6e4c09e407b7cd2ad8a1d17ab4e6 (diff) |
Merge #6650
6650: Make completion and assists module independent r=matklad a=SomeoneToIgnore
A follow-up of https://github.com/rust-analyzer/rust-analyzer/pull/6553#discussion_r524402907
Move the common code for both assists and completion modules into a separate crate.
Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/completion/src/render/function.rs')
-rw-r--r-- | crates/completion/src/render/function.rs | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/crates/completion/src/render/function.rs b/crates/completion/src/render/function.rs index e8b726ad6..542383d7e 100644 --- a/crates/completion/src/render/function.rs +++ b/crates/completion/src/render/function.rs | |||
@@ -1,22 +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 | let _p = profile::span("render_fn"); | 17 | let _p = profile::span("render_fn"); |
19 | FunctionRender::new(ctx, local_name, fn_).render(import_data) | 18 | FunctionRender::new(ctx, local_name, fn_).render(import_to_add) |
20 | } | 19 | } |
21 | 20 | ||
22 | #[derive(Debug)] | 21 | #[derive(Debug)] |
@@ -39,10 +38,7 @@ impl<'a> FunctionRender<'a> { | |||
39 | FunctionRender { ctx, name, fn_, ast_node } | 38 | FunctionRender { ctx, name, fn_, ast_node } |
40 | } | 39 | } |
41 | 40 | ||
42 | fn render( | 41 | fn render(self, import_to_add: Option<ImportToAdd>) -> CompletionItem { |
43 | self, | ||
44 | import_data: Option<(ModPath, ImportScope, Option<MergeBehaviour>)>, | ||
45 | ) -> CompletionItem { | ||
46 | let params = self.params(); | 42 | let params = self.params(); |
47 | CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), self.name.clone()) | 43 | CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), self.name.clone()) |
48 | .kind(self.kind()) | 44 | .kind(self.kind()) |
@@ -50,7 +46,7 @@ impl<'a> FunctionRender<'a> { | |||
50 | .set_deprecated(self.ctx.is_deprecated(self.fn_)) | 46 | .set_deprecated(self.ctx.is_deprecated(self.fn_)) |
51 | .detail(self.detail()) | 47 | .detail(self.detail()) |
52 | .add_call_parens(self.ctx.completion, self.name, params) | 48 | .add_call_parens(self.ctx.completion, self.name, params) |
53 | .import_data(import_data) | 49 | .add_import(import_to_add) |
54 | .build() | 50 | .build() |
55 | } | 51 | } |
56 | 52 | ||