mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 05:08:52 +00:00
more renames
This commit is contained in:
parent
2e971cdcbb
commit
78f41ea707
11 changed files with 79 additions and 21 deletions
|
@ -141,8 +141,8 @@ struct Declaration<'f> (SyntaxNodeRef<'f>);
|
|||
impl<'f> Declaration<'f> {
|
||||
fn cast(node: SyntaxNodeRef<'f>) -> Option<Declaration<'f>> {
|
||||
match node.kind() {
|
||||
| STRUCT | ENUM | FUNCTION | TRAIT_ITEM
|
||||
| CONST_ITEM | STATIC_ITEM | MOD_ITEM | NAMED_FIELD
|
||||
| STRUCT | ENUM | FUNCTION | TRAIT
|
||||
| CONST_ITEM | STATIC_ITEM | MODULE | NAMED_FIELD
|
||||
| TYPE_ITEM => Some(Declaration(node)),
|
||||
_ => None
|
||||
}
|
||||
|
|
|
@ -4,6 +4,30 @@ use {
|
|||
SyntaxKind::*,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Enum<R: TreeRoot = Arc<SyntaxRoot>> {
|
||||
syntax: SyntaxNode<R>,
|
||||
}
|
||||
|
||||
impl<R: TreeRoot> AstNode<R> for Enum<R> {
|
||||
fn cast(syntax: SyntaxNode<R>) -> Option<Self> {
|
||||
match syntax.kind() {
|
||||
ENUM => Some(Enum { syntax }),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxNode<R> { &self.syntax }
|
||||
}
|
||||
|
||||
impl<R: TreeRoot> Enum<R> {
|
||||
pub fn name(&self) -> Option<Name<R>> {
|
||||
self.syntax()
|
||||
.children()
|
||||
.filter_map(Name::cast)
|
||||
.next()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct File<R: TreeRoot = Arc<SyntaxRoot>> {
|
||||
syntax: SyntaxNode<R>,
|
||||
|
@ -68,3 +92,27 @@ impl<R: TreeRoot> AstNode<R> for Name<R> {
|
|||
|
||||
impl<R: TreeRoot> Name<R> {}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Struct<R: TreeRoot = Arc<SyntaxRoot>> {
|
||||
syntax: SyntaxNode<R>,
|
||||
}
|
||||
|
||||
impl<R: TreeRoot> AstNode<R> for Struct<R> {
|
||||
fn cast(syntax: SyntaxNode<R>) -> Option<Self> {
|
||||
match syntax.kind() {
|
||||
STRUCT => Some(Struct { syntax }),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
fn syntax(&self) -> &SyntaxNode<R> { &self.syntax }
|
||||
}
|
||||
|
||||
impl<R: TreeRoot> Struct<R> {
|
||||
pub fn name(&self) -> Option<Name<R>> {
|
||||
self.syntax()
|
||||
.children()
|
||||
.filter_map(Name::cast)
|
||||
.next()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -112,11 +112,11 @@ Grammar(
|
|||
"ENUM",
|
||||
"FUNCTION",
|
||||
"EXTERN_CRATE_ITEM",
|
||||
"MOD_ITEM",
|
||||
"MODULE",
|
||||
"USE_ITEM",
|
||||
"STATIC_ITEM",
|
||||
"CONST_ITEM",
|
||||
"TRAIT_ITEM",
|
||||
"TRAIT",
|
||||
"IMPL_ITEM",
|
||||
"TYPE_ITEM",
|
||||
"MACRO_CALL",
|
||||
|
@ -224,6 +224,16 @@ Grammar(
|
|||
["name", "Name"]
|
||||
]
|
||||
),
|
||||
"Struct": (
|
||||
options: [
|
||||
["name", "Name"]
|
||||
]
|
||||
),
|
||||
"Enum": (
|
||||
options: [
|
||||
["name", "Name"]
|
||||
]
|
||||
),
|
||||
"Name": (),
|
||||
},
|
||||
)
|
||||
|
|
|
@ -121,7 +121,7 @@ pub(super) fn maybe_item(p: &mut Parser) -> MaybeItem {
|
|||
// unsafe auto trait T {}
|
||||
TRAIT_KW => {
|
||||
traits::trait_item(p);
|
||||
TRAIT_ITEM
|
||||
TRAIT
|
||||
}
|
||||
|
||||
// test unsafe_impl
|
||||
|
@ -161,7 +161,7 @@ fn items_without_modifiers(p: &mut Parser) -> Option<SyntaxKind> {
|
|||
}
|
||||
MOD_KW => {
|
||||
mod_item(p);
|
||||
MOD_ITEM
|
||||
MODULE
|
||||
}
|
||||
STRUCT_KW => {
|
||||
structs::struct_item(p);
|
||||
|
|
|
@ -112,11 +112,11 @@ pub enum SyntaxKind {
|
|||
ENUM,
|
||||
FUNCTION,
|
||||
EXTERN_CRATE_ITEM,
|
||||
MOD_ITEM,
|
||||
MODULE,
|
||||
USE_ITEM,
|
||||
STATIC_ITEM,
|
||||
CONST_ITEM,
|
||||
TRAIT_ITEM,
|
||||
TRAIT,
|
||||
IMPL_ITEM,
|
||||
TYPE_ITEM,
|
||||
MACRO_CALL,
|
||||
|
@ -347,11 +347,11 @@ impl SyntaxKind {
|
|||
ENUM => &SyntaxInfo { name: "ENUM" },
|
||||
FUNCTION => &SyntaxInfo { name: "FUNCTION" },
|
||||
EXTERN_CRATE_ITEM => &SyntaxInfo { name: "EXTERN_CRATE_ITEM" },
|
||||
MOD_ITEM => &SyntaxInfo { name: "MOD_ITEM" },
|
||||
MODULE => &SyntaxInfo { name: "MODULE" },
|
||||
USE_ITEM => &SyntaxInfo { name: "USE_ITEM" },
|
||||
STATIC_ITEM => &SyntaxInfo { name: "STATIC_ITEM" },
|
||||
CONST_ITEM => &SyntaxInfo { name: "CONST_ITEM" },
|
||||
TRAIT_ITEM => &SyntaxInfo { name: "TRAIT_ITEM" },
|
||||
TRAIT => &SyntaxInfo { name: "TRAIT" },
|
||||
IMPL_ITEM => &SyntaxInfo { name: "IMPL_ITEM" },
|
||||
TYPE_ITEM => &SyntaxInfo { name: "TYPE_ITEM" },
|
||||
MACRO_CALL => &SyntaxInfo { name: "MACRO_CALL" },
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
FILE@[0; 18)
|
||||
TRAIT_ITEM@[0; 17)
|
||||
TRAIT@[0; 17)
|
||||
UNSAFE_KW@[0; 6)
|
||||
WHITESPACE@[6; 7)
|
||||
TRAIT_KW@[7; 12)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
FILE@[0; 23)
|
||||
TRAIT_ITEM@[0; 22)
|
||||
TRAIT@[0; 22)
|
||||
UNSAFE_KW@[0; 6)
|
||||
WHITESPACE@[6; 7)
|
||||
AUTO_KW@[7; 11)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
FILE@[0; 42)
|
||||
TRAIT_ITEM@[0; 41)
|
||||
TRAIT@[0; 41)
|
||||
TRAIT_KW@[0; 5)
|
||||
WHITESPACE@[5; 6)
|
||||
NAME@[6; 7)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
FILE@[0; 16)
|
||||
TRAIT_ITEM@[0; 15)
|
||||
TRAIT@[0; 15)
|
||||
AUTO_KW@[0; 4)
|
||||
WHITESPACE@[4; 5)
|
||||
TRAIT_KW@[5; 10)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
FILE@[0; 22)
|
||||
TRAIT_ITEM@[0; 21)
|
||||
TRAIT@[0; 21)
|
||||
TRAIT_KW@[0; 5)
|
||||
WHITESPACE@[5; 6)
|
||||
NAME@[6; 7)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
FILE@[0; 118)
|
||||
MOD_ITEM@[0; 6)
|
||||
MODULE@[0; 6)
|
||||
MOD_KW@[0; 3)
|
||||
WHITESPACE@[3; 4)
|
||||
NAME@[4; 5)
|
||||
IDENT@[4; 5) "a"
|
||||
SEMI@[5; 6)
|
||||
WHITESPACE@[6; 8)
|
||||
MOD_ITEM@[8; 17)
|
||||
MODULE@[8; 17)
|
||||
MOD_KW@[8; 11)
|
||||
WHITESPACE@[11; 12)
|
||||
NAME@[12; 13)
|
||||
|
@ -16,7 +16,7 @@ FILE@[0; 118)
|
|||
WHITESPACE@[15; 16)
|
||||
R_CURLY@[16; 17)
|
||||
WHITESPACE@[17; 19)
|
||||
MOD_ITEM@[19; 65)
|
||||
MODULE@[19; 65)
|
||||
MOD_KW@[19; 22)
|
||||
WHITESPACE@[22; 23)
|
||||
NAME@[23; 24)
|
||||
|
@ -49,7 +49,7 @@ FILE@[0; 118)
|
|||
WHITESPACE@[63; 64)
|
||||
R_CURLY@[64; 65)
|
||||
WHITESPACE@[65; 67)
|
||||
MOD_ITEM@[67; 118)
|
||||
MODULE@[67; 118)
|
||||
MOD_KW@[67; 70)
|
||||
WHITESPACE@[70; 71)
|
||||
NAME@[71; 72)
|
||||
|
@ -65,14 +65,14 @@ FILE@[0; 118)
|
|||
IDENT@[82; 86) "attr"
|
||||
R_BRACK@[86; 87)
|
||||
WHITESPACE@[87; 92)
|
||||
MOD_ITEM@[92; 98)
|
||||
MODULE@[92; 98)
|
||||
MOD_KW@[92; 95)
|
||||
WHITESPACE@[95; 96)
|
||||
NAME@[96; 97)
|
||||
IDENT@[96; 97) "e"
|
||||
SEMI@[97; 98)
|
||||
WHITESPACE@[98; 103)
|
||||
MOD_ITEM@[103; 116)
|
||||
MODULE@[103; 116)
|
||||
MOD_KW@[103; 106)
|
||||
WHITESPACE@[106; 107)
|
||||
NAME@[107; 108)
|
||||
|
|
Loading…
Reference in a new issue