mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-11 21:06:23 +00:00
add SyntaxEditor::delete_all
to migrate utils.rs add_trait_assoc_items_to_impl
This commit is contained in:
parent
8611b71459
commit
e600060680
3 changed files with 68 additions and 27 deletions
|
@ -83,6 +83,16 @@ impl SyntaxEditor {
|
|||
self.changes.push(Change::Replace(element.syntax_element(), None));
|
||||
}
|
||||
|
||||
pub fn delete_all(&mut self, range: RangeInclusive<SyntaxElement>) {
|
||||
if range.start() == range.end() {
|
||||
self.delete(range.start());
|
||||
return;
|
||||
}
|
||||
|
||||
debug_assert!(is_ancestor_or_self_of_element(range.start(), &self.root));
|
||||
self.changes.push(Change::ReplaceAll(range, Vec::new()))
|
||||
}
|
||||
|
||||
pub fn replace(&mut self, old: impl Element, new: impl Element) {
|
||||
let old = old.syntax_element();
|
||||
debug_assert!(is_ancestor_or_self_of_element(&old, &self.root));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue