|
1 | 1 | use syntax::{ |
2 | 2 | ast::{self, NameOwner, VisibilityOwner}, |
3 | 3 | AstNode, |
4 | | - SyntaxKind::{CONST, ENUM, FN, MODULE, STATIC, STRUCT, TRAIT, VISIBILITY}, |
| 4 | + SyntaxKind::{CONST, ENUM, FN, MODULE, STATIC, STRUCT, TRAIT, TYPE_ALIAS, VISIBILITY}, |
5 | 5 | T, |
6 | 6 | }; |
7 | 7 | use test_utils::mark; |
@@ -30,13 +30,20 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
30 | 30 | let item_keyword = ctx.token_at_offset().find(|leaf| { |
31 | 31 | matches!( |
32 | 32 | leaf.kind(), |
33 | | - T![const] | T![static] | T![fn] | T![mod] | T![struct] | T![enum] | T![trait] |
| 33 | + T![const] |
| 34 | + | T![static] |
| 35 | + | T![fn] |
| 36 | + | T![mod] |
| 37 | + | T![struct] |
| 38 | + | T![enum] |
| 39 | + | T![trait] |
| 40 | + | T![type] |
34 | 41 | ) |
35 | 42 | }); |
36 | 43 |
|
37 | 44 | let (offset, target) = if let Some(keyword) = item_keyword { |
38 | 45 | let parent = keyword.parent(); |
39 | | - let def_kws = vec![CONST, STATIC, FN, MODULE, STRUCT, ENUM, TRAIT]; |
| 46 | + let def_kws = vec![CONST, STATIC, TYPE_ALIAS, FN, MODULE, STRUCT, ENUM, TRAIT]; |
40 | 47 | // Parent is not a definition, can't add visibility |
41 | 48 | if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) { |
42 | 49 | return None; |
@@ -159,6 +166,11 @@ mod tests { |
159 | 166 | check_assist(change_visibility, "<|>static FOO = 3u8;", "pub(crate) static FOO = 3u8;"); |
160 | 167 | } |
161 | 168 |
|
| 169 | + #[test] |
| 170 | + fn change_visibility_type_alias() { |
| 171 | + check_assist(change_visibility, "<|>type T = ();", "pub(crate) type T = ();"); |
| 172 | + } |
| 173 | + |
162 | 174 | #[test] |
163 | 175 | fn change_visibility_handles_comment_attrs() { |
164 | 176 | check_assist( |
|
0 commit comments