diff options
author | Aleksey Kladov <[email protected]> | 2018-08-25 09:44:17 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-25 09:44:17 +0100 |
commit | cf278ed3bf71d336422f7d7d7d51be92b717b720 (patch) | |
tree | 57bc0fa827e9af90be00918ab26d35832d1a1425 /crates/libsyntax2/src | |
parent | 9fae494a8da347a32cdcd3dcd714ba00aaff9664 (diff) |
rename file -> root
Diffstat (limited to 'crates/libsyntax2/src')
-rw-r--r-- | crates/libsyntax2/src/ast/generated.rs | 52 | ||||
-rw-r--r-- | crates/libsyntax2/src/grammar.ron | 4 | ||||
-rw-r--r-- | crates/libsyntax2/src/grammar/mod.rs | 2 | ||||
-rw-r--r-- | crates/libsyntax2/src/lib.rs | 4 | ||||
-rw-r--r-- | crates/libsyntax2/src/syntax_kinds/generated.rs | 4 |
5 files changed, 33 insertions, 33 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> {} | |||
104 | impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {} | 104 | impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {} |
105 | impl<'a> EnumDef<'a> {} | 105 | impl<'a> EnumDef<'a> {} |
106 | 106 | ||
107 | // File | ||
108 | #[derive(Debug, Clone, Copy)] | ||
109 | pub struct File<'a> { | ||
110 | syntax: SyntaxNodeRef<'a>, | ||
111 | } | ||
112 | |||
113 | impl<'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 | |||
123 | impl<'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)] |
135 | pub struct FnDef<'a> { | 109 | pub struct FnDef<'a> { |
@@ -439,6 +413,32 @@ impl<'a> AstNode<'a> for ReferenceType<'a> { | |||
439 | 413 | ||
440 | impl<'a> ReferenceType<'a> {} | 414 | impl<'a> ReferenceType<'a> {} |
441 | 415 | ||
416 | // Root | ||
417 | #[derive(Debug, Clone, Copy)] | ||
418 | pub struct Root<'a> { | ||
419 | syntax: SyntaxNodeRef<'a>, | ||
420 | } | ||
421 | |||
422 | impl<'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 | |||
432 | impl<'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)] |
444 | pub struct SliceType<'a> { | 444 | pub struct SliceType<'a> { |
diff --git a/crates/libsyntax2/src/grammar.ron b/crates/libsyntax2/src/grammar.ron index f4792df1d..0ea7e8ce1 100644 --- a/crates/libsyntax2/src/grammar.ron +++ b/crates/libsyntax2/src/grammar.ron | |||
@@ -114,7 +114,7 @@ Grammar( | |||
114 | "SHEBANG", | 114 | "SHEBANG", |
115 | ], | 115 | ], |
116 | nodes: [ | 116 | nodes: [ |
117 | "FILE", | 117 | "ROOT", |
118 | 118 | ||
119 | "STRUCT_DEF", | 119 | "STRUCT_DEF", |
120 | "ENUM_DEF", | 120 | "ENUM_DEF", |
@@ -235,7 +235,7 @@ Grammar( | |||
235 | "ARG_LIST", | 235 | "ARG_LIST", |
236 | ], | 236 | ], |
237 | ast: { | 237 | ast: { |
238 | "File": ( | 238 | "Root": ( |
239 | collections: [ | 239 | collections: [ |
240 | ["functions", "FnDef"], | 240 | ["functions", "FnDef"], |
241 | ["modules", "Module"], | 241 | ["modules", "Module"], |
diff --git a/crates/libsyntax2/src/grammar/mod.rs b/crates/libsyntax2/src/grammar/mod.rs index 0f118f12d..e3ca2714c 100644 --- a/crates/libsyntax2/src/grammar/mod.rs +++ b/crates/libsyntax2/src/grammar/mod.rs | |||
@@ -40,7 +40,7 @@ pub(crate) fn file(p: &mut Parser) { | |||
40 | let file = p.start(); | 40 | let file = p.start(); |
41 | p.eat(SHEBANG); | 41 | p.eat(SHEBANG); |
42 | items::mod_contents(p, false); | 42 | items::mod_contents(p, false); |
43 | file.complete(p, FILE); | 43 | file.complete(p, ROOT); |
44 | } | 44 | } |
45 | 45 | ||
46 | 46 | ||
diff --git a/crates/libsyntax2/src/lib.rs b/crates/libsyntax2/src/lib.rs index b3efe2a18..9b45e2575 100644 --- a/crates/libsyntax2/src/lib.rs +++ b/crates/libsyntax2/src/lib.rs | |||
@@ -60,8 +60,8 @@ impl ParsedFile { | |||
60 | let root = ::parse(text); | 60 | let root = ::parse(text); |
61 | ParsedFile { root } | 61 | ParsedFile { root } |
62 | } | 62 | } |
63 | pub fn ast(&self) -> ast::File { | 63 | pub fn ast(&self) -> ast::Root { |
64 | ast::File::cast(self.syntax()).unwrap() | 64 | ast::Root::cast(self.syntax()).unwrap() |
65 | } | 65 | } |
66 | pub fn syntax(&self) -> SyntaxNodeRef { | 66 | pub fn syntax(&self) -> SyntaxNodeRef { |
67 | self.root.borrowed() | 67 | self.root.borrowed() |
diff --git a/crates/libsyntax2/src/syntax_kinds/generated.rs b/crates/libsyntax2/src/syntax_kinds/generated.rs index 6c7f44aee..6a24cb19e 100644 --- a/crates/libsyntax2/src/syntax_kinds/generated.rs +++ b/crates/libsyntax2/src/syntax_kinds/generated.rs | |||
@@ -115,7 +115,7 @@ pub enum SyntaxKind { | |||
115 | COMMENT, | 115 | COMMENT, |
116 | DOC_COMMENT, | 116 | DOC_COMMENT, |
117 | SHEBANG, | 117 | SHEBANG, |
118 | FILE, | 118 | ROOT, |
119 | STRUCT_DEF, | 119 | STRUCT_DEF, |
120 | ENUM_DEF, | 120 | ENUM_DEF, |
121 | FN_DEF, | 121 | FN_DEF, |
@@ -375,7 +375,7 @@ impl SyntaxKind { | |||
375 | COMMENT => &SyntaxInfo { name: "COMMENT" }, | 375 | COMMENT => &SyntaxInfo { name: "COMMENT" }, |
376 | DOC_COMMENT => &SyntaxInfo { name: "DOC_COMMENT" }, | 376 | DOC_COMMENT => &SyntaxInfo { name: "DOC_COMMENT" }, |
377 | SHEBANG => &SyntaxInfo { name: "SHEBANG" }, | 377 | SHEBANG => &SyntaxInfo { name: "SHEBANG" }, |
378 | FILE => &SyntaxInfo { name: "FILE" }, | 378 | ROOT => &SyntaxInfo { name: "ROOT" }, |
379 | STRUCT_DEF => &SyntaxInfo { name: "STRUCT_DEF" }, | 379 | STRUCT_DEF => &SyntaxInfo { name: "STRUCT_DEF" }, |
380 | ENUM_DEF => &SyntaxInfo { name: "ENUM_DEF" }, | 380 | ENUM_DEF => &SyntaxInfo { name: "ENUM_DEF" }, |
381 | FN_DEF => &SyntaxInfo { name: "FN_DEF" }, | 381 | FN_DEF => &SyntaxInfo { name: "FN_DEF" }, |