From cc4c90aa2cf4da819dd324a7bbf8b36f6a068a6d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 8 Aug 2018 19:44:16 +0300 Subject: minor --- src/lib.rs | 2 +- src/yellow/green.rs | 60 ++++++++++++++++++++++++++--------------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 94d843db3..0ae8082f1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,9 +35,9 @@ mod grammar; mod parser_impl; mod syntax_kinds; +mod yellow; /// Utilities for simple uses of the parser. pub mod utils; -mod yellow; pub use { ast::File, diff --git a/src/yellow/green.rs b/src/yellow/green.rs index 8ddcc74b8..3ade46f45 100644 --- a/src/yellow/green.rs +++ b/src/yellow/green.rs @@ -78,6 +78,36 @@ fn assert_send_sync() { f::(); } +#[derive(Clone, Debug)] +pub(crate) struct GreenBranch { + text_len: TextUnit, + kind: SyntaxKind, + children: Vec, +} + +impl GreenBranch { + fn new(kind: SyntaxKind, children: Vec) -> GreenBranch { + let text_len = children.iter().map(|x| x.text_len()).sum::(); + GreenBranch { + text_len, + kind, + children, + } + } + + pub fn kind(&self) -> SyntaxKind { + self.kind + } + + pub fn text_len(&self) -> TextUnit { + self.text_len + } + + pub fn children(&self) -> &[GreenNode] { + self.children.as_slice() + } +} + #[derive(Clone, Debug)] pub(crate) enum GreenLeaf { Whitespace { @@ -143,33 +173,3 @@ const N_NEWLINES: usize = 16; const N_SPACES: usize = 64; const WS: &str = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n "; - -#[derive(Clone, Debug)] -pub(crate) struct GreenBranch { - text_len: TextUnit, - kind: SyntaxKind, - children: Vec, -} - -impl GreenBranch { - fn new(kind: SyntaxKind, children: Vec) -> GreenBranch { - let text_len = children.iter().map(|x| x.text_len()).sum::(); - GreenBranch { - text_len, - kind, - children, - } - } - - pub fn kind(&self) -> SyntaxKind { - self.kind - } - - pub fn text_len(&self) -> TextUnit { - self.text_len - } - - pub fn children(&self) -> &[GreenNode] { - self.children.as_slice() - } -} -- cgit v1.2.3