internal: remove one more immutable tree

This commit is contained in:
Aleksey Kladov 2021-05-10 19:04:41 +03:00
parent ab528e85f7
commit 0650f77dd9
7 changed files with 57 additions and 56 deletions

View file

@ -12,7 +12,7 @@
use itertools::Itertools;
use stdx::{format_to, never};
use crate::{ast, AstNode, SourceFile, SyntaxKind, SyntaxNode, SyntaxToken};
use crate::{ast, AstNode, SourceFile, SyntaxKind, SyntaxToken};
/// While the parent module defines basic atomic "constructors", the `ext`
/// module defines shortcuts for common things.
@ -601,17 +601,11 @@ fn ast_from_text<N: AstNode>(text: &str) -> N {
panic!("Failed to make ast node `{}` from text {}", std::any::type_name::<N>(), text)
}
};
let node = node.syntax().clone();
let node = unroot(node);
let node = N::cast(node).unwrap();
let node = node.clone_subtree();
assert_eq!(node.syntax().text_range().start(), 0.into());
node
}
fn unroot(n: SyntaxNode) -> SyntaxNode {
SyntaxNode::new_root(n.green().into())
}
pub fn token(kind: SyntaxKind) -> SyntaxToken {
tokens::SOURCE_FILE
.tree()