1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use ra_ap_text_edit::{TextEdit, TextEditBuilder, TextRange, TextSize};

#[derive(Default, Debug, Clone)]
pub struct Upgrader {
    edit: TextEditBuilder,
}

impl Upgrader {
    pub fn replace(&mut self, range: TextRange, replace_with: String) {
        self.edit.replace(range, replace_with)
    }

    pub fn delete(&mut self, range: TextRange) {
        self.edit.delete(range)
    }

    pub fn insert(&mut self, offset: TextSize, text: String) {
        self.edit.insert(offset, text)
    }

    pub fn add_dep(&mut self) {}

    pub fn add_feature(&mut self) {}

    pub(crate) fn finish(&mut self) -> TextEdit {
        let edit = self.edit.clone().finish();
        self.edit = TextEditBuilder::default();
        edit
    }
}