rename POS_FIELD -> POS_FIELD_DEF

to match NAMED_FIELD_DEF
This commit is contained in:
Aleksey Kladov 2019-01-26 00:24:12 +03:00
parent 3c7acecade
commit 23172a116c
15 changed files with 65 additions and 65 deletions

View file

@ -193,7 +193,7 @@ pub struct StructField {
#[derive(Debug)] #[derive(Debug)]
pub enum FieldSource { pub enum FieldSource {
Named(TreeArc<ast::NamedFieldDef>), Named(TreeArc<ast::NamedFieldDef>),
Pos(TreeArc<ast::PosField>), Pos(TreeArc<ast::PosFieldDef>),
} }
impl StructField { impl StructField {

View file

@ -9,9 +9,9 @@ pub fn extend_selection(root: &SyntaxNode, range: TextRange) -> Option<TextRange
let list_kinds = [ let list_kinds = [
FIELD_PAT_LIST, FIELD_PAT_LIST,
MATCH_ARM_LIST, MATCH_ARM_LIST,
NAMED_FIELD_LIST,
NAMED_FIELD_DEF_LIST, NAMED_FIELD_DEF_LIST,
POS_FIELD_LIST, POS_FIELD_DEF_LIST,
NAMED_FIELD_LIST,
ENUM_VARIANT_LIST, ENUM_VARIANT_LIST,
USE_TREE_LIST, USE_TREE_LIST,
TYPE_PARAM_LIST, TYPE_PARAM_LIST,

View file

@ -407,7 +407,7 @@ impl<'a, N: AstNode + 'a> Iterator for AstChildren<'a, N> {
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum StructFlavor<'a> { pub enum StructFlavor<'a> {
Tuple(&'a PosFieldList), Tuple(&'a PosFieldDefList),
Named(&'a NamedFieldDefList), Named(&'a NamedFieldDefList),
Unit, Unit,
} }
@ -416,7 +416,7 @@ impl StructFlavor<'_> {
fn from_node<N: AstNode>(node: &N) -> StructFlavor { fn from_node<N: AstNode>(node: &N) -> StructFlavor {
if let Some(nfdl) = child_opt::<_, NamedFieldDefList>(node) { if let Some(nfdl) = child_opt::<_, NamedFieldDefList>(node) {
StructFlavor::Named(nfdl) StructFlavor::Named(nfdl)
} else if let Some(pfl) = child_opt::<_, PosFieldList>(node) { } else if let Some(pfl) = child_opt::<_, PosFieldDefList>(node) {
StructFlavor::Tuple(pfl) StructFlavor::Tuple(pfl)
} else { } else {
StructFlavor::Unit StructFlavor::Unit

View file

@ -2851,68 +2851,68 @@ impl PointerType {
} }
} }
// PosField // PosFieldDef
#[derive(Debug, PartialEq, Eq, Hash)] #[derive(Debug, PartialEq, Eq, Hash)]
#[repr(transparent)] #[repr(transparent)]
pub struct PosField { pub struct PosFieldDef {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for PosField { unsafe impl TransparentNewType for PosFieldDef {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode<RaTypes>;
} }
impl AstNode for PosField { impl AstNode for PosFieldDef {
fn cast(syntax: &SyntaxNode) -> Option<&Self> { fn cast(syntax: &SyntaxNode) -> Option<&Self> {
match syntax.kind() { match syntax.kind() {
POS_FIELD => Some(PosField::from_repr(syntax.into_repr())), POS_FIELD_DEF => Some(PosFieldDef::from_repr(syntax.into_repr())),
_ => None, _ => None,
} }
} }
fn syntax(&self) -> &SyntaxNode { &self.syntax } fn syntax(&self) -> &SyntaxNode { &self.syntax }
} }
impl ToOwned for PosField { impl ToOwned for PosFieldDef {
type Owned = TreeArc<PosField>; type Owned = TreeArc<PosFieldDef>;
fn to_owned(&self) -> TreeArc<PosField> { TreeArc::cast(self.syntax.to_owned()) } fn to_owned(&self) -> TreeArc<PosFieldDef> { TreeArc::cast(self.syntax.to_owned()) }
} }
impl ast::VisibilityOwner for PosField {} impl ast::VisibilityOwner for PosFieldDef {}
impl ast::AttrsOwner for PosField {} impl ast::AttrsOwner for PosFieldDef {}
impl PosField { impl PosFieldDef {
pub fn type_ref(&self) -> Option<&TypeRef> { pub fn type_ref(&self) -> Option<&TypeRef> {
super::child_opt(self) super::child_opt(self)
} }
} }
// PosFieldList // PosFieldDefList
#[derive(Debug, PartialEq, Eq, Hash)] #[derive(Debug, PartialEq, Eq, Hash)]
#[repr(transparent)] #[repr(transparent)]
pub struct PosFieldList { pub struct PosFieldDefList {
pub(crate) syntax: SyntaxNode, pub(crate) syntax: SyntaxNode,
} }
unsafe impl TransparentNewType for PosFieldList { unsafe impl TransparentNewType for PosFieldDefList {
type Repr = rowan::SyntaxNode<RaTypes>; type Repr = rowan::SyntaxNode<RaTypes>;
} }
impl AstNode for PosFieldList { impl AstNode for PosFieldDefList {
fn cast(syntax: &SyntaxNode) -> Option<&Self> { fn cast(syntax: &SyntaxNode) -> Option<&Self> {
match syntax.kind() { 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, _ => None,
} }
} }
fn syntax(&self) -> &SyntaxNode { &self.syntax } fn syntax(&self) -> &SyntaxNode { &self.syntax }
} }
impl ToOwned for PosFieldList { impl ToOwned for PosFieldDefList {
type Owned = TreeArc<PosFieldList>; type Owned = TreeArc<PosFieldDefList>;
fn to_owned(&self) -> TreeArc<PosFieldList> { TreeArc::cast(self.syntax.to_owned()) } fn to_owned(&self) -> TreeArc<PosFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
} }
impl PosFieldList { impl PosFieldDefList {
pub fn fields(&self) -> impl Iterator<Item = &PosField> { pub fn fields(&self) -> impl Iterator<Item = &PosFieldDef> {
super::children(self) super::children(self)
} }
} }

View file

@ -205,8 +205,8 @@ Grammar(
"ENUM_VARIANT", "ENUM_VARIANT",
"NAMED_FIELD_DEF_LIST", "NAMED_FIELD_DEF_LIST",
"NAMED_FIELD_DEF", "NAMED_FIELD_DEF",
"POS_FIELD_LIST", "POS_FIELD_DEF_LIST",
"POS_FIELD", "POS_FIELD_DEF",
"ENUM_VARIANT_LIST", "ENUM_VARIANT_LIST",
"ITEM_LIST", "ITEM_LIST",
"ATTR", "ATTR",
@ -269,8 +269,8 @@ Grammar(
), ),
"NamedFieldDefList": (collections: [["fields", "NamedFieldDef"]]), "NamedFieldDefList": (collections: [["fields", "NamedFieldDef"]]),
"NamedFieldDef": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner"], options: ["TypeRef"] ), "NamedFieldDef": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner"], options: ["TypeRef"] ),
"PosFieldList": (collections: [["fields", "PosField"]]), "PosFieldDefList": (collections: [["fields", "PosFieldDef"]]),
"PosField": ( traits: ["VisibilityOwner", "AttrsOwner"], options: ["TypeRef"]), "PosFieldDef": ( traits: ["VisibilityOwner", "AttrsOwner"], options: ["TypeRef"]),
"EnumDef": ( traits: [ "EnumDef": ( traits: [
"VisibilityOwner", "VisibilityOwner",
"NameOwner", "NameOwner",

View file

@ -28,7 +28,7 @@ pub(super) fn struct_def(p: &mut Parser, kind: SyntaxKind) {
} }
L_CURLY => named_field_def_list(p), L_CURLY => named_field_def_list(p),
L_PAREN if kind == STRUCT_KW => { L_PAREN if kind == STRUCT_KW => {
pos_field_list(p); pos_field_def_list(p);
// test tuple_struct_where // test tuple_struct_where
// struct Test<T>(T) where T: Clone; // struct Test<T>(T) where T: Clone;
// struct Test<T>(T); // struct Test<T>(T);
@ -74,7 +74,7 @@ pub(crate) fn enum_variant_list(p: &mut Parser) {
name(p); name(p);
match p.current() { match p.current() {
L_CURLY => named_field_def_list(p), L_CURLY => named_field_def_list(p),
L_PAREN => pos_field_list(p), L_PAREN => pos_field_def_list(p),
EQ => { EQ => {
p.bump(); p.bump();
expressions::expr(p); 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)); assert!(p.at(L_PAREN));
let m = p.start(); let m = p.start();
if !p.expect(L_PAREN) { if !p.expect(L_PAREN) {
@ -157,12 +157,12 @@ fn pos_field_list(p: &mut Parser) {
break; break;
} }
types::type_(p); types::type_(p);
m.complete(p, POS_FIELD); m.complete(p, POS_FIELD_DEF);
if !p.at(R_PAREN) { if !p.at(R_PAREN) {
p.expect(COMMA); p.expect(COMMA);
} }
} }
p.expect(R_PAREN); p.expect(R_PAREN);
m.complete(p, POS_FIELD_LIST); m.complete(p, POS_FIELD_DEF_LIST);
} }

View file

@ -195,8 +195,8 @@ pub enum SyntaxKind {
ENUM_VARIANT, ENUM_VARIANT,
NAMED_FIELD_DEF_LIST, NAMED_FIELD_DEF_LIST,
NAMED_FIELD_DEF, NAMED_FIELD_DEF,
POS_FIELD_LIST, POS_FIELD_DEF_LIST,
POS_FIELD, POS_FIELD_DEF,
ENUM_VARIANT_LIST, ENUM_VARIANT_LIST,
ITEM_LIST, ITEM_LIST,
ATTR, ATTR,
@ -458,8 +458,8 @@ impl SyntaxKind {
ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" }, ENUM_VARIANT => &SyntaxInfo { name: "ENUM_VARIANT" },
NAMED_FIELD_DEF_LIST => &SyntaxInfo { name: "NAMED_FIELD_DEF_LIST" }, NAMED_FIELD_DEF_LIST => &SyntaxInfo { name: "NAMED_FIELD_DEF_LIST" },
NAMED_FIELD_DEF => &SyntaxInfo { name: "NAMED_FIELD_DEF" }, NAMED_FIELD_DEF => &SyntaxInfo { name: "NAMED_FIELD_DEF" },
POS_FIELD_LIST => &SyntaxInfo { name: "POS_FIELD_LIST" }, POS_FIELD_DEF_LIST => &SyntaxInfo { name: "POS_FIELD_DEF_LIST" },
POS_FIELD => &SyntaxInfo { name: "POS_FIELD" }, POS_FIELD_DEF => &SyntaxInfo { name: "POS_FIELD_DEF" },
ENUM_VARIANT_LIST => &SyntaxInfo { name: "ENUM_VARIANT_LIST" }, ENUM_VARIANT_LIST => &SyntaxInfo { name: "ENUM_VARIANT_LIST" },
ITEM_LIST => &SyntaxInfo { name: "ITEM_LIST" }, ITEM_LIST => &SyntaxInfo { name: "ITEM_LIST" },
ATTR => &SyntaxInfo { name: "ATTR" }, ATTR => &SyntaxInfo { name: "ATTR" },

View file

@ -7,10 +7,10 @@ SOURCE_FILE@[0; 86)
WHITESPACE@[10; 11) WHITESPACE@[10; 11)
NAME@[11; 16) NAME@[11; 16)
IDENT@[11; 16) "Cache" IDENT@[11; 16) "Cache"
POS_FIELD_LIST@[16; 72) POS_FIELD_DEF_LIST@[16; 72)
L_PAREN@[16; 17) L_PAREN@[16; 17)
WHITESPACE@[17; 22) WHITESPACE@[17; 22)
POS_FIELD@[22; 68) POS_FIELD_DEF@[22; 68)
PATH_TYPE@[22; 68) PATH_TYPE@[22; 68)
PATH@[22; 68) PATH@[22; 68)
PATH_SEGMENT@[22; 68) PATH_SEGMENT@[22; 68)
@ -55,7 +55,7 @@ SOURCE_FILE@[0; 86)
err: `expected R_ANGLE` err: `expected R_ANGLE`
err: `expected COMMA` err: `expected COMMA`
WHITESPACE@[68; 69) WHITESPACE@[68; 69)
POS_FIELD@[69; 72) POS_FIELD_DEF@[69; 72)
PATH_TYPE@[69; 72) PATH_TYPE@[69; 72)
PATH@[69; 72) PATH@[69; 72)
PATH_SEGMENT@[69; 72) PATH_SEGMENT@[69; 72)

View file

@ -28,9 +28,9 @@ SOURCE_FILE@[0; 575)
ENUM_VARIANT@[50; 62) ENUM_VARIANT@[50; 62)
NAME@[50; 54) NAME@[50; 54)
IDENT@[50; 54) "Var2" IDENT@[50; 54) "Var2"
POS_FIELD_LIST@[54; 62) POS_FIELD_DEF_LIST@[54; 62)
L_PAREN@[54; 55) L_PAREN@[54; 55)
POS_FIELD@[55; 61) POS_FIELD_DEF@[55; 61)
PATH_TYPE@[55; 61) PATH_TYPE@[55; 61)
PATH@[55; 61) PATH@[55; 61)
PATH_SEGMENT@[55; 61) PATH_SEGMENT@[55; 61)
@ -151,9 +151,9 @@ SOURCE_FILE@[0; 575)
ENUM_VARIANT@[363; 372) ENUM_VARIANT@[363; 372)
NAME@[363; 367) NAME@[363; 367)
IDENT@[363; 367) "Nope" IDENT@[363; 367) "Nope"
POS_FIELD_LIST@[367; 372) POS_FIELD_DEF_LIST@[367; 372)
L_PAREN@[367; 368) L_PAREN@[367; 368)
POS_FIELD@[368; 371) POS_FIELD_DEF@[368; 371)
PATH_TYPE@[368; 371) PATH_TYPE@[368; 371)
PATH@[368; 371) PATH@[368; 371)
PATH_SEGMENT@[368; 371) PATH_SEGMENT@[368; 371)

View file

@ -21,7 +21,7 @@ SOURCE_FILE@[0; 106)
WHITESPACE@[32; 33) WHITESPACE@[32; 33)
NAME@[33; 36) NAME@[33; 36)
IDENT@[33; 36) "Foo" IDENT@[33; 36) "Foo"
POS_FIELD_LIST@[36; 38) POS_FIELD_DEF_LIST@[36; 38)
L_PAREN@[36; 37) L_PAREN@[36; 37)
R_PAREN@[37; 38) R_PAREN@[37; 38)
SEMI@[38; 39) SEMI@[38; 39)
@ -31,9 +31,9 @@ SOURCE_FILE@[0; 106)
WHITESPACE@[46; 47) WHITESPACE@[46; 47)
NAME@[47; 50) NAME@[47; 50)
IDENT@[47; 50) "Foo" IDENT@[47; 50) "Foo"
POS_FIELD_LIST@[50; 65) POS_FIELD_DEF_LIST@[50; 65)
L_PAREN@[50; 51) L_PAREN@[50; 51)
POS_FIELD@[51; 57) POS_FIELD_DEF@[51; 57)
PATH_TYPE@[51; 57) PATH_TYPE@[51; 57)
PATH@[51; 57) PATH@[51; 57)
PATH_SEGMENT@[51; 57) PATH_SEGMENT@[51; 57)
@ -41,7 +41,7 @@ SOURCE_FILE@[0; 106)
IDENT@[51; 57) "String" IDENT@[51; 57) "String"
COMMA@[57; 58) COMMA@[57; 58)
WHITESPACE@[58; 59) WHITESPACE@[58; 59)
POS_FIELD@[59; 64) POS_FIELD_DEF@[59; 64)
PATH_TYPE@[59; 64) PATH_TYPE@[59; 64)
PATH@[59; 64) PATH@[59; 64)
PATH_SEGMENT@[59; 64) PATH_SEGMENT@[59; 64)

View file

@ -10,9 +10,9 @@ SOURCE_FILE@[0; 53)
NAME@[12; 13) NAME@[12; 13)
IDENT@[12; 13) "T" IDENT@[12; 13) "T"
R_ANGLE@[13; 14) R_ANGLE@[13; 14)
POS_FIELD_LIST@[14; 17) POS_FIELD_DEF_LIST@[14; 17)
L_PAREN@[14; 15) L_PAREN@[14; 15)
POS_FIELD@[15; 16) POS_FIELD_DEF@[15; 16)
PATH_TYPE@[15; 16) PATH_TYPE@[15; 16)
PATH@[15; 16) PATH@[15; 16)
PATH_SEGMENT@[15; 16) PATH_SEGMENT@[15; 16)
@ -49,9 +49,9 @@ SOURCE_FILE@[0; 53)
NAME@[46; 47) NAME@[46; 47)
IDENT@[46; 47) "T" IDENT@[46; 47) "T"
R_ANGLE@[47; 48) R_ANGLE@[47; 48)
POS_FIELD_LIST@[48; 51) POS_FIELD_DEF_LIST@[48; 51)
L_PAREN@[48; 49) L_PAREN@[48; 49)
POS_FIELD@[49; 50) POS_FIELD_DEF@[49; 50)
PATH_TYPE@[49; 50) PATH_TYPE@[49; 50)
PATH@[49; 50) PATH@[49; 50)
PATH_SEGMENT@[49; 50) PATH_SEGMENT@[49; 50)

View file

@ -5,10 +5,10 @@ SOURCE_FILE@[0; 60)
NAME@[7; 8) NAME@[7; 8)
IDENT@[7; 8) "S" IDENT@[7; 8) "S"
WHITESPACE@[8; 9) WHITESPACE@[8; 9)
POS_FIELD_LIST@[9; 58) POS_FIELD_DEF_LIST@[9; 58)
L_PAREN@[9; 10) L_PAREN@[9; 10)
WHITESPACE@[10; 15) WHITESPACE@[10; 15)
POS_FIELD@[15; 55) POS_FIELD_DEF@[15; 55)
ATTR@[15; 43) ATTR@[15; 43)
POUND@[15; 16) POUND@[15; 16)
TOKEN_TREE@[16; 43) TOKEN_TREE@[16; 43)

View file

@ -21,7 +21,7 @@ SOURCE_FILE@[0; 97)
WHITESPACE@[28; 29) WHITESPACE@[28; 29)
NAME@[29; 30) NAME@[29; 30)
IDENT@[29; 30) "C" IDENT@[29; 30) "C"
POS_FIELD_LIST@[30; 32) POS_FIELD_DEF_LIST@[30; 32)
L_PAREN@[30; 31) L_PAREN@[30; 31)
R_PAREN@[31; 32) R_PAREN@[31; 32)
SEMI@[32; 33) SEMI@[32; 33)
@ -68,9 +68,9 @@ SOURCE_FILE@[0; 97)
WHITESPACE@[82; 83) WHITESPACE@[82; 83)
NAME@[83; 84) NAME@[83; 84)
IDENT@[83; 84) "E" IDENT@[83; 84) "E"
POS_FIELD_LIST@[84; 95) POS_FIELD_DEF_LIST@[84; 95)
L_PAREN@[84; 85) L_PAREN@[84; 85)
POS_FIELD@[85; 90) POS_FIELD_DEF@[85; 90)
VISIBILITY@[85; 88) VISIBILITY@[85; 88)
PUB_KW@[85; 88) PUB_KW@[85; 88)
WHITESPACE@[88; 89) WHITESPACE@[88; 89)
@ -81,7 +81,7 @@ SOURCE_FILE@[0; 97)
IDENT@[89; 90) "x" IDENT@[89; 90) "x"
COMMA@[90; 91) COMMA@[90; 91)
WHITESPACE@[91; 92) WHITESPACE@[91; 92)
POS_FIELD@[92; 93) POS_FIELD_DEF@[92; 93)
PATH_TYPE@[92; 93) PATH_TYPE@[92; 93)
PATH@[92; 93) PATH@[92; 93)
PATH_SEGMENT@[92; 93) PATH_SEGMENT@[92; 93)

View file

@ -23,9 +23,9 @@ SOURCE_FILE@[0; 290)
NAME@[24; 25) NAME@[24; 25)
IDENT@[24; 25) "T" IDENT@[24; 25) "T"
R_ANGLE@[25; 26) R_ANGLE@[25; 26)
POS_FIELD_LIST@[26; 31) POS_FIELD_DEF_LIST@[26; 31)
L_PAREN@[26; 27) L_PAREN@[26; 27)
POS_FIELD@[27; 30) POS_FIELD_DEF@[27; 30)
PATH_TYPE@[27; 30) PATH_TYPE@[27; 30)
PATH@[27; 30) PATH@[27; 30)
PATH_SEGMENT@[27; 30) PATH_SEGMENT@[27; 30)

View file

@ -131,9 +131,9 @@ SOURCE_FILE@[0; 182)
ENUM_VARIANT@[162; 169) ENUM_VARIANT@[162; 169)
NAME@[162; 163) NAME@[162; 163)
IDENT@[162; 163) "D" IDENT@[162; 163) "D"
POS_FIELD_LIST@[163; 169) POS_FIELD_DEF_LIST@[163; 169)
L_PAREN@[163; 164) L_PAREN@[163; 164)
POS_FIELD@[164; 167) POS_FIELD_DEF@[164; 167)
PATH_TYPE@[164; 167) PATH_TYPE@[164; 167)
PATH@[164; 167) PATH@[164; 167)
PATH_SEGMENT@[164; 167) PATH_SEGMENT@[164; 167)
@ -146,7 +146,7 @@ SOURCE_FILE@[0; 182)
ENUM_VARIANT@[175; 178) ENUM_VARIANT@[175; 178)
NAME@[175; 176) NAME@[175; 176)
IDENT@[175; 176) "E" IDENT@[175; 176) "E"
POS_FIELD_LIST@[176; 178) POS_FIELD_DEF_LIST@[176; 178)
L_PAREN@[176; 177) L_PAREN@[176; 177)
R_PAREN@[177; 178) R_PAREN@[177; 178)
COMMA@[178; 179) COMMA@[178; 179)