From 609680ef97dbf82c07b6b06e21aa366423892304 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 17:52:53 +0200 Subject: Rename EnumDef -> Enum --- .../ra_assists/src/handlers/change_visibility.rs | 4 +-- crates/ra_assists/src/handlers/move_bounds.rs | 2 +- crates/ra_hir/src/has_source.rs | 4 +-- crates/ra_hir/src/semantics.rs | 2 +- crates/ra_hir/src/semantics/source_to_def.rs | 6 ++-- crates/ra_hir_def/src/adt.rs | 2 +- crates/ra_hir_def/src/body/lower.rs | 2 +- crates/ra_hir_def/src/item_tree.rs | 4 +-- crates/ra_hir_def/src/item_tree/lower.rs | 6 ++-- crates/ra_hir_def/src/item_tree/tests.rs | 2 +- crates/ra_hir_def/src/keys.rs | 2 +- crates/ra_hir_expand/src/builtin_derive.rs | 2 +- crates/ra_ide/src/display/navigation_target.rs | 8 ++--- crates/ra_ide/src/display/short_label.rs | 2 +- crates/ra_ide/src/file_structure.rs | 4 +-- crates/ra_ide/src/goto_implementation.rs | 2 +- crates/ra_ide/src/syntax_highlighting.rs | 2 +- crates/ra_ide_db/src/defs.rs | 2 +- crates/ra_ide_db/src/symbol_index.rs | 4 +-- crates/ra_mbe/src/tests.rs | 4 +-- crates/ra_parser/src/grammar/items/adt.rs | 2 +- crates/ra_parser/src/syntax_kind/generated.rs | 2 +- crates/ra_syntax/src/ast/generated/nodes.rs | 42 +++++++++++----------- crates/ra_syntax/src/ast/node_ext.rs | 6 ++-- crates/ra_syntax/src/parsing/text_tree_sink.rs | 2 +- .../ra_syntax/test_data/parser/err/0025_nope.rast | 8 ++--- .../inline/ok/0118_impl_inner_attributes.rast | 2 +- .../inline/ok/0134_nocontentexpr_after_item.rast | 2 +- .../inline/ok/0157_variant_discriminant.rast | 2 +- .../ra_syntax/test_data/parser/ok/0019_enums.rast | 10 +++--- .../parser/ok/0047_minus_in_inner_pattern.rast | 2 +- crates/rust-analyzer/src/handlers.rs | 2 +- crates/rust-analyzer/src/to_proto.rs | 2 +- 33 files changed, 75 insertions(+), 75 deletions(-) (limited to 'crates') diff --git a/crates/ra_assists/src/handlers/change_visibility.rs b/crates/ra_assists/src/handlers/change_visibility.rs index 12c40a3cc..44f3e8ee3 100644 --- a/crates/ra_assists/src/handlers/change_visibility.rs +++ b/crates/ra_assists/src/handlers/change_visibility.rs @@ -1,7 +1,7 @@ use ra_syntax::{ ast::{self, NameOwner, VisibilityOwner}, AstNode, - SyntaxKind::{CONST_DEF, ENUM_DEF, FN, MODULE, STATIC_DEF, STRUCT, TRAIT_DEF, VISIBILITY}, + SyntaxKind::{CONST_DEF, ENUM, FN, MODULE, STATIC_DEF, STRUCT, TRAIT_DEF, VISIBILITY}, T, }; use test_utils::mark; @@ -36,7 +36,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { let (offset, target) = if let Some(keyword) = item_keyword { let parent = keyword.parent(); - let def_kws = vec![CONST_DEF, STATIC_DEF, FN, MODULE, STRUCT, ENUM_DEF, TRAIT_DEF]; + let def_kws = vec![CONST_DEF, STATIC_DEF, FN, MODULE, STRUCT, ENUM, TRAIT_DEF]; // Parent is not a definition, can't add visibility if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) { return None; diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/ra_assists/src/handlers/move_bounds.rs index 3b82477c5..84ac75fa8 100644 --- a/crates/ra_assists/src/handlers/move_bounds.rs +++ b/crates/ra_assists/src/handlers/move_bounds.rs @@ -40,7 +40,7 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext ast::Fn(it) => it.body()?.syntax().clone().into(), ast::TraitDef(it) => it.assoc_item_list()?.syntax().clone().into(), ast::ImplDef(it) => it.assoc_item_list()?.syntax().clone().into(), - ast::EnumDef(it) => it.variant_list()?.syntax().clone().into(), + ast::Enum(it) => it.variant_list()?.syntax().clone().into(), ast::Struct(it) => { it.syntax().children_with_tokens() .find(|it| it.kind() == RECORD_FIELD_LIST || it.kind() == T![;])? diff --git a/crates/ra_hir/src/has_source.rs b/crates/ra_hir/src/has_source.rs index 811a12e00..88399f724 100644 --- a/crates/ra_hir/src/has_source.rs +++ b/crates/ra_hir/src/has_source.rs @@ -69,8 +69,8 @@ impl HasSource for Union { } } impl HasSource for Enum { - type Ast = ast::EnumDef; - fn source(self, db: &dyn HirDatabase) -> InFile { + type Ast = ast::Enum; + fn source(self, db: &dyn HirDatabase) -> InFile { self.id.lookup(db.upcast()).source(db.upcast()) } } diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs index 7df018b05..f8e70fe27 100644 --- a/crates/ra_hir/src/semantics.rs +++ b/crates/ra_hir/src/semantics.rs @@ -581,7 +581,7 @@ macro_rules! to_def_impls { to_def_impls![ (crate::Module, ast::Module, module_to_def), (crate::Struct, ast::Struct, struct_to_def), - (crate::Enum, ast::EnumDef, enum_to_def), + (crate::Enum, ast::Enum, enum_to_def), (crate::Union, ast::Union, union_to_def), (crate::Trait, ast::TraitDef, trait_to_def), (crate::ImplDef, ast::ImplDef, impl_to_def), diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/ra_hir/src/semantics/source_to_def.rs index 75b773352..9f81b952f 100644 --- a/crates/ra_hir/src/semantics/source_to_def.rs +++ b/crates/ra_hir/src/semantics/source_to_def.rs @@ -77,7 +77,7 @@ impl SourceToDefCtx<'_, '_> { pub(super) fn struct_to_def(&mut self, src: InFile) -> Option { self.to_def(src, keys::STRUCT) } - pub(super) fn enum_to_def(&mut self, src: InFile) -> Option { + pub(super) fn enum_to_def(&mut self, src: InFile) -> Option { self.to_def(src, keys::ENUM) } pub(super) fn union_to_def(&mut self, src: InFile) -> Option { @@ -170,7 +170,7 @@ impl SourceToDefCtx<'_, '_> { let def = self.struct_to_def(container.with_value(it))?; VariantId::from(def).into() }, - ast::EnumDef(it) => { + ast::Enum(it) => { let def = self.enum_to_def(container.with_value(it))?; def.into() }, @@ -206,7 +206,7 @@ impl SourceToDefCtx<'_, '_> { match (container.value) { ast::Fn(it) => self.fn_to_def(container.with_value(it))?.into(), ast::Struct(it) => self.struct_to_def(container.with_value(it))?.into(), - ast::EnumDef(it) => self.enum_to_def(container.with_value(it))?.into(), + ast::Enum(it) => self.enum_to_def(container.with_value(it))?.into(), ast::TraitDef(it) => self.trait_to_def(container.with_value(it))?.into(), ast::TypeAlias(it) => self.type_alias_to_def(container.with_value(it))?.into(), ast::ImplDef(it) => self.impl_to_def(container.with_value(it))?.into(), diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index 2be23c45d..df98ded62 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs @@ -124,7 +124,7 @@ impl HasChildSource for EnumId { fn lower_enum( db: &dyn DefDatabase, trace: &mut Trace, - ast: &InFile, + ast: &InFile, module_id: ModuleId, ) { let expander = CfgExpander::new(db, ast.file_id, module_id.krate); diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 840841d87..105299f70 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -656,7 +656,7 @@ impl ExprCollector<'_> { let id = self.find_inner_item(&def)?; (StructLoc { container, id }.intern(self.db).into(), def.name()) } - ast::Item::EnumDef(def) => { + ast::Item::Enum(def) => { let id = self.find_inner_item(&def)?; (EnumLoc { container, id }.intern(self.db).into(), def.name()) } diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs index 6b96a4c20..24ad41187 100644 --- a/crates/ra_hir_def/src/item_tree.rs +++ b/crates/ra_hir_def/src/item_tree.rs @@ -416,7 +416,7 @@ mod_items! { Function in functions -> ast::Fn, Struct in structs -> ast::Struct, Union in unions -> ast::Union, - Enum in enums -> ast::EnumDef, + Enum in enums -> ast::Enum, Const in consts -> ast::ConstDef, Static in statics -> ast::StaticDef, Trait in traits -> ast::TraitDef, @@ -543,7 +543,7 @@ pub struct Enum { pub visibility: RawVisibilityId, pub generic_params: GenericParamsId, pub variants: IdRange, - pub ast_id: FileAstId, + pub ast_id: FileAstId, } #[derive(Debug, Clone, Eq, PartialEq)] diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index a85618015..da7238416 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs @@ -80,7 +80,7 @@ impl Ctx { match item { ast::Item::Struct(_) | ast::Item::Union(_) - | ast::Item::EnumDef(_) + | ast::Item::Enum(_) | ast::Item::Fn(_) | ast::Item::TypeAlias(_) | ast::Item::ConstDef(_) @@ -105,7 +105,7 @@ impl Ctx { let items = match item { ast::Item::Struct(ast) => self.lower_struct(ast).map(Into::into), ast::Item::Union(ast) => self.lower_union(ast).map(Into::into), - ast::Item::EnumDef(ast) => self.lower_enum(ast).map(Into::into), + ast::Item::Enum(ast) => self.lower_enum(ast).map(Into::into), ast::Item::Fn(ast) => self.lower_function(ast).map(Into::into), ast::Item::TypeAlias(ast) => self.lower_type_alias(ast).map(Into::into), ast::Item::StaticDef(ast) => self.lower_static(ast).map(Into::into), @@ -246,7 +246,7 @@ impl Ctx { Some(id(self.data().unions.alloc(res))) } - fn lower_enum(&mut self, enum_: &ast::EnumDef) -> Option> { + fn lower_enum(&mut self, enum_: &ast::Enum) -> Option> { let visibility = self.lower_visibility(enum_); let name = enum_.name()?.as_name(); let generic_params = self.lower_generic_params(GenericsOwner::Enum, enum_); diff --git a/crates/ra_hir_def/src/item_tree/tests.rs b/crates/ra_hir_def/src/item_tree/tests.rs index db37223da..bf3474c51 100644 --- a/crates/ra_hir_def/src/item_tree/tests.rs +++ b/crates/ra_hir_def/src/item_tree/tests.rs @@ -250,7 +250,7 @@ fn smoke() { #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct2"))] }, input: None }]) }] Struct { name: Name(Text("Struct2")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(3), fields: Record(IdRange::(1..2)), ast_id: FileAstId::(5), kind: Record } #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("en"))] }, input: None }]) }] - Enum { name: Name(Text("En")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), variants: IdRange::(0..1), ast_id: FileAstId::(6) } + Enum { name: Name(Text("En")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), variants: IdRange::(0..1), ast_id: FileAstId::(6) } #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("un"))] }, input: None }]) }] Union { name: Name(Text("Un")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), fields: Record(IdRange::(3..4)), ast_id: FileAstId::(7) } "##]], diff --git a/crates/ra_hir_def/src/keys.rs b/crates/ra_hir_def/src/keys.rs index d9ec0f305..2695e8c24 100644 --- a/crates/ra_hir_def/src/keys.rs +++ b/crates/ra_hir_def/src/keys.rs @@ -22,7 +22,7 @@ pub const IMPL: Key = Key::new(); pub const TRAIT: Key = Key::new(); pub const STRUCT: Key = Key::new(); pub const UNION: Key = Key::new(); -pub const ENUM: Key = Key::new(); +pub const ENUM: Key = Key::new(); pub const ENUM_VARIANT: Key = Key::new(); pub const TUPLE_FIELD: Key = Key::new(); diff --git a/crates/ra_hir_expand/src/builtin_derive.rs b/crates/ra_hir_expand/src/builtin_derive.rs index 489ec0513..69fa907cb 100644 --- a/crates/ra_hir_expand/src/builtin_derive.rs +++ b/crates/ra_hir_expand/src/builtin_derive.rs @@ -73,7 +73,7 @@ fn parse_adt(tt: &tt::Subtree) -> Result { let (name, params) = match_ast! { match node { ast::Struct(it) => (it.name(), it.generic_param_list()), - ast::EnumDef(it) => (it.name(), it.generic_param_list()), + ast::Enum(it) => (it.name(), it.generic_param_list()), ast::Union(it) => (it.name(), it.generic_param_list()), _ => { debug!("unexpected node is {:?}", node); diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index 5686faaab..02fefd6bb 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs @@ -381,7 +381,7 @@ pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option match node { ast::Fn(it) => it.doc_comment_text(), ast::Struct(it) => it.doc_comment_text(), - ast::EnumDef(it) => it.doc_comment_text(), + ast::Enum(it) => it.doc_comment_text(), ast::TraitDef(it) => it.doc_comment_text(), ast::Module(it) => it.doc_comment_text(), ast::TypeAlias(it) => it.doc_comment_text(), @@ -406,7 +406,7 @@ pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> match node { ast::Fn(it) => it.short_label(), ast::Struct(it) => it.short_label(), - ast::EnumDef(it) => it.short_label(), + ast::Enum(it) => it.short_label(), ast::TraitDef(it) => it.short_label(), ast::Module(it) => it.short_label(), ast::TypeAlias(it) => it.short_label(), @@ -446,7 +446,7 @@ fn foo() { enum FooInner { } } 5..13, ), name: "FooInner", - kind: ENUM_DEF, + kind: ENUM, container_name: None, description: Some( "enum FooInner", @@ -462,7 +462,7 @@ fn foo() { enum FooInner { } } 34..42, ), name: "FooInner", - kind: ENUM_DEF, + kind: ENUM, container_name: Some( "foo", ), diff --git a/crates/ra_ide/src/display/short_label.rs b/crates/ra_ide/src/display/short_label.rs index 504b884c5..5bf70937f 100644 --- a/crates/ra_ide/src/display/short_label.rs +++ b/crates/ra_ide/src/display/short_label.rs @@ -25,7 +25,7 @@ impl ShortLabel for ast::Union { } } -impl ShortLabel for ast::EnumDef { +impl ShortLabel for ast::Enum { fn short_label(&self) -> Option { short_label_from_node(self, "enum ") } diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index 6f198fcbc..c909f96aa 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -128,7 +128,7 @@ fn structure_node(node: &SyntaxNode) -> Option { }, ast::Struct(it) => decl(it), ast::Union(it) => decl(it), - ast::EnumDef(it) => decl(it), + ast::Enum(it) => decl(it), ast::EnumVariant(it) => decl(it), ast::TraitDef(it) => decl(it), ast::Module(it) => decl(it), @@ -308,7 +308,7 @@ fn very_obsolete() {} label: "E", navigation_range: 165..166, node_range: 160..180, - kind: ENUM_DEF, + kind: ENUM, detail: None, deprecated: false, }, diff --git a/crates/ra_ide/src/goto_implementation.rs b/crates/ra_ide/src/goto_implementation.rs index 699fad57d..e2f7e6373 100644 --- a/crates/ra_ide/src/goto_implementation.rs +++ b/crates/ra_ide/src/goto_implementation.rs @@ -45,7 +45,7 @@ fn impls_for_def( ) -> Option> { let ty = match node { ast::AdtDef::Struct(def) => sema.to_def(def)?.ty(sema.db), - ast::AdtDef::EnumDef(def) => sema.to_def(def)?.ty(sema.db), + ast::AdtDef::Enum(def) => sema.to_def(def)?.ty(sema.db), ast::AdtDef::Union(def) => sema.to_def(def)?.ty(sema.db), }; diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index ba1fd6242..7e2833bd5 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -706,7 +706,7 @@ fn highlight_name_by_syntax(name: ast::Name) -> Highlight { let tag = match parent.kind() { STRUCT => HighlightTag::Struct, - ENUM_DEF => HighlightTag::Enum, + ENUM => HighlightTag::Enum, UNION => HighlightTag::Union, TRAIT_DEF => HighlightTag::Trait, TYPE_ALIAS => HighlightTag::TypeAlias, diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index 6a2180f6c..586b3d750 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs @@ -158,7 +158,7 @@ pub fn classify_name(sema: &Semantics, name: &ast::Name) -> Option let def: hir::Union = sema.to_def(&it)?; Some(NameClass::Definition(Definition::ModuleDef(def.into()))) }, - ast::EnumDef(it) => { + ast::Enum(it) => { let def: hir::Enum = sema.to_def(&it)?; Some(NameClass::Definition(Definition::ModuleDef(def.into()))) }, diff --git a/crates/ra_ide_db/src/symbol_index.rs b/crates/ra_ide_db/src/symbol_index.rs index da19f0f33..646d338ae 100644 --- a/crates/ra_ide_db/src/symbol_index.rs +++ b/crates/ra_ide_db/src/symbol_index.rs @@ -344,7 +344,7 @@ impl Query { } fn is_type(kind: SyntaxKind) -> bool { - matches!(kind, STRUCT | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS) + matches!(kind, STRUCT | ENUM | TRAIT_DEF | TYPE_ALIAS) } /// The actual data that is stored in the index. It should be as compact as @@ -399,7 +399,7 @@ fn to_symbol(node: &SyntaxNode) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> { match node { ast::Fn(it) => decl(it), ast::Struct(it) => decl(it), - ast::EnumDef(it) => decl(it), + ast::Enum(it) => decl(it), ast::TraitDef(it) => decl(it), ast::Module(it) => decl(it), ast::TypeAlias(it) => decl(it), diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs index 21af06e73..707e84f42 100644 --- a/crates/ra_mbe/src/tests.rs +++ b/crates/ra_mbe/src/tests.rs @@ -1467,7 +1467,7 @@ macro_rules! quick_error { buf [ ] queue [ ] ) => { - quick_error!(ENUM_DEFINITION [enum $name $( #[$meta] )*] + quick_error!(ENUMINITION [enum $name $( #[$meta] )*] body [] queue [$( $( #[$imeta] )* @@ -1489,7 +1489,7 @@ quick_error ! (SORT [enum Wrapped # [derive (Debug)]] items [ "#, ); - assert_eq!(expanded.to_string(), "quick_error ! (ENUM_DEFINITION [enum Wrapped # [derive (Debug)]] body [] queue [=> One : UNIT [] => Two : TUPLE [s : String]]) ;"); + assert_eq!(expanded.to_string(), "quick_error ! (ENUMINITION [enum Wrapped # [derive (Debug)]] body [] queue [=> One : UNIT [] => Two : TUPLE [s : String]]) ;"); } #[test] diff --git a/crates/ra_parser/src/grammar/items/adt.rs b/crates/ra_parser/src/grammar/items/adt.rs index 2f5cfb6b6..aeb7ce86b 100644 --- a/crates/ra_parser/src/grammar/items/adt.rs +++ b/crates/ra_parser/src/grammar/items/adt.rs @@ -64,7 +64,7 @@ pub(super) fn enum_def(p: &mut Parser, m: Marker) { } else { p.error("expected `{`") } - m.complete(p, ENUM_DEF); + m.complete(p, ENUM); } pub(crate) fn enum_variant_list(p: &mut Parser) { diff --git a/crates/ra_parser/src/syntax_kind/generated.rs b/crates/ra_parser/src/syntax_kind/generated.rs index 4fad765c7..fde9e55f1 100644 --- a/crates/ra_parser/src/syntax_kind/generated.rs +++ b/crates/ra_parser/src/syntax_kind/generated.rs @@ -125,7 +125,7 @@ pub enum SyntaxKind { SOURCE_FILE, STRUCT, UNION, - ENUM_DEF, + ENUM, FN, RET_TYPE, EXTERN_CRATE, diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 0fd3d4f1b..1d1452546 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -44,14 +44,14 @@ impl ConstDef { pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, T![;]) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct EnumDef { +pub struct Enum { pub(crate) syntax: SyntaxNode, } -impl ast::AttrsOwner for EnumDef {} -impl ast::NameOwner for EnumDef {} -impl ast::VisibilityOwner for EnumDef {} -impl ast::GenericParamsOwner for EnumDef {} -impl EnumDef { +impl ast::AttrsOwner for Enum {} +impl ast::NameOwner for Enum {} +impl ast::VisibilityOwner for Enum {} +impl ast::GenericParamsOwner for Enum {} +impl Enum { pub fn enum_token(&self) -> Option { support::token(&self.syntax, T![enum]) } pub fn variant_list(&self) -> Option { support::child(&self.syntax) } } @@ -1273,7 +1273,7 @@ impl MetaItem { #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum Item { ConstDef(ConstDef), - EnumDef(EnumDef), + Enum(Enum), ExternBlock(ExternBlock), ExternCrate(ExternCrate), Fn(Fn), @@ -1392,7 +1392,7 @@ impl ast::VisibilityOwner for ExternItem {} #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AdtDef { Struct(Struct), - EnumDef(EnumDef), + Enum(Enum), Union(Union), } impl ast::AttrsOwner for AdtDef {} @@ -1432,8 +1432,8 @@ impl AstNode for ConstDef { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for EnumDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_DEF } +impl AstNode for Enum { + fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2777,8 +2777,8 @@ impl AstNode for MetaItem { impl From for Item { fn from(node: ConstDef) -> Item { Item::ConstDef(node) } } -impl From for Item { - fn from(node: EnumDef) -> Item { Item::EnumDef(node) } +impl From for Item { + fn from(node: Enum) -> Item { Item::Enum(node) } } impl From for Item { fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) } @@ -2819,7 +2819,7 @@ impl From for Item { impl AstNode for Item { fn can_cast(kind: SyntaxKind) -> bool { match kind { - CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL + CONST_DEF | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL | MODULE | STATIC_DEF | STRUCT | TRAIT_DEF | TYPE_ALIAS | UNION | USE => true, _ => false, } @@ -2827,7 +2827,7 @@ impl AstNode for Item { fn cast(syntax: SyntaxNode) -> Option { let res = match syntax.kind() { CONST_DEF => Item::ConstDef(ConstDef { syntax }), - ENUM_DEF => Item::EnumDef(EnumDef { syntax }), + ENUM => Item::Enum(Enum { syntax }), EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), FN => Item::Fn(Fn { syntax }), @@ -2847,7 +2847,7 @@ impl AstNode for Item { fn syntax(&self) -> &SyntaxNode { match self { Item::ConstDef(it) => &it.syntax, - Item::EnumDef(it) => &it.syntax, + Item::Enum(it) => &it.syntax, Item::ExternBlock(it) => &it.syntax, Item::ExternCrate(it) => &it.syntax, Item::Fn(it) => &it.syntax, @@ -3375,8 +3375,8 @@ impl AstNode for ExternItem { impl From for AdtDef { fn from(node: Struct) -> AdtDef { AdtDef::Struct(node) } } -impl From for AdtDef { - fn from(node: EnumDef) -> AdtDef { AdtDef::EnumDef(node) } +impl From for AdtDef { + fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) } } impl From for AdtDef { fn from(node: Union) -> AdtDef { AdtDef::Union(node) } @@ -3384,14 +3384,14 @@ impl From for AdtDef { impl AstNode for AdtDef { fn can_cast(kind: SyntaxKind) -> bool { match kind { - STRUCT | ENUM_DEF | UNION => true, + STRUCT | ENUM | UNION => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { let res = match syntax.kind() { STRUCT => AdtDef::Struct(Struct { syntax }), - ENUM_DEF => AdtDef::EnumDef(EnumDef { syntax }), + ENUM => AdtDef::Enum(Enum { syntax }), UNION => AdtDef::Union(Union { syntax }), _ => return None, }; @@ -3400,7 +3400,7 @@ impl AstNode for AdtDef { fn syntax(&self) -> &SyntaxNode { match self { AdtDef::Struct(it) => &it.syntax, - AdtDef::EnumDef(it) => &it.syntax, + AdtDef::Enum(it) => &it.syntax, AdtDef::Union(it) => &it.syntax, } } @@ -3470,7 +3470,7 @@ impl std::fmt::Display for ConstDef { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for EnumDef { +impl std::fmt::Display for Enum { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs index 2299988ce..02e6e52c2 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs @@ -248,11 +248,11 @@ impl ast::RecordFieldPat { } impl ast::EnumVariant { - pub fn parent_enum(&self) -> ast::EnumDef { + pub fn parent_enum(&self) -> ast::Enum { self.syntax() .parent() .and_then(|it| it.parent()) - .and_then(ast::EnumDef::cast) + .and_then(ast::Enum::cast) .expect("EnumVariants are always nested in Enums") } pub fn kind(&self) -> StructKind { @@ -479,7 +479,7 @@ impl ast::DocCommentsOwner for ast::Struct {} impl ast::DocCommentsOwner for ast::Union {} impl ast::DocCommentsOwner for ast::RecordField {} impl ast::DocCommentsOwner for ast::TupleField {} -impl ast::DocCommentsOwner for ast::EnumDef {} +impl ast::DocCommentsOwner for ast::Enum {} impl ast::DocCommentsOwner for ast::EnumVariant {} impl ast::DocCommentsOwner for ast::TraitDef {} impl ast::DocCommentsOwner for ast::Module {} diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs index ef260ea59..faffd0d32 100644 --- a/crates/ra_syntax/src/parsing/text_tree_sink.rs +++ b/crates/ra_syntax/src/parsing/text_tree_sink.rs @@ -146,7 +146,7 @@ fn n_attached_trivias<'a>( trivias: impl Iterator, ) -> usize { match kind { - MACRO_CALL | CONST_DEF | TYPE_ALIAS | STRUCT | ENUM_DEF | ENUM_VARIANT | FN | TRAIT_DEF + MACRO_CALL | CONST_DEF | TYPE_ALIAS | STRUCT | ENUM | ENUM_VARIANT | FN | TRAIT_DEF | MODULE | RECORD_FIELD | STATIC_DEF => { let mut res = 0; let mut trivias = trivias.enumerate().peekable(); diff --git a/crates/ra_syntax/test_data/parser/err/0025_nope.rast b/crates/ra_syntax/test_data/parser/err/0025_nope.rast index a1258028d..94456e48c 100644 --- a/crates/ra_syntax/test_data/parser/err/0025_nope.rast +++ b/crates/ra_syntax/test_data/parser/err/0025_nope.rast @@ -11,7 +11,7 @@ SOURCE_FILE@0..575 BLOCK_EXPR@10..574 L_CURLY@10..11 "{" WHITESPACE@11..16 "\n " - ENUM_DEF@16..152 + ENUM@16..152 ENUM_KW@16..20 "enum" WHITESPACE@20..21 " " NAME@21..25 @@ -79,7 +79,7 @@ SOURCE_FILE@0..575 INT_NUMBER@184..185 "1" SEMICOLON@185..186 ";" WHITESPACE@186..191 "\n " - ENUM_DEF@191..223 + ENUM@191..223 ENUM_KW@191..195 "enum" WHITESPACE@195..196 " " NAME@196..201 @@ -95,7 +95,7 @@ SOURCE_FILE@0..575 WHITESPACE@217..222 "\n " R_CURLY@222..223 "}" WHITESPACE@223..229 "\n\n " - ENUM_DEF@229..300 + ENUM@229..300 ENUM_KW@229..233 "enum" WHITESPACE@233..234 " " NAME@234..239 @@ -132,7 +132,7 @@ SOURCE_FILE@0..575 BLOCK_EXPR@306..459 L_CURLY@306..307 "{" WHITESPACE@307..316 "\n " - ENUM_DEF@316..453 + ENUM@316..453 COMMENT@316..329 "// fail again" WHITESPACE@329..338 "\n " ENUM_KW@338..342 "enum" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast b/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast index ea54347fc..25e6cc170 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..94 - ENUM_DEF@0..8 + ENUM@0..8 ENUM_KW@0..4 "enum" WHITESPACE@4..5 " " NAME@5..6 diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast b/crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast index 280f947ce..9cc8172e0 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast @@ -11,7 +11,7 @@ SOURCE_FILE@0..111 BLOCK_EXPR@21..110 L_CURLY@21..22 "{" WHITESPACE@22..27 "\n " - ENUM_DEF@27..75 + ENUM@27..75 ENUM_KW@27..31 "enum" WHITESPACE@31..32 " " NAME@32..41 diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast b/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast index 289fdfd6d..0331558d2 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..23 - ENUM_DEF@0..22 + ENUM@0..22 ENUM_KW@0..4 "enum" WHITESPACE@4..5 " " NAME@5..6 diff --git a/crates/ra_syntax/test_data/parser/ok/0019_enums.rast b/crates/ra_syntax/test_data/parser/ok/0019_enums.rast index 1a32d88fd..1ffcffc1a 100644 --- a/crates/ra_syntax/test_data/parser/ok/0019_enums.rast +++ b/crates/ra_syntax/test_data/parser/ok/0019_enums.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..182 - ENUM_DEF@0..11 + ENUM@0..11 ENUM_KW@0..4 "enum" WHITESPACE@4..5 " " NAME@5..7 @@ -10,7 +10,7 @@ SOURCE_FILE@0..182 WHITESPACE@9..10 "\n" R_CURLY@10..11 "}" WHITESPACE@11..13 "\n\n" - ENUM_DEF@13..27 + ENUM@13..27 ENUM_KW@13..17 "enum" WHITESPACE@17..18 " " NAME@18..20 @@ -27,7 +27,7 @@ SOURCE_FILE@0..182 WHITESPACE@25..26 "\n" R_CURLY@26..27 "}" WHITESPACE@27..29 "\n\n" - ENUM_DEF@29..46 + ENUM@29..46 ENUM_KW@29..33 "enum" WHITESPACE@33..34 " " NAME@34..36 @@ -42,7 +42,7 @@ SOURCE_FILE@0..182 WHITESPACE@44..45 "\n" R_CURLY@45..46 "}" WHITESPACE@46..48 "\n\n" - ENUM_DEF@48..66 + ENUM@48..66 ENUM_KW@48..52 "enum" WHITESPACE@52..53 " " NAME@53..55 @@ -58,7 +58,7 @@ SOURCE_FILE@0..182 WHITESPACE@64..65 "\n" R_CURLY@65..66 "}" WHITESPACE@66..68 "\n\n" - ENUM_DEF@68..181 + ENUM@68..181 ENUM_KW@68..72 "enum" WHITESPACE@72..73 " " NAME@73..75 diff --git a/crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast b/crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast index fcf605ec8..9db4f0aa1 100644 --- a/crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast +++ b/crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast @@ -256,7 +256,7 @@ SOURCE_FILE@0..395 WHITESPACE@339..340 "\n" R_CURLY@340..341 "}" WHITESPACE@341..343 "\n\n" - ENUM_DEF@343..367 + ENUM@343..367 ENUM_KW@343..347 "enum" WHITESPACE@347..348 " " NAME@348..349 diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index cb11dffd0..df4969b80 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -926,7 +926,7 @@ pub(crate) fn handle_code_lens( it.kind, SyntaxKind::TRAIT_DEF | SyntaxKind::STRUCT - | SyntaxKind::ENUM_DEF + | SyntaxKind::ENUM | SyntaxKind::UNION ) }) diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index a09a74c41..62acbfb91 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -33,7 +33,7 @@ pub(crate) fn symbol_kind(syntax_kind: SyntaxKind) -> lsp_types::SymbolKind { match syntax_kind { SyntaxKind::FN => lsp_types::SymbolKind::Function, SyntaxKind::STRUCT => lsp_types::SymbolKind::Struct, - SyntaxKind::ENUM_DEF => lsp_types::SymbolKind::Enum, + SyntaxKind::ENUM => lsp_types::SymbolKind::Enum, SyntaxKind::ENUM_VARIANT => lsp_types::SymbolKind::EnumMember, SyntaxKind::TRAIT_DEF => lsp_types::SymbolKind::Interface, SyntaxKind::MACRO_CALL => lsp_types::SymbolKind::Function, -- cgit v1.2.3