aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-25 13:55:09 +0000
committerAleksey Kladov <[email protected]>2019-11-25 14:50:49 +0000
commite1c0bdaf75f8d88a5c28b3e44def17d91d4f46b3 (patch)
tree15cb5466dd2fab58d1591afc50bd28aeab65359d /crates/ra_syntax/src/ast
parentbe00d74c7b61fb82bdade482e95035a21f9dd736 (diff)
Introduce dedicated AST node for union
Although structs and unions have the same syntax and differ only in the keyword, re-using the single syntax node for both of them leads to confusion in practice, and propagates further down the hir in an upleasent way. Moreover, static and consts also share syntax, but we use different nodes for them.
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index de506d7cd..1a03ae56c 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -3789,6 +3789,34 @@ impl AstNode for TypeRef {
3789} 3789}
3790impl TypeRef {} 3790impl TypeRef {}
3791#[derive(Debug, Clone, PartialEq, Eq, Hash)] 3791#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3792pub struct UnionDef {
3793 pub(crate) syntax: SyntaxNode,
3794}
3795impl AstNode for UnionDef {
3796 fn can_cast(kind: SyntaxKind) -> bool {
3797 match kind {
3798 UNION_DEF => true,
3799 _ => false,
3800 }
3801 }
3802 fn cast(syntax: SyntaxNode) -> Option<Self> {
3803 if Self::can_cast(syntax.kind()) {
3804 Some(Self { syntax })
3805 } else {
3806 None
3807 }
3808 }
3809 fn syntax(&self) -> &SyntaxNode {
3810 &self.syntax
3811 }
3812}
3813impl ast::VisibilityOwner for UnionDef {}
3814impl ast::NameOwner for UnionDef {}
3815impl ast::TypeParamsOwner for UnionDef {}
3816impl ast::AttrsOwner for UnionDef {}
3817impl ast::DocCommentsOwner for UnionDef {}
3818impl UnionDef {}
3819#[derive(Debug, Clone, PartialEq, Eq, Hash)]
3792pub struct UseItem { 3820pub struct UseItem {
3793 pub(crate) syntax: SyntaxNode, 3821 pub(crate) syntax: SyntaxNode,
3794} 3822}