internal: allow macro tests to inspect parse tree

This commit is contained in:
Aleksey Kladov 2021-10-09 17:58:17 +03:00
parent aac23f7832
commit c41b7bbe69
3 changed files with 53 additions and 42 deletions

View file

@ -69,6 +69,13 @@ fn check(ra_fixture: &str, mut expect: Expect) {
let indent = IndentLevel::from_node(call.syntax());
let pp = reindent(indent, pp);
format_to!(expn_text, "{}", pp);
if call.to_string().contains("// +tree") {
let tree = format!("{:#?}", parse.syntax_node())
.split_inclusive("\n")
.map(|line| format!("// {}", line))
.collect::<String>();
format_to!(expn_text, "\n{}", tree)
}
}
let range = call.syntax().text_range();
let range: Range<usize> = range.into();