diff options
author | Aleksey Kladov <[email protected]> | 2018-11-07 15:32:33 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-11-07 15:42:36 +0000 |
commit | f8b36bbc3b968754b71844d942286e81415627b8 (patch) | |
tree | 72be8cc4bac951b00746291e4b357b86def7d4c7 /crates/ra_editor/src/test_utils.rs | |
parent | 2119fe214303325e86174b139d7ad8193b2ce251 (diff) |
Rename File -> SourceFileNode
Diffstat (limited to 'crates/ra_editor/src/test_utils.rs')
-rw-r--r-- | crates/ra_editor/src/test_utils.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/crates/ra_editor/src/test_utils.rs b/crates/ra_editor/src/test_utils.rs index bc3d700f6..cbeb6433b 100644 --- a/crates/ra_editor/src/test_utils.rs +++ b/crates/ra_editor/src/test_utils.rs | |||
@@ -1,10 +1,14 @@ | |||
1 | use crate::LocalEdit; | 1 | use crate::LocalEdit; |
2 | pub use crate::_test_utils::*; | 2 | pub use crate::_test_utils::*; |
3 | use ra_syntax::{File, TextRange, TextUnit}; | 3 | use ra_syntax::{SourceFileNode, TextRange, TextUnit}; |
4 | 4 | ||
5 | pub fn check_action<F: Fn(&File, TextUnit) -> Option<LocalEdit>>(before: &str, after: &str, f: F) { | 5 | pub fn check_action<F: Fn(&SourceFileNode, TextUnit) -> Option<LocalEdit>>( |
6 | before: &str, | ||
7 | after: &str, | ||
8 | f: F, | ||
9 | ) { | ||
6 | let (before_cursor_pos, before) = extract_offset(before); | 10 | let (before_cursor_pos, before) = extract_offset(before); |
7 | let file = File::parse(&before); | 11 | let file = SourceFileNode::parse(&before); |
8 | let result = f(&file, before_cursor_pos).expect("code action is not applicable"); | 12 | let result = f(&file, before_cursor_pos).expect("code action is not applicable"); |
9 | let actual = result.edit.apply(&before); | 13 | let actual = result.edit.apply(&before); |
10 | let actual_cursor_pos = match result.cursor_position { | 14 | let actual_cursor_pos = match result.cursor_position { |
@@ -15,13 +19,13 @@ pub fn check_action<F: Fn(&File, TextUnit) -> Option<LocalEdit>>(before: &str, a | |||
15 | assert_eq_text!(after, &actual); | 19 | assert_eq_text!(after, &actual); |
16 | } | 20 | } |
17 | 21 | ||
18 | pub fn check_action_range<F: Fn(&File, TextRange) -> Option<LocalEdit>>( | 22 | pub fn check_action_range<F: Fn(&SourceFileNode, TextRange) -> Option<LocalEdit>>( |
19 | before: &str, | 23 | before: &str, |
20 | after: &str, | 24 | after: &str, |
21 | f: F, | 25 | f: F, |
22 | ) { | 26 | ) { |
23 | let (range, before) = extract_range(before); | 27 | let (range, before) = extract_range(before); |
24 | let file = File::parse(&before); | 28 | let file = SourceFileNode::parse(&before); |
25 | let result = f(&file, range).expect("code action is not applicable"); | 29 | let result = f(&file, range).expect("code action is not applicable"); |
26 | let actual = result.edit.apply(&before); | 30 | let actual = result.edit.apply(&before); |
27 | let actual_cursor_pos = match result.cursor_position { | 31 | let actual_cursor_pos = match result.cursor_position { |