mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
fix: Fix token downmapping being quadratic
This commit is contained in:
parent
bc9c952b6d
commit
5d951a6a46
2 changed files with 167 additions and 134 deletions
|
@ -605,8 +605,8 @@ pub struct ExpansionInfo {
|
|||
}
|
||||
|
||||
impl ExpansionInfo {
|
||||
pub fn expanded(&self) -> InFile<SyntaxNode> {
|
||||
self.expanded.clone().into()
|
||||
pub fn expanded(&self) -> InMacroFile<SyntaxNode> {
|
||||
self.expanded.clone()
|
||||
}
|
||||
|
||||
pub fn call_node(&self) -> Option<InFile<SyntaxNode>> {
|
||||
|
@ -617,13 +617,13 @@ impl ExpansionInfo {
|
|||
pub fn map_range_down<'a>(
|
||||
&'a self,
|
||||
span: SpanData,
|
||||
) -> Option<impl Iterator<Item = InMacroFile<SyntaxToken>> + 'a> {
|
||||
) -> Option<InMacroFile<impl Iterator<Item = SyntaxToken> + 'a>> {
|
||||
let tokens = self
|
||||
.exp_map
|
||||
.ranges_with_span(span)
|
||||
.flat_map(move |range| self.expanded.value.covering_element(range).into_token());
|
||||
|
||||
Some(tokens.map(move |token| InMacroFile::new(self.expanded.file_id, token)))
|
||||
Some(InMacroFile::new(self.expanded.file_id, tokens))
|
||||
}
|
||||
|
||||
/// Looks up the span at the given offset.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue