diff options
author | Kirill Bulatov <[email protected]> | 2021-03-07 22:25:45 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2021-03-08 21:59:20 +0000 |
commit | dccbb38d2e28bfeb53f31c13de3b83e72f1a476c (patch) | |
tree | cf651b25be3c2dd2618e90738aa4f6600077cc9a /crates/ide_completion/src/completions | |
parent | db61d4ea13113cd6c4e0661075ea9b2f739be862 (diff) |
Less lifetines: derive SemanticsScope in place
Diffstat (limited to 'crates/ide_completion/src/completions')
-rw-r--r-- | crates/ide_completion/src/completions/flyimport.rs | 11 |
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 | ||
172 | fn import_assets<'a>(ctx: &'a CompletionContext, fuzzy_name: String) -> Option<ImportAssets<'a>> { | 172 | fn 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(_)) |