Unnamed repository; edit this file 'description' to name the repository.
add deleted to check if an element is deleted or not
bit-aloo 8 days ago
parent 9d469b5 · commit 87d7d78
-rw-r--r--crates/syntax/src/syntax_editor.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/syntax/src/syntax_editor.rs b/crates/syntax/src/syntax_editor.rs
index 6bad93ebf8..7d15195c6f 100644
--- a/crates/syntax/src/syntax_editor.rs
+++ b/crates/syntax/src/syntax_editor.rs
@@ -203,6 +203,14 @@ impl SyntaxEditor {
pub fn finish(self) -> SyntaxEdit {
edit_algo::apply_edits(self)
}
+
+ pub fn deleted(&self, element: impl Element) -> bool {
+ let element = element.syntax_element();
+ self.changes
+ .borrow()
+ .iter()
+ .any(|change| matches!(change, Change::Replace(existing, None) if *existing == element))
+ }
}
/// Represents a completed [`SyntaxEditor`] operation.