aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/src/mock_analysis.rs16
1 files changed, 6 insertions, 10 deletions
diff --git a/crates/ra_ide/src/mock_analysis.rs b/crates/ra_ide/src/mock_analysis.rs
index e99c2b0a3..5bad3911f 100644
--- a/crates/ra_ide/src/mock_analysis.rs
+++ b/crates/ra_ide/src/mock_analysis.rs
@@ -105,10 +105,13 @@ impl MockAnalysis {
105 pub fn with_files_and_position(fixture: &str) -> (MockAnalysis, FilePosition) { 105 pub fn with_files_and_position(fixture: &str) -> (MockAnalysis, FilePosition) {
106 let mut position = None; 106 let mut position = None;
107 let mut res = MockAnalysis::new(); 107 let mut res = MockAnalysis::new();
108 for entry in Fixture::parse(fixture) { 108 for mut entry in Fixture::parse(fixture) {
109 if entry.text.contains(CURSOR_MARKER) { 109 if entry.text.contains(CURSOR_MARKER) {
110 assert!(position.is_none(), "only one marker (<|>) per fixture is allowed"); 110 assert!(position.is_none(), "only one marker (<|>) per fixture is allowed");
111 position = Some(res.add_file_fixture_with_position(entry)); 111 let (offset, text) = extract_offset(&entry.text);
112 entry.text = text;
113 let file_id = res.add_file_fixture(entry);
114 position = Some(FilePosition { file_id, offset });
112 } else { 115 } else {
113 res.add_file_fixture(entry); 116 res.add_file_fixture(entry);
114 } 117 }
@@ -123,19 +126,12 @@ impl MockAnalysis {
123 file_id 126 file_id
124 } 127 }
125 128
126 fn add_file_fixture_with_position(&mut self, mut fixture: Fixture) -> FilePosition {
127 let (offset, text) = extract_offset(&fixture.text);
128 fixture.text = text;
129 let file_id = self.next_id();
130 self.files.push(MockFileData::from(fixture));
131 FilePosition { file_id, offset }
132 }
133
134 pub fn add_file(&mut self, path: &str, text: &str) -> FileId { 129 pub fn add_file(&mut self, path: &str, text: &str) -> FileId {
135 let file_id = self.next_id(); 130 let file_id = self.next_id();
136 self.files.push(MockFileData::new(path.to_string(), text.to_string())); 131 self.files.push(MockFileData::new(path.to_string(), text.to_string()));
137 file_id 132 file_id
138 } 133 }
134
139 fn add_file_with_range(&mut self, path: &str, text: &str) -> FileRange { 135 fn add_file_with_range(&mut self, path: &str, text: &str) -> FileRange {
140 let (range, text) = extract_range(text); 136 let (range, text) = extract_range(text);
141 let file_id = self.next_id(); 137 let file_id = self.next_id();