diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-09 13:45:24 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-09 13:45:24 +0100 |
commit | 6132111f87a6891db28ce37909607034c228f7a9 (patch) | |
tree | 364b2e0662bb9fe7b0d4af4e933c62cac596d772 /crates/ra_ide/src/mock_analysis.rs | |
parent | 7566d7da8ab035a286f82a60b8e2c679158bc56c (diff) | |
parent | 117392e879f2732aacd029189de844bda286df2c (diff) |
Merge #5281
5281: Remove insta from ra_ide r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
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); |