aboutsummaryrefslogtreecommitdiff
path: root/crates/assists/src/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/assists/src/utils.rs')
-rw-r--r--crates/assists/src/utils.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/assists/src/utils.rs b/crates/assists/src/utils.rs
index 7bd338e99..d1a0a99b1 100644
--- a/crates/assists/src/utils.rs
+++ b/crates/assists/src/utils.rs
@@ -9,6 +9,7 @@ use ide_db::RootDatabase;
9use itertools::Itertools; 9use itertools::Itertools;
10use syntax::{ 10use syntax::{
11 ast::edit::AstNodeEdit, 11 ast::edit::AstNodeEdit,
12 ast::AttrsOwner,
12 ast::NameOwner, 13 ast::NameOwner,
13 ast::{self, edit, make, ArgListOwner}, 14 ast::{self, edit, make, ArgListOwner},
14 AstNode, Direction, 15 AstNode, Direction,
@@ -82,6 +83,23 @@ pub fn extract_trivial_expression(block: &ast::BlockExpr) -> Option<ast::Expr> {
82 None 83 None
83} 84}
84 85
86/// This is a method with a heuristics to support test methods annotated with custom test annotations, such as
87/// `#[test_case(...)]`, `#[tokio::test]` and similar.
88/// Also a regular `#[test]` annotation is supported.
89///
90/// It may produce false positives, for example, `#[wasm_bindgen_test]` requires a different command to run the test,
91/// but it's better than not to have the runnables for the tests at all.
92pub fn test_related_attribute(fn_def: &ast::Fn) -> Option<ast::Attr> {
93 fn_def.attrs().find_map(|attr| {
94 let path = attr.path()?;
95 if path.syntax().text().to_string().contains("test") {
96 Some(attr)
97 } else {
98 None
99 }
100 })
101}
102
85#[derive(Copy, Clone, PartialEq)] 103#[derive(Copy, Clone, PartialEq)]
86pub enum DefaultMethods { 104pub enum DefaultMethods {
87 Only, 105 Only,