minor
This commit is contained in:
parent
eb8e9043e2
commit
cc4c90aa2c
2 changed files with 31 additions and 31 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -78,6 +78,36 @@ fn assert_send_sync() {
|
|||
f::<GreenNode>();
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct GreenBranch {
|
||||
text_len: TextUnit,
|
||||
kind: SyntaxKind,
|
||||
children: Vec<GreenNode>,
|
||||
}
|
||||
|
||||
impl GreenBranch {
|
||||
fn new(kind: SyntaxKind, children: Vec<GreenNode>) -> GreenBranch {
|
||||
let text_len = children.iter().map(|x| x.text_len()).sum::<TextUnit>();
|
||||
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<GreenNode>,
|
||||
}
|
||||
|
||||
impl GreenBranch {
|
||||
fn new(kind: SyntaxKind, children: Vec<GreenNode>) -> GreenBranch {
|
||||
let text_len = children.iter().map(|x| x.text_len()).sum::<TextUnit>();
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue