aboutsummaryrefslogtreecommitdiff
path: root/crates/assists/src/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'crates/assists/src/handlers')
-rw-r--r--crates/assists/src/handlers/ignore_test.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/crates/assists/src/handlers/ignore_test.rs b/crates/assists/src/handlers/ignore_test.rs
new file mode 100644
index 000000000..d2339184f
--- /dev/null
+++ b/crates/assists/src/handlers/ignore_test.rs
@@ -0,0 +1,34 @@
1use syntax::{ast, AstNode};
2
3use crate::{utils::test_related_attribute, AssistContext, AssistId, AssistKind, Assists};
4
5// Assist: ignore_test
6//
7// Adds `#[ignore]` attribute to the test.
8//
9// ```
10// <|>#[test]
11// fn arithmetics {
12// assert_eq!(2 + 2, 5);
13// }
14// ```
15// ->
16// ```
17// #[test]
18// #[ignore]
19// fn arithmetics {
20// assert_eq!(2 + 2, 5);
21// }
22// ```
23pub(crate) fn ignore_test(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
24 let attr: ast::Attr = ctx.find_node_at_offset()?;
25 let func = attr.syntax().parent().and_then(ast::Fn::cast)?;
26 let attr = test_related_attribute(&func)?;
27
28 acc.add(
29 AssistId("ignore_test", AssistKind::None),
30 "Ignore this test",
31 attr.syntax().text_range(),
32 |builder| builder.insert(attr.syntax().text_range().end(), &format!("\n#[ignore]")),
33 )
34}