aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast/generated/nodes.rs42
-rw-r--r--crates/ra_syntax/src/ast/node_ext.rs6
-rw-r--r--crates/ra_syntax/src/parsing/text_tree_sink.rs2
-rw-r--r--crates/ra_syntax/test_data/parser/err/0025_nope.rast8
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0118_impl_inner_attributes.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0134_nocontentexpr_after_item.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/inline/ok/0157_variant_discriminant.rast2
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0019_enums.rast10
-rw-r--r--crates/ra_syntax/test_data/parser/ok/0047_minus_in_inner_pattern.rast2
9 files changed, 38 insertions, 38 deletions
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 {
44 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) } 44 pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![;]) }
45} 45}
46#[derive(Debug, Clone, PartialEq, Eq, Hash)] 46#[derive(Debug, Clone, PartialEq, Eq, Hash)]
47pub struct EnumDef { 47pub struct Enum {
48 pub(crate) syntax: SyntaxNode, 48 pub(crate) syntax: SyntaxNode,
49} 49}
50impl ast::AttrsOwner for EnumDef {} 50impl ast::AttrsOwner for Enum {}
51impl ast::NameOwner for EnumDef {} 51impl ast::NameOwner for Enum {}
52impl ast::VisibilityOwner for EnumDef {} 52impl ast::VisibilityOwner for Enum {}
53impl ast::GenericParamsOwner for EnumDef {} 53impl ast::GenericParamsOwner for Enum {}
54impl EnumDef { 54impl Enum {
55 pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) } 55 pub fn enum_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![enum]) }
56 pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) } 56 pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) }
57} 57}
@@ -1273,7 +1273,7 @@ impl MetaItem {
1273#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1273#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1274pub enum Item { 1274pub enum Item {
1275 ConstDef(ConstDef), 1275 ConstDef(ConstDef),
1276 EnumDef(EnumDef), 1276 Enum(Enum),
1277 ExternBlock(ExternBlock), 1277 ExternBlock(ExternBlock),
1278 ExternCrate(ExternCrate), 1278 ExternCrate(ExternCrate),
1279 Fn(Fn), 1279 Fn(Fn),
@@ -1392,7 +1392,7 @@ impl ast::VisibilityOwner for ExternItem {}
1392#[derive(Debug, Clone, PartialEq, Eq, Hash)] 1392#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1393pub enum AdtDef { 1393pub enum AdtDef {
1394 Struct(Struct), 1394 Struct(Struct),
1395 EnumDef(EnumDef), 1395 Enum(Enum),
1396 Union(Union), 1396 Union(Union),
1397} 1397}
1398impl ast::AttrsOwner for AdtDef {} 1398impl ast::AttrsOwner for AdtDef {}
@@ -1432,8 +1432,8 @@ impl AstNode for ConstDef {
1432 } 1432 }
1433 fn syntax(&self) -> &SyntaxNode { &self.syntax } 1433 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1434} 1434}
1435impl AstNode for EnumDef { 1435impl AstNode for Enum {
1436 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_DEF } 1436 fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM }
1437 fn cast(syntax: SyntaxNode) -> Option<Self> { 1437 fn cast(syntax: SyntaxNode) -> Option<Self> {
1438 if Self::can_cast(syntax.kind()) { 1438 if Self::can_cast(syntax.kind()) {
1439 Some(Self { syntax }) 1439 Some(Self { syntax })
@@ -2777,8 +2777,8 @@ impl AstNode for MetaItem {
2777impl From<ConstDef> for Item { 2777impl From<ConstDef> for Item {
2778 fn from(node: ConstDef) -> Item { Item::ConstDef(node) } 2778 fn from(node: ConstDef) -> Item { Item::ConstDef(node) }
2779} 2779}
2780impl From<EnumDef> for Item { 2780impl From<Enum> for Item {
2781 fn from(node: EnumDef) -> Item { Item::EnumDef(node) } 2781 fn from(node: Enum) -> Item { Item::Enum(node) }
2782} 2782}
2783impl From<ExternBlock> for Item { 2783impl From<ExternBlock> for Item {
2784 fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) } 2784 fn from(node: ExternBlock) -> Item { Item::ExternBlock(node) }
@@ -2819,7 +2819,7 @@ impl From<Use> for Item {
2819impl AstNode for Item { 2819impl 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 | EXTERN_BLOCK | EXTERN_CRATE | FN | IMPL_DEF | MACRO_CALL
2823 | MODULE | STATIC_DEF | STRUCT | TRAIT_DEF | TYPE_ALIAS | UNION | USE => true, 2823 | MODULE | STATIC_DEF | STRUCT | TRAIT_DEF | TYPE_ALIAS | UNION | USE => true,
2824 _ => false, 2824 _ => false,
2825 } 2825 }
@@ -2827,7 +2827,7 @@ impl AstNode for Item {
2827 fn cast(syntax: SyntaxNode) -> Option<Self> { 2827 fn cast(syntax: SyntaxNode) -> Option<Self> {
2828 let res = match syntax.kind() { 2828 let res = match syntax.kind() {
2829 CONST_DEF => Item::ConstDef(ConstDef { syntax }), 2829 CONST_DEF => Item::ConstDef(ConstDef { syntax }),
2830 ENUM_DEF => Item::EnumDef(EnumDef { syntax }), 2830 ENUM => Item::Enum(Enum { syntax }),
2831 EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }), 2831 EXTERN_BLOCK => Item::ExternBlock(ExternBlock { syntax }),
2832 EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }), 2832 EXTERN_CRATE => Item::ExternCrate(ExternCrate { syntax }),
2833 FN => Item::Fn(Fn { syntax }), 2833 FN => Item::Fn(Fn { syntax }),
@@ -2847,7 +2847,7 @@ impl AstNode for Item {
2847 fn syntax(&self) -> &SyntaxNode { 2847 fn syntax(&self) -> &SyntaxNode {
2848 match self { 2848 match self {
2849 Item::ConstDef(it) => &it.syntax, 2849 Item::ConstDef(it) => &it.syntax,
2850 Item::EnumDef(it) => &it.syntax, 2850 Item::Enum(it) => &it.syntax,
2851 Item::ExternBlock(it) => &it.syntax, 2851 Item::ExternBlock(it) => &it.syntax,
2852 Item::ExternCrate(it) => &it.syntax, 2852 Item::ExternCrate(it) => &it.syntax,
2853 Item::Fn(it) => &it.syntax, 2853 Item::Fn(it) => &it.syntax,
@@ -3375,8 +3375,8 @@ impl AstNode for ExternItem {
3375impl From<Struct> for AdtDef { 3375impl From<Struct> for AdtDef {
3376 fn from(node: Struct) -> AdtDef { AdtDef::Struct(node) } 3376 fn from(node: Struct) -> AdtDef { AdtDef::Struct(node) }
3377} 3377}
3378impl From<EnumDef> for AdtDef { 3378impl From<Enum> for AdtDef {
3379 fn from(node: EnumDef) -> AdtDef { AdtDef::EnumDef(node) } 3379 fn from(node: Enum) -> AdtDef { AdtDef::Enum(node) }
3380} 3380}
3381impl From<Union> for AdtDef { 3381impl From<Union> for AdtDef {
3382 fn from(node: Union) -> AdtDef { AdtDef::Union(node) } 3382 fn from(node: Union) -> AdtDef { AdtDef::Union(node) }
@@ -3384,14 +3384,14 @@ impl From<Union> for AdtDef {
3384impl AstNode for AdtDef { 3384impl 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 | ENUM_DEF | UNION => true, 3387 STRUCT | ENUM | UNION => true,
3388 _ => false, 3388 _ => false,
3389 } 3389 }
3390 } 3390 }
3391 fn cast(syntax: SyntaxNode) -> Option<Self> { 3391 fn cast(syntax: SyntaxNode) -> Option<Self> {
3392 let res = match syntax.kind() { 3392 let res = match syntax.kind() {
3393 STRUCT => AdtDef::Struct(Struct { syntax }), 3393 STRUCT => AdtDef::Struct(Struct { syntax }),
3394 ENUM_DEF => AdtDef::EnumDef(EnumDef { syntax }), 3394 ENUM => AdtDef::Enum(Enum { syntax }),
3395 UNION => AdtDef::Union(Union { syntax }), 3395 UNION => AdtDef::Union(Union { syntax }),
3396 _ => return None, 3396 _ => return None,
3397 }; 3397 };
@@ -3400,7 +3400,7 @@ impl AstNode for AdtDef {
3400 fn syntax(&self) -> &SyntaxNode { 3400 fn syntax(&self) -> &SyntaxNode {
3401 match self { 3401 match self {
3402 AdtDef::Struct(it) => &it.syntax, 3402 AdtDef::Struct(it) => &it.syntax,
3403 AdtDef::EnumDef(it) => &it.syntax, 3403 AdtDef::Enum(it) => &it.syntax,
3404 AdtDef::Union(it) => &it.syntax, 3404 AdtDef::Union(it) => &it.syntax,
3405 } 3405 }
3406 } 3406 }
@@ -3470,7 +3470,7 @@ impl std::fmt::Display for ConstDef {
3470 std::fmt::Display::fmt(self.syntax(), f) 3470 std::fmt::Display::fmt(self.syntax(), f)
3471 } 3471 }
3472} 3472}
3473impl std::fmt::Display for EnumDef { 3473impl std::fmt::Display for Enum {
3474 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 3474 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3475 std::fmt::Display::fmt(self.syntax(), f) 3475 std::fmt::Display::fmt(self.syntax(), f)
3476 } 3476 }
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 {
248} 248}
249 249
250impl ast::EnumVariant { 250impl ast::EnumVariant {
251 pub fn parent_enum(&self) -> ast::EnumDef { 251 pub fn parent_enum(&self) -> ast::Enum {
252 self.syntax() 252 self.syntax()
253 .parent() 253 .parent()
254 .and_then(|it| it.parent()) 254 .and_then(|it| it.parent())
255 .and_then(ast::EnumDef::cast) 255 .and_then(ast::Enum::cast)
256 .expect("EnumVariants are always nested in Enums") 256 .expect("EnumVariants are always nested in Enums")
257 } 257 }
258 pub fn kind(&self) -> StructKind { 258 pub fn kind(&self) -> StructKind {
@@ -479,7 +479,7 @@ impl ast::DocCommentsOwner for ast::Struct {}
479impl ast::DocCommentsOwner for ast::Union {} 479impl ast::DocCommentsOwner for ast::Union {}
480impl ast::DocCommentsOwner for ast::RecordField {} 480impl ast::DocCommentsOwner for ast::RecordField {}
481impl ast::DocCommentsOwner for ast::TupleField {} 481impl ast::DocCommentsOwner for ast::TupleField {}
482impl ast::DocCommentsOwner for ast::EnumDef {} 482impl ast::DocCommentsOwner for ast::Enum {}
483impl ast::DocCommentsOwner for ast::EnumVariant {} 483impl ast::DocCommentsOwner for ast::EnumVariant {}
484impl ast::DocCommentsOwner for ast::TraitDef {} 484impl ast::DocCommentsOwner for ast::TraitDef {}
485impl ast::DocCommentsOwner for ast::Module {} 485impl 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>(
146 trivias: impl Iterator<Item = (SyntaxKind, &'a str)>, 146 trivias: impl Iterator<Item = (SyntaxKind, &'a str)>,
147) -> usize { 147) -> usize {
148 match kind { 148 match kind {
149 MACRO_CALL | CONST_DEF | TYPE_ALIAS | STRUCT | ENUM_DEF | ENUM_VARIANT | FN | TRAIT_DEF 149 MACRO_CALL | CONST_DEF | TYPE_ALIAS | STRUCT | ENUM | ENUM_VARIANT | FN | TRAIT_DEF
150 | MODULE | RECORD_FIELD | STATIC_DEF => { 150 | MODULE | RECORD_FIELD | STATIC_DEF => {
151 let mut res = 0; 151 let mut res = 0;
152 let mut trivias = trivias.enumerate().peekable(); 152 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 @@ [email protected]
11 [email protected] 11 [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 ENUM_DEF@16..152 14 [email protected]
15 [email protected] "enum" 15 [email protected] "enum"
16 [email protected] " " 16 [email protected] " "
17 [email protected] 17 [email protected]
@@ -79,7 +79,7 @@ [email protected]
79 [email protected] "1" 79 [email protected] "1"
80 [email protected] ";" 80 [email protected] ";"
81 [email protected] "\n " 81 [email protected] "\n "
82 ENUM_DEF@191..223 82 [email protected]
83 [email protected] "enum" 83 [email protected] "enum"
84 [email protected] " " 84 [email protected] " "
85 [email protected] 85 [email protected]
@@ -95,7 +95,7 @@ [email protected]
95 [email protected] "\n " 95 [email protected] "\n "
96 [email protected] "}" 96 [email protected] "}"
97 [email protected] "\n\n " 97 [email protected] "\n\n "
98 ENUM_DEF@229..300 98 [email protected]
99 [email protected] "enum" 99 [email protected] "enum"
100 [email protected] " " 100 [email protected] " "
101 [email protected] 101 [email protected]
@@ -132,7 +132,7 @@ [email protected]
132 [email protected] 132 [email protected]
133 [email protected] "{" 133 [email protected] "{"
134 [email protected] "\n " 134 [email protected] "\n "
135 ENUM_DEF@316..453 135 [email protected]
136 [email protected] "// fail again" 136 [email protected] "// fail again"
137 [email protected] "\n " 137 [email protected] "\n "
138 [email protected] "enum" 138 [email protected] "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 @@
1[email protected] 1[email protected]
2 ENUM_DEF@0..8 2 [email protected]
3 [email protected] "enum" 3 [email protected] "enum"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
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 @@ [email protected]
11 [email protected] 11 [email protected]
12 [email protected] "{" 12 [email protected] "{"
13 [email protected] "\n " 13 [email protected] "\n "
14 ENUM_DEF@27..75 14 [email protected]
15 [email protected] "enum" 15 [email protected] "enum"
16 [email protected] " " 16 [email protected] " "
17 [email protected] 17 [email protected]
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 @@
1[email protected] 1[email protected]
2 ENUM_DEF@0..22 2 [email protected]
3 [email protected] "enum" 3 [email protected] "enum"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
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 @@
1[email protected] 1[email protected]
2 ENUM_DEF@0..11 2 [email protected]
3 [email protected] "enum" 3 [email protected] "enum"
4 [email protected] " " 4 [email protected] " "
5 [email protected] 5 [email protected]
@@ -10,7 +10,7 @@ [email protected]
10 [email protected] "\n" 10 [email protected] "\n"
11 [email protected] "}" 11 [email protected] "}"
12 [email protected] "\n\n" 12 [email protected] "\n\n"
13 ENUM_DEF@13..27 13 [email protected]
14 [email protected] "enum" 14 [email protected] "enum"
15 [email protected] " " 15 [email protected] " "
16 [email protected] 16 [email protected]
@@ -27,7 +27,7 @@ [email protected]
27 [email protected] "\n" 27 [email protected] "\n"
28 [email protected] "}" 28 [email protected] "}"
29 [email protected] "\n\n" 29 [email protected] "\n\n"
30 ENUM_DEF@29..46 30 [email protected]
31 [email protected] "enum" 31 [email protected] "enum"
32 [email protected] " " 32 [email protected] " "
33 [email protected] 33 [email protected]
@@ -42,7 +42,7 @@ [email protected]
42 [email protected] "\n" 42 [email protected] "\n"
43 [email protected] "}" 43 [email protected] "}"
44 [email protected] "\n\n" 44 [email protected] "\n\n"
45 ENUM_DEF@48..66 45 [email protected]
46 [email protected] "enum" 46 [email protected] "enum"
47 [email protected] " " 47 [email protected] " "
48 [email protected] 48 [email protected]
@@ -58,7 +58,7 @@ [email protected]
58 [email protected] "\n" 58 [email protected] "\n"
59 [email protected] "}" 59 [email protected] "}"
60 [email protected] "\n\n" 60 [email protected] "\n\n"
61 ENUM_DEF@68..181 61 [email protected]
62 [email protected] "enum" 62 [email protected] "enum"
63 [email protected] " " 63 [email protected] " "
64 [email protected] 64 [email protected]
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 @@ [email protected]
256 [email protected] "\n" 256 [email protected] "\n"
257 [email protected] "}" 257 [email protected] "}"
258 [email protected] "\n\n" 258 [email protected] "\n\n"
259 ENUM_DEF@343..367 259 [email protected]
260 [email protected] "enum" 260 [email protected] "enum"
261 [email protected] " " 261 [email protected] " "
262 [email protected] 262 [email protected]