diff options
Diffstat (limited to 'crates/ra_assists/src/handlers/fix_visibility.rs')
-rw-r--r-- | crates/ra_assists/src/handlers/fix_visibility.rs | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/crates/ra_assists/src/handlers/fix_visibility.rs b/crates/ra_assists/src/handlers/fix_visibility.rs index 54601d1f3..19d4dac5e 100644 --- a/crates/ra_assists/src/handlers/fix_visibility.rs +++ b/crates/ra_assists/src/handlers/fix_visibility.rs | |||
@@ -1,12 +1,8 @@ | |||
1 | use hir::{db::HirDatabase, HasSource, HasVisibility, PathResolution}; | 1 | use hir::{db::HirDatabase, HasSource, HasVisibility, PathResolution}; |
2 | use ra_db::FileId; | 2 | use ra_db::FileId; |
3 | use ra_syntax::{ | 3 | use ra_syntax::{ast, AstNode, TextRange, TextSize}; |
4 | ast, AstNode, | ||
5 | SyntaxKind::{ATTR, COMMENT, WHITESPACE}, | ||
6 | SyntaxNode, TextRange, TextSize, | ||
7 | }; | ||
8 | 4 | ||
9 | use crate::{AssistContext, AssistId, Assists}; | 5 | use crate::{utils::vis_offset, AssistContext, AssistId, Assists}; |
10 | 6 | ||
11 | // FIXME: this really should be a fix for diagnostic, rather than an assist. | 7 | // FIXME: this really should be a fix for diagnostic, rather than an assist. |
12 | 8 | ||
@@ -177,17 +173,6 @@ fn target_data_for_def( | |||
177 | Some((offset, target, target_file, target_name)) | 173 | Some((offset, target, target_file, target_name)) |
178 | } | 174 | } |
179 | 175 | ||
180 | fn vis_offset(node: &SyntaxNode) -> TextSize { | ||
181 | node.children_with_tokens() | ||
182 | .skip_while(|it| match it.kind() { | ||
183 | WHITESPACE | COMMENT | ATTR => true, | ||
184 | _ => false, | ||
185 | }) | ||
186 | .next() | ||
187 | .map(|it| it.text_range().start()) | ||
188 | .unwrap_or_else(|| node.text_range().start()) | ||
189 | } | ||
190 | |||
191 | #[cfg(test)] | 176 | #[cfg(test)] |
192 | mod tests { | 177 | mod tests { |
193 | use crate::tests::{check_assist, check_assist_not_applicable}; | 178 | use crate::tests::{check_assist, check_assist_not_applicable}; |