Skip to content

Commit 80b3b74

Browse files
bors[bot]maan2003
andauthored
9215: change visibility for use and macro items r=jonas-schievink a=Maan2003 Co-authored-by: Maan2003 <manmeetmann2003@gmail.com>
2 parents 050232a + 4c1a022 commit 80b3b74

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

crates/ide_assists/src/handlers/change_visibility.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use syntax::{
22
ast::{self, NameOwner, VisibilityOwner},
33
AstNode,
4-
SyntaxKind::{CONST, ENUM, FN, MODULE, STATIC, STRUCT, TRAIT, TYPE_ALIAS, VISIBILITY},
4+
SyntaxKind::{
5+
CONST, ENUM, FN, MACRO_DEF, MODULE, STATIC, STRUCT, TRAIT, TYPE_ALIAS, USE, VISIBILITY,
6+
},
57
T,
68
};
79

@@ -37,12 +39,15 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
3739
| T![enum]
3840
| T![trait]
3941
| T![type]
42+
| T![use]
43+
| T![macro]
4044
)
4145
});
4246

4347
let (offset, target) = if let Some(keyword) = item_keyword {
4448
let parent = keyword.parent()?;
45-
let def_kws = vec![CONST, STATIC, TYPE_ALIAS, FN, MODULE, STRUCT, ENUM, TRAIT];
49+
let def_kws =
50+
vec![CONST, STATIC, TYPE_ALIAS, FN, MODULE, STRUCT, ENUM, TRAIT, USE, MACRO_DEF];
4651
// Parent is not a definition, can't add visibility
4752
if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) {
4853
return None;
@@ -122,6 +127,8 @@ mod tests {
122127
check_assist(change_visibility, "$0trait Foo {}", "pub(crate) trait Foo {}");
123128
check_assist(change_visibility, "m$0od {}", "pub(crate) mod {}");
124129
check_assist(change_visibility, "unsafe f$0n foo() {}", "pub(crate) unsafe fn foo() {}");
130+
check_assist(change_visibility, "$0macro foo() {}", "pub(crate) macro foo() {}");
131+
check_assist(change_visibility, "$0use foo;", "pub(crate) use foo;");
125132
}
126133

127134
#[test]

0 commit comments

Comments
 (0)