WIP: fix: make rename multi-token mapping aware

This commit is contained in:
Anatol Ulrich 2021-10-27 04:31:14 +02:00
parent a3830dfd3b
commit 6decfceae1
2 changed files with 108 additions and 66 deletions

View file

@ -54,6 +54,13 @@ impl SourceChange {
pub fn get_source_edit(&self, file_id: FileId) -> Option<&TextEdit> {
self.source_file_edits.get(&file_id)
}
pub fn merge(mut self, other: SourceChange) -> SourceChange {
self.extend(other.source_file_edits);
self.extend(other.file_system_edits);
self.is_snippet |= other.is_snippet; // TODO correct?
self
}
}
impl Extend<(FileId, TextEdit)> for SourceChange {
@ -62,6 +69,12 @@ impl Extend<(FileId, TextEdit)> for SourceChange {
}
}
impl Extend<FileSystemEdit> for SourceChange {
fn extend<T: IntoIterator<Item = FileSystemEdit>>(&mut self, iter: T) {
iter.into_iter().for_each(|edit| self.push_file_system_edit(edit));
}
}
impl From<FxHashMap<FileId, TextEdit>> for SourceChange {
fn from(source_file_edits: FxHashMap<FileId, TextEdit>) -> SourceChange {
SourceChange { source_file_edits, file_system_edits: Vec::new(), is_snippet: false }