aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/completions
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/completions')
-rw-r--r--crates/ide_completion/src/completions/flyimport.rs11
1 files changed, 8 insertions, 3 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(_))