mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 04:23:25 +00:00
Rename syntax_node_to_token_tree_censored
This commit is contained in:
parent
ecf3cff4a6
commit
bdb7ae5dd0
4 changed files with 10 additions and 9 deletions
|
@ -151,8 +151,11 @@ pub fn expand_speculative(
|
|||
let censor = censor_for_macro_input(&loc, &speculative_args);
|
||||
let mut fixups = fixup::fixup_syntax(&speculative_args);
|
||||
fixups.replace.extend(censor.into_iter().map(|node| (node, Vec::new())));
|
||||
let (mut tt, spec_args_tmap) =
|
||||
mbe::syntax_node_to_token_tree_censored(&speculative_args, fixups.replace, fixups.append);
|
||||
let (mut tt, spec_args_tmap) = mbe::syntax_node_to_token_tree_with_modifications(
|
||||
&speculative_args,
|
||||
fixups.replace,
|
||||
fixups.append,
|
||||
);
|
||||
|
||||
let (attr_arg, token_id) = match loc.kind {
|
||||
MacroCallKind::Attr { invoc_attr_index, .. } => {
|
||||
|
@ -303,11 +306,10 @@ fn macro_arg(
|
|||
|
||||
let node = SyntaxNode::new_root(arg);
|
||||
let censor = censor_for_macro_input(&loc, &node);
|
||||
// TODO only fixup for attribute macro input
|
||||
let mut fixups = fixup::fixup_syntax(&node);
|
||||
fixups.replace.extend(censor.into_iter().map(|node| (node, Vec::new())));
|
||||
let (mut tt, tmap) =
|
||||
mbe::syntax_node_to_token_tree_censored(&node, fixups.replace, fixups.append);
|
||||
mbe::syntax_node_to_token_tree_with_modifications(&node, fixups.replace, fixups.append);
|
||||
|
||||
if loc.def.is_proc_macro() {
|
||||
// proc macros expect their inputs without parentheses, MBEs expect it with them included
|
||||
|
|
|
@ -123,7 +123,7 @@ mod tests {
|
|||
let parsed = syntax::SourceFile::parse(ra_fixture);
|
||||
eprintln!("parse: {:#?}", parsed.syntax_node());
|
||||
let fixups = super::fixup_syntax(&parsed.syntax_node());
|
||||
let (mut tt, tmap) = mbe::syntax_node_to_token_tree_censored(
|
||||
let (mut tt, tmap) = mbe::syntax_node_to_token_tree_with_modifications(
|
||||
&parsed.syntax_node(),
|
||||
fixups.replace,
|
||||
fixups.append,
|
||||
|
|
|
@ -30,7 +30,7 @@ pub use tt::{Delimiter, DelimiterKind, Punct};
|
|||
pub use crate::{
|
||||
syntax_bridge::{
|
||||
parse_exprs_with_sep, parse_to_token_tree, syntax_node_to_token_tree,
|
||||
syntax_node_to_token_tree_censored, token_tree_to_syntax_node, SyntheticToken,
|
||||
syntax_node_to_token_tree_with_modifications, token_tree_to_syntax_node, SyntheticToken,
|
||||
SyntheticTokenId,
|
||||
},
|
||||
token_map::TokenMap,
|
||||
|
|
|
@ -15,13 +15,12 @@ use crate::{to_parser_input::to_parser_input, tt_iter::TtIter, TokenMap};
|
|||
/// Convert the syntax node to a `TokenTree` (what macro
|
||||
/// will consume).
|
||||
pub fn syntax_node_to_token_tree(node: &SyntaxNode) -> (tt::Subtree, TokenMap) {
|
||||
syntax_node_to_token_tree_censored(node, Default::default(), Default::default())
|
||||
syntax_node_to_token_tree_with_modifications(node, Default::default(), Default::default())
|
||||
}
|
||||
|
||||
// TODO rename
|
||||
/// Convert the syntax node to a `TokenTree` (what macro will consume)
|
||||
/// with the censored range excluded.
|
||||
pub fn syntax_node_to_token_tree_censored(
|
||||
pub fn syntax_node_to_token_tree_with_modifications(
|
||||
node: &SyntaxNode,
|
||||
replace: FxHashMap<SyntaxNode, Vec<SyntheticToken>>,
|
||||
append: FxHashMap<SyntaxNode, Vec<SyntheticToken>>,
|
||||
|
|
Loading…
Reference in a new issue