diff options
author | Aleksey Kladov <[email protected]> | 2020-07-30 16:36:46 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-07-30 16:38:52 +0100 |
commit | 1ae4721c9cfea746fce59a816b1c266bf373d6cf (patch) | |
tree | 2a31c4bdfb62fe00b5109366155b0b4a40bf471d /crates/ra_syntax/src/ast | |
parent | 8ddbf06e39a13ed3f45e57d77727b7a35cec1749 (diff) |
Finalize union grammar
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 42 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/node_ext.rs | 2 |
2 files changed, 22 insertions, 22 deletions
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 1776fb6e6..d153e8528 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -199,14 +199,14 @@ impl TypeAlias { | |||
199 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } | 199 | pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } |
200 | } | 200 | } |
201 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 201 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
202 | pub struct UnionDef { | 202 | pub struct Union { |
203 | pub(crate) syntax: SyntaxNode, | 203 | pub(crate) syntax: SyntaxNode, |
204 | } | 204 | } |
205 | impl ast::AttrsOwner for UnionDef {} | 205 | impl ast::AttrsOwner for Union {} |
206 | impl ast::NameOwner for UnionDef {} | 206 | impl ast::NameOwner for Union {} |
207 | impl ast::VisibilityOwner for UnionDef {} | 207 | impl ast::VisibilityOwner for Union {} |
208 | impl ast::GenericParamsOwner for UnionDef {} | 208 | impl ast::GenericParamsOwner for Union {} |
209 | impl UnionDef { | 209 | impl Union { |
210 | pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) } | 210 | pub fn union_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![union]) } |
211 | pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) } | 211 | pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) } |
212 | } | 212 | } |
@@ -1284,7 +1284,7 @@ pub enum Item { | |||
1284 | StructDef(StructDef), | 1284 | StructDef(StructDef), |
1285 | TraitDef(TraitDef), | 1285 | TraitDef(TraitDef), |
1286 | TypeAlias(TypeAlias), | 1286 | TypeAlias(TypeAlias), |
1287 | UnionDef(UnionDef), | 1287 | Union(Union), |
1288 | Use(Use), | 1288 | Use(Use), |
1289 | } | 1289 | } |
1290 | impl ast::AttrsOwner for Item {} | 1290 | impl ast::AttrsOwner for Item {} |
@@ -1393,7 +1393,7 @@ impl ast::VisibilityOwner for ExternItem {} | |||
1393 | pub enum AdtDef { | 1393 | pub enum AdtDef { |
1394 | StructDef(StructDef), | 1394 | StructDef(StructDef), |
1395 | EnumDef(EnumDef), | 1395 | EnumDef(EnumDef), |
1396 | UnionDef(UnionDef), | 1396 | Union(Union), |
1397 | } | 1397 | } |
1398 | impl ast::AttrsOwner for AdtDef {} | 1398 | impl ast::AttrsOwner for AdtDef {} |
1399 | impl ast::GenericParamsOwner for AdtDef {} | 1399 | impl ast::GenericParamsOwner for AdtDef {} |
@@ -1553,8 +1553,8 @@ impl AstNode for TypeAlias { | |||
1553 | } | 1553 | } |
1554 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1554 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1555 | } | 1555 | } |
1556 | impl AstNode for UnionDef { | 1556 | impl AstNode for Union { |
1557 | fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_DEF } | 1557 | fn can_cast(kind: SyntaxKind) -> bool { kind == UNION } |
1558 | fn cast(syntax: SyntaxNode) -> Option<Self> { | 1558 | fn cast(syntax: SyntaxNode) -> Option<Self> { |
1559 | if Self::can_cast(syntax.kind()) { | 1559 | if Self::can_cast(syntax.kind()) { |
1560 | Some(Self { syntax }) | 1560 | Some(Self { syntax }) |
@@ -2810,8 +2810,8 @@ impl From<TraitDef> for Item { | |||
2810 | impl From<TypeAlias> for Item { | 2810 | impl From<TypeAlias> for Item { |
2811 | fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) } | 2811 | fn from(node: TypeAlias) -> Item { Item::TypeAlias(node) } |
2812 | } | 2812 | } |
2813 | impl From<UnionDef> for Item { | 2813 | impl From<Union> for Item { |
2814 | fn from(node: UnionDef) -> Item { Item::UnionDef(node) } | 2814 | fn from(node: Union) -> Item { Item::Union(node) } |
2815 | } | 2815 | } |
2816 | impl From<Use> for Item { | 2816 | impl From<Use> for Item { |
2817 | fn from(node: Use) -> Item { Item::Use(node) } | 2817 | fn from(node: Use) -> Item { Item::Use(node) } |
@@ -2820,7 +2820,7 @@ impl AstNode for Item { | |||
2820 | fn can_cast(kind: SyntaxKind) -> bool { | 2820 | fn can_cast(kind: SyntaxKind) -> bool { |
2821 | match kind { | 2821 | match kind { |
2822 | CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL | 2822 | CONST_DEF | ENUM_DEF | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL |
2823 | | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS | UNION_DEF | USE => true, | 2823 | | MODULE | STATIC_DEF | STRUCT_DEF | TRAIT_DEF | TYPE_ALIAS | UNION | USE => true, |
2824 | _ => false, | 2824 | _ => false, |
2825 | } | 2825 | } |
2826 | } | 2826 | } |
@@ -2838,7 +2838,7 @@ impl AstNode for Item { | |||
2838 | STRUCT_DEF => Item::StructDef(StructDef { syntax }), | 2838 | STRUCT_DEF => Item::StructDef(StructDef { syntax }), |
2839 | TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), | 2839 | TRAIT_DEF => Item::TraitDef(TraitDef { syntax }), |
2840 | TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }), | 2840 | TYPE_ALIAS => Item::TypeAlias(TypeAlias { syntax }), |
2841 | UNION_DEF => Item::UnionDef(UnionDef { syntax }), | 2841 | UNION => Item::Union(Union { syntax }), |
2842 | USE => Item::Use(Use { syntax }), | 2842 | USE => Item::Use(Use { syntax }), |
2843 | _ => return None, | 2843 | _ => return None, |
2844 | }; | 2844 | }; |
@@ -2858,7 +2858,7 @@ impl AstNode for Item { | |||
2858 | Item::StructDef(it) => &it.syntax, | 2858 | Item::StructDef(it) => &it.syntax, |
2859 | Item::TraitDef(it) => &it.syntax, | 2859 | Item::TraitDef(it) => &it.syntax, |
2860 | Item::TypeAlias(it) => &it.syntax, | 2860 | Item::TypeAlias(it) => &it.syntax, |
2861 | Item::UnionDef(it) => &it.syntax, | 2861 | Item::Union(it) => &it.syntax, |
2862 | Item::Use(it) => &it.syntax, | 2862 | Item::Use(it) => &it.syntax, |
2863 | } | 2863 | } |
2864 | } | 2864 | } |
@@ -3378,13 +3378,13 @@ impl From<StructDef> for AdtDef { | |||
3378 | impl From<EnumDef> for AdtDef { | 3378 | impl From<EnumDef> for AdtDef { |
3379 | fn from(node: EnumDef) -> AdtDef { AdtDef::EnumDef(node) } | 3379 | fn from(node: EnumDef) -> AdtDef { AdtDef::EnumDef(node) } |
3380 | } | 3380 | } |
3381 | impl From<UnionDef> for AdtDef { | 3381 | impl From<Union> for AdtDef { |
3382 | fn from(node: UnionDef) -> AdtDef { AdtDef::UnionDef(node) } | 3382 | fn from(node: Union) -> AdtDef { AdtDef::Union(node) } |
3383 | } | 3383 | } |
3384 | impl AstNode for AdtDef { | 3384 | impl AstNode for AdtDef { |
3385 | fn can_cast(kind: SyntaxKind) -> bool { | 3385 | fn can_cast(kind: SyntaxKind) -> bool { |
3386 | match kind { | 3386 | match kind { |
3387 | STRUCT_DEF | ENUM_DEF | UNION_DEF => true, | 3387 | STRUCT_DEF | ENUM_DEF | UNION => true, |
3388 | _ => false, | 3388 | _ => false, |
3389 | } | 3389 | } |
3390 | } | 3390 | } |
@@ -3392,7 +3392,7 @@ impl AstNode for AdtDef { | |||
3392 | let res = match syntax.kind() { | 3392 | let res = match syntax.kind() { |
3393 | STRUCT_DEF => AdtDef::StructDef(StructDef { syntax }), | 3393 | STRUCT_DEF => AdtDef::StructDef(StructDef { syntax }), |
3394 | ENUM_DEF => AdtDef::EnumDef(EnumDef { syntax }), | 3394 | ENUM_DEF => AdtDef::EnumDef(EnumDef { syntax }), |
3395 | UNION_DEF => AdtDef::UnionDef(UnionDef { syntax }), | 3395 | UNION => AdtDef::Union(Union { syntax }), |
3396 | _ => return None, | 3396 | _ => return None, |
3397 | }; | 3397 | }; |
3398 | Some(res) | 3398 | Some(res) |
@@ -3401,7 +3401,7 @@ impl AstNode for AdtDef { | |||
3401 | match self { | 3401 | match self { |
3402 | AdtDef::StructDef(it) => &it.syntax, | 3402 | AdtDef::StructDef(it) => &it.syntax, |
3403 | AdtDef::EnumDef(it) => &it.syntax, | 3403 | AdtDef::EnumDef(it) => &it.syntax, |
3404 | AdtDef::UnionDef(it) => &it.syntax, | 3404 | AdtDef::Union(it) => &it.syntax, |
3405 | } | 3405 | } |
3406 | } | 3406 | } |
3407 | } | 3407 | } |
@@ -3525,7 +3525,7 @@ impl std::fmt::Display for TypeAlias { | |||
3525 | std::fmt::Display::fmt(self.syntax(), f) | 3525 | std::fmt::Display::fmt(self.syntax(), f) |
3526 | } | 3526 | } |
3527 | } | 3527 | } |
3528 | impl std::fmt::Display for UnionDef { | 3528 | impl std::fmt::Display for Union { |
3529 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 3529 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
3530 | std::fmt::Display::fmt(self.syntax(), f) | 3530 | std::fmt::Display::fmt(self.syntax(), f) |
3531 | } | 3531 | } |
diff --git a/crates/ra_syntax/src/ast/node_ext.rs b/crates/ra_syntax/src/ast/node_ext.rs index ffe6746d3..ce11a7513 100644 --- a/crates/ra_syntax/src/ast/node_ext.rs +++ b/crates/ra_syntax/src/ast/node_ext.rs | |||
@@ -476,7 +476,7 @@ impl ast::TokenTree { | |||
476 | impl ast::DocCommentsOwner for ast::SourceFile {} | 476 | impl ast::DocCommentsOwner for ast::SourceFile {} |
477 | impl ast::DocCommentsOwner for ast::Fn {} | 477 | impl ast::DocCommentsOwner for ast::Fn {} |
478 | impl ast::DocCommentsOwner for ast::StructDef {} | 478 | impl ast::DocCommentsOwner for ast::StructDef {} |
479 | impl ast::DocCommentsOwner for ast::UnionDef {} | 479 | impl ast::DocCommentsOwner for ast::Union {} |
480 | impl ast::DocCommentsOwner for ast::RecordField {} | 480 | impl ast::DocCommentsOwner for ast::RecordField {} |
481 | impl ast::DocCommentsOwner for ast::TupleField {} | 481 | impl ast::DocCommentsOwner for ast::TupleField {} |
482 | impl ast::DocCommentsOwner for ast::EnumDef {} | 482 | impl ast::DocCommentsOwner for ast::EnumDef {} |