Some improvements to introduce_variable.

This commit is contained in:
Andrea Pretto 2019-01-30 21:36:49 +01:00
parent 7a1494ced5
commit a5fe4a08fb
3 changed files with 181 additions and 8 deletions

View file

@ -23,6 +23,18 @@ pub fn check_action<F: Fn(&SourceFile, TextUnit) -> Option<LocalEdit>>(
assert_eq_text!(after, &actual);
}
pub fn check_action_not_applicable<F: Fn(&SourceFile, TextUnit) -> Option<LocalEdit>>(
text: &str,
f: F,
) {
let (text_cursor_pos, text) = extract_offset(text);
let file = SourceFile::parse(&text);
assert!(
f(&file, text_cursor_pos).is_none(),
"code action is applicable but it shouldn't"
);
}
pub fn check_action_range<F: Fn(&SourceFile, TextRange) -> Option<LocalEdit>>(
before: &str,
after: &str,