From 23172a116c3cc4ca9a692dfdd05051d1a4aee2b2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 26 Jan 2019 00:24:12 +0300 Subject: rename POS_FIELD -> POS_FIELD_DEF to match NAMED_FIELD_DEF --- crates/ra_syntax/src/ast.rs | 4 +-- crates/ra_syntax/src/ast/generated.rs | 42 +++++++++++----------- crates/ra_syntax/src/grammar.ron | 8 ++--- crates/ra_syntax/src/grammar/items/nominal.rs | 10 +++--- crates/ra_syntax/src/syntax_kinds/generated.rs | 8 ++--- .../tests/data/parser/err/0013_invalid_type.txt | 6 ++-- .../ra_syntax/tests/data/parser/err/0025_nope.txt | 8 ++--- .../data/parser/inline/ok/0083_struct_items.txt | 8 ++--- .../parser/inline/ok/0114_tuple_struct_where.txt | 8 ++--- .../data/parser/inline/ok/0115_pos_field_attrs.txt | 4 +-- .../tests/data/parser/ok/0016_struct_flavors.txt | 8 ++--- .../data/parser/ok/0018_struct_type_params.txt | 4 +-- .../ra_syntax/tests/data/parser/ok/0019_enums.txt | 6 ++-- 13 files changed, 62 insertions(+), 62 deletions(-) (limited to 'crates/ra_syntax') 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> { #[derive(Debug, Clone, PartialEq, Eq)] pub enum StructFlavor<'a> { - Tuple(&'a PosFieldList), + Tuple(&'a PosFieldDefList), Named(&'a NamedFieldDefList), Unit, } @@ -416,7 +416,7 @@ impl StructFlavor<'_> { fn from_node(node: &N) -> StructFlavor { if let Some(nfdl) = child_opt::<_, NamedFieldDefList>(node) { StructFlavor::Named(nfdl) - } else if let Some(pfl) = child_opt::<_, PosFieldList>(node) { + } else if let Some(pfl) = child_opt::<_, PosFieldDefList>(node) { StructFlavor::Tuple(pfl) } else { StructFlavor::Unit diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index e936c2a6d..3ace6533c 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -2851,68 +2851,68 @@ impl PointerType { } } -// PosField +// PosFieldDef #[derive(Debug, PartialEq, Eq, Hash)] #[repr(transparent)] -pub struct PosField { +pub struct PosFieldDef { pub(crate) syntax: SyntaxNode, } -unsafe impl TransparentNewType for PosField { +unsafe impl TransparentNewType for PosFieldDef { type Repr = rowan::SyntaxNode; } -impl AstNode for PosField { +impl AstNode for PosFieldDef { fn cast(syntax: &SyntaxNode) -> Option<&Self> { match syntax.kind() { - POS_FIELD => Some(PosField::from_repr(syntax.into_repr())), + POS_FIELD_DEF => Some(PosFieldDef::from_repr(syntax.into_repr())), _ => None, } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl ToOwned for PosField { - type Owned = TreeArc; - fn to_owned(&self) -> TreeArc { TreeArc::cast(self.syntax.to_owned()) } +impl ToOwned for PosFieldDef { + type Owned = TreeArc; + fn to_owned(&self) -> TreeArc { TreeArc::cast(self.syntax.to_owned()) } } -impl ast::VisibilityOwner for PosField {} -impl ast::AttrsOwner for PosField {} -impl PosField { +impl ast::VisibilityOwner for PosFieldDef {} +impl ast::AttrsOwner for PosFieldDef {} +impl PosFieldDef { pub fn type_ref(&self) -> Option<&TypeRef> { super::child_opt(self) } } -// PosFieldList +// PosFieldDefList #[derive(Debug, PartialEq, Eq, Hash)] #[repr(transparent)] -pub struct PosFieldList { +pub struct PosFieldDefList { pub(crate) syntax: SyntaxNode, } -unsafe impl TransparentNewType for PosFieldList { +unsafe impl TransparentNewType for PosFieldDefList { type Repr = rowan::SyntaxNode; } -impl AstNode for PosFieldList { +impl AstNode for PosFieldDefList { fn cast(syntax: &SyntaxNode) -> Option<&Self> { match syntax.kind() { - POS_FIELD_LIST => Some(PosFieldList::from_repr(syntax.into_repr())), + POS_FIELD_DEF_LIST => Some(PosFieldDefList::from_repr(syntax.into_repr())), _ => None, } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl ToOwned for PosFieldList { - type Owned = TreeArc; - fn to_owned(&self) -> TreeArc { TreeArc::cast(self.syntax.to_owned()) } +impl ToOwned for PosFieldDefList { + type Owned = TreeArc; + fn to_owned(&self) -> TreeArc { TreeArc::cast(self.syntax.to_owned()) } } -impl PosFieldList { - pub fn fields(&self) -> impl Iterator { +impl PosFieldDefList { + pub fn fields(&self) -> impl Iterator { super::children(self) } } diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index a92d9bbda..85fc79038 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron @@ -205,8 +205,8 @@ Grammar( "ENUM_VARIANT", "NAMED_FIELD_DEF_LIST", "NAMED_FIELD_DEF", - "POS_FIELD_LIST", - "POS_FIELD", + "POS_FIELD_DEF_LIST", + "POS_FIELD_DEF", "ENUM_VARIANT_LIST", "ITEM_LIST", "ATTR", @@ -269,8 +269,8 @@ Grammar( ), "NamedFieldDefList": (collections: [["fields", "NamedFieldDef"]]), "NamedFieldDef": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner"], options: ["TypeRef"] ), - "PosFieldList": (collections: [["fields", "PosField"]]), - "PosField": ( traits: ["VisibilityOwner", "AttrsOwner"], options: ["TypeRef"]), + "PosFieldDefList": (collections: [["fields", "PosFieldDef"]]), + "PosFieldDef": ( traits: ["VisibilityOwner", "AttrsOwner"], options: ["TypeRef"]), "EnumDef": ( traits: [ "VisibilityOwner", "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) { } L_CURLY => named_field_def_list(p), L_PAREN if kind == STRUCT_KW => { - pos_field_list(p); + pos_field_def_list(p); // test tuple_struct_where // struct Test(T) where T: Clone; // struct Test(T); @@ -74,7 +74,7 @@ pub(crate) fn enum_variant_list(p: &mut Parser) { name(p); match p.current() { L_CURLY => named_field_def_list(p), - L_PAREN => pos_field_list(p), + L_PAREN => pos_field_def_list(p), EQ => { p.bump(); expressions::expr(p); @@ -132,7 +132,7 @@ pub(crate) fn named_field_def_list(p: &mut Parser) { } } -fn pos_field_list(p: &mut Parser) { +fn pos_field_def_list(p: &mut Parser) { assert!(p.at(L_PAREN)); let m = p.start(); if !p.expect(L_PAREN) { @@ -157,12 +157,12 @@ fn pos_field_list(p: &mut Parser) { break; } types::type_(p); - m.complete(p, POS_FIELD); + m.complete(p, POS_FIELD_DEF); if !p.at(R_PAREN) { p.expect(COMMA); } } p.expect(R_PAREN); - m.complete(p, POS_FIELD_LIST); + m.complete(p, POS_FIELD_DEF_LIST); } 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 { ENUM_VARIANT, NAMED_FIELD_DEF_LIST, NAMED_FIELD_DEF, - POS_FIELD_LIST, - POS_FIELD, + POS_FIELD_DEF_LIST, + POS_FIELD_DEF, ENUM_VARIANT_LIST, ITEM_LIST, ATTR, @@ -458,8 +458,8 @@ impl SyntaxKind { ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" }, NAMED_FIELD_DEF_LIST => &SyntaxInfo { name: "NAMED_FIELD_DEF_LIST" }, NAMED_FIELD_DEF => &SyntaxInfo { name: "NAMED_FIELD_DEF" }, - POS_FIELD_LIST => &SyntaxInfo { name: "POS_FIELD_LIST" }, - POS_FIELD => &SyntaxInfo { name: "POS_FIELD" }, + POS_FIELD_DEF_LIST => &SyntaxInfo { name: "POS_FIELD_DEF_LIST" }, + POS_FIELD_DEF => &SyntaxInfo { name: "POS_FIELD_DEF" }, ENUM_VARIANT_LIST => &SyntaxInfo { name: "ENUM_VARIANT_LIST" }, ITEM_LIST => &SyntaxInfo { name: "ITEM_LIST" }, ATTR => &SyntaxInfo { name: "ATTR" }, diff --git a/crates/ra_syntax/tests/data/parser/err/0013_invalid_type.txt b/crates/ra_syntax/tests/data/parser/err/0013_invalid_type.txt index 83d716b2f..1ec15194c 100644 --- a/crates/ra_syntax/tests/data/parser/err/0013_invalid_type.txt +++ b/crates/ra_syntax/tests/data/parser/err/0013_invalid_type.txt @@ -7,10 +7,10 @@ SOURCE_FILE@[0; 86) WHITESPACE@[10; 11) NAME@[11; 16) IDENT@[11; 16) "Cache" - POS_FIELD_LIST@[16; 72) + POS_FIELD_DEF_LIST@[16; 72) L_PAREN@[16; 17) WHITESPACE@[17; 22) - POS_FIELD@[22; 68) + POS_FIELD_DEF@[22; 68) PATH_TYPE@[22; 68) PATH@[22; 68) PATH_SEGMENT@[22; 68) @@ -55,7 +55,7 @@ SOURCE_FILE@[0; 86) err: `expected R_ANGLE` err: `expected COMMA` WHITESPACE@[68; 69) - POS_FIELD@[69; 72) + POS_FIELD_DEF@[69; 72) PATH_TYPE@[69; 72) PATH@[69; 72) PATH_SEGMENT@[69; 72) diff --git a/crates/ra_syntax/tests/data/parser/err/0025_nope.txt b/crates/ra_syntax/tests/data/parser/err/0025_nope.txt index 615064f77..e0824ca56 100644 --- a/crates/ra_syntax/tests/data/parser/err/0025_nope.txt +++ b/crates/ra_syntax/tests/data/parser/err/0025_nope.txt @@ -28,9 +28,9 @@ SOURCE_FILE@[0; 575) ENUM_VARIANT@[50; 62) NAME@[50; 54) IDENT@[50; 54) "Var2" - POS_FIELD_LIST@[54; 62) + POS_FIELD_DEF_LIST@[54; 62) L_PAREN@[54; 55) - POS_FIELD@[55; 61) + POS_FIELD_DEF@[55; 61) PATH_TYPE@[55; 61) PATH@[55; 61) PATH_SEGMENT@[55; 61) @@ -151,9 +151,9 @@ SOURCE_FILE@[0; 575) ENUM_VARIANT@[363; 372) NAME@[363; 367) IDENT@[363; 367) "Nope" - POS_FIELD_LIST@[367; 372) + POS_FIELD_DEF_LIST@[367; 372) L_PAREN@[367; 368) - POS_FIELD@[368; 371) + POS_FIELD_DEF@[368; 371) PATH_TYPE@[368; 371) PATH@[368; 371) PATH_SEGMENT@[368; 371) diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0083_struct_items.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0083_struct_items.txt index 058639375..6247729f6 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0083_struct_items.txt +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0083_struct_items.txt @@ -21,7 +21,7 @@ SOURCE_FILE@[0; 106) WHITESPACE@[32; 33) NAME@[33; 36) IDENT@[33; 36) "Foo" - POS_FIELD_LIST@[36; 38) + POS_FIELD_DEF_LIST@[36; 38) L_PAREN@[36; 37) R_PAREN@[37; 38) SEMI@[38; 39) @@ -31,9 +31,9 @@ SOURCE_FILE@[0; 106) WHITESPACE@[46; 47) NAME@[47; 50) IDENT@[47; 50) "Foo" - POS_FIELD_LIST@[50; 65) + POS_FIELD_DEF_LIST@[50; 65) L_PAREN@[50; 51) - POS_FIELD@[51; 57) + POS_FIELD_DEF@[51; 57) PATH_TYPE@[51; 57) PATH@[51; 57) PATH_SEGMENT@[51; 57) @@ -41,7 +41,7 @@ SOURCE_FILE@[0; 106) IDENT@[51; 57) "String" COMMA@[57; 58) WHITESPACE@[58; 59) - POS_FIELD@[59; 64) + POS_FIELD_DEF@[59; 64) PATH_TYPE@[59; 64) PATH@[59; 64) PATH_SEGMENT@[59; 64) diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0114_tuple_struct_where.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0114_tuple_struct_where.txt index b7de83072..4f439f21c 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0114_tuple_struct_where.txt +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0114_tuple_struct_where.txt @@ -10,9 +10,9 @@ SOURCE_FILE@[0; 53) NAME@[12; 13) IDENT@[12; 13) "T" R_ANGLE@[13; 14) - POS_FIELD_LIST@[14; 17) + POS_FIELD_DEF_LIST@[14; 17) L_PAREN@[14; 15) - POS_FIELD@[15; 16) + POS_FIELD_DEF@[15; 16) PATH_TYPE@[15; 16) PATH@[15; 16) PATH_SEGMENT@[15; 16) @@ -49,9 +49,9 @@ SOURCE_FILE@[0; 53) NAME@[46; 47) IDENT@[46; 47) "T" R_ANGLE@[47; 48) - POS_FIELD_LIST@[48; 51) + POS_FIELD_DEF_LIST@[48; 51) L_PAREN@[48; 49) - POS_FIELD@[49; 50) + POS_FIELD_DEF@[49; 50) PATH_TYPE@[49; 50) PATH@[49; 50) PATH_SEGMENT@[49; 50) diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0115_pos_field_attrs.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0115_pos_field_attrs.txt index 99ec0755b..4da84ba48 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0115_pos_field_attrs.txt +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0115_pos_field_attrs.txt @@ -5,10 +5,10 @@ SOURCE_FILE@[0; 60) NAME@[7; 8) IDENT@[7; 8) "S" WHITESPACE@[8; 9) - POS_FIELD_LIST@[9; 58) + POS_FIELD_DEF_LIST@[9; 58) L_PAREN@[9; 10) WHITESPACE@[10; 15) - POS_FIELD@[15; 55) + POS_FIELD_DEF@[15; 55) ATTR@[15; 43) POUND@[15; 16) TOKEN_TREE@[16; 43) diff --git a/crates/ra_syntax/tests/data/parser/ok/0016_struct_flavors.txt b/crates/ra_syntax/tests/data/parser/ok/0016_struct_flavors.txt index 1d355823d..d021d6de6 100644 --- a/crates/ra_syntax/tests/data/parser/ok/0016_struct_flavors.txt +++ b/crates/ra_syntax/tests/data/parser/ok/0016_struct_flavors.txt @@ -21,7 +21,7 @@ SOURCE_FILE@[0; 97) WHITESPACE@[28; 29) NAME@[29; 30) IDENT@[29; 30) "C" - POS_FIELD_LIST@[30; 32) + POS_FIELD_DEF_LIST@[30; 32) L_PAREN@[30; 31) R_PAREN@[31; 32) SEMI@[32; 33) @@ -68,9 +68,9 @@ SOURCE_FILE@[0; 97) WHITESPACE@[82; 83) NAME@[83; 84) IDENT@[83; 84) "E" - POS_FIELD_LIST@[84; 95) + POS_FIELD_DEF_LIST@[84; 95) L_PAREN@[84; 85) - POS_FIELD@[85; 90) + POS_FIELD_DEF@[85; 90) VISIBILITY@[85; 88) PUB_KW@[85; 88) WHITESPACE@[88; 89) @@ -81,7 +81,7 @@ SOURCE_FILE@[0; 97) IDENT@[89; 90) "x" COMMA@[90; 91) WHITESPACE@[91; 92) - POS_FIELD@[92; 93) + POS_FIELD_DEF@[92; 93) PATH_TYPE@[92; 93) PATH@[92; 93) PATH_SEGMENT@[92; 93) diff --git a/crates/ra_syntax/tests/data/parser/ok/0018_struct_type_params.txt b/crates/ra_syntax/tests/data/parser/ok/0018_struct_type_params.txt index 491d154df..05480c81b 100644 --- a/crates/ra_syntax/tests/data/parser/ok/0018_struct_type_params.txt +++ b/crates/ra_syntax/tests/data/parser/ok/0018_struct_type_params.txt @@ -23,9 +23,9 @@ SOURCE_FILE@[0; 290) NAME@[24; 25) IDENT@[24; 25) "T" R_ANGLE@[25; 26) - POS_FIELD_LIST@[26; 31) + POS_FIELD_DEF_LIST@[26; 31) L_PAREN@[26; 27) - POS_FIELD@[27; 30) + POS_FIELD_DEF@[27; 30) PATH_TYPE@[27; 30) PATH@[27; 30) PATH_SEGMENT@[27; 30) diff --git a/crates/ra_syntax/tests/data/parser/ok/0019_enums.txt b/crates/ra_syntax/tests/data/parser/ok/0019_enums.txt index 6925219e8..2ac55cfbc 100644 --- a/crates/ra_syntax/tests/data/parser/ok/0019_enums.txt +++ b/crates/ra_syntax/tests/data/parser/ok/0019_enums.txt @@ -131,9 +131,9 @@ SOURCE_FILE@[0; 182) ENUM_VARIANT@[162; 169) NAME@[162; 163) IDENT@[162; 163) "D" - POS_FIELD_LIST@[163; 169) + POS_FIELD_DEF_LIST@[163; 169) L_PAREN@[163; 164) - POS_FIELD@[164; 167) + POS_FIELD_DEF@[164; 167) PATH_TYPE@[164; 167) PATH@[164; 167) PATH_SEGMENT@[164; 167) @@ -146,7 +146,7 @@ SOURCE_FILE@[0; 182) ENUM_VARIANT@[175; 178) NAME@[175; 176) IDENT@[175; 176) "E" - POS_FIELD_LIST@[176; 178) + POS_FIELD_DEF_LIST@[176; 178) L_PAREN@[176; 177) R_PAREN@[177; 178) COMMA@[178; 179) -- cgit v1.2.3