From f6ed16674c461cb20c39e787fffab2269b9629b0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 20 Dec 2020 10:05:24 +0300 Subject: Align code_model name with ungrammar --- crates/assists/src/handlers/extract_struct_from_enum_variant.rs | 8 ++++---- crates/assists/src/handlers/fill_match_arms.rs | 2 +- crates/assists/src/handlers/fix_visibility.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/assists') diff --git a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs index 2e56bd7ff..030b9cd0c 100644 --- a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs @@ -1,7 +1,7 @@ use std::iter; use either::Either; -use hir::{AsName, EnumVariant, Module, ModuleDef, Name}; +use hir::{AsName, Module, ModuleDef, Name, Variant}; use ide_db::helpers::{ insert_use::{insert_use, ImportScope}, mod_path_to_ast, @@ -53,7 +53,7 @@ pub(crate) fn extract_struct_from_enum_variant( let variant_hir_name = variant_hir.name(ctx.db()); let enum_module_def = ModuleDef::from(enum_hir); let usages = - Definition::ModuleDef(ModuleDef::EnumVariant(variant_hir)).usages(&ctx.sema).all(); + Definition::ModuleDef(ModuleDef::Variant(variant_hir)).usages(&ctx.sema).all(); let mut visited_modules_set = FxHashSet::default(); let current_module = enum_hir.module(ctx.db()); @@ -109,7 +109,7 @@ fn extract_field_list_if_applicable( } } -fn existing_definition(db: &RootDatabase, variant_name: &ast::Name, variant: &EnumVariant) -> bool { +fn existing_definition(db: &RootDatabase, variant_name: &ast::Name, variant: &Variant) -> bool { variant .parent_enum(db) .module(db) @@ -119,7 +119,7 @@ fn existing_definition(db: &RootDatabase, variant_name: &ast::Name, variant: &En // only check type-namespace hir::ScopeDef::ModuleDef(def) => matches!(def, ModuleDef::Module(_) | ModuleDef::Adt(_) | - ModuleDef::EnumVariant(_) | ModuleDef::Trait(_) | + ModuleDef::Variant(_) | ModuleDef::Trait(_) | ModuleDef::TypeAlias(_) | ModuleDef::BuiltinType(_) ), _ => false, diff --git a/crates/assists/src/handlers/fill_match_arms.rs b/crates/assists/src/handlers/fill_match_arms.rs index ef12ef0cf..cb60a3128 100644 --- a/crates/assists/src/handlers/fill_match_arms.rs +++ b/crates/assists/src/handlers/fill_match_arms.rs @@ -192,7 +192,7 @@ fn resolve_tuple_of_enum_def( .collect() } -fn build_pat(db: &RootDatabase, module: hir::Module, var: hir::EnumVariant) -> Option { +fn build_pat(db: &RootDatabase, module: hir::Module, var: hir::Variant) -> Option { let path = mod_path_to_ast(&module.find_use_path(db, ModuleDef::from(var))?); // FIXME: use HIR for this; it doesn't currently expose struct vs. tuple vs. unit variants though diff --git a/crates/assists/src/handlers/fix_visibility.rs b/crates/assists/src/handlers/fix_visibility.rs index c86720787..8558a8ff0 100644 --- a/crates/assists/src/handlers/fix_visibility.rs +++ b/crates/assists/src/handlers/fix_visibility.rs @@ -201,7 +201,7 @@ fn target_data_for_def( (vis_offset(syntax), in_file_source.value.visibility(), syntax.text_range(), file_id) } // Enum variants can't be private, we can't modify builtin types - hir::ModuleDef::EnumVariant(_) | hir::ModuleDef::BuiltinType(_) => return None, + hir::ModuleDef::Variant(_) | hir::ModuleDef::BuiltinType(_) => return None, }; Some((offset, current_visibility, target, target_file, target_name)) -- cgit v1.2.3