Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-assists/src/handlers/extract_module.rs')
| -rw-r--r-- | crates/ide-assists/src/handlers/extract_module.rs | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/crates/ide-assists/src/handlers/extract_module.rs b/crates/ide-assists/src/handlers/extract_module.rs index a77b5e4a1a..b82b7984d4 100644 --- a/crates/ide-assists/src/handlers/extract_module.rs +++ b/crates/ide-assists/src/handlers/extract_module.rs @@ -1,8 +1,7 @@ use std::iter; use either::Either; -use hir::{HasSource, HirFileIdExt, ModuleSource}; -use ide_db::base_db::salsa::AsDynDatabase; +use hir::{HasSource, ModuleSource}; use ide_db::{ FileId, FxHashMap, FxHashSet, assists::AssistId, @@ -114,7 +113,7 @@ pub(crate) fn extract_module(acc: &mut Assists, ctx: &AssistContext<'_>) -> Opti let (usages_to_be_processed, record_fields, use_stmts_to_be_inserted) = module.get_usages_and_record_fields(ctx); - builder.edit_file(ctx.file_id()); + builder.edit_file(ctx.vfs_file_id()); use_stmts_to_be_inserted.into_iter().for_each(|(_, use_stmt)| { builder.insert(ctx.selection_trimmed().end(), format!("\n{use_stmt}")); }); @@ -126,7 +125,7 @@ pub(crate) fn extract_module(acc: &mut Assists, ctx: &AssistContext<'_>) -> Opti let mut usages_to_be_processed_for_cur_file = vec![]; for (file_id, usages) in usages_to_be_processed { - if file_id == ctx.file_id() { + if file_id == ctx.vfs_file_id() { usages_to_be_processed_for_cur_file = usages; continue; } @@ -136,7 +135,7 @@ pub(crate) fn extract_module(acc: &mut Assists, ctx: &AssistContext<'_>) -> Opti } } - builder.edit_file(ctx.file_id()); + builder.edit_file(ctx.vfs_file_id()); for (text_range, usage) in usages_to_be_processed_for_cur_file { builder.replace(text_range, usage); } @@ -333,10 +332,7 @@ impl Module { let mut use_stmts_set = FxHashSet::default(); for (file_id, refs) in node_def.usages(&ctx.sema).all() { - let editioned_file_id = - ide_db::base_db::EditionedFileId::new(ctx.sema.db.as_dyn_database(), file_id); - - let source_file = ctx.sema.parse(editioned_file_id); + let source_file = ctx.sema.parse(file_id); let usages = refs.into_iter().filter_map(|FileReference { range, .. }| { // handle normal usages let name_ref = find_node_at_range::<ast::NameRef>(source_file.syntax(), range)?; @@ -368,7 +364,7 @@ impl Module { None }); - refs_in_files.entry(file_id.file_id()).or_default().extend(usages); + refs_in_files.entry(file_id.file_id(ctx.db())).or_default().extend(usages); } } @@ -463,10 +459,7 @@ impl Module { let file_id = ctx.file_id(); let usage_res = def.usages(&ctx.sema).in_scope(&SearchScope::single_file(file_id)).all(); - let editioned_file_id = - ide_db::base_db::EditionedFileId::new(ctx.sema.db.as_dyn_database(), file_id); - - let file = ctx.sema.parse(editioned_file_id); + let file = ctx.sema.parse(file_id); // track uses which does not exists in `Use` let mut uses_exist_in_sel = false; @@ -492,7 +485,7 @@ impl Module { ctx, curr_parent_module, selection_range, - file_id.file_id(), + file_id.file_id(ctx.db()), ); // Find use stmt that use def in current file @@ -679,7 +672,7 @@ fn check_def_in_mod_and_out_sel( let have_same_parent = if let Some(ast_module) = &curr_parent_module { ctx.sema.to_module_def(ast_module).is_some_and(|it| it == $x.module(ctx.db())) } else { - source.file_id.original_file(ctx.db()) == curr_file_id + source.file_id.original_file(ctx.db()).file_id(ctx.db()) == curr_file_id }; let in_sel = !selection_range.contains_range(source.value.syntax().text_range()); @@ -695,7 +688,7 @@ fn check_def_in_mod_and_out_sel( (Some(ast_module), Some(hir_module)) => { ctx.sema.to_module_def(ast_module).is_some_and(|it| it == hir_module) } - _ => source.file_id.original_file(ctx.db()) == curr_file_id, + _ => source.file_id.original_file(ctx.db()).file_id(ctx.db()) == curr_file_id, }; if have_same_parent { |