diff options
Diffstat (limited to 'crates/ide_completion/src/lib.rs')
-rw-r--r-- | crates/ide_completion/src/lib.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/crates/ide_completion/src/lib.rs b/crates/ide_completion/src/lib.rs index ca2e5e706..d19368de0 100644 --- a/crates/ide_completion/src/lib.rs +++ b/crates/ide_completion/src/lib.rs | |||
@@ -15,7 +15,7 @@ use completions::flyimport::position_for_import; | |||
15 | use ide_db::{ | 15 | use ide_db::{ |
16 | base_db::FilePosition, | 16 | base_db::FilePosition, |
17 | helpers::{import_assets::LocatedImport, insert_use::ImportScope}, | 17 | helpers::{import_assets::LocatedImport, insert_use::ImportScope}, |
18 | imports_locator, RootDatabase, | 18 | items_locator, RootDatabase, |
19 | }; | 19 | }; |
20 | use text_edit::TextEdit; | 20 | use text_edit::TextEdit; |
21 | 21 | ||
@@ -141,7 +141,6 @@ pub fn resolve_completion_edits( | |||
141 | position: FilePosition, | 141 | position: FilePosition, |
142 | full_import_path: &str, | 142 | full_import_path: &str, |
143 | imported_name: String, | 143 | imported_name: String, |
144 | import_for_trait_assoc_item: bool, | ||
145 | ) -> Option<Vec<TextEdit>> { | 144 | ) -> Option<Vec<TextEdit>> { |
146 | let ctx = CompletionContext::new(db, position, config)?; | 145 | let ctx = CompletionContext::new(db, position, config)?; |
147 | let position_for_import = position_for_import(&ctx, None)?; | 146 | let position_for_import = position_for_import(&ctx, None)?; |
@@ -151,19 +150,17 @@ pub fn resolve_completion_edits( | |||
151 | let current_crate = current_module.krate(); | 150 | let current_crate = current_module.krate(); |
152 | 151 | ||
153 | let (import_path, item_to_import) = | 152 | let (import_path, item_to_import) = |
154 | imports_locator::find_exact_imports(&ctx.sema, current_crate, imported_name) | 153 | items_locator::with_for_exact_name(&ctx.sema, current_crate, imported_name) |
154 | .into_iter() | ||
155 | .filter_map(|candidate| { | 155 | .filter_map(|candidate| { |
156 | let item: hir::ItemInNs = candidate.either(Into::into, Into::into); | ||
157 | current_module | 156 | current_module |
158 | .find_use_path_prefixed(db, item, config.insert_use.prefix_kind) | 157 | .find_use_path_prefixed(db, candidate, config.insert_use.prefix_kind) |
159 | .zip(Some(item)) | 158 | .zip(Some(candidate)) |
160 | }) | 159 | }) |
161 | .find(|(mod_path, _)| mod_path.to_string() == full_import_path)?; | 160 | .find(|(mod_path, _)| mod_path.to_string() == full_import_path)?; |
162 | let import = LocatedImport::new(import_path, item_to_import, None); | 161 | let import = LocatedImport::new(import_path, item_to_import, item_to_import); |
163 | 162 | ||
164 | ImportEdit { import_path, import_scope, import_for_trait_assoc_item } | 163 | ImportEdit { import, import_scope }.to_text_edit(config.insert_use).map(|edit| vec![edit]) |
165 | .to_text_edit(config.insert_use) | ||
166 | .map(|edit| vec![edit]) | ||
167 | } | 164 | } |
168 | 165 | ||
169 | #[cfg(test)] | 166 | #[cfg(test)] |