aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/assists/change_visibility.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src/assists/change_visibility.rs')
-rw-r--r--crates/ra_assists/src/assists/change_visibility.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/crates/ra_assists/src/assists/change_visibility.rs b/crates/ra_assists/src/assists/change_visibility.rs
index fd766bb46..f325b6f92 100644
--- a/crates/ra_assists/src/assists/change_visibility.rs
+++ b/crates/ra_assists/src/assists/change_visibility.rs
@@ -1,4 +1,3 @@
1use hir::db::HirDatabase;
2use ra_syntax::{ 1use ra_syntax::{
3 ast::{self, NameOwner, VisibilityOwner}, 2 ast::{self, NameOwner, VisibilityOwner},
4 AstNode, 3 AstNode,
@@ -22,14 +21,14 @@ use crate::{Assist, AssistCtx, AssistId};
22// ``` 21// ```
23// pub(crate) fn frobnicate() {} 22// pub(crate) fn frobnicate() {}
24// ``` 23// ```
25pub(crate) fn change_visibility(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 24pub(crate) fn change_visibility(ctx: AssistCtx) -> Option<Assist> {
26 if let Some(vis) = ctx.find_node_at_offset::<ast::Visibility>() { 25 if let Some(vis) = ctx.find_node_at_offset::<ast::Visibility>() {
27 return change_vis(ctx, vis); 26 return change_vis(ctx, vis);
28 } 27 }
29 add_vis(ctx) 28 add_vis(ctx)
30} 29}
31 30
32fn add_vis(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 31fn add_vis(ctx: AssistCtx) -> Option<Assist> {
33 let item_keyword = ctx.token_at_offset().find(|leaf| match leaf.kind() { 32 let item_keyword = ctx.token_at_offset().find(|leaf| match leaf.kind() {
34 T![fn] | T![mod] | T![struct] | T![enum] | T![trait] => true, 33 T![fn] | T![mod] | T![struct] | T![enum] | T![trait] => true,
35 _ => false, 34 _ => false,
@@ -75,7 +74,7 @@ fn vis_offset(node: &SyntaxNode) -> TextUnit {
75 .unwrap_or_else(|| node.text_range().start()) 74 .unwrap_or_else(|| node.text_range().start())
76} 75}
77 76
78fn change_vis(ctx: AssistCtx<impl HirDatabase>, vis: ast::Visibility) -> Option<Assist> { 77fn change_vis(ctx: AssistCtx, vis: ast::Visibility) -> Option<Assist> {
79 if vis.syntax().text() == "pub" { 78 if vis.syntax().text() == "pub" {
80 return ctx.add_assist( 79 return ctx.add_assist(
81 AssistId("change_visibility"), 80 AssistId("change_visibility"),