aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/ast
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-25 09:44:17 +0100
committerAleksey Kladov <[email protected]>2018-08-25 09:44:17 +0100
commitcf278ed3bf71d336422f7d7d7d51be92b717b720 (patch)
tree57bc0fa827e9af90be00918ab26d35832d1a1425 /crates/libsyntax2/src/ast
parent9fae494a8da347a32cdcd3dcd714ba00aaff9664 (diff)
rename file -> root
Diffstat (limited to 'crates/libsyntax2/src/ast')
-rw-r--r--crates/libsyntax2/src/ast/generated.rs52
1 files changed, 26 insertions, 26 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs
index 8eb91c1df..52668c37b 100644
--- a/crates/libsyntax2/src/ast/generated.rs
+++ b/crates/libsyntax2/src/ast/generated.rs
@@ -104,32 +104,6 @@ impl<'a> ast::TypeParamsOwner<'a> for EnumDef<'a> {}
104impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {} 104impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {}
105impl<'a> EnumDef<'a> {} 105impl<'a> EnumDef<'a> {}
106 106
107// File
108#[derive(Debug, Clone, Copy)]
109pub struct File<'a> {
110 syntax: SyntaxNodeRef<'a>,
111}
112
113impl<'a> AstNode<'a> for File<'a> {
114 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
115 match syntax.kind() {
116 FILE => Some(File { syntax }),
117 _ => None,
118 }
119 }
120 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
121}
122
123impl<'a> File<'a> {
124 pub fn functions(self) -> impl Iterator<Item = FnDef<'a>> + 'a {
125 super::children(self)
126 }
127
128 pub fn modules(self) -> impl Iterator<Item = Module<'a>> + 'a {
129 super::children(self)
130 }
131}
132
133// FnDef 107// FnDef
134#[derive(Debug, Clone, Copy)] 108#[derive(Debug, Clone, Copy)]
135pub struct FnDef<'a> { 109pub struct FnDef<'a> {
@@ -439,6 +413,32 @@ impl<'a> AstNode<'a> for ReferenceType<'a> {
439 413
440impl<'a> ReferenceType<'a> {} 414impl<'a> ReferenceType<'a> {}
441 415
416// Root
417#[derive(Debug, Clone, Copy)]
418pub struct Root<'a> {
419 syntax: SyntaxNodeRef<'a>,
420}
421
422impl<'a> AstNode<'a> for Root<'a> {
423 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
424 match syntax.kind() {
425 ROOT => Some(Root { syntax }),
426 _ => None,
427 }
428 }
429 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
430}
431
432impl<'a> Root<'a> {
433 pub fn functions(self) -> impl Iterator<Item = FnDef<'a>> + 'a {
434 super::children(self)
435 }
436
437 pub fn modules(self) -> impl Iterator<Item = Module<'a>> + 'a {
438 super::children(self)
439 }
440}
441
442// SliceType 442// SliceType
443#[derive(Debug, Clone, Copy)] 443#[derive(Debug, Clone, Copy)]
444pub struct SliceType<'a> { 444pub struct SliceType<'a> {