mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-11 20:58:54 +00:00
Replace attribute with equivalent whitespace
This is needed to that the `TokenMap` we create contains offsets that match the source.
This commit is contained in:
parent
d616a6a456
commit
1d5c60ff54
1 changed files with 4 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
||||||
//! Macro input conditioning.
|
//! Macro input conditioning.
|
||||||
|
|
||||||
use syntax::{
|
use syntax::{
|
||||||
ast::{self, AttrsOwner},
|
ast::{self, make, AttrsOwner},
|
||||||
AstNode, SyntaxNode,
|
AstNode, SyntaxNode,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,7 +61,9 @@ fn remove_attr_invoc(item: ast::Item, attr_index: usize) -> ast::Item {
|
||||||
.attrs()
|
.attrs()
|
||||||
.nth(attr_index)
|
.nth(attr_index)
|
||||||
.unwrap_or_else(|| panic!("cannot find attribute #{}", attr_index));
|
.unwrap_or_else(|| panic!("cannot find attribute #{}", attr_index));
|
||||||
attr.syntax().detach();
|
let syntax_index = attr.syntax().index();
|
||||||
|
let ws = make::tokens::whitespace(&" ".repeat(u32::from(attr.syntax().text().len()) as usize));
|
||||||
|
item.syntax().splice_children(syntax_index..syntax_index + 1, vec![ws.into()]);
|
||||||
item
|
item
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue