aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast.rs4
-rw-r--r--crates/ra_syntax/src/ast/generated.rs43
-rw-r--r--crates/ra_syntax/src/grammar.ron10
-rw-r--r--crates/ra_syntax/src/grammar/items/nominal.rs10
-rw-r--r--crates/ra_syntax/src/parser_impl/event.rs2
-rw-r--r--crates/ra_syntax/src/syntax_kinds/generated.rs8
6 files changed, 39 insertions, 38 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 165b308d1..00c60ebf3 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -407,7 +407,7 @@ impl<'a, N: AstNode + 'a> Iterator for AstChildren<'a, N> {
407 407
408#[derive(Debug, Clone, PartialEq, Eq)] 408#[derive(Debug, Clone, PartialEq, Eq)]
409pub enum StructFlavor<'a> { 409pub enum StructFlavor<'a> {
410 Tuple(&'a PosFieldList), 410 Tuple(&'a PosFieldDefList),
411 Named(&'a NamedFieldDefList), 411 Named(&'a NamedFieldDefList),
412 Unit, 412 Unit,
413} 413}
@@ -416,7 +416,7 @@ impl StructFlavor<'_> {
416 fn from_node<N: AstNode>(node: &N) -> StructFlavor { 416 fn from_node<N: AstNode>(node: &N) -> StructFlavor {
417 if let Some(nfdl) = child_opt::<_, NamedFieldDefList>(node) { 417 if let Some(nfdl) = child_opt::<_, NamedFieldDefList>(node) {
418 StructFlavor::Named(nfdl) 418 StructFlavor::Named(nfdl)
419 } else if let Some(pfl) = child_opt::<_, PosFieldList>(node) { 419 } else if let Some(pfl) = child_opt::<_, PosFieldDefList>(node) {
420 StructFlavor::Tuple(pfl) 420 StructFlavor::Tuple(pfl)
421 } else { 421 } else {
422 StructFlavor::Unit 422 StructFlavor::Unit
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 7da19d782..3ace6533c 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -2248,6 +2248,7 @@ impl ToOwned for NamedFieldDef {
2248impl ast::VisibilityOwner for NamedFieldDef {} 2248impl ast::VisibilityOwner for NamedFieldDef {}
2249impl ast::NameOwner for NamedFieldDef {} 2249impl ast::NameOwner for NamedFieldDef {}
2250impl ast::AttrsOwner for NamedFieldDef {} 2250impl ast::AttrsOwner for NamedFieldDef {}
2251impl ast::DocCommentsOwner for NamedFieldDef {}
2251impl NamedFieldDef { 2252impl NamedFieldDef {
2252 pub fn type_ref(&self) -> Option<&TypeRef> { 2253 pub fn type_ref(&self) -> Option<&TypeRef> {
2253 super::child_opt(self) 2254 super::child_opt(self)
@@ -2850,68 +2851,68 @@ impl PointerType {
2850 } 2851 }
2851} 2852}
2852 2853
2853// PosField 2854// PosFieldDef
2854#[derive(Debug, PartialEq, Eq, Hash)] 2855#[derive(Debug, PartialEq, Eq, Hash)]
2855#[repr(transparent)] 2856#[repr(transparent)]
2856pub struct PosField { 2857pub struct PosFieldDef {
2857 pub(crate) syntax: SyntaxNode, 2858 pub(crate) syntax: SyntaxNode,
2858} 2859}
2859unsafe impl TransparentNewType for PosField { 2860unsafe impl TransparentNewType for PosFieldDef {
2860 type Repr = rowan::SyntaxNode<RaTypes>; 2861 type Repr = rowan::SyntaxNode<RaTypes>;
2861} 2862}
2862 2863
2863impl AstNode for PosField { 2864impl AstNode for PosFieldDef {
2864 fn cast(syntax: &SyntaxNode) -> Option<&Self> { 2865 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2865 match syntax.kind() { 2866 match syntax.kind() {
2866 POS_FIELD => Some(PosField::from_repr(syntax.into_repr())), 2867 POS_FIELD_DEF => Some(PosFieldDef::from_repr(syntax.into_repr())),
2867 _ => None, 2868 _ => None,
2868 } 2869 }
2869 } 2870 }
2870 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2871 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2871} 2872}
2872 2873
2873impl ToOwned for PosField { 2874impl ToOwned for PosFieldDef {
2874 type Owned = TreeArc<PosField>; 2875 type Owned = TreeArc<PosFieldDef>;
2875 fn to_owned(&self) -> TreeArc<PosField> { TreeArc::cast(self.syntax.to_owned()) } 2876 fn to_owned(&self) -> TreeArc<PosFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
2876} 2877}
2877 2878
2878 2879
2879impl ast::VisibilityOwner for PosField {} 2880impl ast::VisibilityOwner for PosFieldDef {}
2880impl ast::AttrsOwner for PosField {} 2881impl ast::AttrsOwner for PosFieldDef {}
2881impl PosField { 2882impl PosFieldDef {
2882 pub fn type_ref(&self) -> Option<&TypeRef> { 2883 pub fn type_ref(&self) -> Option<&TypeRef> {
2883 super::child_opt(self) 2884 super::child_opt(self)
2884 } 2885 }
2885} 2886}
2886 2887
2887// PosFieldList 2888// PosFieldDefList
2888#[derive(Debug, PartialEq, Eq, Hash)] 2889#[derive(Debug, PartialEq, Eq, Hash)]
2889#[repr(transparent)] 2890#[repr(transparent)]
2890pub struct PosFieldList { 2891pub struct PosFieldDefList {
2891 pub(crate) syntax: SyntaxNode, 2892 pub(crate) syntax: SyntaxNode,
2892} 2893}
2893unsafe impl TransparentNewType for PosFieldList { 2894unsafe impl TransparentNewType for PosFieldDefList {
2894 type Repr = rowan::SyntaxNode<RaTypes>; 2895 type Repr = rowan::SyntaxNode<RaTypes>;
2895} 2896}
2896 2897
2897impl AstNode for PosFieldList { 2898impl AstNode for PosFieldDefList {
2898 fn cast(syntax: &SyntaxNode) -> Option<&Self> { 2899 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
2899 match syntax.kind() { 2900 match syntax.kind() {
2900 POS_FIELD_LIST => Some(PosFieldList::from_repr(syntax.into_repr())), 2901 POS_FIELD_DEF_LIST => Some(PosFieldDefList::from_repr(syntax.into_repr())),
2901 _ => None, 2902 _ => None,
2902 } 2903 }
2903 } 2904 }
2904 fn syntax(&self) -> &SyntaxNode { &self.syntax } 2905 fn syntax(&self) -> &SyntaxNode { &self.syntax }
2905} 2906}
2906 2907
2907impl ToOwned for PosFieldList { 2908impl ToOwned for PosFieldDefList {
2908 type Owned = TreeArc<PosFieldList>; 2909 type Owned = TreeArc<PosFieldDefList>;
2909 fn to_owned(&self) -> TreeArc<PosFieldList> { TreeArc::cast(self.syntax.to_owned()) } 2910 fn to_owned(&self) -> TreeArc<PosFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
2910} 2911}
2911 2912
2912 2913
2913impl PosFieldList { 2914impl PosFieldDefList {
2914 pub fn fields(&self) -> impl Iterator<Item = &PosField> { 2915 pub fn fields(&self) -> impl Iterator<Item = &PosFieldDef> {
2915 super::children(self) 2916 super::children(self)
2916 } 2917 }
2917} 2918}
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
index cb5d6cde8..85fc79038 100644
--- a/crates/ra_syntax/src/grammar.ron
+++ b/crates/ra_syntax/src/grammar.ron
@@ -205,8 +205,8 @@ Grammar(
205 "ENUM_VARIANT", 205 "ENUM_VARIANT",
206 "NAMED_FIELD_DEF_LIST", 206 "NAMED_FIELD_DEF_LIST",
207 "NAMED_FIELD_DEF", 207 "NAMED_FIELD_DEF",
208 "POS_FIELD_LIST", 208 "POS_FIELD_DEF_LIST",
209 "POS_FIELD", 209 "POS_FIELD_DEF",
210 "ENUM_VARIANT_LIST", 210 "ENUM_VARIANT_LIST",
211 "ITEM_LIST", 211 "ITEM_LIST",
212 "ATTR", 212 "ATTR",
@@ -268,9 +268,9 @@ Grammar(
268 ] 268 ]
269 ), 269 ),
270 "NamedFieldDefList": (collections: [["fields", "NamedFieldDef"]]), 270 "NamedFieldDefList": (collections: [["fields", "NamedFieldDef"]]),
271 "NamedFieldDef": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner"], options: ["TypeRef"] ), 271 "NamedFieldDef": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner"], options: ["TypeRef"] ),
272 "PosFieldList": (collections: [["fields", "PosField"]]), 272 "PosFieldDefList": (collections: [["fields", "PosFieldDef"]]),
273 "PosField": ( traits: ["VisibilityOwner", "AttrsOwner"], options: ["TypeRef"]), 273 "PosFieldDef": ( traits: ["VisibilityOwner", "AttrsOwner"], options: ["TypeRef"]),
274 "EnumDef": ( traits: [ 274 "EnumDef": ( traits: [
275 "VisibilityOwner", 275 "VisibilityOwner",
276 "NameOwner", 276 "NameOwner",
diff --git a/crates/ra_syntax/src/grammar/items/nominal.rs b/crates/ra_syntax/src/grammar/items/nominal.rs
index 0784fb7b1..ff9b38f9c 100644
--- a/crates/ra_syntax/src/grammar/items/nominal.rs
+++ b/crates/ra_syntax/src/grammar/items/nominal.rs
@@ -28,7 +28,7 @@ pub(super) fn struct_def(p: &mut Parser, kind: SyntaxKind) {
28 } 28 }
29 L_CURLY => named_field_def_list(p), 29 L_CURLY => named_field_def_list(p),
30 L_PAREN if kind == STRUCT_KW => { 30 L_PAREN if kind == STRUCT_KW => {
31 pos_field_list(p); 31 pos_field_def_list(p);
32 // test tuple_struct_where 32 // test tuple_struct_where
33 // struct Test<T>(T) where T: Clone; 33 // struct Test<T>(T) where T: Clone;
34 // struct Test<T>(T); 34 // struct Test<T>(T);
@@ -74,7 +74,7 @@ pub(crate) fn enum_variant_list(p: &mut Parser) {
74 name(p); 74 name(p);
75 match p.current() { 75 match p.current() {
76 L_CURLY => named_field_def_list(p), 76 L_CURLY => named_field_def_list(p),
77 L_PAREN => pos_field_list(p), 77 L_PAREN => pos_field_def_list(p),
78 EQ => { 78 EQ => {
79 p.bump(); 79 p.bump();
80 expressions::expr(p); 80 expressions::expr(p);
@@ -132,7 +132,7 @@ pub(crate) fn named_field_def_list(p: &mut Parser) {
132 } 132 }
133} 133}
134 134
135fn pos_field_list(p: &mut Parser) { 135fn pos_field_def_list(p: &mut Parser) {
136 assert!(p.at(L_PAREN)); 136 assert!(p.at(L_PAREN));
137 let m = p.start(); 137 let m = p.start();
138 if !p.expect(L_PAREN) { 138 if !p.expect(L_PAREN) {
@@ -157,12 +157,12 @@ fn pos_field_list(p: &mut Parser) {
157 break; 157 break;
158 } 158 }
159 types::type_(p); 159 types::type_(p);
160 m.complete(p, POS_FIELD); 160 m.complete(p, POS_FIELD_DEF);
161 161
162 if !p.at(R_PAREN) { 162 if !p.at(R_PAREN) {
163 p.expect(COMMA); 163 p.expect(COMMA);
164 } 164 }
165 } 165 }
166 p.expect(R_PAREN); 166 p.expect(R_PAREN);
167 m.complete(p, POS_FIELD_LIST); 167 m.complete(p, POS_FIELD_DEF_LIST);
168} 168}
diff --git a/crates/ra_syntax/src/parser_impl/event.rs b/crates/ra_syntax/src/parser_impl/event.rs
index bd77fee89..33e10ef85 100644
--- a/crates/ra_syntax/src/parser_impl/event.rs
+++ b/crates/ra_syntax/src/parser_impl/event.rs
@@ -250,7 +250,7 @@ fn n_attached_trivias<'a>(
250) -> usize { 250) -> usize {
251 match kind { 251 match kind {
252 CONST_DEF | TYPE_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF | TRAIT_DEF 252 CONST_DEF | TYPE_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF | TRAIT_DEF
253 | MODULE => { 253 | MODULE | NAMED_FIELD_DEF => {
254 let mut res = 0; 254 let mut res = 0;
255 for (i, (kind, text)) in trivias.enumerate() { 255 for (i, (kind, text)) in trivias.enumerate() {
256 match kind { 256 match kind {
diff --git a/crates/ra_syntax/src/syntax_kinds/generated.rs b/crates/ra_syntax/src/syntax_kinds/generated.rs
index 06faf7557..14f610891 100644
--- a/crates/ra_syntax/src/syntax_kinds/generated.rs
+++ b/crates/ra_syntax/src/syntax_kinds/generated.rs
@@ -195,8 +195,8 @@ pub enum SyntaxKind {
195 ENUM_VARIANT, 195 ENUM_VARIANT,
196 NAMED_FIELD_DEF_LIST, 196 NAMED_FIELD_DEF_LIST,
197 NAMED_FIELD_DEF, 197 NAMED_FIELD_DEF,
198 POS_FIELD_LIST, 198 POS_FIELD_DEF_LIST,
199 POS_FIELD, 199 POS_FIELD_DEF,
200 ENUM_VARIANT_LIST, 200 ENUM_VARIANT_LIST,
201 ITEM_LIST, 201 ITEM_LIST,
202 ATTR, 202 ATTR,
@@ -458,8 +458,8 @@ impl SyntaxKind {
458 ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" }, 458 ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" },
459 NAMED_FIELD_DEF_LIST => &SyntaxInfo { name: "NAMED_FIELD_DEF_LIST" }, 459 NAMED_FIELD_DEF_LIST => &SyntaxInfo { name: "NAMED_FIELD_DEF_LIST" },
460 NAMED_FIELD_DEF => &SyntaxInfo { name: "NAMED_FIELD_DEF" }, 460 NAMED_FIELD_DEF => &SyntaxInfo { name: "NAMED_FIELD_DEF" },
461 POS_FIELD_LIST => &SyntaxInfo { name: "POS_FIELD_LIST" }, 461 POS_FIELD_DEF_LIST => &SyntaxInfo { name: "POS_FIELD_DEF_LIST" },
462 POS_FIELD => &SyntaxInfo { name: "POS_FIELD" }, 462 POS_FIELD_DEF => &SyntaxInfo { name: "POS_FIELD_DEF" },
463 ENUM_VARIANT_LIST => &SyntaxInfo { name: "ENUM_VARIANT_LIST" }, 463 ENUM_VARIANT_LIST => &SyntaxInfo { name: "ENUM_VARIANT_LIST" },
464 ITEM_LIST => &SyntaxInfo { name: "ITEM_LIST" }, 464 ITEM_LIST => &SyntaxInfo { name: "ITEM_LIST" },
465 ATTR => &SyntaxInfo { name: "ATTR" }, 465 ATTR => &SyntaxInfo { name: "ATTR" },