diff options
Diffstat (limited to 'crates/completion/src/render.rs')
-rw-r--r-- | crates/completion/src/render.rs | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/crates/completion/src/render.rs b/crates/completion/src/render.rs index 504757a6a..b940388df 100644 --- a/crates/completion/src/render.rs +++ b/crates/completion/src/render.rs | |||
@@ -9,14 +9,13 @@ pub(crate) mod type_alias; | |||
9 | 9 | ||
10 | mod builder_ext; | 10 | mod builder_ext; |
11 | 11 | ||
12 | use hir::{Documentation, HasAttrs, HirDisplay, ModPath, Mutability, ScopeDef, Type}; | 12 | use hir::{Documentation, HasAttrs, HirDisplay, Mutability, ScopeDef, Type}; |
13 | use ide_db::helpers::insert_use::{ImportScope, MergeBehaviour}; | ||
14 | use ide_db::RootDatabase; | 13 | use ide_db::RootDatabase; |
15 | use syntax::TextRange; | 14 | use syntax::TextRange; |
16 | use test_utils::mark; | 15 | use test_utils::mark; |
17 | 16 | ||
18 | use crate::{ | 17 | use crate::{ |
19 | config::SnippetCap, item::ImportToAdd, CompletionContext, CompletionItem, CompletionItemKind, | 18 | config::SnippetCap, item::ImportEdit, CompletionContext, CompletionItem, CompletionItemKind, |
20 | CompletionKind, CompletionScore, | 19 | CompletionKind, CompletionScore, |
21 | }; | 20 | }; |
22 | 21 | ||
@@ -48,15 +47,12 @@ pub(crate) fn render_resolution<'a>( | |||
48 | 47 | ||
49 | pub(crate) fn render_resolution_with_import<'a>( | 48 | pub(crate) fn render_resolution_with_import<'a>( |
50 | ctx: RenderContext<'a>, | 49 | ctx: RenderContext<'a>, |
51 | import_path: ModPath, | 50 | import_edit: ImportEdit, |
52 | import_scope: ImportScope, | ||
53 | merge_behaviour: Option<MergeBehaviour>, | ||
54 | resolution: &ScopeDef, | 51 | resolution: &ScopeDef, |
55 | ) -> Option<CompletionItem> { | 52 | ) -> Option<CompletionItem> { |
56 | let local_name = import_path.segments.last()?.to_string(); | ||
57 | Render::new(ctx).render_resolution( | 53 | Render::new(ctx).render_resolution( |
58 | local_name, | 54 | import_edit.import_path.segments.last()?.to_string(), |
59 | Some(ImportToAdd { import_path, import_scope, merge_behaviour }), | 55 | Some(import_edit), |
60 | resolution, | 56 | resolution, |
61 | ) | 57 | ) |
62 | } | 58 | } |
@@ -147,7 +143,7 @@ impl<'a> Render<'a> { | |||
147 | fn render_resolution( | 143 | fn render_resolution( |
148 | self, | 144 | self, |
149 | local_name: String, | 145 | local_name: String, |
150 | import_to_add: Option<ImportToAdd>, | 146 | import_to_add: Option<ImportEdit>, |
151 | resolution: &ScopeDef, | 147 | resolution: &ScopeDef, |
152 | ) -> Option<CompletionItem> { | 148 | ) -> Option<CompletionItem> { |
153 | let _p = profile::span("render_resolution"); | 149 | let _p = profile::span("render_resolution"); |
@@ -451,28 +447,6 @@ fn main() { let _: m::Spam = S<|> } | |||
451 | kind: Module, | 447 | kind: Module, |
452 | }, | 448 | }, |
453 | CompletionItem { | 449 | CompletionItem { |
454 | label: "m::Spam", | ||
455 | source_range: 75..76, | ||
456 | text_edit: TextEdit { | ||
457 | indels: [ | ||
458 | Indel { | ||
459 | insert: "use m::Spam;", | ||
460 | delete: 0..0, | ||
461 | }, | ||
462 | Indel { | ||
463 | insert: "\n\n", | ||
464 | delete: 0..0, | ||
465 | }, | ||
466 | Indel { | ||
467 | insert: "Spam", | ||
468 | delete: 75..76, | ||
469 | }, | ||
470 | ], | ||
471 | }, | ||
472 | kind: Enum, | ||
473 | lookup: "Spam", | ||
474 | }, | ||
475 | CompletionItem { | ||
476 | label: "m::Spam::Foo", | 450 | label: "m::Spam::Foo", |
477 | source_range: 75..76, | 451 | source_range: 75..76, |
478 | delete: 75..76, | 452 | delete: 75..76, |