From 216a5344c8ef3c3e430d2761dc8b1a7b60250a15 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 17:50:40 +0200 Subject: Rename StructDef -> Struct --- crates/ra_syntax/src/ast.rs | 2 +- crates/ra_syntax/src/ast/generated/nodes.rs | 42 +++++++++++++------------- crates/ra_syntax/src/ast/node_ext.rs | 4 +-- crates/ra_syntax/src/parsing/text_tree_sink.rs | 4 +-- 4 files changed, 26 insertions(+), 26 deletions(-) (limited to 'crates/ra_syntax/src') diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index 452e67c70..b69b6e85e 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs @@ -235,7 +235,7 @@ fn test_comments_preserve_trailing_whitespace() { ) .ok() .unwrap(); - let def = file.syntax().descendants().find_map(StructDef::cast).unwrap(); + let def = file.syntax().descendants().find_map(Struct::cast).unwrap(); assert_eq!( "Representation of a Realm. \nIn the specification these are called Realm Records.", def.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 d153e8528..0fd3d4f1b 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -155,14 +155,14 @@ impl StaticDef { pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, T![;]) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] -pub struct StructDef { +pub struct Struct { pub(crate) syntax: SyntaxNode, } -impl ast::AttrsOwner for StructDef {} -impl ast::NameOwner for StructDef {} -impl ast::VisibilityOwner for StructDef {} -impl ast::GenericParamsOwner for StructDef {} -impl StructDef { +impl ast::AttrsOwner for Struct {} +impl ast::NameOwner for Struct {} +impl ast::VisibilityOwner for Struct {} +impl ast::GenericParamsOwner for Struct {} +impl Struct { pub fn struct_token(&self) -> Option { support::token(&self.syntax, T![struct]) } pub fn semicolon_token(&self) -> Option { support::token(&self.syntax, T![;]) } pub fn field_list(&self) -> Option { support::child(&self.syntax) } @@ -1281,7 +1281,7 @@ pub enum Item { MacroCall(MacroCall), Module(Module), StaticDef(StaticDef), - StructDef(StructDef), + Struct(Struct), TraitDef(TraitDef), TypeAlias(TypeAlias), Union(Union), @@ -1391,7 +1391,7 @@ impl ast::NameOwner for ExternItem {} impl ast::VisibilityOwner for ExternItem {} #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum AdtDef { - StructDef(StructDef), + Struct(Struct), EnumDef(EnumDef), Union(Union), } @@ -1520,8 +1520,8 @@ impl AstNode for StaticDef { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl AstNode for StructDef { - fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_DEF } +impl AstNode for Struct { + fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT } fn cast(syntax: SyntaxNode) -> Option { if Self::can_cast(syntax.kind()) { Some(Self { syntax }) @@ -2801,8 +2801,8 @@ impl From for Item { impl From for Item { fn from(node: StaticDef) -> Item { Item::StaticDef(node) } } -impl From for Item { - fn from(node: StructDef) -> Item { Item::StructDef(node) } +impl From for Item { + fn from(node: Struct) -> Item { Item::Struct(node) } } impl From for Item { fn from(node: TraitDef) -> Item { Item::TraitDef(node) } @@ -2820,7 +2820,7 @@ 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 - | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS | UNION | USE => true, + | MODULE | STATIC_DEF | STRUCT | TRAIT_DEF | TYPE_ALIAS | UNION | USE => true, _ => false, } } @@ -2835,7 +2835,7 @@ impl AstNode for Item { MACRO_CALL => Item::MacroCall(MacroCall { syntax }), MODULE => Item::Module(Module { syntax }), STATIC_DEF => Item::StaticDef(StaticDef { syntax }), - STRUCT_DEF => Item::StructDef(StructDef { syntax }), + STRUCT => Item::Struct(Struct { syntax }), TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }), UNION => Item::Union(Union { syntax }), @@ -2855,7 +2855,7 @@ impl AstNode for Item { Item::MacroCall(it) => &it.syntax, Item::Module(it) => &it.syntax, Item::StaticDef(it) => &it.syntax, - Item::StructDef(it) => &it.syntax, + Item::Struct(it) => &it.syntax, Item::TraitDef(it) => &it.syntax, Item::TypeAlias(it) => &it.syntax, Item::Union(it) => &it.syntax, @@ -3372,8 +3372,8 @@ impl AstNode for ExternItem { } } } -impl From for AdtDef { - fn from(node: StructDef) -> AdtDef { AdtDef::StructDef(node) } +impl From for AdtDef { + fn from(node: Struct) -> AdtDef { AdtDef::Struct(node) } } impl From for AdtDef { fn from(node: EnumDef) -> AdtDef { AdtDef::EnumDef(node) } @@ -3384,13 +3384,13 @@ impl From for AdtDef { impl AstNode for AdtDef { fn can_cast(kind: SyntaxKind) -> bool { match kind { - STRUCT_DEF | ENUM_DEF | UNION => true, + STRUCT | ENUM_DEF | UNION => true, _ => false, } } fn cast(syntax: SyntaxNode) -> Option { let res = match syntax.kind() { - STRUCT_DEF => AdtDef::StructDef(StructDef { syntax }), + STRUCT => AdtDef::Struct(Struct { syntax }), ENUM_DEF => AdtDef::EnumDef(EnumDef { syntax }), UNION => AdtDef::Union(Union { syntax }), _ => return None, @@ -3399,7 +3399,7 @@ impl AstNode for AdtDef { } fn syntax(&self) -> &SyntaxNode { match self { - AdtDef::StructDef(it) => &it.syntax, + AdtDef::Struct(it) => &it.syntax, AdtDef::EnumDef(it) => &it.syntax, AdtDef::Union(it) => &it.syntax, } @@ -3510,7 +3510,7 @@ impl std::fmt::Display for StaticDef { std::fmt::Display::fmt(self.syntax(), f) } } -impl std::fmt::Display for StructDef { +impl std::fmt::Display for Struct { 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 ce11a7513..2299988ce 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs @@ -183,7 +183,7 @@ impl StructKind { } } -impl ast::StructDef { +impl ast::Struct { pub fn kind(&self) -> StructKind { StructKind::from_node(self) } @@ -475,7 +475,7 @@ impl ast::TokenTree { impl ast::DocCommentsOwner for ast::SourceFile {} impl ast::DocCommentsOwner for ast::Fn {} -impl ast::DocCommentsOwner for ast::StructDef {} +impl ast::DocCommentsOwner for ast::Struct {} impl ast::DocCommentsOwner for ast::Union {} impl ast::DocCommentsOwner for ast::RecordField {} impl ast::DocCommentsOwner for ast::TupleField {} diff --git a/crates/ra_syntax/src/parsing/text_tree_sink.rs b/crates/ra_syntax/src/parsing/text_tree_sink.rs index 0a1246c59..ef260ea59 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_DEF | ENUM_DEF | ENUM_VARIANT | FN - | TRAIT_DEF | MODULE | RECORD_FIELD | STATIC_DEF => { + MACRO_CALL | CONST_DEF | TYPE_ALIAS | STRUCT | ENUM_DEF | ENUM_VARIANT | FN | TRAIT_DEF + | MODULE | RECORD_FIELD | STATIC_DEF => { let mut res = 0; let mut trivias = trivias.enumerate().peekable(); -- cgit v1.2.3