diff options
Diffstat (limited to 'crates/ra_ide/src/mock_analysis.rs')
-rw-r--r-- | crates/ra_ide/src/mock_analysis.rs | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/crates/ra_ide/src/mock_analysis.rs b/crates/ra_ide/src/mock_analysis.rs index a393d3dba..b28054688 100644 --- a/crates/ra_ide/src/mock_analysis.rs +++ b/crates/ra_ide/src/mock_analysis.rs | |||
@@ -71,20 +71,13 @@ impl MockAnalysis { | |||
71 | } | 71 | } |
72 | 72 | ||
73 | pub fn id_of(&self, path: &str) -> FileId { | 73 | pub fn id_of(&self, path: &str) -> FileId { |
74 | let (idx, _) = self | 74 | let (file_id, _) = |
75 | .files | 75 | self.files().find(|(_, data)| path == data.path).expect("no file in this mock"); |
76 | .iter() | 76 | file_id |
77 | .enumerate() | ||
78 | .find(|(_, data)| path == data.path) | ||
79 | .expect("no file in this mock"); | ||
80 | FileId(idx as u32 + 1) | ||
81 | } | 77 | } |
82 | pub fn annotations(&self) -> Vec<(FileRange, String)> { | 78 | pub fn annotations(&self) -> Vec<(FileRange, String)> { |
83 | self.files | 79 | self.files() |
84 | .iter() | 80 | .flat_map(|(file_id, fixture)| { |
85 | .enumerate() | ||
86 | .flat_map(|(idx, fixture)| { | ||
87 | let file_id = FileId(idx as u32 + 1); | ||
88 | let annotations = extract_annotations(&fixture.text); | 81 | let annotations = extract_annotations(&fixture.text); |
89 | annotations | 82 | annotations |
90 | .into_iter() | 83 | .into_iter() |
@@ -92,6 +85,9 @@ impl MockAnalysis { | |||
92 | }) | 85 | }) |
93 | .collect() | 86 | .collect() |
94 | } | 87 | } |
88 | pub fn files(&self) -> impl Iterator<Item = (FileId, &Fixture)> + '_ { | ||
89 | self.files.iter().enumerate().map(|(idx, fixture)| (FileId(idx as u32 + 1), fixture)) | ||
90 | } | ||
95 | pub fn annotation(&self) -> (FileRange, String) { | 91 | pub fn annotation(&self) -> (FileRange, String) { |
96 | let mut all = self.annotations(); | 92 | let mut all = self.annotations(); |
97 | assert_eq!(all.len(), 1); | 93 | assert_eq!(all.len(), 1); |