diff options
Diffstat (limited to 'crates/completion/src/render.rs')
-rw-r--r-- | crates/completion/src/render.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/crates/completion/src/render.rs b/crates/completion/src/render.rs index bce02f577..504757a6a 100644 --- a/crates/completion/src/render.rs +++ b/crates/completion/src/render.rs | |||
@@ -9,15 +9,15 @@ pub(crate) mod type_alias; | |||
9 | 9 | ||
10 | mod builder_ext; | 10 | mod builder_ext; |
11 | 11 | ||
12 | use assists::utils::{ImportScope, MergeBehaviour}; | ||
13 | use hir::{Documentation, HasAttrs, HirDisplay, ModPath, Mutability, ScopeDef, Type}; | 12 | use hir::{Documentation, HasAttrs, HirDisplay, ModPath, Mutability, ScopeDef, Type}; |
13 | use ide_db::helpers::insert_use::{ImportScope, MergeBehaviour}; | ||
14 | use ide_db::RootDatabase; | 14 | use ide_db::RootDatabase; |
15 | use syntax::TextRange; | 15 | use syntax::TextRange; |
16 | use test_utils::mark; | 16 | use test_utils::mark; |
17 | 17 | ||
18 | use crate::{ | 18 | use crate::{ |
19 | config::SnippetCap, CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, | 19 | config::SnippetCap, item::ImportToAdd, CompletionContext, CompletionItem, CompletionItemKind, |
20 | CompletionScore, | 20 | CompletionKind, CompletionScore, |
21 | }; | 21 | }; |
22 | 22 | ||
23 | use crate::render::{enum_variant::render_enum_variant, function::render_fn, macro_::render_macro}; | 23 | use crate::render::{enum_variant::render_enum_variant, function::render_fn, macro_::render_macro}; |
@@ -48,15 +48,15 @@ pub(crate) fn render_resolution<'a>( | |||
48 | 48 | ||
49 | pub(crate) fn render_resolution_with_import<'a>( | 49 | pub(crate) fn render_resolution_with_import<'a>( |
50 | ctx: RenderContext<'a>, | 50 | ctx: RenderContext<'a>, |
51 | import: ModPath, | 51 | import_path: ModPath, |
52 | import_scope: ImportScope, | 52 | import_scope: ImportScope, |
53 | merge_behaviour: Option<MergeBehaviour>, | 53 | merge_behaviour: Option<MergeBehaviour>, |
54 | resolution: &ScopeDef, | 54 | resolution: &ScopeDef, |
55 | ) -> Option<CompletionItem> { | 55 | ) -> Option<CompletionItem> { |
56 | let local_name = import.segments.last()?.to_string(); | 56 | let local_name = import_path.segments.last()?.to_string(); |
57 | Render::new(ctx).render_resolution( | 57 | Render::new(ctx).render_resolution( |
58 | local_name, | 58 | local_name, |
59 | Some((import, import_scope, merge_behaviour)), | 59 | Some(ImportToAdd { import_path, import_scope, merge_behaviour }), |
60 | resolution, | 60 | resolution, |
61 | ) | 61 | ) |
62 | } | 62 | } |
@@ -147,7 +147,7 @@ impl<'a> Render<'a> { | |||
147 | fn render_resolution( | 147 | fn render_resolution( |
148 | self, | 148 | self, |
149 | local_name: String, | 149 | local_name: String, |
150 | import_data: Option<(ModPath, ImportScope, Option<MergeBehaviour>)>, | 150 | import_to_add: Option<ImportToAdd>, |
151 | resolution: &ScopeDef, | 151 | resolution: &ScopeDef, |
152 | ) -> Option<CompletionItem> { | 152 | ) -> Option<CompletionItem> { |
153 | let _p = profile::span("render_resolution"); | 153 | let _p = profile::span("render_resolution"); |
@@ -160,15 +160,16 @@ impl<'a> Render<'a> { | |||
160 | 160 | ||
161 | let kind = match resolution { | 161 | let kind = match resolution { |
162 | ScopeDef::ModuleDef(Function(func)) => { | 162 | ScopeDef::ModuleDef(Function(func)) => { |
163 | let item = render_fn(self.ctx, import_data, Some(local_name), *func); | 163 | let item = render_fn(self.ctx, import_to_add, Some(local_name), *func); |
164 | return Some(item); | 164 | return Some(item); |
165 | } | 165 | } |
166 | ScopeDef::ModuleDef(EnumVariant(var)) => { | 166 | ScopeDef::ModuleDef(EnumVariant(var)) => { |
167 | let item = render_enum_variant(self.ctx, import_data, Some(local_name), *var, None); | 167 | let item = |
168 | render_enum_variant(self.ctx, import_to_add, Some(local_name), *var, None); | ||
168 | return Some(item); | 169 | return Some(item); |
169 | } | 170 | } |
170 | ScopeDef::MacroDef(mac) => { | 171 | ScopeDef::MacroDef(mac) => { |
171 | let item = render_macro(self.ctx, import_data, local_name, *mac); | 172 | let item = render_macro(self.ctx, import_to_add, local_name, *mac); |
172 | return item; | 173 | return item; |
173 | } | 174 | } |
174 | 175 | ||
@@ -193,7 +194,7 @@ impl<'a> Render<'a> { | |||
193 | local_name, | 194 | local_name, |
194 | ) | 195 | ) |
195 | .kind(CompletionItemKind::UnresolvedReference) | 196 | .kind(CompletionItemKind::UnresolvedReference) |
196 | .import_data(import_data) | 197 | .add_import(import_to_add) |
197 | .build(); | 198 | .build(); |
198 | return Some(item); | 199 | return Some(item); |
199 | } | 200 | } |
@@ -248,7 +249,7 @@ impl<'a> Render<'a> { | |||
248 | 249 | ||
249 | let item = item | 250 | let item = item |
250 | .kind(kind) | 251 | .kind(kind) |
251 | .import_data(import_data) | 252 | .add_import(import_to_add) |
252 | .set_documentation(docs) | 253 | .set_documentation(docs) |
253 | .set_ref_match(ref_match) | 254 | .set_ref_match(ref_match) |
254 | .build(); | 255 | .build(); |