aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_db/src/source_change.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_db/src/source_change.rs')
-rw-r--r--crates/ra_ide_db/src/source_change.rs27
1 files changed, 7 insertions, 20 deletions
diff --git a/crates/ra_ide_db/src/source_change.rs b/crates/ra_ide_db/src/source_change.rs
index af81a91a4..3484f5588 100644
--- a/crates/ra_ide_db/src/source_change.rs
+++ b/crates/ra_ide_db/src/source_change.rs
@@ -3,8 +3,8 @@
3//! 3//!
4//! It can be viewed as a dual for `AnalysisChange`. 4//! It can be viewed as a dual for `AnalysisChange`.
5 5
6use ra_db::{FileId, FilePosition, RelativePathBuf, SourceRootId}; 6use ra_db::{FileId, RelativePathBuf, SourceRootId};
7use ra_text_edit::{TextEdit, TextSize}; 7use ra_text_edit::TextEdit;
8 8
9#[derive(Debug, Clone)] 9#[derive(Debug, Clone)]
10pub struct SourceChange { 10pub struct SourceChange {
@@ -12,7 +12,7 @@ pub struct SourceChange {
12 pub label: String, 12 pub label: String,
13 pub source_file_edits: Vec<SourceFileEdit>, 13 pub source_file_edits: Vec<SourceFileEdit>,
14 pub file_system_edits: Vec<FileSystemEdit>, 14 pub file_system_edits: Vec<FileSystemEdit>,
15 pub cursor_position: Option<FilePosition>, 15 pub is_snippet: bool,
16} 16}
17 17
18impl SourceChange { 18impl SourceChange {
@@ -27,7 +27,7 @@ impl SourceChange {
27 label: label.into(), 27 label: label.into(),
28 source_file_edits, 28 source_file_edits,
29 file_system_edits, 29 file_system_edits,
30 cursor_position: None, 30 is_snippet: false,
31 } 31 }
32 } 32 }
33 33
@@ -40,7 +40,7 @@ impl SourceChange {
40 label: label, 40 label: label,
41 source_file_edits: edits, 41 source_file_edits: edits,
42 file_system_edits: vec![], 42 file_system_edits: vec![],
43 cursor_position: None, 43 is_snippet: false,
44 } 44 }
45 } 45 }
46 46
@@ -51,7 +51,7 @@ impl SourceChange {
51 label: label.into(), 51 label: label.into(),
52 source_file_edits: vec![], 52 source_file_edits: vec![],
53 file_system_edits: edits, 53 file_system_edits: edits,
54 cursor_position: None, 54 is_snippet: false,
55 } 55 }
56 } 56 }
57 57
@@ -76,18 +76,6 @@ impl SourceChange {
76 pub fn file_system_edit<L: Into<String>>(label: L, edit: FileSystemEdit) -> Self { 76 pub fn file_system_edit<L: Into<String>>(label: L, edit: FileSystemEdit) -> Self {
77 SourceChange::file_system_edits(label, vec![edit]) 77 SourceChange::file_system_edits(label, vec![edit])
78 } 78 }
79
80 /// Sets the cursor position to the given `FilePosition`
81 pub fn with_cursor(mut self, cursor_position: FilePosition) -> Self {
82 self.cursor_position = Some(cursor_position);
83 self
84 }
85
86 /// Sets the cursor position to the given `FilePosition`
87 pub fn with_cursor_opt(mut self, cursor_position: Option<FilePosition>) -> Self {
88 self.cursor_position = cursor_position;
89 self
90 }
91} 79}
92 80
93#[derive(Debug, Clone)] 81#[derive(Debug, Clone)]
@@ -105,7 +93,6 @@ pub enum FileSystemEdit {
105pub struct SingleFileChange { 93pub struct SingleFileChange {
106 pub label: String, 94 pub label: String,
107 pub edit: TextEdit, 95 pub edit: TextEdit,
108 pub cursor_position: Option<TextSize>,
109} 96}
110 97
111impl SingleFileChange { 98impl SingleFileChange {
@@ -114,7 +101,7 @@ impl SingleFileChange {
114 label: self.label, 101 label: self.label,
115 source_file_edits: vec![SourceFileEdit { file_id, edit: self.edit }], 102 source_file_edits: vec![SourceFileEdit { file_id, edit: self.edit }],
116 file_system_edits: Vec::new(), 103 file_system_edits: Vec::new(),
117 cursor_position: self.cursor_position.map(|offset| FilePosition { file_id, offset }), 104 is_snippet: false,
118 } 105 }
119 } 106 }
120} 107}