diff options
Diffstat (limited to 'crates/ra_ide/src/mock_analysis.rs')
-rw-r--r-- | crates/ra_ide/src/mock_analysis.rs | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/crates/ra_ide/src/mock_analysis.rs b/crates/ra_ide/src/mock_analysis.rs index 981bdf924..e99c2b0a3 100644 --- a/crates/ra_ide/src/mock_analysis.rs +++ b/crates/ra_ide/src/mock_analysis.rs | |||
@@ -117,13 +117,13 @@ impl MockAnalysis { | |||
117 | (res, position) | 117 | (res, position) |
118 | } | 118 | } |
119 | 119 | ||
120 | pub fn add_file_fixture(&mut self, fixture: Fixture) -> FileId { | 120 | fn add_file_fixture(&mut self, fixture: Fixture) -> FileId { |
121 | let file_id = self.next_id(); | 121 | let file_id = self.next_id(); |
122 | self.files.push(MockFileData::from(fixture)); | 122 | self.files.push(MockFileData::from(fixture)); |
123 | file_id | 123 | file_id |
124 | } | 124 | } |
125 | 125 | ||
126 | pub fn add_file_fixture_with_position(&mut self, mut fixture: Fixture) -> FilePosition { | 126 | fn add_file_fixture_with_position(&mut self, mut fixture: Fixture) -> FilePosition { |
127 | let (offset, text) = extract_offset(&fixture.text); | 127 | let (offset, text) = extract_offset(&fixture.text); |
128 | fixture.text = text; | 128 | fixture.text = text; |
129 | let file_id = self.next_id(); | 129 | let file_id = self.next_id(); |
@@ -136,13 +136,7 @@ impl MockAnalysis { | |||
136 | self.files.push(MockFileData::new(path.to_string(), text.to_string())); | 136 | self.files.push(MockFileData::new(path.to_string(), text.to_string())); |
137 | file_id | 137 | file_id |
138 | } | 138 | } |
139 | pub fn add_file_with_position(&mut self, path: &str, text: &str) -> FilePosition { | 139 | fn add_file_with_range(&mut self, path: &str, text: &str) -> FileRange { |
140 | let (offset, text) = extract_offset(text); | ||
141 | let file_id = self.next_id(); | ||
142 | self.files.push(MockFileData::new(path.to_string(), text)); | ||
143 | FilePosition { file_id, offset } | ||
144 | } | ||
145 | pub fn add_file_with_range(&mut self, path: &str, text: &str) -> FileRange { | ||
146 | let (range, text) = extract_range(text); | 140 | let (range, text) = extract_range(text); |
147 | let file_id = self.next_id(); | 141 | let file_id = self.next_id(); |
148 | self.files.push(MockFileData::new(path.to_string(), text)); | 142 | self.files.push(MockFileData::new(path.to_string(), text)); |
@@ -222,18 +216,11 @@ pub fn analysis_and_position(ra_fixture: &str) -> (Analysis, FilePosition) { | |||
222 | 216 | ||
223 | /// Creates analysis for a single file. | 217 | /// Creates analysis for a single file. |
224 | pub fn single_file(ra_fixture: &str) -> (Analysis, FileId) { | 218 | pub fn single_file(ra_fixture: &str) -> (Analysis, FileId) { |
225 | let mut mock = MockAnalysis::new(); | 219 | let mock = MockAnalysis::with_files(ra_fixture); |
226 | let file_id = mock.add_file("/main.rs", ra_fixture); | 220 | let file_id = mock.id_of("/main.rs"); |
227 | (mock.analysis(), file_id) | 221 | (mock.analysis(), file_id) |
228 | } | 222 | } |
229 | 223 | ||
230 | /// Creates analysis for a single file, returns position marked with <|>. | ||
231 | pub fn single_file_with_position(ra_fixture: &str) -> (Analysis, FilePosition) { | ||
232 | let mut mock = MockAnalysis::new(); | ||
233 | let pos = mock.add_file_with_position("/main.rs", ra_fixture); | ||
234 | (mock.analysis(), pos) | ||
235 | } | ||
236 | |||
237 | /// Creates analysis for a single file, returns range marked with a pair of <|>. | 224 | /// Creates analysis for a single file, returns range marked with a pair of <|>. |
238 | pub fn single_file_with_range(ra_fixture: &str) -> (Analysis, FileRange) { | 225 | pub fn single_file_with_range(ra_fixture: &str) -> (Analysis, FileRange) { |
239 | let mut mock = MockAnalysis::new(); | 226 | let mut mock = MockAnalysis::new(); |