diff options
Diffstat (limited to 'crates/ide')
23 files changed, 90 insertions, 99 deletions
diff --git a/crates/ide/src/call_hierarchy.rs b/crates/ide/src/call_hierarchy.rs index 0fb49de71..d2cf2cc7d 100644 --- a/crates/ide/src/call_hierarchy.rs +++ b/crates/ide/src/call_hierarchy.rs | |||
@@ -139,7 +139,7 @@ impl CallLocations { | |||
139 | mod tests { | 139 | mod tests { |
140 | use base_db::FilePosition; | 140 | use base_db::FilePosition; |
141 | 141 | ||
142 | use crate::mock_analysis::analysis_and_position; | 142 | use crate::fixture; |
143 | 143 | ||
144 | fn check_hierarchy( | 144 | fn check_hierarchy( |
145 | ra_fixture: &str, | 145 | ra_fixture: &str, |
@@ -147,7 +147,7 @@ mod tests { | |||
147 | expected_incoming: &[&str], | 147 | expected_incoming: &[&str], |
148 | expected_outgoing: &[&str], | 148 | expected_outgoing: &[&str], |
149 | ) { | 149 | ) { |
150 | let (analysis, pos) = analysis_and_position(ra_fixture); | 150 | let (analysis, pos) = fixture::position(ra_fixture); |
151 | 151 | ||
152 | let mut navs = analysis.call_hierarchy(pos).unwrap().unwrap().info; | 152 | let mut navs = analysis.call_hierarchy(pos).unwrap().unwrap().info; |
153 | assert_eq!(navs.len(), 1); | 153 | assert_eq!(navs.len(), 1); |
diff --git a/crates/ide/src/call_info.rs b/crates/ide/src/call_info.rs index 7e99c6b72..d7b2b926e 100644 --- a/crates/ide/src/call_info.rs +++ b/crates/ide/src/call_info.rs | |||
@@ -232,10 +232,10 @@ mod tests { | |||
232 | use expect_test::{expect, Expect}; | 232 | use expect_test::{expect, Expect}; |
233 | use test_utils::mark; | 233 | use test_utils::mark; |
234 | 234 | ||
235 | use crate::mock_analysis::analysis_and_position; | 235 | use crate::fixture; |
236 | 236 | ||
237 | fn check(ra_fixture: &str, expect: Expect) { | 237 | fn check(ra_fixture: &str, expect: Expect) { |
238 | let (analysis, position) = analysis_and_position(ra_fixture); | 238 | let (analysis, position) = fixture::position(ra_fixture); |
239 | let call_info = analysis.call_info(position).unwrap(); | 239 | let call_info = analysis.call_info(position).unwrap(); |
240 | let actual = match call_info { | 240 | let actual = match call_info { |
241 | Some(call_info) => { | 241 | Some(call_info) => { |
diff --git a/crates/ide/src/completion.rs b/crates/ide/src/completion.rs index daea2aa95..697f691b0 100644 --- a/crates/ide/src/completion.rs +++ b/crates/ide/src/completion.rs | |||
@@ -133,7 +133,7 @@ pub(crate) fn completions( | |||
133 | #[cfg(test)] | 133 | #[cfg(test)] |
134 | mod tests { | 134 | mod tests { |
135 | use crate::completion::completion_config::CompletionConfig; | 135 | use crate::completion::completion_config::CompletionConfig; |
136 | use crate::mock_analysis::analysis_and_position; | 136 | use crate::fixture; |
137 | 137 | ||
138 | struct DetailAndDocumentation<'a> { | 138 | struct DetailAndDocumentation<'a> { |
139 | detail: &'a str, | 139 | detail: &'a str, |
@@ -141,7 +141,7 @@ mod tests { | |||
141 | } | 141 | } |
142 | 142 | ||
143 | fn check_detail_and_documentation(ra_fixture: &str, expected: DetailAndDocumentation) { | 143 | fn check_detail_and_documentation(ra_fixture: &str, expected: DetailAndDocumentation) { |
144 | let (analysis, position) = analysis_and_position(ra_fixture); | 144 | let (analysis, position) = fixture::position(ra_fixture); |
145 | let config = CompletionConfig::default(); | 145 | let config = CompletionConfig::default(); |
146 | let completions = analysis.completions(&config, position).unwrap().unwrap(); | 146 | let completions = analysis.completions(&config, position).unwrap().unwrap(); |
147 | for item in completions { | 147 | for item in completions { |
diff --git a/crates/ide/src/completion/test_utils.rs b/crates/ide/src/completion/test_utils.rs index 1452d7e9e..feb8cd2a6 100644 --- a/crates/ide/src/completion/test_utils.rs +++ b/crates/ide/src/completion/test_utils.rs | |||
@@ -8,8 +8,7 @@ use test_utils::assert_eq_text; | |||
8 | 8 | ||
9 | use crate::{ | 9 | use crate::{ |
10 | completion::{completion_item::CompletionKind, CompletionConfig}, | 10 | completion::{completion_item::CompletionKind, CompletionConfig}, |
11 | mock_analysis::analysis_and_position, | 11 | fixture, CompletionItem, |
12 | CompletionItem, | ||
13 | }; | 12 | }; |
14 | 13 | ||
15 | pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> { | 14 | pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> { |
@@ -80,7 +79,7 @@ pub(crate) fn check_edit_with_config( | |||
80 | ra_fixture_after: &str, | 79 | ra_fixture_after: &str, |
81 | ) { | 80 | ) { |
82 | let ra_fixture_after = trim_indent(ra_fixture_after); | 81 | let ra_fixture_after = trim_indent(ra_fixture_after); |
83 | let (analysis, position) = analysis_and_position(ra_fixture_before); | 82 | let (analysis, position) = fixture::position(ra_fixture_before); |
84 | let completions: Vec<CompletionItem> = | 83 | let completions: Vec<CompletionItem> = |
85 | analysis.completions(&config, position).unwrap().unwrap().into(); | 84 | analysis.completions(&config, position).unwrap().unwrap().into(); |
86 | let (completion,) = completions | 85 | let (completion,) = completions |
@@ -94,7 +93,7 @@ pub(crate) fn check_edit_with_config( | |||
94 | } | 93 | } |
95 | 94 | ||
96 | pub(crate) fn check_pattern_is_applicable(code: &str, check: fn(SyntaxElement) -> bool) { | 95 | pub(crate) fn check_pattern_is_applicable(code: &str, check: fn(SyntaxElement) -> bool) { |
97 | let (analysis, pos) = analysis_and_position(code); | 96 | let (analysis, pos) = fixture::position(code); |
98 | analysis | 97 | analysis |
99 | .with_db(|db| { | 98 | .with_db(|db| { |
100 | let sema = Semantics::new(db); | 99 | let sema = Semantics::new(db); |
@@ -109,6 +108,6 @@ pub(crate) fn get_all_completion_items( | |||
109 | config: CompletionConfig, | 108 | config: CompletionConfig, |
110 | code: &str, | 109 | code: &str, |
111 | ) -> Vec<CompletionItem> { | 110 | ) -> Vec<CompletionItem> { |
112 | let (analysis, position) = analysis_and_position(code); | 111 | let (analysis, position) = fixture::position(code); |
113 | analysis.completions(&config, position).unwrap().unwrap().into() | 112 | analysis.completions(&config, position).unwrap().unwrap().into() |
114 | } | 113 | } |
diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index 906f72a42..f5d627b6e 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs | |||
@@ -218,10 +218,7 @@ mod tests { | |||
218 | use stdx::trim_indent; | 218 | use stdx::trim_indent; |
219 | use test_utils::assert_eq_text; | 219 | use test_utils::assert_eq_text; |
220 | 220 | ||
221 | use crate::{ | 221 | use crate::{fixture, DiagnosticsConfig}; |
222 | mock_analysis::{analysis_and_position, many_files, single_file}, | ||
223 | DiagnosticsConfig, | ||
224 | }; | ||
225 | 222 | ||
226 | /// Takes a multi-file input fixture with annotated cursor positions, | 223 | /// Takes a multi-file input fixture with annotated cursor positions, |
227 | /// and checks that: | 224 | /// and checks that: |
@@ -231,7 +228,7 @@ mod tests { | |||
231 | fn check_fix(ra_fixture_before: &str, ra_fixture_after: &str) { | 228 | fn check_fix(ra_fixture_before: &str, ra_fixture_after: &str) { |
232 | let after = trim_indent(ra_fixture_after); | 229 | let after = trim_indent(ra_fixture_after); |
233 | 230 | ||
234 | let (analysis, file_position) = analysis_and_position(ra_fixture_before); | 231 | let (analysis, file_position) = fixture::position(ra_fixture_before); |
235 | let diagnostic = analysis | 232 | let diagnostic = analysis |
236 | .diagnostics(&DiagnosticsConfig::default(), file_position.file_id) | 233 | .diagnostics(&DiagnosticsConfig::default(), file_position.file_id) |
237 | .unwrap() | 234 | .unwrap() |
@@ -260,7 +257,7 @@ mod tests { | |||
260 | /// which has a fix that can apply to other files. | 257 | /// which has a fix that can apply to other files. |
261 | fn check_apply_diagnostic_fix_in_other_file(ra_fixture_before: &str, ra_fixture_after: &str) { | 258 | fn check_apply_diagnostic_fix_in_other_file(ra_fixture_before: &str, ra_fixture_after: &str) { |
262 | let ra_fixture_after = &trim_indent(ra_fixture_after); | 259 | let ra_fixture_after = &trim_indent(ra_fixture_after); |
263 | let (analysis, file_pos) = analysis_and_position(ra_fixture_before); | 260 | let (analysis, file_pos) = fixture::position(ra_fixture_before); |
264 | let current_file_id = file_pos.file_id; | 261 | let current_file_id = file_pos.file_id; |
265 | let diagnostic = analysis | 262 | let diagnostic = analysis |
266 | .diagnostics(&DiagnosticsConfig::default(), current_file_id) | 263 | .diagnostics(&DiagnosticsConfig::default(), current_file_id) |
@@ -282,7 +279,7 @@ mod tests { | |||
282 | /// Takes a multi-file input fixture with annotated cursor position and checks that no diagnostics | 279 | /// Takes a multi-file input fixture with annotated cursor position and checks that no diagnostics |
283 | /// apply to the file containing the cursor. | 280 | /// apply to the file containing the cursor. |
284 | fn check_no_diagnostics(ra_fixture: &str) { | 281 | fn check_no_diagnostics(ra_fixture: &str) { |
285 | let (analysis, files) = many_files(ra_fixture); | 282 | let (analysis, files) = fixture::files(ra_fixture); |
286 | let diagnostics = files | 283 | let diagnostics = files |
287 | .into_iter() | 284 | .into_iter() |
288 | .flat_map(|file_id| { | 285 | .flat_map(|file_id| { |
@@ -293,7 +290,7 @@ mod tests { | |||
293 | } | 290 | } |
294 | 291 | ||
295 | fn check_expect(ra_fixture: &str, expect: Expect) { | 292 | fn check_expect(ra_fixture: &str, expect: Expect) { |
296 | let (analysis, file_id) = single_file(ra_fixture); | 293 | let (analysis, file_id) = fixture::file(ra_fixture); |
297 | let diagnostics = analysis.diagnostics(&DiagnosticsConfig::default(), file_id).unwrap(); | 294 | let diagnostics = analysis.diagnostics(&DiagnosticsConfig::default(), file_id).unwrap(); |
298 | expect.assert_debug_eq(&diagnostics) | 295 | expect.assert_debug_eq(&diagnostics) |
299 | } | 296 | } |
@@ -785,7 +782,7 @@ struct Foo { | |||
785 | let mut config = DiagnosticsConfig::default(); | 782 | let mut config = DiagnosticsConfig::default(); |
786 | config.disabled.insert("unresolved-module".into()); | 783 | config.disabled.insert("unresolved-module".into()); |
787 | 784 | ||
788 | let (analysis, file_id) = single_file(r#"mod foo;"#); | 785 | let (analysis, file_id) = fixture::file(r#"mod foo;"#); |
789 | 786 | ||
790 | let diagnostics = analysis.diagnostics(&config, file_id).unwrap(); | 787 | let diagnostics = analysis.diagnostics(&config, file_id).unwrap(); |
791 | assert!(diagnostics.is_empty()); | 788 | assert!(diagnostics.is_empty()); |
diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index bace2f3a3..cf9d617dc 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs | |||
@@ -423,11 +423,11 @@ pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> | |||
423 | mod tests { | 423 | mod tests { |
424 | use expect_test::expect; | 424 | use expect_test::expect; |
425 | 425 | ||
426 | use crate::{mock_analysis::single_file, Query}; | 426 | use crate::{fixture, Query}; |
427 | 427 | ||
428 | #[test] | 428 | #[test] |
429 | fn test_nav_for_symbol() { | 429 | fn test_nav_for_symbol() { |
430 | let (analysis, _) = single_file( | 430 | let (analysis, _) = fixture::file( |
431 | r#" | 431 | r#" |
432 | enum FooInner { } | 432 | enum FooInner { } |
433 | fn foo() { enum FooInner { } } | 433 | fn foo() { enum FooInner { } } |
@@ -478,7 +478,7 @@ fn foo() { enum FooInner { } } | |||
478 | 478 | ||
479 | #[test] | 479 | #[test] |
480 | fn test_world_symbols_are_case_sensitive() { | 480 | fn test_world_symbols_are_case_sensitive() { |
481 | let (analysis, _) = single_file( | 481 | let (analysis, _) = fixture::file( |
482 | r#" | 482 | r#" |
483 | fn foo() {} | 483 | fn foo() {} |
484 | struct Foo; | 484 | struct Foo; |
diff --git a/crates/ide/src/expand_macro.rs b/crates/ide/src/expand_macro.rs index 8a285bcf7..8d75e0f05 100644 --- a/crates/ide/src/expand_macro.rs +++ b/crates/ide/src/expand_macro.rs | |||
@@ -122,10 +122,10 @@ fn insert_whitespaces(syn: SyntaxNode) -> String { | |||
122 | mod tests { | 122 | mod tests { |
123 | use expect_test::{expect, Expect}; | 123 | use expect_test::{expect, Expect}; |
124 | 124 | ||
125 | use crate::mock_analysis::analysis_and_position; | 125 | use crate::fixture; |
126 | 126 | ||
127 | fn check(ra_fixture: &str, expect: Expect) { | 127 | fn check(ra_fixture: &str, expect: Expect) { |
128 | let (analysis, pos) = analysis_and_position(ra_fixture); | 128 | let (analysis, pos) = fixture::position(ra_fixture); |
129 | let expansion = analysis.expand_macro(pos).unwrap().unwrap(); | 129 | let expansion = analysis.expand_macro(pos).unwrap().unwrap(); |
130 | let actual = format!("{}\n{}", expansion.name, expansion.expansion); | 130 | let actual = format!("{}\n{}", expansion.name, expansion.expansion); |
131 | expect.assert_eq(&actual); | 131 | expect.assert_eq(&actual); |
diff --git a/crates/ide/src/extend_selection.rs b/crates/ide/src/extend_selection.rs index 34563a026..3ee0af8ad 100644 --- a/crates/ide/src/extend_selection.rs +++ b/crates/ide/src/extend_selection.rs | |||
@@ -315,12 +315,12 @@ fn adj_comments(comment: &ast::Comment, dir: Direction) -> ast::Comment { | |||
315 | 315 | ||
316 | #[cfg(test)] | 316 | #[cfg(test)] |
317 | mod tests { | 317 | mod tests { |
318 | use crate::mock_analysis::analysis_and_position; | 318 | use crate::fixture; |
319 | 319 | ||
320 | use super::*; | 320 | use super::*; |
321 | 321 | ||
322 | fn do_check(before: &str, afters: &[&str]) { | 322 | fn do_check(before: &str, afters: &[&str]) { |
323 | let (analysis, position) = analysis_and_position(&before); | 323 | let (analysis, position) = fixture::position(&before); |
324 | let before = analysis.file_text(position.file_id).unwrap(); | 324 | let before = analysis.file_text(position.file_id).unwrap(); |
325 | let range = TextRange::empty(position.offset); | 325 | let range = TextRange::empty(position.offset); |
326 | let mut frange = FileRange { file_id: position.file_id, range }; | 326 | let mut frange = FileRange { file_id: position.file_id, range }; |
diff --git a/crates/ide/src/mock_analysis.rs b/crates/ide/src/fixture.rs index 838547599..ed06689f0 100644 --- a/crates/ide/src/mock_analysis.rs +++ b/crates/ide/src/fixture.rs | |||
@@ -1,41 +1,40 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! Utilities for creating `Analysis` instances for tests. |
2 | |||
3 | use base_db::fixture::ChangeFixture; | 2 | use base_db::fixture::ChangeFixture; |
4 | use test_utils::{extract_annotations, RangeOrOffset}; | 3 | use test_utils::{extract_annotations, RangeOrOffset}; |
5 | 4 | ||
6 | use crate::{Analysis, AnalysisHost, FileId, FilePosition, FileRange}; | 5 | use crate::{Analysis, AnalysisHost, FileId, FilePosition, FileRange}; |
7 | 6 | ||
8 | /// Creates analysis from a multi-file fixture, returns positions marked with <|>. | 7 | /// Creates analysis for a single file. |
9 | pub(crate) fn analysis_and_position(ra_fixture: &str) -> (Analysis, FilePosition) { | 8 | pub(crate) fn file(ra_fixture: &str) -> (Analysis, FileId) { |
10 | let mut host = AnalysisHost::default(); | 9 | let mut host = AnalysisHost::default(); |
11 | let change_fixture = ChangeFixture::parse(ra_fixture); | 10 | let change_fixture = ChangeFixture::parse(ra_fixture); |
12 | host.db.apply_change(change_fixture.change); | 11 | host.db.apply_change(change_fixture.change); |
13 | let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker (<|>)"); | 12 | (host.analysis(), change_fixture.files[0]) |
14 | let offset = match range_or_offset { | ||
15 | RangeOrOffset::Range(_) => panic!(), | ||
16 | RangeOrOffset::Offset(it) => it, | ||
17 | }; | ||
18 | (host.analysis(), FilePosition { file_id, offset }) | ||
19 | } | 13 | } |
20 | 14 | ||
21 | /// Creates analysis for a single file. | 15 | /// Creates analysis for many files. |
22 | pub(crate) fn single_file(ra_fixture: &str) -> (Analysis, FileId) { | 16 | pub(crate) fn files(ra_fixture: &str) -> (Analysis, Vec<FileId>) { |
23 | let mut host = AnalysisHost::default(); | 17 | let mut host = AnalysisHost::default(); |
24 | let change_fixture = ChangeFixture::parse(ra_fixture); | 18 | let change_fixture = ChangeFixture::parse(ra_fixture); |
25 | host.db.apply_change(change_fixture.change); | 19 | host.db.apply_change(change_fixture.change); |
26 | (host.analysis(), change_fixture.files[0]) | 20 | (host.analysis(), change_fixture.files) |
27 | } | 21 | } |
28 | 22 | ||
29 | /// Creates analysis for a single file. | 23 | /// Creates analysis from a multi-file fixture, returns positions marked with <|>. |
30 | pub(crate) fn many_files(ra_fixture: &str) -> (Analysis, Vec<FileId>) { | 24 | pub(crate) fn position(ra_fixture: &str) -> (Analysis, FilePosition) { |
31 | let mut host = AnalysisHost::default(); | 25 | let mut host = AnalysisHost::default(); |
32 | let change_fixture = ChangeFixture::parse(ra_fixture); | 26 | let change_fixture = ChangeFixture::parse(ra_fixture); |
33 | host.db.apply_change(change_fixture.change); | 27 | host.db.apply_change(change_fixture.change); |
34 | (host.analysis(), change_fixture.files) | 28 | let (file_id, range_or_offset) = change_fixture.file_position.expect("expected a marker (<|>)"); |
29 | let offset = match range_or_offset { | ||
30 | RangeOrOffset::Range(_) => panic!(), | ||
31 | RangeOrOffset::Offset(it) => it, | ||
32 | }; | ||
33 | (host.analysis(), FilePosition { file_id, offset }) | ||
35 | } | 34 | } |
36 | 35 | ||
37 | /// Creates analysis for a single file, returns range marked with a pair of <|>. | 36 | /// Creates analysis for a single file, returns range marked with a pair of <|>. |
38 | pub(crate) fn analysis_and_range(ra_fixture: &str) -> (Analysis, FileRange) { | 37 | pub(crate) fn range(ra_fixture: &str) -> (Analysis, FileRange) { |
39 | let mut host = AnalysisHost::default(); | 38 | let mut host = AnalysisHost::default(); |
40 | let change_fixture = ChangeFixture::parse(ra_fixture); | 39 | let change_fixture = ChangeFixture::parse(ra_fixture); |
41 | host.db.apply_change(change_fixture.change); | 40 | host.db.apply_change(change_fixture.change); |
@@ -48,9 +47,7 @@ pub(crate) fn analysis_and_range(ra_fixture: &str) -> (Analysis, FileRange) { | |||
48 | } | 47 | } |
49 | 48 | ||
50 | /// Creates analysis from a multi-file fixture, returns positions marked with <|>. | 49 | /// Creates analysis from a multi-file fixture, returns positions marked with <|>. |
51 | pub(crate) fn analysis_and_annotations( | 50 | pub(crate) fn annotations(ra_fixture: &str) -> (Analysis, FilePosition, Vec<(FileRange, String)>) { |
52 | ra_fixture: &str, | ||
53 | ) -> (Analysis, FilePosition, Vec<(FileRange, String)>) { | ||
54 | let mut host = AnalysisHost::default(); | 51 | let mut host = AnalysisHost::default(); |
55 | let change_fixture = ChangeFixture::parse(ra_fixture); | 52 | let change_fixture = ChangeFixture::parse(ra_fixture); |
56 | host.db.apply_change(change_fixture.change); | 53 | host.db.apply_change(change_fixture.change); |
diff --git a/crates/ide/src/fn_references.rs b/crates/ide/src/fn_references.rs index 1989a562b..459f201ed 100644 --- a/crates/ide/src/fn_references.rs +++ b/crates/ide/src/fn_references.rs | |||
@@ -25,15 +25,14 @@ fn method_range(item: SyntaxNode, file_id: FileId) -> Option<FileRange> { | |||
25 | 25 | ||
26 | #[cfg(test)] | 26 | #[cfg(test)] |
27 | mod tests { | 27 | mod tests { |
28 | use crate::mock_analysis::analysis_and_position; | 28 | use crate::fixture; |
29 | use crate::{FileRange, TextSize}; | 29 | use crate::{FileRange, TextSize}; |
30 | use std::ops::RangeInclusive; | 30 | use std::ops::RangeInclusive; |
31 | 31 | ||
32 | #[test] | 32 | #[test] |
33 | fn test_find_all_methods() { | 33 | fn test_find_all_methods() { |
34 | let (analysis, pos) = analysis_and_position( | 34 | let (analysis, pos) = fixture::position( |
35 | r#" | 35 | r#" |
36 | //- /lib.rs | ||
37 | fn private_fn() {<|>} | 36 | fn private_fn() {<|>} |
38 | 37 | ||
39 | pub fn pub_fn() {} | 38 | pub fn pub_fn() {} |
@@ -48,9 +47,8 @@ mod tests { | |||
48 | 47 | ||
49 | #[test] | 48 | #[test] |
50 | fn test_find_trait_methods() { | 49 | fn test_find_trait_methods() { |
51 | let (analysis, pos) = analysis_and_position( | 50 | let (analysis, pos) = fixture::position( |
52 | r#" | 51 | r#" |
53 | //- /lib.rs | ||
54 | trait Foo { | 52 | trait Foo { |
55 | fn bar() {<|>} | 53 | fn bar() {<|>} |
56 | fn baz() {} | 54 | fn baz() {} |
@@ -64,7 +62,7 @@ mod tests { | |||
64 | 62 | ||
65 | #[test] | 63 | #[test] |
66 | fn test_skip_tests() { | 64 | fn test_skip_tests() { |
67 | let (analysis, pos) = analysis_and_position( | 65 | let (analysis, pos) = fixture::position( |
68 | r#" | 66 | r#" |
69 | //- /lib.rs | 67 | //- /lib.rs |
70 | #[test] | 68 | #[test] |
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs index 5fd2d1e9a..582bf4837 100644 --- a/crates/ide/src/goto_definition.rs +++ b/crates/ide/src/goto_definition.rs | |||
@@ -103,10 +103,10 @@ mod tests { | |||
103 | use base_db::FileRange; | 103 | use base_db::FileRange; |
104 | use syntax::{TextRange, TextSize}; | 104 | use syntax::{TextRange, TextSize}; |
105 | 105 | ||
106 | use crate::mock_analysis::analysis_and_annotations; | 106 | use crate::fixture; |
107 | 107 | ||
108 | fn check(ra_fixture: &str) { | 108 | fn check(ra_fixture: &str) { |
109 | let (analysis, position, mut annotations) = analysis_and_annotations(ra_fixture); | 109 | let (analysis, position, mut annotations) = fixture::annotations(ra_fixture); |
110 | let (mut expected, data) = annotations.pop().unwrap(); | 110 | let (mut expected, data) = annotations.pop().unwrap(); |
111 | match data.as_str() { | 111 | match data.as_str() { |
112 | "" => (), | 112 | "" => (), |
diff --git a/crates/ide/src/goto_implementation.rs b/crates/ide/src/goto_implementation.rs index a88854d05..6c586bbd1 100644 --- a/crates/ide/src/goto_implementation.rs +++ b/crates/ide/src/goto_implementation.rs | |||
@@ -76,10 +76,10 @@ fn impls_for_trait( | |||
76 | mod tests { | 76 | mod tests { |
77 | use base_db::FileRange; | 77 | use base_db::FileRange; |
78 | 78 | ||
79 | use crate::mock_analysis::analysis_and_annotations; | 79 | use crate::fixture; |
80 | 80 | ||
81 | fn check(ra_fixture: &str) { | 81 | fn check(ra_fixture: &str) { |
82 | let (analysis, position, annotations) = analysis_and_annotations(ra_fixture); | 82 | let (analysis, position, annotations) = fixture::annotations(ra_fixture); |
83 | 83 | ||
84 | let navs = analysis.goto_implementation(position).unwrap().unwrap().info; | 84 | let navs = analysis.goto_implementation(position).unwrap().unwrap().info; |
85 | 85 | ||
diff --git a/crates/ide/src/goto_type_definition.rs b/crates/ide/src/goto_type_definition.rs index b55a2dbb1..6d0df04dd 100644 --- a/crates/ide/src/goto_type_definition.rs +++ b/crates/ide/src/goto_type_definition.rs | |||
@@ -56,10 +56,10 @@ fn pick_best(tokens: TokenAtOffset<SyntaxToken>) -> Option<SyntaxToken> { | |||
56 | mod tests { | 56 | mod tests { |
57 | use base_db::FileRange; | 57 | use base_db::FileRange; |
58 | 58 | ||
59 | use crate::mock_analysis::analysis_and_annotations; | 59 | use crate::fixture; |
60 | 60 | ||
61 | fn check(ra_fixture: &str) { | 61 | fn check(ra_fixture: &str) { |
62 | let (analysis, position, mut annotations) = analysis_and_annotations(ra_fixture); | 62 | let (analysis, position, mut annotations) = fixture::annotations(ra_fixture); |
63 | let (expected, data) = annotations.pop().unwrap(); | 63 | let (expected, data) = annotations.pop().unwrap(); |
64 | assert!(data.is_empty()); | 64 | assert!(data.is_empty()); |
65 | 65 | ||
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs index 008061a39..9cf02f0a3 100644 --- a/crates/ide/src/hover.rs +++ b/crates/ide/src/hover.rs | |||
@@ -377,17 +377,17 @@ mod tests { | |||
377 | use base_db::FileLoader; | 377 | use base_db::FileLoader; |
378 | use expect_test::{expect, Expect}; | 378 | use expect_test::{expect, Expect}; |
379 | 379 | ||
380 | use crate::mock_analysis::analysis_and_position; | 380 | use crate::fixture; |
381 | 381 | ||
382 | use super::*; | 382 | use super::*; |
383 | 383 | ||
384 | fn check_hover_no_result(ra_fixture: &str) { | 384 | fn check_hover_no_result(ra_fixture: &str) { |
385 | let (analysis, position) = analysis_and_position(ra_fixture); | 385 | let (analysis, position) = fixture::position(ra_fixture); |
386 | assert!(analysis.hover(position, true).unwrap().is_none()); | 386 | assert!(analysis.hover(position, true).unwrap().is_none()); |
387 | } | 387 | } |
388 | 388 | ||
389 | fn check(ra_fixture: &str, expect: Expect) { | 389 | fn check(ra_fixture: &str, expect: Expect) { |
390 | let (analysis, position) = analysis_and_position(ra_fixture); | 390 | let (analysis, position) = fixture::position(ra_fixture); |
391 | let hover = analysis.hover(position, true).unwrap().unwrap(); | 391 | let hover = analysis.hover(position, true).unwrap().unwrap(); |
392 | 392 | ||
393 | let content = analysis.db.file_text(position.file_id); | 393 | let content = analysis.db.file_text(position.file_id); |
@@ -398,7 +398,7 @@ mod tests { | |||
398 | } | 398 | } |
399 | 399 | ||
400 | fn check_hover_no_links(ra_fixture: &str, expect: Expect) { | 400 | fn check_hover_no_links(ra_fixture: &str, expect: Expect) { |
401 | let (analysis, position) = analysis_and_position(ra_fixture); | 401 | let (analysis, position) = fixture::position(ra_fixture); |
402 | let hover = analysis.hover(position, false).unwrap().unwrap(); | 402 | let hover = analysis.hover(position, false).unwrap().unwrap(); |
403 | 403 | ||
404 | let content = analysis.db.file_text(position.file_id); | 404 | let content = analysis.db.file_text(position.file_id); |
@@ -409,7 +409,7 @@ mod tests { | |||
409 | } | 409 | } |
410 | 410 | ||
411 | fn check_actions(ra_fixture: &str, expect: Expect) { | 411 | fn check_actions(ra_fixture: &str, expect: Expect) { |
412 | let (analysis, position) = analysis_and_position(ra_fixture); | 412 | let (analysis, position) = fixture::position(ra_fixture); |
413 | let hover = analysis.hover(position, true).unwrap().unwrap(); | 413 | let hover = analysis.hover(position, true).unwrap().unwrap(); |
414 | expect.assert_debug_eq(&hover.info.actions) | 414 | expect.assert_debug_eq(&hover.info.actions) |
415 | } | 415 | } |
@@ -963,7 +963,7 @@ impl Thing { | |||
963 | "#]], | 963 | "#]], |
964 | ) | 964 | ) |
965 | } /* FIXME: revive these tests | 965 | } /* FIXME: revive these tests |
966 | let (analysis, position) = analysis_and_position( | 966 | let (analysis, position) = fixture::position( |
967 | " | 967 | " |
968 | struct Thing { x: u32 } | 968 | struct Thing { x: u32 } |
969 | impl Thing { | 969 | impl Thing { |
@@ -977,7 +977,7 @@ impl Thing { | |||
977 | let hover = analysis.hover(position).unwrap().unwrap(); | 977 | let hover = analysis.hover(position).unwrap().unwrap(); |
978 | assert_eq!(trim_markup(&hover.info.markup.as_str()), ("Thing")); | 978 | assert_eq!(trim_markup(&hover.info.markup.as_str()), ("Thing")); |
979 | 979 | ||
980 | let (analysis, position) = analysis_and_position( | 980 | let (analysis, position) = fixture::position( |
981 | " | 981 | " |
982 | enum Thing { A } | 982 | enum Thing { A } |
983 | impl Thing { | 983 | impl Thing { |
@@ -990,7 +990,7 @@ impl Thing { | |||
990 | let hover = analysis.hover(position).unwrap().unwrap(); | 990 | let hover = analysis.hover(position).unwrap().unwrap(); |
991 | assert_eq!(trim_markup(&hover.info.markup.as_str()), ("enum Thing")); | 991 | assert_eq!(trim_markup(&hover.info.markup.as_str()), ("enum Thing")); |
992 | 992 | ||
993 | let (analysis, position) = analysis_and_position( | 993 | let (analysis, position) = fixture::position( |
994 | " | 994 | " |
995 | enum Thing { A } | 995 | enum Thing { A } |
996 | impl Thing { | 996 | impl Thing { |
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs index 583f39d85..0afe5f8fd 100644 --- a/crates/ide/src/inlay_hints.rs +++ b/crates/ide/src/inlay_hints.rs | |||
@@ -339,14 +339,14 @@ mod tests { | |||
339 | use expect_test::{expect, Expect}; | 339 | use expect_test::{expect, Expect}; |
340 | use test_utils::extract_annotations; | 340 | use test_utils::extract_annotations; |
341 | 341 | ||
342 | use crate::{inlay_hints::InlayHintsConfig, mock_analysis::single_file}; | 342 | use crate::{fixture, inlay_hints::InlayHintsConfig}; |
343 | 343 | ||
344 | fn check(ra_fixture: &str) { | 344 | fn check(ra_fixture: &str) { |
345 | check_with_config(InlayHintsConfig::default(), ra_fixture); | 345 | check_with_config(InlayHintsConfig::default(), ra_fixture); |
346 | } | 346 | } |
347 | 347 | ||
348 | fn check_with_config(config: InlayHintsConfig, ra_fixture: &str) { | 348 | fn check_with_config(config: InlayHintsConfig, ra_fixture: &str) { |
349 | let (analysis, file_id) = single_file(ra_fixture); | 349 | let (analysis, file_id) = fixture::file(ra_fixture); |
350 | let expected = extract_annotations(&*analysis.file_text(file_id).unwrap()); | 350 | let expected = extract_annotations(&*analysis.file_text(file_id).unwrap()); |
351 | let inlay_hints = analysis.inlay_hints(file_id, &config).unwrap(); | 351 | let inlay_hints = analysis.inlay_hints(file_id, &config).unwrap(); |
352 | let actual = | 352 | let actual = |
@@ -355,7 +355,7 @@ mod tests { | |||
355 | } | 355 | } |
356 | 356 | ||
357 | fn check_expect(config: InlayHintsConfig, ra_fixture: &str, expect: Expect) { | 357 | fn check_expect(config: InlayHintsConfig, ra_fixture: &str, expect: Expect) { |
358 | let (analysis, file_id) = single_file(ra_fixture); | 358 | let (analysis, file_id) = fixture::file(ra_fixture); |
359 | let inlay_hints = analysis.inlay_hints(file_id, &config).unwrap(); | 359 | let inlay_hints = analysis.inlay_hints(file_id, &config).unwrap(); |
360 | expect.assert_debug_eq(&inlay_hints) | 360 | expect.assert_debug_eq(&inlay_hints) |
361 | } | 361 | } |
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs index 073b766a5..1aa673cf8 100644 --- a/crates/ide/src/lib.rs +++ b/crates/ide/src/lib.rs | |||
@@ -16,7 +16,7 @@ macro_rules! eprintln { | |||
16 | } | 16 | } |
17 | 17 | ||
18 | #[cfg(test)] | 18 | #[cfg(test)] |
19 | mod mock_analysis; | 19 | mod fixture; |
20 | 20 | ||
21 | mod markup; | 21 | mod markup; |
22 | mod prime_caches; | 22 | mod prime_caches; |
diff --git a/crates/ide/src/parent_module.rs b/crates/ide/src/parent_module.rs index 253454476..ef94acfec 100644 --- a/crates/ide/src/parent_module.rs +++ b/crates/ide/src/parent_module.rs | |||
@@ -65,11 +65,11 @@ pub(crate) fn crate_for(db: &RootDatabase, file_id: FileId) -> Vec<CrateId> { | |||
65 | mod tests { | 65 | mod tests { |
66 | use test_utils::mark; | 66 | use test_utils::mark; |
67 | 67 | ||
68 | use crate::mock_analysis::{analysis_and_position, single_file}; | 68 | use crate::fixture::{self}; |
69 | 69 | ||
70 | #[test] | 70 | #[test] |
71 | fn test_resolve_parent_module() { | 71 | fn test_resolve_parent_module() { |
72 | let (analysis, pos) = analysis_and_position( | 72 | let (analysis, pos) = fixture::position( |
73 | " | 73 | " |
74 | //- /lib.rs | 74 | //- /lib.rs |
75 | mod foo; | 75 | mod foo; |
@@ -84,7 +84,7 @@ mod tests { | |||
84 | #[test] | 84 | #[test] |
85 | fn test_resolve_parent_module_on_module_decl() { | 85 | fn test_resolve_parent_module_on_module_decl() { |
86 | mark::check!(test_resolve_parent_module_on_module_decl); | 86 | mark::check!(test_resolve_parent_module_on_module_decl); |
87 | let (analysis, pos) = analysis_and_position( | 87 | let (analysis, pos) = fixture::position( |
88 | " | 88 | " |
89 | //- /lib.rs | 89 | //- /lib.rs |
90 | mod foo; | 90 | mod foo; |
@@ -102,7 +102,7 @@ mod tests { | |||
102 | 102 | ||
103 | #[test] | 103 | #[test] |
104 | fn test_resolve_parent_module_for_inline() { | 104 | fn test_resolve_parent_module_for_inline() { |
105 | let (analysis, pos) = analysis_and_position( | 105 | let (analysis, pos) = fixture::position( |
106 | " | 106 | " |
107 | //- /lib.rs | 107 | //- /lib.rs |
108 | mod foo { | 108 | mod foo { |
@@ -118,7 +118,7 @@ mod tests { | |||
118 | 118 | ||
119 | #[test] | 119 | #[test] |
120 | fn test_resolve_crate_root() { | 120 | fn test_resolve_crate_root() { |
121 | let (analysis, file_id) = single_file( | 121 | let (analysis, file_id) = fixture::file( |
122 | r#" | 122 | r#" |
123 | //- /main.rs | 123 | //- /main.rs |
124 | mod foo; | 124 | mod foo; |
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index 157e0dc94..e0830eb4f 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs | |||
@@ -194,7 +194,7 @@ mod tests { | |||
194 | use expect_test::{expect, Expect}; | 194 | use expect_test::{expect, Expect}; |
195 | use stdx::format_to; | 195 | use stdx::format_to; |
196 | 196 | ||
197 | use crate::{mock_analysis::analysis_and_position, SearchScope}; | 197 | use crate::{fixture, SearchScope}; |
198 | 198 | ||
199 | #[test] | 199 | #[test] |
200 | fn test_struct_literal_after_space() { | 200 | fn test_struct_literal_after_space() { |
@@ -674,7 +674,7 @@ fn g() { f(); } | |||
674 | } | 674 | } |
675 | 675 | ||
676 | fn check_with_scope(ra_fixture: &str, search_scope: Option<SearchScope>, expect: Expect) { | 676 | fn check_with_scope(ra_fixture: &str, search_scope: Option<SearchScope>, expect: Expect) { |
677 | let (analysis, pos) = analysis_and_position(ra_fixture); | 677 | let (analysis, pos) = fixture::position(ra_fixture); |
678 | let refs = analysis.find_all_refs(pos, search_scope).unwrap().unwrap(); | 678 | let refs = analysis.find_all_refs(pos, search_scope).unwrap().unwrap(); |
679 | 679 | ||
680 | let mut actual = String::new(); | 680 | let mut actual = String::new(); |
diff --git a/crates/ide/src/references/rename.rs b/crates/ide/src/references/rename.rs index 366527070..8cbe1ae5a 100644 --- a/crates/ide/src/references/rename.rs +++ b/crates/ide/src/references/rename.rs | |||
@@ -275,11 +275,11 @@ mod tests { | |||
275 | use test_utils::{assert_eq_text, mark}; | 275 | use test_utils::{assert_eq_text, mark}; |
276 | use text_edit::TextEdit; | 276 | use text_edit::TextEdit; |
277 | 277 | ||
278 | use crate::{mock_analysis::analysis_and_position, FileId}; | 278 | use crate::{fixture, FileId}; |
279 | 279 | ||
280 | fn check(new_name: &str, ra_fixture_before: &str, ra_fixture_after: &str) { | 280 | fn check(new_name: &str, ra_fixture_before: &str, ra_fixture_after: &str) { |
281 | let ra_fixture_after = &trim_indent(ra_fixture_after); | 281 | let ra_fixture_after = &trim_indent(ra_fixture_after); |
282 | let (analysis, position) = analysis_and_position(ra_fixture_before); | 282 | let (analysis, position) = fixture::position(ra_fixture_before); |
283 | let source_change = analysis.rename(position, new_name).unwrap(); | 283 | let source_change = analysis.rename(position, new_name).unwrap(); |
284 | let mut text_edit_builder = TextEdit::builder(); | 284 | let mut text_edit_builder = TextEdit::builder(); |
285 | let mut file_id: Option<FileId> = None; | 285 | let mut file_id: Option<FileId> = None; |
@@ -297,7 +297,7 @@ mod tests { | |||
297 | } | 297 | } |
298 | 298 | ||
299 | fn check_expect(new_name: &str, ra_fixture: &str, expect: Expect) { | 299 | fn check_expect(new_name: &str, ra_fixture: &str, expect: Expect) { |
300 | let (analysis, position) = analysis_and_position(ra_fixture); | 300 | let (analysis, position) = fixture::position(ra_fixture); |
301 | let source_change = analysis.rename(position, new_name).unwrap().unwrap(); | 301 | let source_change = analysis.rename(position, new_name).unwrap().unwrap(); |
302 | expect.assert_debug_eq(&source_change) | 302 | expect.assert_debug_eq(&source_change) |
303 | } | 303 | } |
@@ -314,7 +314,7 @@ mod tests { | |||
314 | 314 | ||
315 | #[test] | 315 | #[test] |
316 | fn test_rename_to_invalid_identifier() { | 316 | fn test_rename_to_invalid_identifier() { |
317 | let (analysis, position) = analysis_and_position(r#"fn main() { let i<|> = 1; }"#); | 317 | let (analysis, position) = fixture::position(r#"fn main() { let i<|> = 1; }"#); |
318 | let new_name = "invalid!"; | 318 | let new_name = "invalid!"; |
319 | let source_change = analysis.rename(position, new_name).unwrap(); | 319 | let source_change = analysis.rename(position, new_name).unwrap(); |
320 | assert!(source_change.is_none()); | 320 | assert!(source_change.is_none()); |
diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs index 961066277..752ef2f21 100644 --- a/crates/ide/src/runnables.rs +++ b/crates/ide/src/runnables.rs | |||
@@ -292,7 +292,7 @@ fn has_test_function_or_multiple_test_submodules(module: &ast::Module) -> bool { | |||
292 | mod tests { | 292 | mod tests { |
293 | use expect_test::{expect, Expect}; | 293 | use expect_test::{expect, Expect}; |
294 | 294 | ||
295 | use crate::mock_analysis::analysis_and_position; | 295 | use crate::fixture; |
296 | 296 | ||
297 | use super::{RunnableAction, BENCH, BIN, DOCTEST, TEST}; | 297 | use super::{RunnableAction, BENCH, BIN, DOCTEST, TEST}; |
298 | 298 | ||
@@ -302,7 +302,7 @@ mod tests { | |||
302 | actions: &[&RunnableAction], | 302 | actions: &[&RunnableAction], |
303 | expect: Expect, | 303 | expect: Expect, |
304 | ) { | 304 | ) { |
305 | let (analysis, position) = analysis_and_position(ra_fixture); | 305 | let (analysis, position) = fixture::position(ra_fixture); |
306 | let runnables = analysis.runnables(position.file_id).unwrap(); | 306 | let runnables = analysis.runnables(position.file_id).unwrap(); |
307 | expect.assert_debug_eq(&runnables); | 307 | expect.assert_debug_eq(&runnables); |
308 | assert_eq!( | 308 | assert_eq!( |
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs index eaa4e163e..694c4b7fa 100644 --- a/crates/ide/src/syntax_highlighting/tests.rs +++ b/crates/ide/src/syntax_highlighting/tests.rs | |||
@@ -3,7 +3,7 @@ use std::fs; | |||
3 | use expect_test::{expect_file, ExpectFile}; | 3 | use expect_test::{expect_file, ExpectFile}; |
4 | use test_utils::project_dir; | 4 | use test_utils::project_dir; |
5 | 5 | ||
6 | use crate::{mock_analysis::single_file, FileRange, TextRange}; | 6 | use crate::{fixture, FileRange, TextRange}; |
7 | 7 | ||
8 | #[test] | 8 | #[test] |
9 | fn test_highlighting() { | 9 | fn test_highlighting() { |
@@ -178,7 +178,7 @@ fn accidentally_quadratic() { | |||
178 | let file = project_dir().join("crates/syntax/test_data/accidentally_quadratic"); | 178 | let file = project_dir().join("crates/syntax/test_data/accidentally_quadratic"); |
179 | let src = fs::read_to_string(file).unwrap(); | 179 | let src = fs::read_to_string(file).unwrap(); |
180 | 180 | ||
181 | let (analysis, file_id) = single_file(&src); | 181 | let (analysis, file_id) = fixture::file(&src); |
182 | 182 | ||
183 | // let t = std::time::Instant::now(); | 183 | // let t = std::time::Instant::now(); |
184 | let _ = analysis.highlight(file_id).unwrap(); | 184 | let _ = analysis.highlight(file_id).unwrap(); |
@@ -187,7 +187,7 @@ fn accidentally_quadratic() { | |||
187 | 187 | ||
188 | #[test] | 188 | #[test] |
189 | fn test_ranges() { | 189 | fn test_ranges() { |
190 | let (analysis, file_id) = single_file( | 190 | let (analysis, file_id) = fixture::file( |
191 | r#" | 191 | r#" |
192 | #[derive(Clone, Debug)] | 192 | #[derive(Clone, Debug)] |
193 | struct Foo { | 193 | struct Foo { |
@@ -228,7 +228,7 @@ fn main() { | |||
228 | 228 | ||
229 | #[test] | 229 | #[test] |
230 | fn ranges_sorted() { | 230 | fn ranges_sorted() { |
231 | let (analysis, file_id) = single_file( | 231 | let (analysis, file_id) = fixture::file( |
232 | r#" | 232 | r#" |
233 | #[foo(bar = "bar")] | 233 | #[foo(bar = "bar")] |
234 | macro_rules! test {} | 234 | macro_rules! test {} |
@@ -479,7 +479,7 @@ fn test_extern_crate() { | |||
479 | /// result as HTML, and compares it with the HTML file given as `snapshot`. | 479 | /// result as HTML, and compares it with the HTML file given as `snapshot`. |
480 | /// Note that the `snapshot` file is overwritten by the rendered HTML. | 480 | /// Note that the `snapshot` file is overwritten by the rendered HTML. |
481 | fn check_highlighting(ra_fixture: &str, expect: ExpectFile, rainbow: bool) { | 481 | fn check_highlighting(ra_fixture: &str, expect: ExpectFile, rainbow: bool) { |
482 | let (analysis, file_id) = single_file(ra_fixture); | 482 | let (analysis, file_id) = fixture::file(ra_fixture); |
483 | let actual_html = &analysis.highlight_as_html(file_id, rainbow).unwrap(); | 483 | let actual_html = &analysis.highlight_as_html(file_id, rainbow).unwrap(); |
484 | expect.assert_eq(actual_html) | 484 | expect.assert_eq(actual_html) |
485 | } | 485 | } |
diff --git a/crates/ide/src/syntax_tree.rs b/crates/ide/src/syntax_tree.rs index f80044959..0eed2dbd7 100644 --- a/crates/ide/src/syntax_tree.rs +++ b/crates/ide/src/syntax_tree.rs | |||
@@ -104,12 +104,12 @@ fn syntax_tree_for_token(node: &SyntaxToken, text_range: TextRange) -> Option<St | |||
104 | mod tests { | 104 | mod tests { |
105 | use test_utils::assert_eq_text; | 105 | use test_utils::assert_eq_text; |
106 | 106 | ||
107 | use crate::mock_analysis::{analysis_and_range, single_file}; | 107 | use crate::fixture; |
108 | 108 | ||
109 | #[test] | 109 | #[test] |
110 | fn test_syntax_tree_without_range() { | 110 | fn test_syntax_tree_without_range() { |
111 | // Basic syntax | 111 | // Basic syntax |
112 | let (analysis, file_id) = single_file(r#"fn foo() {}"#); | 112 | let (analysis, file_id) = fixture::file(r#"fn foo() {}"#); |
113 | let syn = analysis.syntax_tree(file_id, None).unwrap(); | 113 | let syn = analysis.syntax_tree(file_id, None).unwrap(); |
114 | 114 | ||
115 | assert_eq_text!( | 115 | assert_eq_text!( |
@@ -132,7 +132,7 @@ [email protected] | |||
132 | .trim() | 132 | .trim() |
133 | ); | 133 | ); |
134 | 134 | ||
135 | let (analysis, file_id) = single_file( | 135 | let (analysis, file_id) = fixture::file( |
136 | r#" | 136 | r#" |
137 | fn test() { | 137 | fn test() { |
138 | assert!(" | 138 | assert!(" |
@@ -184,7 +184,7 @@ [email protected] | |||
184 | 184 | ||
185 | #[test] | 185 | #[test] |
186 | fn test_syntax_tree_with_range() { | 186 | fn test_syntax_tree_with_range() { |
187 | let (analysis, range) = analysis_and_range(r#"<|>fn foo() {}<|>"#.trim()); | 187 | let (analysis, range) = fixture::range(r#"<|>fn foo() {}<|>"#.trim()); |
188 | let syn = analysis.syntax_tree(range.file_id, Some(range.range)).unwrap(); | 188 | let syn = analysis.syntax_tree(range.file_id, Some(range.range)).unwrap(); |
189 | 189 | ||
190 | assert_eq_text!( | 190 | assert_eq_text!( |
@@ -206,7 +206,7 @@ [email protected] | |||
206 | .trim() | 206 | .trim() |
207 | ); | 207 | ); |
208 | 208 | ||
209 | let (analysis, range) = analysis_and_range( | 209 | let (analysis, range) = fixture::range( |
210 | r#"fn test() { | 210 | r#"fn test() { |
211 | <|>assert!(" | 211 | <|>assert!(" |
212 | fn foo() { | 212 | fn foo() { |
@@ -242,7 +242,7 @@ [email protected] | |||
242 | 242 | ||
243 | #[test] | 243 | #[test] |
244 | fn test_syntax_tree_inside_string() { | 244 | fn test_syntax_tree_inside_string() { |
245 | let (analysis, range) = analysis_and_range( | 245 | let (analysis, range) = fixture::range( |
246 | r#"fn test() { | 246 | r#"fn test() { |
247 | assert!(" | 247 | assert!(" |
248 | <|>fn foo() { | 248 | <|>fn foo() { |
@@ -276,7 +276,7 @@ [email protected] | |||
276 | ); | 276 | ); |
277 | 277 | ||
278 | // With a raw string | 278 | // With a raw string |
279 | let (analysis, range) = analysis_and_range( | 279 | let (analysis, range) = fixture::range( |
280 | r###"fn test() { | 280 | r###"fn test() { |
281 | assert!(r#" | 281 | assert!(r#" |
282 | <|>fn foo() { | 282 | <|>fn foo() { |
@@ -310,7 +310,7 @@ [email protected] | |||
310 | ); | 310 | ); |
311 | 311 | ||
312 | // With a raw string | 312 | // With a raw string |
313 | let (analysis, range) = analysis_and_range( | 313 | let (analysis, range) = fixture::range( |
314 | r###"fn test() { | 314 | r###"fn test() { |
315 | assert!(r<|>#" | 315 | assert!(r<|>#" |
316 | fn foo() { | 316 | fn foo() { |
diff --git a/crates/ide/src/typing/on_enter.rs b/crates/ide/src/typing/on_enter.rs index f7d46146c..a0dc4b9df 100644 --- a/crates/ide/src/typing/on_enter.rs +++ b/crates/ide/src/typing/on_enter.rs | |||
@@ -109,10 +109,10 @@ mod tests { | |||
109 | use stdx::trim_indent; | 109 | use stdx::trim_indent; |
110 | use test_utils::{assert_eq_text, mark}; | 110 | use test_utils::{assert_eq_text, mark}; |
111 | 111 | ||
112 | use crate::mock_analysis::analysis_and_position; | 112 | use crate::fixture; |
113 | 113 | ||
114 | fn apply_on_enter(before: &str) -> Option<String> { | 114 | fn apply_on_enter(before: &str) -> Option<String> { |
115 | let (analysis, position) = analysis_and_position(&before); | 115 | let (analysis, position) = fixture::position(&before); |
116 | let result = analysis.on_enter(position).unwrap()?; | 116 | let result = analysis.on_enter(position).unwrap()?; |
117 | 117 | ||
118 | let mut actual = analysis.file_text(position.file_id).unwrap().to_string(); | 118 | let mut actual = analysis.file_text(position.file_id).unwrap().to_string(); |