diff options
author | Hirokazu Hata <[email protected]> | 2019-01-03 09:27:02 +0000 |
---|---|---|
committer | Hirokazu Hata <[email protected]> | 2019-01-03 09:27:02 +0000 |
commit | f99e96698c81a731842ef21ae564470a7d391046 (patch) | |
tree | 58c2be0c0b8bce548cb51c32f9777666785e8407 /crates/ra_analysis | |
parent | f5992964edb0e6dba7970c344b46bfd75f57e9a0 (diff) |
Remove unnecessary mock functions
Diffstat (limited to 'crates/ra_analysis')
-rw-r--r-- | crates/ra_analysis/src/mock_analysis.rs | 28 |
1 files changed, 1 insertions, 27 deletions
diff --git a/crates/ra_analysis/src/mock_analysis.rs b/crates/ra_analysis/src/mock_analysis.rs index b37371499..960529404 100644 --- a/crates/ra_analysis/src/mock_analysis.rs +++ b/crates/ra_analysis/src/mock_analysis.rs | |||
@@ -55,26 +55,6 @@ impl MockAnalysis { | |||
55 | (res, position) | 55 | (res, position) |
56 | } | 56 | } |
57 | 57 | ||
58 | /// Same as `with_files`, but requires that a single file contains two `<|>` marker, | ||
59 | /// whose range is also returned. | ||
60 | pub fn with_files_and_range(fixture: &str) -> (MockAnalysis, FileRange) { | ||
61 | let mut range = None; | ||
62 | let mut res = MockAnalysis::new(); | ||
63 | for entry in parse_fixture(fixture) { | ||
64 | if entry.text.contains(CURSOR_MARKER) { | ||
65 | assert!( | ||
66 | range.is_none(), | ||
67 | "only two marker (<|>) per fixture is allowed" | ||
68 | ); | ||
69 | range = Some(res.add_file_with_range(&entry.meta, &entry.text)); | ||
70 | } else { | ||
71 | res.add_file(&entry.meta, &entry.text); | ||
72 | } | ||
73 | } | ||
74 | let range = range.expect("expected two marker (<|>)"); | ||
75 | (res, range) | ||
76 | } | ||
77 | |||
78 | pub fn add_file(&mut self, path: &str, text: &str) -> FileId { | 58 | pub fn add_file(&mut self, path: &str, text: &str) -> FileId { |
79 | let file_id = FileId((self.files.len() + 1) as u32); | 59 | let file_id = FileId((self.files.len() + 1) as u32); |
80 | self.files.push((path.to_string(), text.to_string())); | 60 | self.files.push((path.to_string(), text.to_string())); |
@@ -122,18 +102,12 @@ impl MockAnalysis { | |||
122 | } | 102 | } |
123 | } | 103 | } |
124 | 104 | ||
125 | /// Creates analysis from a multi-file fixture, returns positions marked with a <|>. | 105 | /// Creates analysis from a multi-file fixture, returns positions marked with <|>. |
126 | pub fn analysis_and_position(fixture: &str) -> (Analysis, FilePosition) { | 106 | pub fn analysis_and_position(fixture: &str) -> (Analysis, FilePosition) { |
127 | let (mock, position) = MockAnalysis::with_files_and_position(fixture); | 107 | let (mock, position) = MockAnalysis::with_files_and_position(fixture); |
128 | (mock.analysis(), position) | 108 | (mock.analysis(), position) |
129 | } | 109 | } |
130 | 110 | ||
131 | /// Creates analysis from a multi-file fixture, returns ranges marked with two <|>. | ||
132 | pub fn analysis_and_range(fixture: &str) -> (Analysis, FileRange) { | ||
133 | let (mock, range) = MockAnalysis::with_files_and_range(fixture); | ||
134 | (mock.analysis(), range) | ||
135 | } | ||
136 | |||
137 | /// Creates analysis for a single file. | 111 | /// Creates analysis for a single file. |
138 | pub fn single_file(code: &str) -> (Analysis, FileId) { | 112 | pub fn single_file(code: &str) -> (Analysis, FileId) { |
139 | let mut mock = MockAnalysis::new(); | 113 | let mut mock = MockAnalysis::new(); |