diff options
Diffstat (limited to 'crates/ra_assists/src/handlers/change_visibility.rs')
-rw-r--r-- | crates/ra_assists/src/handlers/change_visibility.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/crates/ra_assists/src/handlers/change_visibility.rs b/crates/ra_assists/src/handlers/change_visibility.rs index 4343b423c..724daa93f 100644 --- a/crates/ra_assists/src/handlers/change_visibility.rs +++ b/crates/ra_assists/src/handlers/change_visibility.rs | |||
@@ -1,9 +1,7 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast::{self, NameOwner, VisibilityOwner}, | 2 | ast::{self, NameOwner, VisibilityOwner}, |
3 | AstNode, | 3 | AstNode, |
4 | SyntaxKind::{ | 4 | SyntaxKind::{CONST, ENUM, FN, MODULE, STATIC, STRUCT, TRAIT, VISIBILITY}, |
5 | CONST_DEF, ENUM_DEF, FN_DEF, MODULE, STATIC_DEF, STRUCT_DEF, TRAIT_DEF, VISIBILITY, | ||
6 | }, | ||
7 | T, | 5 | T, |
8 | }; | 6 | }; |
9 | use test_utils::mark; | 7 | use test_utils::mark; |
@@ -38,7 +36,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
38 | 36 | ||
39 | let (offset, target) = if let Some(keyword) = item_keyword { | 37 | let (offset, target) = if let Some(keyword) = item_keyword { |
40 | let parent = keyword.parent(); | 38 | let parent = keyword.parent(); |
41 | let def_kws = vec![CONST_DEF, STATIC_DEF, FN_DEF, MODULE, STRUCT_DEF, ENUM_DEF, TRAIT_DEF]; | 39 | let def_kws = vec![CONST, STATIC, FN, MODULE, STRUCT, ENUM, TRAIT]; |
42 | // Parent is not a definition, can't add visibility | 40 | // Parent is not a definition, can't add visibility |
43 | if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) { | 41 | if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) { |
44 | return None; | 42 | return None; |
@@ -49,7 +47,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
49 | } | 47 | } |
50 | (vis_offset(&parent), keyword.text_range()) | 48 | (vis_offset(&parent), keyword.text_range()) |
51 | } else if let Some(field_name) = ctx.find_node_at_offset::<ast::Name>() { | 49 | } else if let Some(field_name) = ctx.find_node_at_offset::<ast::Name>() { |
52 | let field = field_name.syntax().ancestors().find_map(ast::RecordFieldDef::cast)?; | 50 | let field = field_name.syntax().ancestors().find_map(ast::RecordField::cast)?; |
53 | if field.name()? != field_name { | 51 | if field.name()? != field_name { |
54 | mark::hit!(change_visibility_field_false_positive); | 52 | mark::hit!(change_visibility_field_false_positive); |
55 | return None; | 53 | return None; |
@@ -58,7 +56,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
58 | return None; | 56 | return None; |
59 | } | 57 | } |
60 | (vis_offset(field.syntax()), field_name.syntax().text_range()) | 58 | (vis_offset(field.syntax()), field_name.syntax().text_range()) |
61 | } else if let Some(field) = ctx.find_node_at_offset::<ast::TupleFieldDef>() { | 59 | } else if let Some(field) = ctx.find_node_at_offset::<ast::TupleField>() { |
62 | if field.visibility().is_some() { | 60 | if field.visibility().is_some() { |
63 | return None; | 61 | return None; |
64 | } | 62 | } |