diff options
Diffstat (limited to 'crates/ra_ide_api/src/source_change.rs')
-rw-r--r-- | crates/ra_ide_api/src/source_change.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/crates/ra_ide_api/src/source_change.rs b/crates/ra_ide_api/src/source_change.rs index 80e8821b0..4e63bbf6f 100644 --- a/crates/ra_ide_api/src/source_change.rs +++ b/crates/ra_ide_api/src/source_change.rs | |||
@@ -6,7 +6,7 @@ | |||
6 | use ra_text_edit::TextEdit; | 6 | use ra_text_edit::TextEdit; |
7 | use relative_path::RelativePathBuf; | 7 | use relative_path::RelativePathBuf; |
8 | 8 | ||
9 | use crate::{FileId, FilePosition, SourceRootId}; | 9 | use crate::{FileId, FilePosition, SourceRootId, TextUnit}; |
10 | 10 | ||
11 | #[derive(Debug)] | 11 | #[derive(Debug)] |
12 | pub struct SourceChange { | 12 | pub struct SourceChange { |
@@ -100,3 +100,20 @@ pub enum FileSystemEdit { | |||
100 | CreateFile { source_root: SourceRootId, path: RelativePathBuf }, | 100 | CreateFile { source_root: SourceRootId, path: RelativePathBuf }, |
101 | MoveFile { src: FileId, dst_source_root: SourceRootId, dst_path: RelativePathBuf }, | 101 | MoveFile { src: FileId, dst_source_root: SourceRootId, dst_path: RelativePathBuf }, |
102 | } | 102 | } |
103 | |||
104 | pub(crate) struct SingleFileChange { | ||
105 | pub label: String, | ||
106 | pub edit: TextEdit, | ||
107 | pub cursor_position: Option<TextUnit>, | ||
108 | } | ||
109 | |||
110 | impl SingleFileChange { | ||
111 | pub(crate) fn into_source_change(self, file_id: FileId) -> SourceChange { | ||
112 | SourceChange { | ||
113 | label: self.label, | ||
114 | source_file_edits: vec![SourceFileEdit { file_id, edit: self.edit }], | ||
115 | file_system_edits: Vec::new(), | ||
116 | cursor_position: self.cursor_position.map(|offset| FilePosition { file_id, offset }), | ||
117 | } | ||
118 | } | ||
119 | } | ||