aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/lib.rs')
-rw-r--r--crates/ide_completion/src/lib.rs29
1 files changed, 19 insertions, 10 deletions
diff --git a/crates/ide_completion/src/lib.rs b/crates/ide_completion/src/lib.rs
index d9ea7b7ea..5ac1cb48d 100644
--- a/crates/ide_completion/src/lib.rs
+++ b/crates/ide_completion/src/lib.rs
@@ -14,7 +14,10 @@ mod completions;
14use completions::flyimport::position_for_import; 14use completions::flyimport::position_for_import;
15use ide_db::{ 15use ide_db::{
16 base_db::FilePosition, 16 base_db::FilePosition,
17 helpers::{import_assets::LocatedImport, insert_use::ImportScope}, 17 helpers::{
18 import_assets::{LocatedImport, NameToImport},
19 insert_use::ImportScope,
20 },
18 items_locator, RootDatabase, 21 items_locator, RootDatabase,
19}; 22};
20use text_edit::TextEdit; 23use text_edit::TextEdit;
@@ -130,6 +133,8 @@ pub fn completions(
130 completions::trait_impl::complete_trait_impl(&mut acc, &ctx); 133 completions::trait_impl::complete_trait_impl(&mut acc, &ctx);
131 completions::mod_::complete_mod(&mut acc, &ctx); 134 completions::mod_::complete_mod(&mut acc, &ctx);
132 completions::flyimport::import_on_the_fly(&mut acc, &ctx); 135 completions::flyimport::import_on_the_fly(&mut acc, &ctx);
136 completions::lifetime::complete_lifetime(&mut acc, &ctx);
137 completions::lifetime::complete_label(&mut acc, &ctx);
133 138
134 Some(acc) 139 Some(acc)
135} 140}
@@ -149,15 +154,19 @@ pub fn resolve_completion_edits(
149 let current_module = ctx.sema.scope(position_for_import).module()?; 154 let current_module = ctx.sema.scope(position_for_import).module()?;
150 let current_crate = current_module.krate(); 155 let current_crate = current_module.krate();
151 156
152 let (import_path, item_to_import) = 157 let (import_path, item_to_import) = items_locator::items_with_name(
153 items_locator::with_exact_name(&ctx.sema, current_crate, imported_name) 158 &ctx.sema,
154 .into_iter() 159 current_crate,
155 .filter_map(|candidate| { 160 NameToImport::Exact(imported_name),
156 current_module 161 items_locator::AssocItemSearch::Include,
157 .find_use_path_prefixed(db, candidate, config.insert_use.prefix_kind) 162 Some(items_locator::DEFAULT_QUERY_SEARCH_LIMIT),
158 .zip(Some(candidate)) 163 )
159 }) 164 .filter_map(|candidate| {
160 .find(|(mod_path, _)| mod_path.to_string() == full_import_path)?; 165 current_module
166 .find_use_path_prefixed(db, candidate, config.insert_use.prefix_kind)
167 .zip(Some(candidate))
168 })
169 .find(|(mod_path, _)| mod_path.to_string() == full_import_path)?;
161 let import = 170 let import =
162 LocatedImport::new(import_path.clone(), item_to_import, item_to_import, Some(import_path)); 171 LocatedImport::new(import_path.clone(), item_to_import, item_to_import, Some(import_path));
163 172