From cf278ed3bf71d336422f7d7d7d51be92b717b720 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 25 Aug 2018 11:44:17 +0300 Subject: rename file -> root --- crates/libsyntax2/src/ast/generated.rs | 52 ++++++++++++------------- crates/libsyntax2/src/grammar.ron | 4 +- crates/libsyntax2/src/grammar/mod.rs | 2 +- crates/libsyntax2/src/lib.rs | 4 +- crates/libsyntax2/src/syntax_kinds/generated.rs | 4 +- 5 files changed, 33 insertions(+), 33 deletions(-) (limited to 'crates/libsyntax2/src') 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> {} impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {} impl<'a> EnumDef<'a> {} -// File -#[derive(Debug, Clone, Copy)] -pub struct File<'a> { - syntax: SyntaxNodeRef<'a>, -} - -impl<'a> AstNode<'a> for File<'a> { - fn cast(syntax: SyntaxNodeRef<'a>) -> Option { - match syntax.kind() { - FILE => Some(File { syntax }), - _ => None, - } - } - fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } -} - -impl<'a> File<'a> { - pub fn functions(self) -> impl Iterator> + 'a { - super::children(self) - } - - pub fn modules(self) -> impl Iterator> + 'a { - super::children(self) - } -} - // FnDef #[derive(Debug, Clone, Copy)] pub struct FnDef<'a> { @@ -439,6 +413,32 @@ impl<'a> AstNode<'a> for ReferenceType<'a> { impl<'a> ReferenceType<'a> {} +// Root +#[derive(Debug, Clone, Copy)] +pub struct Root<'a> { + syntax: SyntaxNodeRef<'a>, +} + +impl<'a> AstNode<'a> for Root<'a> { + fn cast(syntax: SyntaxNodeRef<'a>) -> Option { + match syntax.kind() { + ROOT => Some(Root { syntax }), + _ => None, + } + } + fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } +} + +impl<'a> Root<'a> { + pub fn functions(self) -> impl Iterator> + 'a { + super::children(self) + } + + pub fn modules(self) -> impl Iterator> + 'a { + super::children(self) + } +} + // SliceType #[derive(Debug, Clone, Copy)] 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( "SHEBANG", ], nodes: [ - "FILE", + "ROOT", "STRUCT_DEF", "ENUM_DEF", @@ -235,7 +235,7 @@ Grammar( "ARG_LIST", ], ast: { - "File": ( + "Root": ( collections: [ ["functions", "FnDef"], ["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) { let file = p.start(); p.eat(SHEBANG); items::mod_contents(p, false); - file.complete(p, FILE); + file.complete(p, ROOT); } 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 { let root = ::parse(text); ParsedFile { root } } - pub fn ast(&self) -> ast::File { - ast::File::cast(self.syntax()).unwrap() + pub fn ast(&self) -> ast::Root { + ast::Root::cast(self.syntax()).unwrap() } pub fn syntax(&self) -> SyntaxNodeRef { 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 { COMMENT, DOC_COMMENT, SHEBANG, - FILE, + ROOT, STRUCT_DEF, ENUM_DEF, FN_DEF, @@ -375,7 +375,7 @@ impl SyntaxKind { COMMENT => &SyntaxInfo { name: "COMMENT" }, DOC_COMMENT => &SyntaxInfo { name: "DOC_COMMENT" }, SHEBANG => &SyntaxInfo { name: "SHEBANG" }, - FILE => &SyntaxInfo { name: "FILE" }, + ROOT => &SyntaxInfo { name: "ROOT" }, STRUCT_DEF => &SyntaxInfo { name: "STRUCT_DEF" }, ENUM_DEF => &SyntaxInfo { name: "ENUM_DEF" }, FN_DEF => &SyntaxInfo { name: "FN_DEF" }, -- cgit v1.2.3