diff options
author | Aleksey Kladov <[email protected]> | 2019-01-08 19:17:36 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-08 19:17:36 +0000 |
commit | 1967884d6836219ee78a754ca5c66ac781351559 (patch) | |
tree | 7594f37cd0a5200eb097b9d472c61f0223d01d05 /crates/ra_editor/src/test_utils.rs | |
parent | 4f4f7933b1b7ff34f8633b1686b18b2d1b994c47 (diff) |
rename ra_editor -> ra_ide_api_light
Diffstat (limited to 'crates/ra_editor/src/test_utils.rs')
-rw-r--r-- | crates/ra_editor/src/test_utils.rs | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/crates/ra_editor/src/test_utils.rs b/crates/ra_editor/src/test_utils.rs deleted file mode 100644 index dc2470aa3..000000000 --- a/crates/ra_editor/src/test_utils.rs +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | use ra_syntax::{SourceFile, TextRange, TextUnit}; | ||
2 | |||
3 | use crate::LocalEdit; | ||
4 | pub use test_utils::*; | ||
5 | |||
6 | pub fn check_action<F: Fn(&SourceFile, TextUnit) -> Option<LocalEdit>>( | ||
7 | before: &str, | ||
8 | after: &str, | ||
9 | f: F, | ||
10 | ) { | ||
11 | let (before_cursor_pos, before) = extract_offset(before); | ||
12 | let file = SourceFile::parse(&before); | ||
13 | let result = f(&file, before_cursor_pos).expect("code action is not applicable"); | ||
14 | let actual = result.edit.apply(&before); | ||
15 | let actual_cursor_pos = match result.cursor_position { | ||
16 | None => result | ||
17 | .edit | ||
18 | .apply_to_offset(before_cursor_pos) | ||
19 | .expect("cursor position is affected by the edit"), | ||
20 | Some(off) => off, | ||
21 | }; | ||
22 | let actual = add_cursor(&actual, actual_cursor_pos); | ||
23 | assert_eq_text!(after, &actual); | ||
24 | } | ||
25 | |||
26 | pub fn check_action_range<F: Fn(&SourceFile, TextRange) -> Option<LocalEdit>>( | ||
27 | before: &str, | ||
28 | after: &str, | ||
29 | f: F, | ||
30 | ) { | ||
31 | let (range, before) = extract_range(before); | ||
32 | let file = SourceFile::parse(&before); | ||
33 | let result = f(&file, range).expect("code action is not applicable"); | ||
34 | let actual = result.edit.apply(&before); | ||
35 | let actual_cursor_pos = match result.cursor_position { | ||
36 | None => result.edit.apply_to_offset(range.start()).unwrap(), | ||
37 | Some(off) => off, | ||
38 | }; | ||
39 | let actual = add_cursor(&actual, actual_cursor_pos); | ||
40 | assert_eq_text!(after, &actual); | ||
41 | } | ||