mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Less lifetines: derive SemanticsScope in place
This commit is contained in:
parent
db61d4ea13
commit
dccbb38d2e
7 changed files with 49 additions and 50 deletions
|
@ -169,23 +169,28 @@ pub(crate) fn position_for_import<'a>(
|
|||
})
|
||||
}
|
||||
|
||||
fn import_assets<'a>(ctx: &'a CompletionContext, fuzzy_name: String) -> Option<ImportAssets<'a>> {
|
||||
fn import_assets(ctx: &CompletionContext, fuzzy_name: String) -> Option<ImportAssets> {
|
||||
let current_module = ctx.scope.module()?;
|
||||
if let Some(dot_receiver) = &ctx.dot_receiver {
|
||||
ImportAssets::for_fuzzy_method_call(
|
||||
current_module,
|
||||
ctx.sema.type_of_expr(dot_receiver)?,
|
||||
fuzzy_name,
|
||||
ctx.scope.clone(),
|
||||
dot_receiver.syntax().clone(),
|
||||
)
|
||||
} else {
|
||||
let fuzzy_name_length = fuzzy_name.len();
|
||||
let approximate_node = match current_module.definition_source(ctx.db).value {
|
||||
hir::ModuleSource::SourceFile(s) => s.syntax().clone(),
|
||||
hir::ModuleSource::Module(m) => m.syntax().clone(),
|
||||
hir::ModuleSource::BlockExpr(b) => b.syntax().clone(),
|
||||
};
|
||||
let assets_for_path = ImportAssets::for_fuzzy_path(
|
||||
current_module,
|
||||
ctx.path_qual.clone(),
|
||||
fuzzy_name,
|
||||
&ctx.sema,
|
||||
ctx.scope.clone(),
|
||||
approximate_node,
|
||||
)?;
|
||||
|
||||
if matches!(assets_for_path.import_candidate(), ImportCandidate::Path(_))
|
||||
|
|
|
@ -150,7 +150,7 @@ pub fn resolve_completion_edits(
|
|||
let current_crate = current_module.krate();
|
||||
|
||||
let (import_path, item_to_import) =
|
||||
items_locator::with_for_exact_name(&ctx.sema, current_crate, imported_name)
|
||||
items_locator::with_exact_name(&ctx.sema, current_crate, imported_name)
|
||||
.into_iter()
|
||||
.filter_map(|candidate| {
|
||||
current_module
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue