aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-05-20 11:59:20 +0100
committerAleksey Kladov <[email protected]>2020-05-20 12:02:53 +0100
commitecac5d7de2192873c24b7b06d4964d188d8abe6a (patch)
treef916c9d90a5b1817db4aed2c60db2ce4809dab1f /crates/ra_assists
parent5258c817f78ecdfe12d7eec44ab3169134cba71d (diff)
Switch to new magic marks
Diffstat (limited to 'crates/ra_assists')
-rw-r--r--crates/ra_assists/src/handlers/add_from_impl_for_enum.rs8
-rw-r--r--crates/ra_assists/src/handlers/change_visibility.rs8
-rw-r--r--crates/ra_assists/src/handlers/fill_match_arms.rs9
-rw-r--r--crates/ra_assists/src/handlers/inline_local_variable.rs16
-rw-r--r--crates/ra_assists/src/handlers/introduce_variable.rs16
-rw-r--r--crates/ra_assists/src/lib.rs1
-rw-r--r--crates/ra_assists/src/marks.rs13
7 files changed, 29 insertions, 42 deletions
diff --git a/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs b/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs
index eb57b7231..5f6c8b19a 100644
--- a/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs
+++ b/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs
@@ -1,6 +1,6 @@
1use ra_ide_db::RootDatabase; 1use ra_ide_db::RootDatabase;
2use ra_syntax::ast::{self, AstNode, NameOwner}; 2use ra_syntax::ast::{self, AstNode, NameOwner};
3use test_utils::tested_by; 3use test_utils::mark;
4 4
5use crate::{utils::FamousDefs, AssistContext, AssistId, Assists}; 5use crate::{utils::FamousDefs, AssistContext, AssistId, Assists};
6 6
@@ -39,7 +39,7 @@ pub(crate) fn add_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext) ->
39 }; 39 };
40 40
41 if existing_from_impl(&ctx.sema, &variant).is_some() { 41 if existing_from_impl(&ctx.sema, &variant).is_some() {
42 tested_by!(test_add_from_impl_already_exists); 42 mark::hit!(test_add_from_impl_already_exists);
43 return None; 43 return None;
44 } 44 }
45 45
@@ -90,7 +90,7 @@ fn existing_from_impl(
90 90
91#[cfg(test)] 91#[cfg(test)]
92mod tests { 92mod tests {
93 use test_utils::covers; 93 use test_utils::mark;
94 94
95 use crate::tests::{check_assist, check_assist_not_applicable}; 95 use crate::tests::{check_assist, check_assist_not_applicable};
96 96
@@ -149,7 +149,7 @@ impl From<foo::bar::baz::Boo> for A {
149 149
150 #[test] 150 #[test]
151 fn test_add_from_impl_already_exists() { 151 fn test_add_from_impl_already_exists() {
152 covers!(test_add_from_impl_already_exists); 152 mark::check!(test_add_from_impl_already_exists);
153 check_not_applicable( 153 check_not_applicable(
154 r#" 154 r#"
155enum A { <|>One(u32), } 155enum A { <|>One(u32), }
diff --git a/crates/ra_assists/src/handlers/change_visibility.rs b/crates/ra_assists/src/handlers/change_visibility.rs
index 40cf4b422..71d55e0c3 100644
--- a/crates/ra_assists/src/handlers/change_visibility.rs
+++ b/crates/ra_assists/src/handlers/change_visibility.rs
@@ -9,7 +9,7 @@ use ra_syntax::{
9}; 9};
10 10
11use hir::{db::HirDatabase, HasSource, HasVisibility, PathResolution}; 11use hir::{db::HirDatabase, HasSource, HasVisibility, PathResolution};
12use test_utils::tested_by; 12use test_utils::mark;
13 13
14use crate::{AssistContext, AssistId, Assists}; 14use crate::{AssistContext, AssistId, Assists};
15use ra_db::FileId; 15use ra_db::FileId;
@@ -55,7 +55,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
55 } else if let Some(field_name) = ctx.find_node_at_offset::<ast::Name>() { 55 } else if let Some(field_name) = ctx.find_node_at_offset::<ast::Name>() {
56 let field = field_name.syntax().ancestors().find_map(ast::RecordFieldDef::cast)?; 56 let field = field_name.syntax().ancestors().find_map(ast::RecordFieldDef::cast)?;
57 if field.name()? != field_name { 57 if field.name()? != field_name {
58 tested_by!(change_visibility_field_false_positive); 58 mark::hit!(change_visibility_field_false_positive);
59 return None; 59 return None;
60 } 60 }
61 if field.visibility().is_some() { 61 if field.visibility().is_some() {
@@ -255,7 +255,7 @@ fn change_vis(acc: &mut Assists, vis: ast::Visibility) -> Option<()> {
255 255
256#[cfg(test)] 256#[cfg(test)]
257mod tests { 257mod tests {
258 use test_utils::covers; 258 use test_utils::mark;
259 259
260 use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; 260 use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target};
261 261
@@ -288,7 +288,7 @@ mod tests {
288 288
289 #[test] 289 #[test]
290 fn change_visibility_field_false_positive() { 290 fn change_visibility_field_false_positive() {
291 covers!(change_visibility_field_false_positive); 291 mark::check!(change_visibility_field_false_positive);
292 check_assist_not_applicable( 292 check_assist_not_applicable(
293 change_visibility, 293 change_visibility,
294 r"struct S { field: [(); { let <|>x = ();}] }", 294 r"struct S { field: [(); { let <|>x = ();}] }",
diff --git a/crates/ra_assists/src/handlers/fill_match_arms.rs b/crates/ra_assists/src/handlers/fill_match_arms.rs
index b57ff75ae..bbdcdc626 100644
--- a/crates/ra_assists/src/handlers/fill_match_arms.rs
+++ b/crates/ra_assists/src/handlers/fill_match_arms.rs
@@ -4,7 +4,7 @@ use hir::{Adt, HasSource, ModuleDef, Semantics};
4use itertools::Itertools; 4use itertools::Itertools;
5use ra_ide_db::RootDatabase; 5use ra_ide_db::RootDatabase;
6use ra_syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat}; 6use ra_syntax::ast::{self, make, AstNode, MatchArm, NameOwner, Pat};
7use test_utils::tested_by; 7use test_utils::mark;
8 8
9use crate::{utils::FamousDefs, AssistContext, AssistId, Assists}; 9use crate::{utils::FamousDefs, AssistContext, AssistId, Assists};
10 10
@@ -58,7 +58,7 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option<
58 .collect::<Vec<_>>(); 58 .collect::<Vec<_>>();
59 if Some(enum_def) == FamousDefs(&ctx.sema, module.krate()).core_option_Option() { 59 if Some(enum_def) == FamousDefs(&ctx.sema, module.krate()).core_option_Option() {
60 // Match `Some` variant first. 60 // Match `Some` variant first.
61 tested_by!(option_order); 61 mark::hit!(option_order);
62 variants.reverse() 62 variants.reverse()
63 } 63 }
64 variants 64 variants
@@ -174,13 +174,14 @@ fn build_pat(db: &RootDatabase, module: hir::Module, var: hir::EnumVariant) -> O
174 174
175#[cfg(test)] 175#[cfg(test)]
176mod tests { 176mod tests {
177 use test_utils::mark;
178
177 use crate::{ 179 use crate::{
178 tests::{check_assist, check_assist_not_applicable, check_assist_target}, 180 tests::{check_assist, check_assist_not_applicable, check_assist_target},
179 utils::FamousDefs, 181 utils::FamousDefs,
180 }; 182 };
181 183
182 use super::fill_match_arms; 184 use super::fill_match_arms;
183 use test_utils::covers;
184 185
185 #[test] 186 #[test]
186 fn all_match_arms_provided() { 187 fn all_match_arms_provided() {
@@ -750,7 +751,7 @@ mod tests {
750 751
751 #[test] 752 #[test]
752 fn option_order() { 753 fn option_order() {
753 covers!(option_order); 754 mark::check!(option_order);
754 let before = r#" 755 let before = r#"
755fn foo(opt: Option<i32>) { 756fn foo(opt: Option<i32>) {
756 match opt<|> { 757 match opt<|> {
diff --git a/crates/ra_assists/src/handlers/inline_local_variable.rs b/crates/ra_assists/src/handlers/inline_local_variable.rs
index 5b26814d3..46d675a4e 100644
--- a/crates/ra_assists/src/handlers/inline_local_variable.rs
+++ b/crates/ra_assists/src/handlers/inline_local_variable.rs
@@ -3,7 +3,7 @@ use ra_syntax::{
3 ast::{self, AstNode, AstToken}, 3 ast::{self, AstNode, AstToken},
4 TextRange, 4 TextRange,
5}; 5};
6use test_utils::tested_by; 6use test_utils::mark;
7 7
8use crate::{ 8use crate::{
9 assist_context::{AssistContext, Assists}, 9 assist_context::{AssistContext, Assists},
@@ -33,11 +33,11 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O
33 _ => return None, 33 _ => return None,
34 }; 34 };
35 if bind_pat.mut_token().is_some() { 35 if bind_pat.mut_token().is_some() {
36 tested_by!(test_not_inline_mut_variable); 36 mark::hit!(test_not_inline_mut_variable);
37 return None; 37 return None;
38 } 38 }
39 if !bind_pat.syntax().text_range().contains_inclusive(ctx.offset()) { 39 if !bind_pat.syntax().text_range().contains_inclusive(ctx.offset()) {
40 tested_by!(not_applicable_outside_of_bind_pat); 40 mark::hit!(not_applicable_outside_of_bind_pat);
41 return None; 41 return None;
42 } 42 }
43 let initializer_expr = let_stmt.initializer()?; 43 let initializer_expr = let_stmt.initializer()?;
@@ -46,7 +46,7 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O
46 let def = Definition::Local(def); 46 let def = Definition::Local(def);
47 let refs = def.find_usages(ctx.db, None); 47 let refs = def.find_usages(ctx.db, None);
48 if refs.is_empty() { 48 if refs.is_empty() {
49 tested_by!(test_not_applicable_if_variable_unused); 49 mark::hit!(test_not_applicable_if_variable_unused);
50 return None; 50 return None;
51 }; 51 };
52 52
@@ -122,7 +122,7 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O
122 122
123#[cfg(test)] 123#[cfg(test)]
124mod tests { 124mod tests {
125 use test_utils::covers; 125 use test_utils::mark;
126 126
127 use crate::tests::{check_assist, check_assist_not_applicable}; 127 use crate::tests::{check_assist, check_assist_not_applicable};
128 128
@@ -330,7 +330,7 @@ fn foo() {
330 330
331 #[test] 331 #[test]
332 fn test_not_inline_mut_variable() { 332 fn test_not_inline_mut_variable() {
333 covers!(test_not_inline_mut_variable); 333 mark::check!(test_not_inline_mut_variable);
334 check_assist_not_applicable( 334 check_assist_not_applicable(
335 inline_local_variable, 335 inline_local_variable,
336 r" 336 r"
@@ -663,7 +663,7 @@ fn foo() {
663 663
664 #[test] 664 #[test]
665 fn test_not_applicable_if_variable_unused() { 665 fn test_not_applicable_if_variable_unused() {
666 covers!(test_not_applicable_if_variable_unused); 666 mark::check!(test_not_applicable_if_variable_unused);
667 check_assist_not_applicable( 667 check_assist_not_applicable(
668 inline_local_variable, 668 inline_local_variable,
669 r" 669 r"
@@ -676,7 +676,7 @@ fn foo() {
676 676
677 #[test] 677 #[test]
678 fn not_applicable_outside_of_bind_pat() { 678 fn not_applicable_outside_of_bind_pat() {
679 covers!(not_applicable_outside_of_bind_pat); 679 mark::check!(not_applicable_outside_of_bind_pat);
680 check_assist_not_applicable( 680 check_assist_not_applicable(
681 inline_local_variable, 681 inline_local_variable,
682 r" 682 r"
diff --git a/crates/ra_assists/src/handlers/introduce_variable.rs b/crates/ra_assists/src/handlers/introduce_variable.rs
index fdf3ada0d..56c610fed 100644
--- a/crates/ra_assists/src/handlers/introduce_variable.rs
+++ b/crates/ra_assists/src/handlers/introduce_variable.rs
@@ -7,7 +7,7 @@ use ra_syntax::{
7 SyntaxNode, TextSize, 7 SyntaxNode, TextSize,
8}; 8};
9use stdx::format_to; 9use stdx::format_to;
10use test_utils::tested_by; 10use test_utils::mark;
11 11
12use crate::{AssistContext, AssistId, Assists}; 12use crate::{AssistContext, AssistId, Assists};
13 13
@@ -33,7 +33,7 @@ pub(crate) fn introduce_variable(acc: &mut Assists, ctx: &AssistContext) -> Opti
33 } 33 }
34 let node = ctx.covering_element(); 34 let node = ctx.covering_element();
35 if node.kind() == COMMENT { 35 if node.kind() == COMMENT {
36 tested_by!(introduce_var_in_comment_is_not_applicable); 36 mark::hit!(introduce_var_in_comment_is_not_applicable);
37 return None; 37 return None;
38 } 38 }
39 let expr = node.ancestors().find_map(valid_target_expr)?; 39 let expr = node.ancestors().find_map(valid_target_expr)?;
@@ -61,7 +61,7 @@ pub(crate) fn introduce_variable(acc: &mut Assists, ctx: &AssistContext) -> Opti
61 false 61 false
62 }; 62 };
63 if is_full_stmt { 63 if is_full_stmt {
64 tested_by!(test_introduce_var_expr_stmt); 64 mark::hit!(test_introduce_var_expr_stmt);
65 if full_stmt.unwrap().semicolon_token().is_none() { 65 if full_stmt.unwrap().semicolon_token().is_none() {
66 buf.push_str(";"); 66 buf.push_str(";");
67 } 67 }
@@ -113,7 +113,7 @@ fn anchor_stmt(expr: ast::Expr) -> Option<(SyntaxNode, bool)> {
113 expr.syntax().ancestors().find_map(|node| { 113 expr.syntax().ancestors().find_map(|node| {
114 if let Some(expr) = node.parent().and_then(ast::BlockExpr::cast).and_then(|it| it.expr()) { 114 if let Some(expr) = node.parent().and_then(ast::BlockExpr::cast).and_then(|it| it.expr()) {
115 if expr.syntax() == &node { 115 if expr.syntax() == &node {
116 tested_by!(test_introduce_var_last_expr); 116 mark::hit!(test_introduce_var_last_expr);
117 return Some((node, false)); 117 return Some((node, false));
118 } 118 }
119 } 119 }
@@ -134,7 +134,7 @@ fn anchor_stmt(expr: ast::Expr) -> Option<(SyntaxNode, bool)> {
134 134
135#[cfg(test)] 135#[cfg(test)]
136mod tests { 136mod tests {
137 use test_utils::covers; 137 use test_utils::mark;
138 138
139 use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; 139 use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target};
140 140
@@ -158,13 +158,13 @@ fn foo() {
158 158
159 #[test] 159 #[test]
160 fn introduce_var_in_comment_is_not_applicable() { 160 fn introduce_var_in_comment_is_not_applicable() {
161 covers!(introduce_var_in_comment_is_not_applicable); 161 mark::check!(introduce_var_in_comment_is_not_applicable);
162 check_assist_not_applicable(introduce_variable, "fn main() { 1 + /* <|>comment<|> */ 1; }"); 162 check_assist_not_applicable(introduce_variable, "fn main() { 1 + /* <|>comment<|> */ 1; }");
163 } 163 }
164 164
165 #[test] 165 #[test]
166 fn test_introduce_var_expr_stmt() { 166 fn test_introduce_var_expr_stmt() {
167 covers!(test_introduce_var_expr_stmt); 167 mark::check!(test_introduce_var_expr_stmt);
168 check_assist( 168 check_assist(
169 introduce_variable, 169 introduce_variable,
170 " 170 "
@@ -209,7 +209,7 @@ fn foo() {
209 209
210 #[test] 210 #[test]
211 fn test_introduce_var_last_expr() { 211 fn test_introduce_var_last_expr() {
212 covers!(test_introduce_var_last_expr); 212 mark::check!(test_introduce_var_last_expr);
213 check_assist( 213 check_assist(
214 introduce_variable, 214 introduce_variable,
215 " 215 "
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs
index 339f24100..a4a497c73 100644
--- a/crates/ra_assists/src/lib.rs
+++ b/crates/ra_assists/src/lib.rs
@@ -12,7 +12,6 @@ macro_rules! eprintln {
12 12
13mod assist_config; 13mod assist_config;
14mod assist_context; 14mod assist_context;
15mod marks;
16#[cfg(test)] 15#[cfg(test)]
17mod tests; 16mod tests;
18pub mod utils; 17pub mod utils;
diff --git a/crates/ra_assists/src/marks.rs b/crates/ra_assists/src/marks.rs
deleted file mode 100644
index 525ec4abc..000000000
--- a/crates/ra_assists/src/marks.rs
+++ /dev/null
@@ -1,13 +0,0 @@
1//! See test_utils/src/marks.rs
2
3test_utils::marks![
4 option_order
5 introduce_var_in_comment_is_not_applicable
6 test_introduce_var_expr_stmt
7 test_introduce_var_last_expr
8 not_applicable_outside_of_bind_pat
9 test_not_inline_mut_variable
10 test_not_applicable_if_variable_unused
11 change_visibility_field_false_positive
12 test_add_from_impl_already_exists
13];