mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
add syntax-tree based indents
This commit is contained in:
parent
264a07975d
commit
c00f298fd2
4 changed files with 103 additions and 13 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue