From fb0bc941a504e2ef5cf8766e0faa58bfeaecc712 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 9 Jul 2020 14:33:03 +0200 Subject: Cleanup diagnostics tests --- crates/ra_ide/src/mock_analysis.rs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'crates/ra_ide/src/mock_analysis.rs') 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 { } pub fn id_of(&self, path: &str) -> FileId { - let (idx, _) = self - .files - .iter() - .enumerate() - .find(|(_, data)| path == data.path) - .expect("no file in this mock"); - FileId(idx as u32 + 1) + let (file_id, _) = + self.files().find(|(_, data)| path == data.path).expect("no file in this mock"); + file_id } pub fn annotations(&self) -> Vec<(FileRange, String)> { - self.files - .iter() - .enumerate() - .flat_map(|(idx, fixture)| { - let file_id = FileId(idx as u32 + 1); + self.files() + .flat_map(|(file_id, fixture)| { let annotations = extract_annotations(&fixture.text); annotations .into_iter() @@ -92,6 +85,9 @@ impl MockAnalysis { }) .collect() } + pub fn files(&self) -> impl Iterator + '_ { + self.files.iter().enumerate().map(|(idx, fixture)| (FileId(idx as u32 + 1), fixture)) + } pub fn annotation(&self) -> (FileRange, String) { let mut all = self.annotations(); assert_eq!(all.len(), 1); -- cgit v1.2.3