add syntax-tree based indents

This commit is contained in:
Aleksey Kladov 2019-10-12 22:07:47 +03:00
parent 264a07975d
commit c00f298fd2
4 changed files with 103 additions and 13 deletions

View file

@ -160,6 +160,12 @@ pub mod tokens {
.unwrap()
}
pub fn whitespace(text: &str) -> SyntaxToken {
assert!(text.trim().is_empty());
let sf = SourceFile::parse(text).ok().unwrap();
sf.syntax().first_child_or_token().unwrap().into_token().unwrap()
}
pub fn single_newline() -> SyntaxToken {
SOURCE_FILE
.tree()