aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2021-03-07 22:25:45 +0000
committerKirill Bulatov <[email protected]>2021-03-08 21:59:20 +0000
commitdccbb38d2e28bfeb53f31c13de3b83e72f1a476c (patch)
treecf651b25be3c2dd2618e90738aa4f6600077cc9a /crates/ide_completion/src
parentdb61d4ea13113cd6c4e0661075ea9b2f739be862 (diff)
Less lifetines: derive SemanticsScope in place
Diffstat (limited to 'crates/ide_completion/src')
-rw-r--r--crates/ide_completion/src/completions/flyimport.rs11
-rw-r--r--crates/ide_completion/src/lib.rs2
2 files changed, 9 insertions, 4 deletions
diff --git a/crates/ide_completion/src/completions/flyimport.rs b/crates/ide_completion/src/completions/flyimport.rs
index 8a11cba41..391a11c91 100644
--- a/crates/ide_completion/src/completions/flyimport.rs
+++ b/crates/ide_completion/src/completions/flyimport.rs
@@ -169,23 +169,28 @@ pub(crate) fn position_for_import<'a>(
169 }) 169 })
170} 170}
171 171
172fn import_assets<'a>(ctx: &'a CompletionContext, fuzzy_name: String) -> Option<ImportAssets<'a>> { 172fn import_assets(ctx: &CompletionContext, fuzzy_name: String) -> Option<ImportAssets> {
173 let current_module = ctx.scope.module()?; 173 let current_module = ctx.scope.module()?;
174 if let Some(dot_receiver) = &ctx.dot_receiver { 174 if let Some(dot_receiver) = &ctx.dot_receiver {
175 ImportAssets::for_fuzzy_method_call( 175 ImportAssets::for_fuzzy_method_call(
176 current_module, 176 current_module,
177 ctx.sema.type_of_expr(dot_receiver)?, 177 ctx.sema.type_of_expr(dot_receiver)?,
178 fuzzy_name, 178 fuzzy_name,
179 ctx.scope.clone(), 179 dot_receiver.syntax().clone(),
180 ) 180 )
181 } else { 181 } else {
182 let fuzzy_name_length = fuzzy_name.len(); 182 let fuzzy_name_length = fuzzy_name.len();
183 let approximate_node = match current_module.definition_source(ctx.db).value {
184 hir::ModuleSource::SourceFile(s) => s.syntax().clone(),
185 hir::ModuleSource::Module(m) => m.syntax().clone(),
186 hir::ModuleSource::BlockExpr(b) => b.syntax().clone(),
187 };
183 let assets_for_path = ImportAssets::for_fuzzy_path( 188 let assets_for_path = ImportAssets::for_fuzzy_path(
184 current_module, 189 current_module,
185 ctx.path_qual.clone(), 190 ctx.path_qual.clone(),
186 fuzzy_name, 191 fuzzy_name,
187 &ctx.sema, 192 &ctx.sema,
188 ctx.scope.clone(), 193 approximate_node,
189 )?; 194 )?;
190 195
191 if matches!(assets_for_path.import_candidate(), ImportCandidate::Path(_)) 196 if matches!(assets_for_path.import_candidate(), ImportCandidate::Path(_))
diff --git a/crates/ide_completion/src/lib.rs b/crates/ide_completion/src/lib.rs
index 5470914fb..a0c8c374d 100644
--- a/crates/ide_completion/src/lib.rs
+++ b/crates/ide_completion/src/lib.rs
@@ -150,7 +150,7 @@ pub fn resolve_completion_edits(
150 let current_crate = current_module.krate(); 150 let current_crate = current_module.krate();
151 151
152 let (import_path, item_to_import) = 152 let (import_path, item_to_import) =
153 items_locator::with_for_exact_name(&ctx.sema, current_crate, imported_name) 153 items_locator::with_exact_name(&ctx.sema, current_crate, imported_name)
154 .into_iter() 154 .into_iter()
155 .filter_map(|candidate| { 155 .filter_map(|candidate| {
156 current_module 156 current_module