internal: remove useless helpers

We generally avoid "syntax only" helper wrappers, which don't do much:
they make code easier to write, but harder to read. They also make
investigations harder, as "find_usages" needs to be invoked both for the
wrapped and unwrapped APIs
This commit is contained in:
Aleksey Kladov 2021-08-09 15:41:19 +03:00
parent 977fef713e
commit 9aa6be71a5
12 changed files with 32 additions and 36 deletions

View file

@ -29,7 +29,8 @@ macro_rules! impl_fixture {
let macro_invocation =
source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap();
let (invocation_tt, _) = ast_to_token_tree(&macro_invocation.token_tree().unwrap());
let (invocation_tt, _) =
syntax_node_to_token_tree(macro_invocation.token_tree().unwrap().syntax());
self.rules.expand(&invocation_tt).result()
}
@ -100,7 +101,7 @@ macro_rules! impl_fixture {
.descendants()
.find_map(ast::TokenTree::cast)
.unwrap();
let mut wrapped = ast_to_token_tree(&wrapped).0;
let mut wrapped = syntax_node_to_token_tree(wrapped.syntax()).0;
wrapped.delimiter = None;
wrapped
};
@ -163,7 +164,8 @@ fn parse_macro_rules_to_tt(ra_fixture: &str) -> tt::Subtree {
let macro_definition =
source_file.syntax().descendants().find_map(ast::MacroRules::cast).unwrap();
let (definition_tt, _) = ast_to_token_tree(&macro_definition.token_tree().unwrap());
let (definition_tt, _) =
syntax_node_to_token_tree(macro_definition.token_tree().unwrap().syntax());
let parsed = parse_to_token_tree(
&ra_fixture[macro_definition.token_tree().unwrap().syntax().text_range()],
@ -180,7 +182,7 @@ fn parse_macro_def_to_tt(ra_fixture: &str) -> tt::Subtree {
let macro_definition =
source_file.syntax().descendants().find_map(ast::MacroDef::cast).unwrap();
let (definition_tt, _) = ast_to_token_tree(&macro_definition.body().unwrap());
let (definition_tt, _) = syntax_node_to_token_tree(macro_definition.body().unwrap().syntax());
let parsed =
parse_to_token_tree(&ra_fixture[macro_definition.body().unwrap().syntax().text_range()])