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 --- 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 +- 9 files changed, 38 insertions(+), 38 deletions(-) (limited to 'crates/ra_syntax') 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 -- cgit v1.2.3