mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
introduce SingleFileChange
This commit is contained in:
parent
b112430ca7
commit
6f00bb1cb0
3 changed files with 64 additions and 35 deletions
|
@ -6,7 +6,7 @@
|
|||
use ra_text_edit::TextEdit;
|
||||
use relative_path::RelativePathBuf;
|
||||
|
||||
use crate::{FileId, FilePosition, SourceRootId};
|
||||
use crate::{FileId, FilePosition, SourceRootId, TextUnit};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SourceChange {
|
||||
|
@ -100,3 +100,20 @@ pub enum FileSystemEdit {
|
|||
CreateFile { source_root: SourceRootId, path: RelativePathBuf },
|
||||
MoveFile { src: FileId, dst_source_root: SourceRootId, dst_path: RelativePathBuf },
|
||||
}
|
||||
|
||||
pub(crate) struct SingleFileChange {
|
||||
pub label: String,
|
||||
pub edit: TextEdit,
|
||||
pub cursor_position: Option<TextUnit>,
|
||||
}
|
||||
|
||||
impl SingleFileChange {
|
||||
pub(crate) fn into_source_change(self, file_id: FileId) -> SourceChange {
|
||||
SourceChange {
|
||||
label: self.label,
|
||||
source_file_edits: vec![SourceFileEdit { file_id, edit: self.edit }],
|
||||
file_system_edits: Vec::new(),
|
||||
cursor_position: self.cursor_position.map(|offset| FilePosition { file_id, offset }),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue