use rustc_hash::FxHashSet;
use syntax::{
ast::{
- self, edit::IndentLevel, edit_in_place::Indent, make, AstNode, AttrsOwner,
- GenericParamsOwner, NameOwner, TypeBoundsOwner, VisibilityOwner,
+ self, edit::IndentLevel, edit_in_place::Indent, make, AstNode, HasAttrs, HasGenericParams,
+ HasName, HasTypeBounds, HasVisibility,
},
match_ast,
ted::{self, Position},
|builder| {
let variant_hir_name = variant_hir.name(ctx.db());
let enum_module_def = ModuleDef::from(enum_hir);
- let usages =
- Definition::ModuleDef(ModuleDef::Variant(variant_hir)).usages(&ctx.sema).all();
+ let usages = Definition::Variant(variant_hir).usages(&ctx.sema).all();
let mut visited_modules_set = FxHashSet::default();
let current_module = enum_hir.module(ctx.db());
// record file references of the file the def resides in, we only want to swap to the edited file in the builder once
let mut def_file_references = None;
for (file_id, references) in usages {
- if file_id == ctx.frange.file_id {
+ if file_id == ctx.file_id() {
def_file_references = Some(references);
continue;
}
apply_references(ctx.config.insert_use, path, node, import)
});
}
- builder.edit_file(ctx.frange.file_id);
+ builder.edit_file(ctx.file_id());
let variant = builder.make_mut(variant.clone());
if let Some(references) = def_file_references {
if let Some(mut mod_path) = mod_path {
mod_path.pop_segment();
mod_path.push_segment(variant_hir_name.clone());
- let scope = ImportScope::find_insert_use_container(&scope_node)?;
+ let scope = ImportScope::find_insert_use_container(&scope_node, &ctx.sema)?;
visited_modules.insert(module);
return Some((segment, scope_node, Some((scope, mod_path))));
}