mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Fix the eager token maps by re-mapping the textranges between the input and input expansion
This commit is contained in:
parent
2366c16bf9
commit
6a7b905c86
18 changed files with 434 additions and 157 deletions
|
@ -68,6 +68,21 @@ pub mod token_id {
|
|||
Self::Subtree(Subtree { delimiter: Delimiter::unspecified(), token_trees: vec![] })
|
||||
}
|
||||
}
|
||||
|
||||
impl Subtree {
|
||||
pub fn visit_ids(&mut self, f: &impl Fn(TokenId) -> TokenId) {
|
||||
self.delimiter.open = f(self.delimiter.open);
|
||||
self.delimiter.close = f(self.delimiter.close);
|
||||
self.token_trees.iter_mut().for_each(|tt| match tt {
|
||||
crate::TokenTree::Leaf(leaf) => match leaf {
|
||||
crate::Leaf::Literal(it) => it.span = f(it.span),
|
||||
crate::Leaf::Punct(it) => it.span = f(it.span),
|
||||
crate::Leaf::Ident(it) => it.span = f(it.span),
|
||||
},
|
||||
crate::TokenTree::Subtree(s) => s.visit_ids(f),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue