diff options
Diffstat (limited to 'crates/ra_assists')
-rw-r--r-- | crates/ra_assists/src/add_derive.rs | 4 | ||||
-rw-r--r-- | crates/ra_assists/src/add_explicit_type.rs | 11 | ||||
-rw-r--r-- | crates/ra_assists/src/add_impl.rs | 4 | ||||
-rw-r--r-- | crates/ra_assists/src/add_missing_impl_members.rs | 11 | ||||
-rw-r--r-- | crates/ra_assists/src/assist_ctx.rs | 10 | ||||
-rw-r--r-- | crates/ra_assists/src/ast_editor.rs | 10 | ||||
-rw-r--r-- | crates/ra_assists/src/auto_import.rs | 17 | ||||
-rw-r--r-- | crates/ra_assists/src/change_visibility.rs | 13 | ||||
-rw-r--r-- | crates/ra_assists/src/fill_match_arms.rs | 9 | ||||
-rw-r--r-- | crates/ra_assists/src/flip_binexpr.rs | 4 | ||||
-rw-r--r-- | crates/ra_assists/src/flip_comma.rs | 8 | ||||
-rw-r--r-- | crates/ra_assists/src/inline_local_variable.rs | 4 | ||||
-rw-r--r-- | crates/ra_assists/src/introduce_variable.rs | 12 | ||||
-rw-r--r-- | crates/ra_assists/src/lib.rs | 16 | ||||
-rw-r--r-- | crates/ra_assists/src/move_guard.rs | 9 | ||||
-rw-r--r-- | crates/ra_assists/src/remove_dbg.rs | 5 | ||||
-rw-r--r-- | crates/ra_assists/src/replace_if_let_with_match.rs | 6 | ||||
-rw-r--r-- | crates/ra_assists/src/split_import.rs | 8 |
18 files changed, 79 insertions, 82 deletions
diff --git a/crates/ra_assists/src/add_derive.rs b/crates/ra_assists/src/add_derive.rs index 0c4cf2615..bf7d55d6d 100644 --- a/crates/ra_assists/src/add_derive.rs +++ b/crates/ra_assists/src/add_derive.rs | |||
@@ -1,11 +1,11 @@ | |||
1 | use hir::db::HirDatabase; | 1 | use hir::db::HirDatabase; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | ast::{self, AstNode, AttrsOwner}, | 3 | ast::{self, AstNode, AttrsOwner}, |
4 | SyntaxKind::{WHITESPACE, COMMENT}, | 4 | SyntaxKind::{COMMENT, WHITESPACE}, |
5 | TextUnit, | 5 | TextUnit, |
6 | }; | 6 | }; |
7 | 7 | ||
8 | use crate::{AssistCtx, Assist, AssistId}; | 8 | use crate::{Assist, AssistCtx, AssistId}; |
9 | 9 | ||
10 | pub(crate) fn add_derive(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 10 | pub(crate) fn add_derive(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
11 | let nominal = ctx.node_at_offset::<ast::NominalDef>()?; | 11 | let nominal = ctx.node_at_offset::<ast::NominalDef>()?; |
diff --git a/crates/ra_assists/src/add_explicit_type.rs b/crates/ra_assists/src/add_explicit_type.rs index f3ed74b7f..bb47a32f0 100644 --- a/crates/ra_assists/src/add_explicit_type.rs +++ b/crates/ra_assists/src/add_explicit_type.rs | |||
@@ -1,13 +1,10 @@ | |||
1 | use hir::{ | 1 | use hir::{db::HirDatabase, HirDisplay, Ty}; |
2 | HirDisplay, Ty, | ||
3 | db::HirDatabase, | ||
4 | }; | ||
5 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | ast::{AstNode, LetStmt, NameOwner, PatKind}, | ||
6 | T, | 4 | T, |
7 | ast::{LetStmt, PatKind, NameOwner, AstNode} | ||
8 | }; | 5 | }; |
9 | 6 | ||
10 | use crate::{AssistCtx, Assist, AssistId}; | 7 | use crate::{Assist, AssistCtx, AssistId}; |
11 | 8 | ||
12 | /// Add explicit type assist. | 9 | /// Add explicit type assist. |
13 | pub(crate) fn add_explicit_type(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 10 | pub(crate) fn add_explicit_type(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
@@ -56,7 +53,7 @@ fn is_unknown(ty: &Ty) -> bool { | |||
56 | mod tests { | 53 | mod tests { |
57 | use super::*; | 54 | use super::*; |
58 | 55 | ||
59 | use crate::helpers::{ check_assist, check_assist_target, check_assist_not_applicable }; | 56 | use crate::helpers::{check_assist, check_assist_not_applicable, check_assist_target}; |
60 | 57 | ||
61 | #[test] | 58 | #[test] |
62 | fn add_explicit_type_target() { | 59 | fn add_explicit_type_target() { |
diff --git a/crates/ra_assists/src/add_impl.rs b/crates/ra_assists/src/add_impl.rs index fa1c85890..b81922c1d 100644 --- a/crates/ra_assists/src/add_impl.rs +++ b/crates/ra_assists/src/add_impl.rs | |||
@@ -1,11 +1,11 @@ | |||
1 | use join_to_string::join; | ||
2 | use hir::db::HirDatabase; | 1 | use hir::db::HirDatabase; |
2 | use join_to_string::join; | ||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | ast::{self, AstNode, NameOwner, TypeParamsOwner}, | 4 | ast::{self, AstNode, NameOwner, TypeParamsOwner}, |
5 | TextUnit, | 5 | TextUnit, |
6 | }; | 6 | }; |
7 | 7 | ||
8 | use crate::{AssistCtx, Assist, AssistId}; | 8 | use crate::{Assist, AssistCtx, AssistId}; |
9 | 9 | ||
10 | pub(crate) fn add_impl(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 10 | pub(crate) fn add_impl(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
11 | let nominal = ctx.node_at_offset::<ast::NominalDef>()?; | 11 | let nominal = ctx.node_at_offset::<ast::NominalDef>()?; |
diff --git a/crates/ra_assists/src/add_missing_impl_members.rs b/crates/ra_assists/src/add_missing_impl_members.rs index 0c903a563..7fc8f63b3 100644 --- a/crates/ra_assists/src/add_missing_impl_members.rs +++ b/crates/ra_assists/src/add_missing_impl_members.rs | |||
@@ -1,9 +1,12 @@ | |||
1 | use crate::{Assist, AssistId, AssistCtx, ast_editor::{AstEditor, AstBuilder}}; | 1 | use crate::{ |
2 | ast_editor::{AstBuilder, AstEditor}, | ||
3 | Assist, AssistCtx, AssistId, | ||
4 | }; | ||
2 | 5 | ||
3 | use hir::{HasSource, db::HirDatabase}; | 6 | use hir::{db::HirDatabase, HasSource}; |
4 | use ra_syntax::{SmolStr, TreeArc}; | ||
5 | use ra_syntax::ast::{self, AstNode, ImplItem, ImplItemKind, NameOwner}; | ||
6 | use ra_db::FilePosition; | 7 | use ra_db::FilePosition; |
8 | use ra_syntax::ast::{self, AstNode, ImplItem, ImplItemKind, NameOwner}; | ||
9 | use ra_syntax::{SmolStr, TreeArc}; | ||
7 | 10 | ||
8 | #[derive(PartialEq)] | 11 | #[derive(PartialEq)] |
9 | enum AddMissingImplMembersMode { | 12 | enum AddMissingImplMembersMode { |
diff --git a/crates/ra_assists/src/assist_ctx.rs b/crates/ra_assists/src/assist_ctx.rs index 1d58d9e71..0ba5f3ae6 100644 --- a/crates/ra_assists/src/assist_ctx.rs +++ b/crates/ra_assists/src/assist_ctx.rs | |||
@@ -1,13 +1,13 @@ | |||
1 | use hir::db::HirDatabase; | 1 | use hir::db::HirDatabase; |
2 | use ra_text_edit::TextEditBuilder; | ||
3 | use ra_db::FileRange; | 2 | use ra_db::FileRange; |
3 | use ra_fmt::{leading_indent, reindent}; | ||
4 | use ra_syntax::{ | 4 | use ra_syntax::{ |
5 | SourceFile, TextRange, AstNode, TextUnit, SyntaxNode, SyntaxElement, SyntaxToken, | 5 | algo::{find_covering_element, find_node_at_offset, find_token_at_offset, TokenAtOffset}, |
6 | algo::{find_token_at_offset, find_node_at_offset, find_covering_element, TokenAtOffset}, | 6 | AstNode, SourceFile, SyntaxElement, SyntaxNode, SyntaxToken, TextRange, TextUnit, |
7 | }; | 7 | }; |
8 | use ra_fmt::{leading_indent, reindent}; | 8 | use ra_text_edit::TextEditBuilder; |
9 | 9 | ||
10 | use crate::{AssistLabel, AssistAction, AssistId}; | 10 | use crate::{AssistAction, AssistId, AssistLabel}; |
11 | 11 | ||
12 | #[derive(Clone, Debug)] | 12 | #[derive(Clone, Debug)] |
13 | pub(crate) enum Assist { | 13 | pub(crate) enum Assist { |
diff --git a/crates/ra_assists/src/ast_editor.rs b/crates/ra_assists/src/ast_editor.rs index 5f8ba3df6..c9a5cf8d9 100644 --- a/crates/ra_assists/src/ast_editor.rs +++ b/crates/ra_assists/src/ast_editor.rs | |||
@@ -1,10 +1,12 @@ | |||
1 | use std::{iter, ops::RangeInclusive}; | 1 | use std::{iter, ops::RangeInclusive}; |
2 | 2 | ||
3 | use arrayvec::ArrayVec; | 3 | use arrayvec::ArrayVec; |
4 | use ra_text_edit::TextEditBuilder; | ||
5 | use ra_syntax::{AstNode, TreeArc, ast, SyntaxKind::*, SyntaxElement, SourceFile, InsertPosition, Direction, T}; | ||
6 | use ra_fmt::leading_indent; | ||
7 | use hir::Name; | 4 | use hir::Name; |
5 | use ra_fmt::leading_indent; | ||
6 | use ra_syntax::{ | ||
7 | ast, AstNode, Direction, InsertPosition, SourceFile, SyntaxElement, SyntaxKind::*, TreeArc, T, | ||
8 | }; | ||
9 | use ra_text_edit::TextEditBuilder; | ||
8 | 10 | ||
9 | pub struct AstEditor<N: AstNode> { | 11 | pub struct AstEditor<N: AstNode> { |
10 | original_ast: TreeArc<N>, | 12 | original_ast: TreeArc<N>, |
@@ -283,7 +285,7 @@ fn ast_node_from_file_text<N: AstNode>(text: &str) -> TreeArc<N> { | |||
283 | 285 | ||
284 | mod tokens { | 286 | mod tokens { |
285 | use once_cell::sync::Lazy; | 287 | use once_cell::sync::Lazy; |
286 | use ra_syntax::{AstNode, SourceFile, TreeArc, SyntaxToken, SyntaxKind::*, T}; | 288 | use ra_syntax::{AstNode, SourceFile, SyntaxKind::*, SyntaxToken, TreeArc, T}; |
287 | 289 | ||
288 | static SOURCE_FILE: Lazy<TreeArc<SourceFile>> = Lazy::new(|| SourceFile::parse(",\n; ;").tree); | 290 | static SOURCE_FILE: Lazy<TreeArc<SourceFile>> = Lazy::new(|| SourceFile::parse(",\n; ;").tree); |
289 | 291 | ||
diff --git a/crates/ra_assists/src/auto_import.rs b/crates/ra_assists/src/auto_import.rs index 9617beb5c..75ab8fa0f 100644 --- a/crates/ra_assists/src/auto_import.rs +++ b/crates/ra_assists/src/auto_import.rs | |||
@@ -1,14 +1,15 @@ | |||
1 | use hir::{self, db::HirDatabase}; | ||
1 | use ra_text_edit::TextEditBuilder; | 2 | use ra_text_edit::TextEditBuilder; |
2 | use hir::{ self, db::HirDatabase}; | ||
3 | 3 | ||
4 | use ra_syntax::{ | ||
5 | T, | ||
6 | ast::{ self, NameOwner }, AstNode, SyntaxNode, Direction, TextRange, SmolStr, | ||
7 | SyntaxKind::{ PATH, PATH_SEGMENT } | ||
8 | }; | ||
9 | use crate::{ | 4 | use crate::{ |
5 | assist_ctx::{Assist, AssistCtx}, | ||
10 | AssistId, | 6 | AssistId, |
11 | assist_ctx::{AssistCtx, Assist}, | 7 | }; |
8 | use ra_syntax::{ | ||
9 | ast::{self, NameOwner}, | ||
10 | AstNode, Direction, SmolStr, | ||
11 | SyntaxKind::{PATH, PATH_SEGMENT}, | ||
12 | SyntaxNode, TextRange, T, | ||
12 | }; | 13 | }; |
13 | 14 | ||
14 | fn collect_path_segments_raw<'a>( | 15 | fn collect_path_segments_raw<'a>( |
@@ -577,7 +578,7 @@ pub(crate) fn auto_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist | |||
577 | #[cfg(test)] | 578 | #[cfg(test)] |
578 | mod tests { | 579 | mod tests { |
579 | use super::*; | 580 | use super::*; |
580 | use crate::helpers::{ check_assist, check_assist_not_applicable }; | 581 | use crate::helpers::{check_assist, check_assist_not_applicable}; |
581 | 582 | ||
582 | #[test] | 583 | #[test] |
583 | fn test_auto_import_add_use_no_anchor() { | 584 | fn test_auto_import_add_use_no_anchor() { |
diff --git a/crates/ra_assists/src/change_visibility.rs b/crates/ra_assists/src/change_visibility.rs index 4eb24d27f..6cabba3e3 100644 --- a/crates/ra_assists/src/change_visibility.rs +++ b/crates/ra_assists/src/change_visibility.rs | |||
@@ -1,12 +1,15 @@ | |||
1 | use hir::db::HirDatabase; | 1 | use hir::db::HirDatabase; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | T, | 3 | ast::{self, NameOwner, VisibilityOwner}, |
4 | AstNode, SyntaxNode, TextUnit, | 4 | AstNode, |
5 | ast::{self, VisibilityOwner, NameOwner}, | 5 | SyntaxKind::{ |
6 | SyntaxKind::{VISIBILITY, FN_DEF, MODULE, STRUCT_DEF, ENUM_DEF, TRAIT_DEF, IDENT, WHITESPACE, COMMENT, ATTR}, | 6 | ATTR, COMMENT, ENUM_DEF, FN_DEF, IDENT, MODULE, STRUCT_DEF, TRAIT_DEF, VISIBILITY, |
7 | WHITESPACE, | ||
8 | }, | ||
9 | SyntaxNode, TextUnit, T, | ||
7 | }; | 10 | }; |
8 | 11 | ||
9 | use crate::{AssistCtx, Assist, AssistId}; | 12 | use crate::{Assist, AssistCtx, AssistId}; |
10 | 13 | ||
11 | pub(crate) fn change_visibility(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 14 | pub(crate) fn change_visibility(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
12 | if let Some(vis) = ctx.node_at_offset::<ast::Visibility>() { | 15 | if let Some(vis) = ctx.node_at_offset::<ast::Visibility>() { |
diff --git a/crates/ra_assists/src/fill_match_arms.rs b/crates/ra_assists/src/fill_match_arms.rs index 71b101b40..d51010b84 100644 --- a/crates/ra_assists/src/fill_match_arms.rs +++ b/crates/ra_assists/src/fill_match_arms.rs | |||
@@ -1,13 +1,10 @@ | |||
1 | use std::fmt::Write; | ||
2 | use itertools::Itertools; | 1 | use itertools::Itertools; |
2 | use std::fmt::Write; | ||
3 | 3 | ||
4 | use hir::{ | 4 | use hir::{db::HirDatabase, AdtDef, FieldSource, HasSource}; |
5 | AdtDef, FieldSource, HasSource, | ||
6 | db::HirDatabase, | ||
7 | }; | ||
8 | use ra_syntax::ast::{self, AstNode}; | 5 | use ra_syntax::ast::{self, AstNode}; |
9 | 6 | ||
10 | use crate::{AssistCtx, Assist, AssistId}; | 7 | use crate::{Assist, AssistCtx, AssistId}; |
11 | 8 | ||
12 | fn is_trivial_arm(arm: &ast::MatchArm) -> bool { | 9 | fn is_trivial_arm(arm: &ast::MatchArm) -> bool { |
13 | fn single_pattern(arm: &ast::MatchArm) -> Option<ast::PatKind> { | 10 | fn single_pattern(arm: &ast::MatchArm) -> Option<ast::PatKind> { |
diff --git a/crates/ra_assists/src/flip_binexpr.rs b/crates/ra_assists/src/flip_binexpr.rs index 02d27f66d..5e41f9346 100644 --- a/crates/ra_assists/src/flip_binexpr.rs +++ b/crates/ra_assists/src/flip_binexpr.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use hir::db::HirDatabase; | 1 | use hir::db::HirDatabase; |
2 | use ra_syntax::ast::{AstNode, BinExpr, BinOp}; | 2 | use ra_syntax::ast::{AstNode, BinExpr, BinOp}; |
3 | 3 | ||
4 | use crate::{AssistCtx, Assist, AssistId}; | 4 | use crate::{Assist, AssistCtx, AssistId}; |
5 | 5 | ||
6 | /// Flip binary expression assist. | 6 | /// Flip binary expression assist. |
7 | pub(crate) fn flip_binexpr(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 7 | pub(crate) fn flip_binexpr(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
@@ -68,7 +68,7 @@ impl From<BinOp> for FlipAction { | |||
68 | mod tests { | 68 | mod tests { |
69 | use super::*; | 69 | use super::*; |
70 | 70 | ||
71 | use crate::helpers::{ check_assist, check_assist_target, check_assist_not_applicable }; | 71 | use crate::helpers::{check_assist, check_assist_not_applicable, check_assist_target}; |
72 | 72 | ||
73 | #[test] | 73 | #[test] |
74 | fn flip_binexpr_target_is_the_op() { | 74 | fn flip_binexpr_target_is_the_op() { |
diff --git a/crates/ra_assists/src/flip_comma.rs b/crates/ra_assists/src/flip_comma.rs index 7626ffad3..d8dba779f 100644 --- a/crates/ra_assists/src/flip_comma.rs +++ b/crates/ra_assists/src/flip_comma.rs | |||
@@ -1,11 +1,7 @@ | |||
1 | use hir::db::HirDatabase; | 1 | use hir::db::HirDatabase; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{algo::non_trivia_sibling, Direction, T}; |
3 | T, | ||
4 | Direction, | ||
5 | algo::non_trivia_sibling, | ||
6 | }; | ||
7 | 3 | ||
8 | use crate::{AssistCtx, Assist, AssistId}; | 4 | use crate::{Assist, AssistCtx, AssistId}; |
9 | 5 | ||
10 | pub(crate) fn flip_comma(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 6 | pub(crate) fn flip_comma(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
11 | let comma = ctx.token_at_offset().find(|leaf| leaf.kind() == T![,])?; | 7 | let comma = ctx.token_at_offset().find(|leaf| leaf.kind() == T![,])?; |
diff --git a/crates/ra_assists/src/inline_local_variable.rs b/crates/ra_assists/src/inline_local_variable.rs index e0479ef13..554de8b46 100644 --- a/crates/ra_assists/src/inline_local_variable.rs +++ b/crates/ra_assists/src/inline_local_variable.rs | |||
@@ -1,11 +1,11 @@ | |||
1 | use hir::db::HirDatabase; | 1 | use hir::db::HirDatabase; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | ast::{self, AstNode, AstToken, PatKind, ExprKind}, | 3 | ast::{self, AstNode, AstToken, ExprKind, PatKind}, |
4 | TextRange, | 4 | TextRange, |
5 | }; | 5 | }; |
6 | 6 | ||
7 | use crate::{Assist, AssistCtx, AssistId}; | ||
8 | use crate::assist_ctx::AssistBuilder; | 7 | use crate::assist_ctx::AssistBuilder; |
8 | use crate::{Assist, AssistCtx, AssistId}; | ||
9 | 9 | ||
10 | pub(crate) fn inline_local_varialbe(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 10 | pub(crate) fn inline_local_varialbe(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
11 | let let_stmt = ctx.node_at_offset::<ast::LetStmt>()?; | 11 | let let_stmt = ctx.node_at_offset::<ast::LetStmt>()?; |
diff --git a/crates/ra_assists/src/introduce_variable.rs b/crates/ra_assists/src/introduce_variable.rs index 28467d341..f7f5ccafa 100644 --- a/crates/ra_assists/src/introduce_variable.rs +++ b/crates/ra_assists/src/introduce_variable.rs | |||
@@ -1,12 +1,14 @@ | |||
1 | use test_utils::tested_by; | ||
2 | use hir::db::HirDatabase; | 1 | use hir::db::HirDatabase; |
3 | use ra_syntax::{ | 2 | use ra_syntax::{ |
4 | ast::{self, AstNode}, | 3 | ast::{self, AstNode}, |
4 | SyntaxKind::{ | ||
5 | BREAK_EXPR, COMMENT, LAMBDA_EXPR, LOOP_EXPR, MATCH_ARM, PATH_EXPR, RETURN_EXPR, WHITESPACE, | ||
6 | }, | ||
5 | SyntaxNode, TextUnit, | 7 | SyntaxNode, TextUnit, |
6 | SyntaxKind::{WHITESPACE, MATCH_ARM, LAMBDA_EXPR, PATH_EXPR, BREAK_EXPR, LOOP_EXPR, RETURN_EXPR, COMMENT}, | ||
7 | }; | 8 | }; |
9 | use test_utils::tested_by; | ||
8 | 10 | ||
9 | use crate::{AssistCtx, Assist, AssistId}; | 11 | use crate::{Assist, AssistCtx, AssistId}; |
10 | 12 | ||
11 | pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 13 | pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
12 | if ctx.frange.range.is_empty() { | 14 | if ctx.frange.range.is_empty() { |
@@ -121,7 +123,9 @@ fn anchor_stmt(expr: &ast::Expr) -> Option<(&SyntaxNode, bool)> { | |||
121 | mod tests { | 123 | mod tests { |
122 | use test_utils::covers; | 124 | use test_utils::covers; |
123 | 125 | ||
124 | use crate::helpers::{check_assist_range_not_applicable, check_assist_range, check_assist_range_target}; | 126 | use crate::helpers::{ |
127 | check_assist_range, check_assist_range_not_applicable, check_assist_range_target, | ||
128 | }; | ||
125 | 129 | ||
126 | use super::*; | 130 | use super::*; |
127 | 131 | ||
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index 28eb0226b..0d848629d 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs | |||
@@ -11,12 +11,12 @@ pub mod ast_editor; | |||
11 | 11 | ||
12 | use itertools::Itertools; | 12 | use itertools::Itertools; |
13 | 13 | ||
14 | use ra_text_edit::TextEdit; | ||
15 | use ra_syntax::{TextRange, TextUnit}; | ||
16 | use ra_db::FileRange; | ||
17 | use hir::db::HirDatabase; | 14 | use hir::db::HirDatabase; |
15 | use ra_db::FileRange; | ||
16 | use ra_syntax::{TextRange, TextUnit}; | ||
17 | use ra_text_edit::TextEdit; | ||
18 | 18 | ||
19 | pub(crate) use crate::assist_ctx::{AssistCtx, Assist}; | 19 | pub(crate) use crate::assist_ctx::{Assist, AssistCtx}; |
20 | 20 | ||
21 | /// Unique identifier of the assist, should not be shown to the user | 21 | /// Unique identifier of the assist, should not be shown to the user |
22 | /// directly. | 22 | /// directly. |
@@ -127,11 +127,11 @@ fn all_assists<DB: HirDatabase>() -> &'static [fn(AssistCtx<DB>) -> Option<Assis | |||
127 | #[cfg(test)] | 127 | #[cfg(test)] |
128 | mod helpers { | 128 | mod helpers { |
129 | use hir::mock::MockDatabase; | 129 | use hir::mock::MockDatabase; |
130 | use ra_syntax::TextRange; | ||
131 | use ra_db::FileRange; | 130 | use ra_db::FileRange; |
132 | use test_utils::{extract_offset, extract_range, assert_eq_text, add_cursor}; | 131 | use ra_syntax::TextRange; |
132 | use test_utils::{add_cursor, assert_eq_text, extract_offset, extract_range}; | ||
133 | 133 | ||
134 | use crate::{AssistCtx, Assist}; | 134 | use crate::{Assist, AssistCtx}; |
135 | 135 | ||
136 | pub(crate) fn check_assist( | 136 | pub(crate) fn check_assist( |
137 | assist: fn(AssistCtx<MockDatabase>) -> Option<Assist>, | 137 | assist: fn(AssistCtx<MockDatabase>) -> Option<Assist>, |
@@ -289,8 +289,8 @@ mod helpers { | |||
289 | #[cfg(test)] | 289 | #[cfg(test)] |
290 | mod tests { | 290 | mod tests { |
291 | use hir::mock::MockDatabase; | 291 | use hir::mock::MockDatabase; |
292 | use ra_syntax::TextRange; | ||
293 | use ra_db::FileRange; | 292 | use ra_db::FileRange; |
293 | use ra_syntax::TextRange; | ||
294 | use test_utils::{extract_offset, extract_range}; | 294 | use test_utils::{extract_offset, extract_range}; |
295 | 295 | ||
296 | #[test] | 296 | #[test] |
diff --git a/crates/ra_assists/src/move_guard.rs b/crates/ra_assists/src/move_guard.rs index 22ba91fb7..e1ce86a33 100644 --- a/crates/ra_assists/src/move_guard.rs +++ b/crates/ra_assists/src/move_guard.rs | |||
@@ -1,12 +1,11 @@ | |||
1 | use hir::db::HirDatabase; | 1 | use hir::db::HirDatabase; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | TextUnit, | ||
4 | SyntaxElement, | ||
5 | ast::{MatchArm, AstNode, AstToken, IfExpr}, | ||
6 | ast, | 3 | ast, |
4 | ast::{AstNode, AstToken, IfExpr, MatchArm}, | ||
5 | SyntaxElement, TextUnit, | ||
7 | }; | 6 | }; |
8 | 7 | ||
9 | use crate::{AssistCtx, Assist, AssistId}; | 8 | use crate::{Assist, AssistCtx, AssistId}; |
10 | 9 | ||
11 | pub(crate) fn move_guard_to_arm_body(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 10 | pub(crate) fn move_guard_to_arm_body(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
12 | let match_arm = ctx.node_at_offset::<MatchArm>()?; | 11 | let match_arm = ctx.node_at_offset::<MatchArm>()?; |
@@ -84,7 +83,7 @@ pub(crate) fn move_arm_cond_to_match_guard(mut ctx: AssistCtx<impl HirDatabase>) | |||
84 | mod tests { | 83 | mod tests { |
85 | use super::*; | 84 | use super::*; |
86 | 85 | ||
87 | use crate::helpers::{ check_assist, check_assist_target, check_assist_not_applicable }; | 86 | use crate::helpers::{check_assist, check_assist_not_applicable, check_assist_target}; |
88 | 87 | ||
89 | #[test] | 88 | #[test] |
90 | fn move_guard_to_arm_body_target() { | 89 | fn move_guard_to_arm_body_target() { |
diff --git a/crates/ra_assists/src/remove_dbg.rs b/crates/ra_assists/src/remove_dbg.rs index 6e900f8ef..5680f76ca 100644 --- a/crates/ra_assists/src/remove_dbg.rs +++ b/crates/ra_assists/src/remove_dbg.rs | |||
@@ -1,10 +1,9 @@ | |||
1 | use crate::{Assist, AssistCtx, AssistId}; | ||
1 | use hir::db::HirDatabase; | 2 | use hir::db::HirDatabase; |
2 | use ra_syntax::{ | 3 | use ra_syntax::{ |
3 | ast::{self, AstNode}, | 4 | ast::{self, AstNode}, |
4 | TextUnit, | 5 | TextUnit, T, |
5 | T | ||
6 | }; | 6 | }; |
7 | use crate::{AssistCtx, Assist, AssistId}; | ||
8 | 7 | ||
9 | pub(crate) fn remove_dbg(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 8 | pub(crate) fn remove_dbg(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
10 | let macro_call = ctx.node_at_offset::<ast::MacroCall>()?; | 9 | let macro_call = ctx.node_at_offset::<ast::MacroCall>()?; |
diff --git a/crates/ra_assists/src/replace_if_let_with_match.rs b/crates/ra_assists/src/replace_if_let_with_match.rs index 2b451f08d..c2c7cf70b 100644 --- a/crates/ra_assists/src/replace_if_let_with_match.rs +++ b/crates/ra_assists/src/replace_if_let_with_match.rs | |||
@@ -1,8 +1,8 @@ | |||
1 | use ra_syntax::{AstNode, ast}; | ||
2 | use ra_fmt::extract_trivial_expression; | ||
3 | use hir::db::HirDatabase; | 1 | use hir::db::HirDatabase; |
2 | use ra_fmt::extract_trivial_expression; | ||
3 | use ra_syntax::{ast, AstNode}; | ||
4 | 4 | ||
5 | use crate::{AssistCtx, Assist, AssistId}; | 5 | use crate::{Assist, AssistCtx, AssistId}; |
6 | 6 | ||
7 | pub(crate) fn replace_if_let_with_match(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 7 | pub(crate) fn replace_if_let_with_match(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
8 | let if_expr: &ast::IfExpr = ctx.node_at_offset()?; | 8 | let if_expr: &ast::IfExpr = ctx.node_at_offset()?; |
diff --git a/crates/ra_assists/src/split_import.rs b/crates/ra_assists/src/split_import.rs index 881c5ecdc..a8feb67c8 100644 --- a/crates/ra_assists/src/split_import.rs +++ b/crates/ra_assists/src/split_import.rs | |||
@@ -1,13 +1,9 @@ | |||
1 | use std::iter::successors; | 1 | use std::iter::successors; |
2 | 2 | ||
3 | use hir::db::HirDatabase; | 3 | use hir::db::HirDatabase; |
4 | use ra_syntax::{ | 4 | use ra_syntax::{ast, AstNode, TextUnit, T}; |
5 | T, | ||
6 | TextUnit, AstNode, | ||
7 | ast, | ||
8 | }; | ||
9 | 5 | ||
10 | use crate::{AssistCtx, Assist, AssistId}; | 6 | use crate::{Assist, AssistCtx, AssistId}; |
11 | 7 | ||
12 | pub(crate) fn split_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 8 | pub(crate) fn split_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
13 | let colon_colon = ctx.token_at_offset().find(|leaf| leaf.kind() == T![::])?; | 9 | let colon_colon = ctx.token_at_offset().find(|leaf| leaf.kind() == T![::])?; |