From f4ae3650d855554575f866264a3c8197dfd12835 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 24 Nov 2020 23:25:13 +0200 Subject: Extract the import code into the shared module --- crates/completion/src/render/enum_variant.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/completion/src/render/enum_variant.rs') diff --git a/crates/completion/src/render/enum_variant.rs b/crates/completion/src/render/enum_variant.rs index 64e742b77..5d4fbb641 100644 --- a/crates/completion/src/render/enum_variant.rs +++ b/crates/completion/src/render/enum_variant.rs @@ -1,7 +1,7 @@ //! Renderer for `enum` variants. -use assists::utils::{ImportScope, MergeBehaviour}; use hir::{HasAttrs, HirDisplay, ModPath, StructKind}; +use ide_helpers::insert_use::{ImportScope, MergeBehaviour}; use itertools::Itertools; use test_utils::mark; -- cgit v1.2.3 From f75f07019bd754e4fcc40c6144cc83911bbf21c8 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 27 Nov 2020 12:22:10 +0200 Subject: Group import data in a struct --- crates/completion/src/render/enum_variant.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'crates/completion/src/render/enum_variant.rs') diff --git a/crates/completion/src/render/enum_variant.rs b/crates/completion/src/render/enum_variant.rs index 5d4fbb641..f4bd02f25 100644 --- a/crates/completion/src/render/enum_variant.rs +++ b/crates/completion/src/render/enum_variant.rs @@ -1,24 +1,23 @@ //! Renderer for `enum` variants. use hir::{HasAttrs, HirDisplay, ModPath, StructKind}; -use ide_helpers::insert_use::{ImportScope, MergeBehaviour}; use itertools::Itertools; use test_utils::mark; use crate::{ - item::{CompletionItem, CompletionItemKind, CompletionKind}, + item::{CompletionItem, CompletionItemKind, CompletionKind, ImportToAdd}, render::{builder_ext::Params, RenderContext}, }; pub(crate) fn render_enum_variant<'a>( ctx: RenderContext<'a>, - import_data: Option<(ModPath, ImportScope, Option)>, + import_to_add: Option, local_name: Option, variant: hir::EnumVariant, path: Option, ) -> CompletionItem { let _p = profile::span("render_enum_variant"); - EnumVariantRender::new(ctx, local_name, variant, path).render(import_data) + EnumVariantRender::new(ctx, local_name, variant, path).render(import_to_add) } #[derive(Debug)] @@ -63,10 +62,7 @@ impl<'a> EnumVariantRender<'a> { } } - fn render( - self, - import_data: Option<(ModPath, ImportScope, Option)>, - ) -> CompletionItem { + fn render(self, import_to_add: Option) -> CompletionItem { let mut builder = CompletionItem::new( CompletionKind::Reference, self.ctx.source_range(), @@ -75,7 +71,7 @@ impl<'a> EnumVariantRender<'a> { .kind(CompletionItemKind::EnumVariant) .set_documentation(self.variant.docs(self.ctx.db())) .set_deprecated(self.ctx.is_deprecated(self.variant)) - .import_data(import_data) + .add_import(import_to_add) .detail(self.detail()); if self.variant_kind == StructKind::Tuple { -- cgit v1.2.3