Impl make::blank_line

This commit is contained in:
Lukas Wirth 2020-09-03 12:36:16 +02:00
parent 07ff9eeca8
commit 952f385682
3 changed files with 20 additions and 27 deletions

View file

@ -339,7 +339,7 @@ pub mod tokens {
use crate::{ast, AstNode, Parse, SourceFile, SyntaxKind::*, SyntaxToken};
pub(super) static SOURCE_FILE: Lazy<Parse<SourceFile>> =
Lazy::new(|| SourceFile::parse("const C: <()>::Item = (1 != 1, 2 == 2, !true)\n;"));
Lazy::new(|| SourceFile::parse("const C: <()>::Item = (1 != 1, 2 == 2, !true)\n;\n\n"));
pub fn single_space() -> SyntaxToken {
SOURCE_FILE
@ -379,6 +379,16 @@ pub mod tokens {
.unwrap()
}
pub fn blank_line() -> SyntaxToken {
SOURCE_FILE
.tree()
.syntax()
.descendants_with_tokens()
.filter_map(|it| it.into_token())
.find(|it| it.kind() == WHITESPACE && it.text().as_str() == "\n\n")
.unwrap()
}
pub struct WsBuilder(SourceFile);
impl WsBuilder {