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/enum_variant.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/enum_variant.rs')
-rw-r--r-- | crates/completion/src/render/enum_variant.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/crates/completion/src/render/enum_variant.rs b/crates/completion/src/render/enum_variant.rs index 64e742b77..f4bd02f25 100644 --- a/crates/completion/src/render/enum_variant.rs +++ b/crates/completion/src/render/enum_variant.rs | |||
@@ -1,24 +1,23 @@ | |||
1 | //! Renderer for `enum` variants. | 1 | //! Renderer for `enum` variants. |
2 | 2 | ||
3 | use assists::utils::{ImportScope, MergeBehaviour}; | ||
4 | use hir::{HasAttrs, HirDisplay, ModPath, StructKind}; | 3 | use hir::{HasAttrs, HirDisplay, ModPath, StructKind}; |
5 | use itertools::Itertools; | 4 | use itertools::Itertools; |
6 | use test_utils::mark; | 5 | use test_utils::mark; |
7 | 6 | ||
8 | use crate::{ | 7 | use crate::{ |
9 | item::{CompletionItem, CompletionItemKind, CompletionKind}, | 8 | item::{CompletionItem, CompletionItemKind, CompletionKind, ImportToAdd}, |
10 | render::{builder_ext::Params, RenderContext}, | 9 | render::{builder_ext::Params, RenderContext}, |
11 | }; | 10 | }; |
12 | 11 | ||
13 | pub(crate) fn render_enum_variant<'a>( | 12 | pub(crate) fn render_enum_variant<'a>( |
14 | ctx: RenderContext<'a>, | 13 | ctx: RenderContext<'a>, |
15 | import_data: Option<(ModPath, ImportScope, Option<MergeBehaviour>)>, | 14 | import_to_add: Option<ImportToAdd>, |
16 | local_name: Option<String>, | 15 | local_name: Option<String>, |
17 | variant: hir::EnumVariant, | 16 | variant: hir::EnumVariant, |
18 | path: Option<ModPath>, | 17 | path: Option<ModPath>, |
19 | ) -> CompletionItem { | 18 | ) -> CompletionItem { |
20 | let _p = profile::span("render_enum_variant"); | 19 | let _p = profile::span("render_enum_variant"); |
21 | EnumVariantRender::new(ctx, local_name, variant, path).render(import_data) | 20 | EnumVariantRender::new(ctx, local_name, variant, path).render(import_to_add) |
22 | } | 21 | } |
23 | 22 | ||
24 | #[derive(Debug)] | 23 | #[derive(Debug)] |
@@ -63,10 +62,7 @@ impl<'a> EnumVariantRender<'a> { | |||
63 | } | 62 | } |
64 | } | 63 | } |
65 | 64 | ||
66 | fn render( | 65 | fn render(self, import_to_add: Option<ImportToAdd>) -> CompletionItem { |
67 | self, | ||
68 | import_data: Option<(ModPath, ImportScope, Option<MergeBehaviour>)>, | ||
69 | ) -> CompletionItem { | ||
70 | let mut builder = CompletionItem::new( | 66 | let mut builder = CompletionItem::new( |
71 | CompletionKind::Reference, | 67 | CompletionKind::Reference, |
72 | self.ctx.source_range(), | 68 | self.ctx.source_range(), |
@@ -75,7 +71,7 @@ impl<'a> EnumVariantRender<'a> { | |||
75 | .kind(CompletionItemKind::EnumVariant) | 71 | .kind(CompletionItemKind::EnumVariant) |
76 | .set_documentation(self.variant.docs(self.ctx.db())) | 72 | .set_documentation(self.variant.docs(self.ctx.db())) |
77 | .set_deprecated(self.ctx.is_deprecated(self.variant)) | 73 | .set_deprecated(self.ctx.is_deprecated(self.variant)) |
78 | .import_data(import_data) | 74 | .add_import(import_to_add) |
79 | .detail(self.detail()); | 75 | .detail(self.detail()); |
80 | 76 | ||
81 | if self.variant_kind == StructKind::Tuple { | 77 | if self.variant_kind == StructKind::Tuple { |