diff options
author | Aleksey Kladov <[email protected]> | 2018-08-11 08:56:40 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-11 08:56:40 +0100 |
commit | 78f41ea707cc8aeaa8d1ba8a7216cb8712f13e98 (patch) | |
tree | 0553368ba2a5b8f67f793413beb22225e3416126 /crates/libsyntax2/src | |
parent | 2e971cdcbbeb543ab6b66dc8558644c1f4a80670 (diff) |
more renames
Diffstat (limited to 'crates/libsyntax2/src')
-rw-r--r-- | crates/libsyntax2/src/ast/generated.rs | 48 | ||||
-rw-r--r-- | crates/libsyntax2/src/grammar.ron | 14 | ||||
-rw-r--r-- | crates/libsyntax2/src/grammar/items/mod.rs | 4 | ||||
-rw-r--r-- | crates/libsyntax2/src/syntax_kinds/generated.rs | 8 |
4 files changed, 66 insertions, 8 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index 12e5a1c3e..c9b587ecb 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs | |||
@@ -5,6 +5,30 @@ use { | |||
5 | }; | 5 | }; |
6 | 6 | ||
7 | #[derive(Debug, Clone, Copy)] | 7 | #[derive(Debug, Clone, Copy)] |
8 | pub struct Enum<R: TreeRoot = Arc<SyntaxRoot>> { | ||
9 | syntax: SyntaxNode<R>, | ||
10 | } | ||
11 | |||
12 | impl<R: TreeRoot> AstNode<R> for Enum<R> { | ||
13 | fn cast(syntax: SyntaxNode<R>) -> Option<Self> { | ||
14 | match syntax.kind() { | ||
15 | ENUM => Some(Enum { syntax }), | ||
16 | _ => None, | ||
17 | } | ||
18 | } | ||
19 | fn syntax(&self) -> &SyntaxNode<R> { &self.syntax } | ||
20 | } | ||
21 | |||
22 | impl<R: TreeRoot> Enum<R> { | ||
23 | pub fn name(&self) -> Option<Name<R>> { | ||
24 | self.syntax() | ||
25 | .children() | ||
26 | .filter_map(Name::cast) | ||
27 | .next() | ||
28 | } | ||
29 | } | ||
30 | |||
31 | #[derive(Debug, Clone, Copy)] | ||
8 | pub struct File<R: TreeRoot = Arc<SyntaxRoot>> { | 32 | pub struct File<R: TreeRoot = Arc<SyntaxRoot>> { |
9 | syntax: SyntaxNode<R>, | 33 | syntax: SyntaxNode<R>, |
10 | } | 34 | } |
@@ -68,3 +92,27 @@ impl<R: TreeRoot> AstNode<R> for Name<R> { | |||
68 | 92 | ||
69 | impl<R: TreeRoot> Name<R> {} | 93 | impl<R: TreeRoot> Name<R> {} |
70 | 94 | ||
95 | #[derive(Debug, Clone, Copy)] | ||
96 | pub struct Struct<R: TreeRoot = Arc<SyntaxRoot>> { | ||
97 | syntax: SyntaxNode<R>, | ||
98 | } | ||
99 | |||
100 | impl<R: TreeRoot> AstNode<R> for Struct<R> { | ||
101 | fn cast(syntax: SyntaxNode<R>) -> Option<Self> { | ||
102 | match syntax.kind() { | ||
103 | STRUCT => Some(Struct { syntax }), | ||
104 | _ => None, | ||
105 | } | ||
106 | } | ||
107 | fn syntax(&self) -> &SyntaxNode<R> { &self.syntax } | ||
108 | } | ||
109 | |||
110 | impl<R: TreeRoot> Struct<R> { | ||
111 | pub fn name(&self) -> Option<Name<R>> { | ||
112 | self.syntax() | ||
113 | .children() | ||
114 | .filter_map(Name::cast) | ||
115 | .next() | ||
116 | } | ||
117 | } | ||
118 | |||
diff --git a/crates/libsyntax2/src/grammar.ron b/crates/libsyntax2/src/grammar.ron index 650f72212..a8916c5c7 100644 --- a/crates/libsyntax2/src/grammar.ron +++ b/crates/libsyntax2/src/grammar.ron | |||
@@ -112,11 +112,11 @@ Grammar( | |||
112 | "ENUM", | 112 | "ENUM", |
113 | "FUNCTION", | 113 | "FUNCTION", |
114 | "EXTERN_CRATE_ITEM", | 114 | "EXTERN_CRATE_ITEM", |
115 | "MOD_ITEM", | 115 | "MODULE", |
116 | "USE_ITEM", | 116 | "USE_ITEM", |
117 | "STATIC_ITEM", | 117 | "STATIC_ITEM", |
118 | "CONST_ITEM", | 118 | "CONST_ITEM", |
119 | "TRAIT_ITEM", | 119 | "TRAIT", |
120 | "IMPL_ITEM", | 120 | "IMPL_ITEM", |
121 | "TYPE_ITEM", | 121 | "TYPE_ITEM", |
122 | "MACRO_CALL", | 122 | "MACRO_CALL", |
@@ -224,6 +224,16 @@ Grammar( | |||
224 | ["name", "Name"] | 224 | ["name", "Name"] |
225 | ] | 225 | ] |
226 | ), | 226 | ), |
227 | "Struct": ( | ||
228 | options: [ | ||
229 | ["name", "Name"] | ||
230 | ] | ||
231 | ), | ||
232 | "Enum": ( | ||
233 | options: [ | ||
234 | ["name", "Name"] | ||
235 | ] | ||
236 | ), | ||
227 | "Name": (), | 237 | "Name": (), |
228 | }, | 238 | }, |
229 | ) | 239 | ) |
diff --git a/crates/libsyntax2/src/grammar/items/mod.rs b/crates/libsyntax2/src/grammar/items/mod.rs index be4ff976a..6f401ea1b 100644 --- a/crates/libsyntax2/src/grammar/items/mod.rs +++ b/crates/libsyntax2/src/grammar/items/mod.rs | |||
@@ -121,7 +121,7 @@ pub(super) fn maybe_item(p: &mut Parser) -> MaybeItem { | |||
121 | // unsafe auto trait T {} | 121 | // unsafe auto trait T {} |
122 | TRAIT_KW => { | 122 | TRAIT_KW => { |
123 | traits::trait_item(p); | 123 | traits::trait_item(p); |
124 | TRAIT_ITEM | 124 | TRAIT |
125 | } | 125 | } |
126 | 126 | ||
127 | // test unsafe_impl | 127 | // test unsafe_impl |
@@ -161,7 +161,7 @@ fn items_without_modifiers(p: &mut Parser) -> Option<SyntaxKind> { | |||
161 | } | 161 | } |
162 | MOD_KW => { | 162 | MOD_KW => { |
163 | mod_item(p); | 163 | mod_item(p); |
164 | MOD_ITEM | 164 | MODULE |
165 | } | 165 | } |
166 | STRUCT_KW => { | 166 | STRUCT_KW => { |
167 | structs::struct_item(p); | 167 | structs::struct_item(p); |
diff --git a/crates/libsyntax2/src/syntax_kinds/generated.rs b/crates/libsyntax2/src/syntax_kinds/generated.rs index 7d2fb60f6..c45a4800c 100644 --- a/crates/libsyntax2/src/syntax_kinds/generated.rs +++ b/crates/libsyntax2/src/syntax_kinds/generated.rs | |||
@@ -112,11 +112,11 @@ pub enum SyntaxKind { | |||
112 | ENUM, | 112 | ENUM, |
113 | FUNCTION, | 113 | FUNCTION, |
114 | EXTERN_CRATE_ITEM, | 114 | EXTERN_CRATE_ITEM, |
115 | MOD_ITEM, | 115 | MODULE, |
116 | USE_ITEM, | 116 | USE_ITEM, |
117 | STATIC_ITEM, | 117 | STATIC_ITEM, |
118 | CONST_ITEM, | 118 | CONST_ITEM, |
119 | TRAIT_ITEM, | 119 | TRAIT, |
120 | IMPL_ITEM, | 120 | IMPL_ITEM, |
121 | TYPE_ITEM, | 121 | TYPE_ITEM, |
122 | MACRO_CALL, | 122 | MACRO_CALL, |
@@ -347,11 +347,11 @@ impl SyntaxKind { | |||
347 | ENUM => &SyntaxInfo { name: "ENUM" }, | 347 | ENUM => &SyntaxInfo { name: "ENUM" }, |
348 | FUNCTION => &SyntaxInfo { name: "FUNCTION" }, | 348 | FUNCTION => &SyntaxInfo { name: "FUNCTION" }, |
349 | EXTERN_CRATE_ITEM => &SyntaxInfo { name: "EXTERN_CRATE_ITEM" }, | 349 | EXTERN_CRATE_ITEM => &SyntaxInfo { name: "EXTERN_CRATE_ITEM" }, |
350 | MOD_ITEM => &SyntaxInfo { name: "MOD_ITEM" }, | 350 | MODULE => &SyntaxInfo { name: "MODULE" }, |
351 | USE_ITEM => &SyntaxInfo { name: "USE_ITEM" }, | 351 | USE_ITEM => &SyntaxInfo { name: "USE_ITEM" }, |
352 | STATIC_ITEM => &SyntaxInfo { name: "STATIC_ITEM" }, | 352 | STATIC_ITEM => &SyntaxInfo { name: "STATIC_ITEM" }, |
353 | CONST_ITEM => &SyntaxInfo { name: "CONST_ITEM" }, | 353 | CONST_ITEM => &SyntaxInfo { name: "CONST_ITEM" }, |
354 | TRAIT_ITEM => &SyntaxInfo { name: "TRAIT_ITEM" }, | 354 | TRAIT => &SyntaxInfo { name: "TRAIT" }, |
355 | IMPL_ITEM => &SyntaxInfo { name: "IMPL_ITEM" }, | 355 | IMPL_ITEM => &SyntaxInfo { name: "IMPL_ITEM" }, |
356 | TYPE_ITEM => &SyntaxInfo { name: "TYPE_ITEM" }, | 356 | TYPE_ITEM => &SyntaxInfo { name: "TYPE_ITEM" }, |
357 | MACRO_CALL => &SyntaxInfo { name: "MACRO_CALL" }, | 357 | MACRO_CALL => &SyntaxInfo { name: "MACRO_CALL" }, |