mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 09:27:27 +00:00
rename POS_FIELD -> POS_FIELD_DEF
to match NAMED_FIELD_DEF
This commit is contained in:
parent
3c7acecade
commit
23172a116c
15 changed files with 65 additions and 65 deletions
|
@ -193,7 +193,7 @@ pub struct StructField {
|
|||
#[derive(Debug)]
|
||||
pub enum FieldSource {
|
||||
Named(TreeArc<ast::NamedFieldDef>),
|
||||
Pos(TreeArc<ast::PosField>),
|
||||
Pos(TreeArc<ast::PosFieldDef>),
|
||||
}
|
||||
|
||||
impl StructField {
|
||||
|
|
|
@ -9,9 +9,9 @@ pub fn extend_selection(root: &SyntaxNode, range: TextRange) -> Option<TextRange
|
|||
let list_kinds = [
|
||||
FIELD_PAT_LIST,
|
||||
MATCH_ARM_LIST,
|
||||
NAMED_FIELD_LIST,
|
||||
NAMED_FIELD_DEF_LIST,
|
||||
POS_FIELD_LIST,
|
||||
POS_FIELD_DEF_LIST,
|
||||
NAMED_FIELD_LIST,
|
||||
ENUM_VARIANT_LIST,
|
||||
USE_TREE_LIST,
|
||||
TYPE_PARAM_LIST,
|
||||
|
|
|
@ -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<N: AstNode>(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
|
||||
|
|
|
@ -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<RaTypes>;
|
||||
}
|
||||
|
||||
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<PosField>;
|
||||
fn to_owned(&self) -> TreeArc<PosField> { TreeArc::cast(self.syntax.to_owned()) }
|
||||
impl ToOwned for PosFieldDef {
|
||||
type Owned = TreeArc<PosFieldDef>;
|
||||
fn to_owned(&self) -> TreeArc<PosFieldDef> { 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<RaTypes>;
|
||||
}
|
||||
|
||||
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<PosFieldList>;
|
||||
fn to_owned(&self) -> TreeArc<PosFieldList> { TreeArc::cast(self.syntax.to_owned()) }
|
||||
impl ToOwned for PosFieldDefList {
|
||||
type Owned = TreeArc<PosFieldDefList>;
|
||||
fn to_owned(&self) -> TreeArc<PosFieldDefList> { TreeArc::cast(self.syntax.to_owned()) }
|
||||
}
|
||||
|
||||
|
||||
impl PosFieldList {
|
||||
pub fn fields(&self) -> impl Iterator<Item = &PosField> {
|
||||
impl PosFieldDefList {
|
||||
pub fn fields(&self) -> impl Iterator<Item = &PosFieldDef> {
|
||||
super::children(self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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>(T) where T: Clone;
|
||||
// struct Test<T>(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);
|
||||
}
|
||||
|
|
|
@ -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" },
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue