From 1766aae145c6925a33e427f2fe6ef2a56c301665 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 17:56:53 +0200 Subject: Rename EnumVariant -> Variant --- crates/ra_syntax/src/ast/generated/nodes.rs | 30 +++++++++++----------- crates/ra_syntax/src/ast/node_ext.rs | 4 +-- crates/ra_syntax/src/parsing/text_tree_sink.rs | 2 +- .../ra_syntax/test_data/parser/err/0025_nope.rast | 20 +++++++-------- .../inline/ok/0118_impl_inner_attributes.rast | 2 +- .../inline/ok/0134_nocontentexpr_after_item.rast | 6 ++--- .../inline/ok/0157_variant_discriminant.rast | 4 +-- .../ra_syntax/test_data/parser/ok/0019_enums.rast | 26 +++++++++---------- .../parser/ok/0047_minus_in_inner_pattern.rast | 4 +-- 9 files changed, 49 insertions(+), 49 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 1d1452546..6613b54ba 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -53,7 +53,7 @@ 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) } + pub fn variant_list(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ExternBlock { @@ -427,22 +427,22 @@ impl TupleField { pub fn type_ref(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct EnumVariantList { +pub struct VariantList { pub(crate) syntax: SyntaxNode, } -impl EnumVariantList { +impl VariantList { pub fn l_curly_token(&self) -> Option { support::token(&self.syntax, T!['{']) } - pub fn variants(&self) -> AstChildren { support::children(&self.syntax) } + pub fn variants(&self) -> AstChildren { support::children(&self.syntax) } pub fn r_curly_token(&self) -> Option { support::token(&self.syntax, T!['}']) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct EnumVariant { +pub struct Variant { pub(crate) syntax: SyntaxNode, } -impl ast::AttrsOwner for EnumVariant {} -impl ast::NameOwner for EnumVariant {} -impl ast::VisibilityOwner for EnumVariant {} -impl EnumVariant { +impl ast::AttrsOwner for Variant {} +impl ast::NameOwner for Variant {} +impl ast::VisibilityOwner for Variant {} +impl Variant { pub fn field_list(&self) -> Option { support::child(&self.syntax) } pub fn eq_token(&self) -> Option { support::token(&self.syntax, T![=]) } pub fn expr(&self) -> Option { support::child(&self.syntax) } @@ -1806,8 +1806,8 @@ impl AstNode for TupleField { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for EnumVariantList { - fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT_LIST } +impl AstNode for VariantList { + fn can_cast(kind: SyntaxKind) -> bool { kind == VARIANT_LIST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1817,8 +1817,8 @@ impl AstNode for EnumVariantList { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for EnumVariant { - fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT } +impl AstNode for Variant { + fn can_cast(kind: SyntaxKind) -> bool { kind == VARIANT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -3640,12 +3640,12 @@ impl std::fmt::Display for TupleField { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for EnumVariantList { +impl std::fmt::Display for VariantList { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for EnumVariant { +impl std::fmt::Display for Variant { 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 02e6e52c2..05ec49cec 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs @@ -247,7 +247,7 @@ impl ast::RecordFieldPat { } } -impl ast::EnumVariant { +impl ast::Variant { pub fn parent_enum(&self) -> ast::Enum { self.syntax() .parent() @@ -480,7 +480,7 @@ impl ast::DocCommentsOwner for ast::Union {} impl ast::DocCommentsOwner for ast::RecordField {} impl ast::DocCommentsOwner for ast::TupleField {} impl ast::DocCommentsOwner for ast::Enum {} -impl ast::DocCommentsOwner for ast::EnumVariant {} +impl ast::DocCommentsOwner for ast::Variant {} impl ast::DocCommentsOwner for ast::TraitDef {} impl ast::DocCommentsOwner for ast::Module {} impl ast::DocCommentsOwner for ast::StaticDef {} diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs index faffd0d32..c586dc320 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 | ENUM_VARIANT | FN | TRAIT_DEF + MACRO_CALL | CONST_DEF | TYPE_ALIAS | STRUCT | 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 94456e48c..fca646557 100644 --- a/crates/ra_syntax/test_data/parser/err/0025_nope.rast +++ b/crates/ra_syntax/test_data/parser/err/0025_nope.rast @@ -17,15 +17,15 @@ SOURCE_FILE@0..575 NAME@21..25 IDENT@21..25 "Test" WHITESPACE@25..26 " " - ENUM_VARIANT_LIST@26..152 + VARIANT_LIST@26..152 L_CURLY@26..27 "{" WHITESPACE@27..36 "\n " - ENUM_VARIANT@36..40 + VARIANT@36..40 NAME@36..40 IDENT@36..40 "Var1" COMMA@40..41 "," WHITESPACE@41..50 "\n " - ENUM_VARIANT@50..62 + VARIANT@50..62 NAME@50..54 IDENT@50..54 "Var2" TUPLE_FIELD_LIST@54..62 @@ -39,7 +39,7 @@ SOURCE_FILE@0..575 R_PAREN@61..62 ")" COMMA@62..63 "," WHITESPACE@63..72 "\n " - ENUM_VARIANT@72..145 + VARIANT@72..145 NAME@72..76 IDENT@72..76 "Var3" WHITESPACE@76..77 " " @@ -85,10 +85,10 @@ SOURCE_FILE@0..575 NAME@196..201 IDENT@196..201 "Test2" WHITESPACE@201..202 " " - ENUM_VARIANT_LIST@202..223 + VARIANT_LIST@202..223 L_CURLY@202..203 "{" WHITESPACE@203..212 "\n " - ENUM_VARIANT@212..216 + VARIANT@212..216 NAME@212..216 IDENT@212..216 "Fine" COMMA@216..217 "," @@ -101,10 +101,10 @@ SOURCE_FILE@0..575 NAME@234..239 IDENT@234..239 "Test3" WHITESPACE@239..240 " " - ENUM_VARIANT_LIST@240..300 + VARIANT_LIST@240..300 L_CURLY@240..241 "{" WHITESPACE@241..250 "\n " - ENUM_VARIANT@250..293 + VARIANT@250..293 NAME@250..259 IDENT@250..259 "StillFine" WHITESPACE@259..260 " " @@ -140,10 +140,10 @@ SOURCE_FILE@0..575 NAME@343..348 IDENT@343..348 "Test4" WHITESPACE@348..349 " " - ENUM_VARIANT_LIST@349..453 + VARIANT_LIST@349..453 L_CURLY@349..350 "{" WHITESPACE@350..363 "\n " - ENUM_VARIANT@363..372 + VARIANT@363..372 NAME@363..367 IDENT@363..367 "Nope" TUPLE_FIELD_LIST@367..372 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 25e6cc170..f2561abd6 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 @@ -4,7 +4,7 @@ SOURCE_FILE@0..94 WHITESPACE@4..5 " " NAME@5..6 IDENT@5..6 "F" - ENUM_VARIANT_LIST@6..8 + VARIANT_LIST@6..8 L_CURLY@6..7 "{" R_CURLY@7..8 "}" WHITESPACE@8..9 "\n" 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 9cc8172e0..429a0506e 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 @@ -17,15 +17,15 @@ SOURCE_FILE@0..111 NAME@32..41 IDENT@32..41 "LocalEnum" WHITESPACE@41..42 " " - ENUM_VARIANT_LIST@42..75 + VARIANT_LIST@42..75 L_CURLY@42..43 "{" WHITESPACE@43..52 "\n " - ENUM_VARIANT@52..55 + VARIANT@52..55 NAME@52..55 IDENT@52..55 "One" COMMA@55..56 "," WHITESPACE@56..65 "\n " - ENUM_VARIANT@65..68 + VARIANT@65..68 NAME@65..68 IDENT@65..68 "Two" COMMA@68..69 "," 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 0331558d2..a2e05eb2e 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 @@ -5,10 +5,10 @@ SOURCE_FILE@0..23 NAME@5..6 IDENT@5..6 "E" WHITESPACE@6..7 " " - ENUM_VARIANT_LIST@7..22 + VARIANT_LIST@7..22 L_CURLY@7..8 "{" WHITESPACE@8..9 " " - ENUM_VARIANT@9..20 + VARIANT@9..20 NAME@9..10 IDENT@9..10 "X" TUPLE_FIELD_LIST@10..15 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 1ffcffc1a..c3df00814 100644 --- a/crates/ra_syntax/test_data/parser/ok/0019_enums.rast +++ b/crates/ra_syntax/test_data/parser/ok/0019_enums.rast @@ -5,7 +5,7 @@ SOURCE_FILE@0..182 NAME@5..7 IDENT@5..7 "E1" WHITESPACE@7..8 " " - ENUM_VARIANT_LIST@8..11 + VARIANT_LIST@8..11 L_CURLY@8..9 "{" WHITESPACE@9..10 "\n" R_CURLY@10..11 "}" @@ -22,7 +22,7 @@ SOURCE_FILE@0..182 IDENT@21..22 "T" R_ANGLE@22..23 ">" WHITESPACE@23..24 " " - ENUM_VARIANT_LIST@24..27 + VARIANT_LIST@24..27 L_CURLY@24..25 "{" WHITESPACE@25..26 "\n" R_CURLY@26..27 "}" @@ -33,10 +33,10 @@ SOURCE_FILE@0..182 NAME@34..36 IDENT@34..36 "E3" WHITESPACE@36..37 " " - ENUM_VARIANT_LIST@37..46 + VARIANT_LIST@37..46 L_CURLY@37..38 "{" WHITESPACE@38..43 "\n " - ENUM_VARIANT@43..44 + VARIANT@43..44 NAME@43..44 IDENT@43..44 "X" WHITESPACE@44..45 "\n" @@ -48,10 +48,10 @@ SOURCE_FILE@0..182 NAME@53..55 IDENT@53..55 "E4" WHITESPACE@55..56 " " - ENUM_VARIANT_LIST@56..66 + VARIANT_LIST@56..66 L_CURLY@56..57 "{" WHITESPACE@57..62 "\n " - ENUM_VARIANT@62..63 + VARIANT@62..63 NAME@62..63 IDENT@62..63 "X" COMMA@63..64 "," @@ -64,15 +64,15 @@ SOURCE_FILE@0..182 NAME@73..75 IDENT@73..75 "E5" WHITESPACE@75..76 " " - ENUM_VARIANT_LIST@76..181 + VARIANT_LIST@76..181 L_CURLY@76..77 "{" WHITESPACE@77..82 "\n " - ENUM_VARIANT@82..83 + VARIANT@82..83 NAME@82..83 IDENT@82..83 "A" COMMA@83..84 "," WHITESPACE@84..89 "\n " - ENUM_VARIANT@89..95 + VARIANT@89..95 NAME@89..90 IDENT@89..90 "B" WHITESPACE@90..91 " " @@ -82,7 +82,7 @@ SOURCE_FILE@0..182 INT_NUMBER@93..95 "92" COMMA@95..96 "," WHITESPACE@96..101 "\n " - ENUM_VARIANT@101..146 + VARIANT@101..146 NAME@101..102 IDENT@101..102 "C" WHITESPACE@102..103 " " @@ -119,7 +119,7 @@ SOURCE_FILE@0..182 R_CURLY@145..146 "}" COMMA@146..147 "," WHITESPACE@147..152 "\n " - ENUM_VARIANT@152..156 + VARIANT@152..156 NAME@152..153 IDENT@152..153 "F" WHITESPACE@153..154 " " @@ -128,7 +128,7 @@ SOURCE_FILE@0..182 R_CURLY@155..156 "}" COMMA@156..157 "," WHITESPACE@157..162 "\n " - ENUM_VARIANT@162..169 + VARIANT@162..169 NAME@162..163 IDENT@162..163 "D" TUPLE_FIELD_LIST@163..169 @@ -143,7 +143,7 @@ SOURCE_FILE@0..182 R_PAREN@168..169 ")" COMMA@169..170 "," WHITESPACE@170..175 "\n " - ENUM_VARIANT@175..178 + VARIANT@175..178 NAME@175..176 IDENT@175..176 "E" TUPLE_FIELD_LIST@176..178 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 9db4f0aa1..7a54fa113 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 @@ -262,10 +262,10 @@ SOURCE_FILE@0..395 NAME@348..349 IDENT@348..349 "A" WHITESPACE@349..350 " " - ENUM_VARIANT_LIST@350..367 + VARIANT_LIST@350..367 L_CURLY@350..351 "{" WHITESPACE@351..356 "\n " - ENUM_VARIANT@356..365 + VARIANT@356..365 NAME@356..357 IDENT@356..357 "B" TUPLE_FIELD_LIST@357..365 -- cgit v1.2.3 From 3cd4112bdc924c132cb0eab9d064511a215421ec Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 18:02:20 +0200 Subject: Finalize const&static grammar --- crates/ra_syntax/src/ast.rs | 2 +- crates/ra_syntax/src/ast/generated/nodes.rs | 85 +++++++++++----------- crates/ra_syntax/src/ast/node_ext.rs | 4 +- crates/ra_syntax/src/parsing/text_tree_sink.rs | 4 +- crates/ra_syntax/src/validation.rs | 4 +- .../parser/err/0037_visibility_in_traits.rast | 2 +- .../test_data/parser/err/0043_default_const.rast | 2 +- .../parser/inline/err/0010_wrong_order_fns.rast | 2 +- .../parser/inline/err/0013_static_underscore.rast | 2 +- .../parser/inline/ok/0001_trait_item_list.rast | 2 +- .../parser/inline/ok/0021_impl_item_list.rast | 2 +- .../parser/inline/ok/0150_array_attrs.rast | 2 +- .../test_data/parser/ok/0023_static_items.rast | 4 +- .../test_data/parser/ok/0024_const_item.rast | 6 +- .../test_data/parser/ok/0066_default_const.rast | 2 +- 15 files changed, 63 insertions(+), 62 deletions(-) (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index b69b6e85e..fd426ece9 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs @@ -139,7 +139,7 @@ fn test_doc_comment_of_statics() { ) .ok() .unwrap(); - let st = file.syntax().descendants().find_map(StaticDef::cast).unwrap(); + let st = file.syntax().descendants().find_map(Static::cast).unwrap(); assert_eq!("Number of levels", st.doc_comment_text().unwrap()); } diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 6613b54ba..00a70fce0 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -28,16 +28,17 @@ impl Attr { pub fn r_brack_token(&self) -> Option { support::token(&self.syntax, T![']']) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct ConstDef { +pub struct Const { pub(crate) syntax: SyntaxNode, } -impl ast::AttrsOwner for ConstDef {} -impl ast::NameOwner for ConstDef {} -impl ast::VisibilityOwner for ConstDef {} -impl ast::TypeAscriptionOwner for ConstDef {} -impl ConstDef { +impl ast::AttrsOwner for Const {} +impl ast::NameOwner for Const {} +impl ast::VisibilityOwner for Const {} +impl ast::TypeAscriptionOwner for Const {} +impl Const { pub fn default_token(&self) -> Option { support::token(&self.syntax, T![default]) } pub fn const_token(&self) -> Option { support::token(&self.syntax, T![const]) } + pub fn underscore_token(&self) -> Option { support::token(&self.syntax, T![_]) } pub fn colon_token(&self) -> Option { support::token(&self.syntax, T![:]) } pub fn eq_token(&self) -> Option { support::token(&self.syntax, T![=]) } pub fn body(&self) -> Option { support::child(&self.syntax) } @@ -139,14 +140,14 @@ impl Module { pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, T![;]) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct StaticDef { +pub struct Static { pub(crate) syntax: SyntaxNode, } -impl ast::AttrsOwner for StaticDef {} -impl ast::NameOwner for StaticDef {} -impl ast::VisibilityOwner for StaticDef {} -impl ast::TypeAscriptionOwner for StaticDef {} -impl StaticDef { +impl ast::AttrsOwner for Static {} +impl ast::NameOwner for Static {} +impl ast::VisibilityOwner for Static {} +impl ast::TypeAscriptionOwner for Static {} +impl Static { pub fn static_token(&self) -> Option { support::token(&self.syntax, T![static]) } pub fn mut_token(&self) -> Option { support::token(&self.syntax, T![mut]) } pub fn colon_token(&self) -> Option { support::token(&self.syntax, T![:]) } @@ -1272,7 +1273,7 @@ impl MetaItem { } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum Item { - ConstDef(ConstDef), + Const(Const), Enum(Enum), ExternBlock(ExternBlock), ExternCrate(ExternCrate), @@ -1280,7 +1281,7 @@ pub enum Item { ImplDef(ImplDef), MacroCall(MacroCall), Module(Module), - StaticDef(StaticDef), + Static(Static), Struct(Struct), TraitDef(TraitDef), TypeAlias(TypeAlias), @@ -1365,7 +1366,7 @@ pub enum Expr { pub enum AssocItem { Fn(Fn), TypeAlias(TypeAlias), - ConstDef(ConstDef), + Const(Const), MacroCall(MacroCall), } impl ast::AttrsOwner for AssocItem {} @@ -1384,7 +1385,7 @@ pub enum AttrInput { #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ExternItem { Fn(Fn), - StaticDef(StaticDef), + Static(Static), } impl ast::AttrsOwner for ExternItem {} impl ast::NameOwner for ExternItem {} @@ -1421,8 +1422,8 @@ impl AstNode for Attr { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for ConstDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_DEF } +impl AstNode for Const { + fn can_cast(kind: SyntaxKind) -> bool { kind == CONST } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -1509,8 +1510,8 @@ impl AstNode for Module { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for StaticDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_DEF } +impl AstNode for Static { + fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2774,8 +2775,8 @@ impl AstNode for MetaItem { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl From for Item { - fn from(node: ConstDef) -> Item { Item::ConstDef(node) } +impl From for Item { + fn from(node: Const) -> Item { Item::Const(node) } } impl From for Item { fn from(node: Enum) -> Item { Item::Enum(node) } @@ -2798,8 +2799,8 @@ impl From for Item { impl From for Item { fn from(node: Module) -> Item { Item::Module(node) } } -impl From for Item { - fn from(node: StaticDef) -> Item { Item::StaticDef(node) } +impl From for Item { + fn from(node: Static) -> Item { Item::Static(node) } } impl From for Item { fn from(node: Struct) -> Item { Item::Struct(node) } @@ -2819,14 +2820,14 @@ impl From for Item { impl AstNode for Item { fn can_cast(kind: SyntaxKind) -> bool { match kind { - CONST_DEF | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL - | MODULE | STATIC_DEF | STRUCT | TRAIT_DEF | TYPE_ALIAS | UNION | USE => true, + CONST | ENUM | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL | MODULE + | STATIC | STRUCT | TRAIT_DEF | TYPE_ALIAS | UNION | USE => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { let res = match syntax.kind() { - CONST_DEF => Item::ConstDef(ConstDef { syntax }), + CONST => Item::Const(Const { syntax }), ENUM => Item::Enum(Enum { syntax }), EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), @@ -2834,7 +2835,7 @@ impl AstNode for Item { IMPL_DEF => Item::ImplDef(ImplDef { syntax }), MACRO_CALL => Item::MacroCall(MacroCall { syntax }), MODULE => Item::Module(Module { syntax }), - STATIC_DEF => Item::StaticDef(StaticDef { syntax }), + STATIC => Item::Static(Static { syntax }), STRUCT => Item::Struct(Struct { syntax }), TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }), @@ -2846,7 +2847,7 @@ impl AstNode for Item { } fn syntax(&self) -> &SyntaxNode { match self { - Item::ConstDef(it) => &it.syntax, + Item::Const(it) => &it.syntax, Item::Enum(it) => &it.syntax, Item::ExternBlock(it) => &it.syntax, Item::ExternCrate(it) => &it.syntax, @@ -2854,7 +2855,7 @@ impl AstNode for Item { Item::ImplDef(it) => &it.syntax, Item::MacroCall(it) => &it.syntax, Item::Module(it) => &it.syntax, - Item::StaticDef(it) => &it.syntax, + Item::Static(it) => &it.syntax, Item::Struct(it) => &it.syntax, Item::TraitDef(it) => &it.syntax, Item::TypeAlias(it) => &it.syntax, @@ -3256,8 +3257,8 @@ impl From for AssocItem { impl From for AssocItem { fn from(node: TypeAlias) -> AssocItem { AssocItem::TypeAlias(node) } } -impl From for AssocItem { - fn from(node: ConstDef) -> AssocItem { AssocItem::ConstDef(node) } +impl From for AssocItem { + fn from(node: Const) -> AssocItem { AssocItem::Const(node) } } impl From for AssocItem { fn from(node: MacroCall) -> AssocItem { AssocItem::MacroCall(node) } @@ -3265,7 +3266,7 @@ impl From for AssocItem { impl AstNode for AssocItem { fn can_cast(kind: SyntaxKind) -> bool { match kind { - FN | TYPE_ALIAS | CONST_DEF | MACRO_CALL => true, + FN | TYPE_ALIAS | CONST | MACRO_CALL => true, _ => false, } } @@ -3273,7 +3274,7 @@ impl AstNode for AssocItem { let res = match syntax.kind() { FN => AssocItem::Fn(Fn { syntax }), TYPE_ALIAS => AssocItem::TypeAlias(TypeAlias { syntax }), - CONST_DEF => AssocItem::ConstDef(ConstDef { syntax }), + CONST => AssocItem::Const(Const { syntax }), MACRO_CALL => AssocItem::MacroCall(MacroCall { syntax }), _ => return None, }; @@ -3283,7 +3284,7 @@ impl AstNode for AssocItem { match self { AssocItem::Fn(it) => &it.syntax, AssocItem::TypeAlias(it) => &it.syntax, - AssocItem::ConstDef(it) => &it.syntax, + AssocItem::Const(it) => &it.syntax, AssocItem::MacroCall(it) => &it.syntax, } } @@ -3347,20 +3348,20 @@ impl AstNode for AttrInput { impl From for ExternItem { fn from(node: Fn) -> ExternItem { ExternItem::Fn(node) } } -impl From for ExternItem { - fn from(node: StaticDef) -> ExternItem { ExternItem::StaticDef(node) } +impl From for ExternItem { + fn from(node: Static) -> ExternItem { ExternItem::Static(node) } } impl AstNode for ExternItem { fn can_cast(kind: SyntaxKind) -> bool { match kind { - FN | STATIC_DEF => true, + FN | STATIC => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { let res = match syntax.kind() { FN => ExternItem::Fn(Fn { syntax }), - STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }), + STATIC => ExternItem::Static(Static { syntax }), _ => return None, }; Some(res) @@ -3368,7 +3369,7 @@ impl AstNode for ExternItem { fn syntax(&self) -> &SyntaxNode { match self { ExternItem::Fn(it) => &it.syntax, - ExternItem::StaticDef(it) => &it.syntax, + ExternItem::Static(it) => &it.syntax, } } } @@ -3465,7 +3466,7 @@ impl std::fmt::Display for Attr { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for ConstDef { +impl std::fmt::Display for Const { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) } @@ -3505,7 +3506,7 @@ impl std::fmt::Display for Module { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for StaticDef { +impl std::fmt::Display for Static { 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 05ec49cec..4da1d5c11 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs @@ -483,8 +483,8 @@ impl ast::DocCommentsOwner for ast::Enum {} impl ast::DocCommentsOwner for ast::Variant {} impl ast::DocCommentsOwner for ast::TraitDef {} impl ast::DocCommentsOwner for ast::Module {} -impl ast::DocCommentsOwner for ast::StaticDef {} -impl ast::DocCommentsOwner for ast::ConstDef {} +impl ast::DocCommentsOwner for ast::Static {} +impl ast::DocCommentsOwner for ast::Const {} impl ast::DocCommentsOwner for ast::TypeAlias {} impl ast::DocCommentsOwner for ast::ImplDef {} impl ast::DocCommentsOwner for ast::MacroCall {} diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs index c586dc320..f7edd86ce 100644 --- a/crates/ra_syntax/src/parsing/text_tree_sink.rs +++ b/crates/ra_syntax/src/parsing/text_tree_sink.rs @@ -146,8 +146,8 @@ fn n_attached_trivias<'a>( trivias: impl Iterator, ) -> usize { match kind { - MACRO_CALL | CONST_DEF | TYPE_ALIAS | STRUCT | ENUM | VARIANT | FN | TRAIT_DEF - | MODULE | RECORD_FIELD | STATIC_DEF => { + MACRO_CALL | CONST | TYPE_ALIAS | STRUCT | ENUM | VARIANT | FN | TRAIT_DEF + | MODULE | RECORD_FIELD | STATIC => { let mut res = 0; let mut trivias = trivias.enumerate().peekable(); diff --git a/crates/ra_syntax/src/validation.rs b/crates/ra_syntax/src/validation.rs index 5b4e14676..a666b18db 100644 --- a/crates/ra_syntax/src/validation.rs +++ b/crates/ra_syntax/src/validation.rs @@ -4,7 +4,7 @@ mod block; use crate::{ ast, match_ast, AstNode, SyntaxError, - SyntaxKind::{BYTE, BYTE_STRING, CHAR, CONST_DEF, FN, INT_NUMBER, STRING, TYPE_ALIAS}, + SyntaxKind::{BYTE, BYTE_STRING, CHAR, CONST, FN, INT_NUMBER, STRING, TYPE_ALIAS}, SyntaxNode, SyntaxToken, TextSize, T, }; use rustc_lexer::unescape::{ @@ -200,7 +200,7 @@ fn validate_visibility(vis: ast::Visibility, errors: &mut Vec) { None => return, }; match parent.kind() { - FN | CONST_DEF | TYPE_ALIAS => (), + FN | CONST | TYPE_ALIAS => (), _ => return, } diff --git a/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast b/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast index c0ba4fba9..b1400aa5f 100644 --- a/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast +++ b/crates/ra_syntax/test_data/parser/err/0037_visibility_in_traits.rast @@ -65,7 +65,7 @@ SOURCE_FILE@0..118 R_PAREN@79..80 ")" SEMICOLON@80..81 ";" WHITESPACE@81..86 "\n " - CONST_DEF@86..115 + CONST@86..115 VISIBILITY@86..96 PUB_KW@86..89 "pub" L_PAREN@89..90 "(" diff --git a/crates/ra_syntax/test_data/parser/err/0043_default_const.rast b/crates/ra_syntax/test_data/parser/err/0043_default_const.rast index 6ca1a4870..f041fa6f7 100644 --- a/crates/ra_syntax/test_data/parser/err/0043_default_const.rast +++ b/crates/ra_syntax/test_data/parser/err/0043_default_const.rast @@ -14,7 +14,7 @@ SOURCE_FILE@0..39 NAME_REF@12..19 IDENT@12..19 "default" WHITESPACE@19..20 " " - CONST_DEF@20..36 + CONST@20..36 CONST_KW@20..25 "const" WHITESPACE@25..26 " " NAME@26..27 diff --git a/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast b/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast index d2a18330f..a6e6552a9 100644 --- a/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast +++ b/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast @@ -17,7 +17,7 @@ SOURCE_FILE@0..50 L_CURLY@22..23 "{" R_CURLY@23..24 "}" WHITESPACE@24..25 "\n" - CONST_DEF@25..46 + CONST@25..46 UNSAFE_KW@25..31 "unsafe" WHITESPACE@31..32 " " CONST_KW@32..37 "const" diff --git a/crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.rast b/crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.rast index ebcc26e0d..8d761b907 100644 --- a/crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.rast +++ b/crates/ra_syntax/test_data/parser/inline/err/0013_static_underscore.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..19 - STATIC_DEF@0..18 + STATIC@0..18 STATIC_KW@0..6 "static" WHITESPACE@6..7 " " ERROR@7..8 diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast b/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast index a62ce23e6..955e00dde 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0001_trait_item_list.rast @@ -27,7 +27,7 @@ SOURCE_FILE@0..83 IDENT@21..26 "Clone" SEMICOLON@26..27 ";" WHITESPACE@27..32 "\n " - CONST_DEF@32..45 + CONST@32..45 CONST_KW@32..37 "const" WHITESPACE@37..38 " " NAME@38..39 diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast b/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast index 3ae870e17..52181ca0c 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0021_impl_item_list.rast @@ -26,7 +26,7 @@ SOURCE_FILE@0..89 IDENT@22..25 "i32" SEMICOLON@25..26 ";" WHITESPACE@26..31 "\n " - CONST_DEF@31..49 + CONST@31..49 CONST_KW@31..36 "const" WHITESPACE@36..37 " " NAME@37..38 diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.rast b/crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.rast index 3c00a2647..0c35bf2b7 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0150_array_attrs.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..40 - CONST_DEF@0..39 + CONST@0..39 CONST_KW@0..5 "const" WHITESPACE@5..6 " " NAME@6..7 diff --git a/crates/ra_syntax/test_data/parser/ok/0023_static_items.rast b/crates/ra_syntax/test_data/parser/ok/0023_static_items.rast index 97d90dc75..9374cf5e9 100644 --- a/crates/ra_syntax/test_data/parser/ok/0023_static_items.rast +++ b/crates/ra_syntax/test_data/parser/ok/0023_static_items.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..47 - STATIC_DEF@0..20 + STATIC@0..20 STATIC_KW@0..6 "static" WHITESPACE@6..7 " " NAME@7..10 @@ -18,7 +18,7 @@ SOURCE_FILE@0..47 INT_NUMBER@18..19 "1" SEMICOLON@19..20 ";" WHITESPACE@20..21 "\n" - STATIC_DEF@21..46 + STATIC@21..46 STATIC_KW@21..27 "static" WHITESPACE@27..28 " " MUT_KW@28..31 "mut" diff --git a/crates/ra_syntax/test_data/parser/ok/0024_const_item.rast b/crates/ra_syntax/test_data/parser/ok/0024_const_item.rast index d241f034c..dd1b9c9a0 100644 --- a/crates/ra_syntax/test_data/parser/ok/0024_const_item.rast +++ b/crates/ra_syntax/test_data/parser/ok/0024_const_item.rast @@ -1,5 +1,5 @@ SOURCE_FILE@0..64 - CONST_DEF@0..17 + CONST@0..17 CONST_KW@0..5 "const" WHITESPACE@5..6 " " UNDERSCORE@6..7 "_" @@ -17,7 +17,7 @@ SOURCE_FILE@0..64 INT_NUMBER@15..16 "0" SEMICOLON@16..17 ";" WHITESPACE@17..18 "\n" - CONST_DEF@18..38 + CONST@18..38 CONST_KW@18..23 "const" WHITESPACE@23..24 " " NAME@24..27 @@ -36,7 +36,7 @@ SOURCE_FILE@0..64 INT_NUMBER@35..37 "92" SEMICOLON@37..38 ";" WHITESPACE@38..39 "\n" - CONST_DEF@39..63 + CONST@39..63 CONST_KW@39..44 "const" WHITESPACE@44..45 " " MUT_KW@45..48 "mut" diff --git a/crates/ra_syntax/test_data/parser/ok/0066_default_const.rast b/crates/ra_syntax/test_data/parser/ok/0066_default_const.rast index 584b2faf1..485efe20c 100644 --- a/crates/ra_syntax/test_data/parser/ok/0066_default_const.rast +++ b/crates/ra_syntax/test_data/parser/ok/0066_default_const.rast @@ -19,7 +19,7 @@ SOURCE_FILE@0..46 ASSOC_ITEM_LIST@15..45 L_CURLY@15..16 "{" WHITESPACE@16..19 "\n " - CONST_DEF@19..43 + CONST@19..43 DEFAULT_KW@19..26 "default" WHITESPACE@26..27 " " CONST_KW@27..32 "const" -- cgit v1.2.3 From ba71f05438a93991aff6970488a720c90774d35b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 18:10:07 +0200 Subject: fmt --- crates/ra_syntax/src/parsing/text_tree_sink.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs index f7edd86ce..95581a84b 100644 --- a/crates/ra_syntax/src/parsing/text_tree_sink.rs +++ b/crates/ra_syntax/src/parsing/text_tree_sink.rs @@ -146,8 +146,8 @@ fn n_attached_trivias<'a>( trivias: impl Iterator, ) -> usize { match kind { - MACRO_CALL | CONST | TYPE_ALIAS | STRUCT | ENUM | VARIANT | FN | TRAIT_DEF - | MODULE | RECORD_FIELD | STATIC => { + MACRO_CALL | CONST | TYPE_ALIAS | STRUCT | ENUM | VARIANT | FN | TRAIT_DEF | MODULE + | RECORD_FIELD | STATIC => { let mut res = 0; let mut trivias = trivias.enumerate().peekable(); -- cgit v1.2.3