Upgrade rowan

Notably, new rowan comes with support for mutable syntax trees.
This commit is contained in:
Aleksey Kladov 2021-01-30 18:19:21 +03:00
parent 62ec04bbd5
commit f5a81ec468
41 changed files with 376 additions and 176 deletions

View file

@ -174,6 +174,11 @@ pub fn block_expr(
pub fn expr_unit() -> ast::Expr {
expr_from_text("()")
}
pub fn expr_literal(text: &str) -> ast::Literal {
assert_eq!(text.trim(), text);
ast_from_text(&format!("fn f() {{ let _ = {}; }}", text))
}
pub fn expr_empty_block() -> ast::Expr {
expr_from_text("{}")
}
@ -390,6 +395,7 @@ pub fn token(kind: SyntaxKind) -> SyntaxToken {
tokens::SOURCE_FILE
.tree()
.syntax()
.clone_for_update()
.descendants_with_tokens()
.filter_map(|it| it.into_token())
.find(|it| it.kind() == kind)
@ -544,6 +550,7 @@ pub mod tokens {
SOURCE_FILE
.tree()
.syntax()
.clone_for_update()
.descendants_with_tokens()
.filter_map(|it| it.into_token())
.find(|it| it.kind() == WHITESPACE && it.text() == " ")
@ -569,13 +576,16 @@ pub mod tokens {
}
pub fn single_newline() -> SyntaxToken {
SOURCE_FILE
let res = SOURCE_FILE
.tree()
.syntax()
.clone_for_update()
.descendants_with_tokens()
.filter_map(|it| it.into_token())
.find(|it| it.kind() == WHITESPACE && it.text() == "\n")
.unwrap()
.unwrap();
res.detach();
res
}
pub fn blank_line() -> SyntaxToken {