diff options
author | Lukas Wirth <[email protected]> | 2020-09-03 11:36:16 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2020-09-03 17:36:07 +0100 |
commit | 952f3856822d471cf5062e82f544c901c385f3ae (patch) | |
tree | fd622081afc58b83eb4a1fae231fb3e575904ccb /crates/syntax/src | |
parent | 07ff9eeca8136563e7d1c09ec82cff9a67ed975a (diff) |
Impl make::blank_line
Diffstat (limited to 'crates/syntax/src')
-rw-r--r-- | crates/syntax/src/ast/make.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs index c2c938ad1..33f1ad7b3 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs | |||
@@ -339,7 +339,7 @@ pub mod tokens { | |||
339 | use crate::{ast, AstNode, Parse, SourceFile, SyntaxKind::*, SyntaxToken}; | 339 | use crate::{ast, AstNode, Parse, SourceFile, SyntaxKind::*, SyntaxToken}; |
340 | 340 | ||
341 | pub(super) static SOURCE_FILE: Lazy<Parse<SourceFile>> = | 341 | pub(super) static SOURCE_FILE: Lazy<Parse<SourceFile>> = |
342 | Lazy::new(|| SourceFile::parse("const C: <()>::Item = (1 != 1, 2 == 2, !true)\n;")); | 342 | Lazy::new(|| SourceFile::parse("const C: <()>::Item = (1 != 1, 2 == 2, !true)\n;\n\n")); |
343 | 343 | ||
344 | pub fn single_space() -> SyntaxToken { | 344 | pub fn single_space() -> SyntaxToken { |
345 | SOURCE_FILE | 345 | SOURCE_FILE |
@@ -379,6 +379,16 @@ pub mod tokens { | |||
379 | .unwrap() | 379 | .unwrap() |
380 | } | 380 | } |
381 | 381 | ||
382 | pub fn blank_line() -> SyntaxToken { | ||
383 | SOURCE_FILE | ||
384 | .tree() | ||
385 | .syntax() | ||
386 | .descendants_with_tokens() | ||
387 | .filter_map(|it| it.into_token()) | ||
388 | .find(|it| it.kind() == WHITESPACE && it.text().as_str() == "\n\n") | ||
389 | .unwrap() | ||
390 | } | ||
391 | |||
382 | pub struct WsBuilder(SourceFile); | 392 | pub struct WsBuilder(SourceFile); |
383 | 393 | ||
384 | impl WsBuilder { | 394 | impl WsBuilder { |