diff options
Diffstat (limited to 'crates/ra_analysis/src/mock_analysis.rs')
-rw-r--r-- | crates/ra_analysis/src/mock_analysis.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/crates/ra_analysis/src/mock_analysis.rs b/crates/ra_analysis/src/mock_analysis.rs index f72911192..76100f548 100644 --- a/crates/ra_analysis/src/mock_analysis.rs +++ b/crates/ra_analysis/src/mock_analysis.rs | |||
@@ -1,13 +1,10 @@ | |||
1 | |||
2 | use std::sync::Arc; | 1 | use std::sync::Arc; |
3 | 2 | ||
4 | use relative_path::{RelativePath, RelativePathBuf}; | ||
5 | use ra_syntax::TextUnit; | 3 | use ra_syntax::TextUnit; |
4 | use relative_path::{RelativePath, RelativePathBuf}; | ||
6 | use test_utils::{extract_offset, parse_fixture, CURSOR_MARKER}; | 5 | use test_utils::{extract_offset, parse_fixture, CURSOR_MARKER}; |
7 | 6 | ||
8 | use crate::{ | 7 | use crate::{Analysis, AnalysisChange, AnalysisHost, FileId, FileResolver}; |
9 | AnalysisChange, Analysis, AnalysisHost, FileId, FileResolver, | ||
10 | }; | ||
11 | 8 | ||
12 | #[derive(Debug)] | 9 | #[derive(Debug)] |
13 | pub struct FilePosition { | 10 | pub struct FilePosition { |
@@ -51,7 +48,10 @@ impl MockAnalysis { | |||
51 | let mut res = MockAnalysis::new(); | 48 | let mut res = MockAnalysis::new(); |
52 | for entry in parse_fixture(fixture) { | 49 | for entry in parse_fixture(fixture) { |
53 | if entry.text.contains(CURSOR_MARKER) { | 50 | if entry.text.contains(CURSOR_MARKER) { |
54 | assert!(position.is_none(), "only one marker (<|>) per fixture is allowed"); | 51 | assert!( |
52 | position.is_none(), | ||
53 | "only one marker (<|>) per fixture is allowed" | ||
54 | ); | ||
55 | position = Some(res.add_file_with_position(&entry.meta, &entry.text)); | 55 | position = Some(res.add_file_with_position(&entry.meta, &entry.text)); |
56 | } else { | 56 | } else { |
57 | res.add_file(&entry.meta, &entry.text); | 57 | res.add_file(&entry.meta, &entry.text); |
@@ -73,7 +73,10 @@ impl MockAnalysis { | |||
73 | FilePosition { file_id, offset } | 73 | FilePosition { file_id, offset } |
74 | } | 74 | } |
75 | pub fn id_of(&self, path: &str) -> FileId { | 75 | pub fn id_of(&self, path: &str) -> FileId { |
76 | let (idx, _) = self.files.iter().enumerate() | 76 | let (idx, _) = self |
77 | .files | ||
78 | .iter() | ||
79 | .enumerate() | ||
77 | .find(|(_, (p, _text))| path == p) | 80 | .find(|(_, (p, _text))| path == p) |
78 | .expect("no file in this mock"); | 81 | .expect("no file in this mock"); |
79 | FileId(idx as u32 + 1) | 82 | FileId(idx as u32 + 1) |