diff options
Diffstat (limited to 'crates/ra_assists/src/assists')
25 files changed, 53 insertions, 84 deletions
diff --git a/crates/ra_assists/src/assists/add_custom_impl.rs b/crates/ra_assists/src/assists/add_custom_impl.rs index f91034967..7fdd816bf 100644 --- a/crates/ra_assists/src/assists/add_custom_impl.rs +++ b/crates/ra_assists/src/assists/add_custom_impl.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use crate::{Assist, AssistCtx, AssistId}; | 3 | use crate::{Assist, AssistCtx, AssistId}; |
4 | use hir::db::HirDatabase; | 4 | |
5 | use join_to_string::join; | 5 | use join_to_string::join; |
6 | use ra_syntax::{ | 6 | use ra_syntax::{ |
7 | ast::{self, AstNode}, | 7 | ast::{self, AstNode}, |
@@ -29,7 +29,7 @@ const DERIVE_TRAIT: &str = "derive"; | |||
29 | // | 29 | // |
30 | // } | 30 | // } |
31 | // ``` | 31 | // ``` |
32 | pub(crate) fn add_custom_impl(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 32 | pub(crate) fn add_custom_impl(ctx: AssistCtx) -> Option<Assist> { |
33 | let input = ctx.find_node_at_offset::<ast::AttrInput>()?; | 33 | let input = ctx.find_node_at_offset::<ast::AttrInput>()?; |
34 | let attr = input.syntax().parent().and_then(ast::Attr::cast)?; | 34 | let attr = input.syntax().parent().and_then(ast::Attr::cast)?; |
35 | 35 | ||
diff --git a/crates/ra_assists/src/assists/add_derive.rs b/crates/ra_assists/src/assists/add_derive.rs index 6d9af3905..b0d1a0a80 100644 --- a/crates/ra_assists/src/assists/add_derive.rs +++ b/crates/ra_assists/src/assists/add_derive.rs | |||
@@ -1,4 +1,3 @@ | |||
1 | use hir::db::HirDatabase; | ||
2 | use ra_syntax::{ | 1 | use ra_syntax::{ |
3 | ast::{self, AstNode, AttrsOwner}, | 2 | ast::{self, AstNode, AttrsOwner}, |
4 | SyntaxKind::{COMMENT, WHITESPACE}, | 3 | SyntaxKind::{COMMENT, WHITESPACE}, |
@@ -25,7 +24,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
25 | // y: u32, | 24 | // y: u32, |
26 | // } | 25 | // } |
27 | // ``` | 26 | // ``` |
28 | pub(crate) fn add_derive(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 27 | pub(crate) fn add_derive(ctx: AssistCtx) -> Option<Assist> { |
29 | let nominal = ctx.find_node_at_offset::<ast::NominalDef>()?; | 28 | let nominal = ctx.find_node_at_offset::<ast::NominalDef>()?; |
30 | let node_start = derive_insertion_offset(&nominal)?; | 29 | let node_start = derive_insertion_offset(&nominal)?; |
31 | ctx.add_assist(AssistId("add_derive"), "Add `#[derive]`", |edit| { | 30 | ctx.add_assist(AssistId("add_derive"), "Add `#[derive]`", |edit| { |
diff --git a/crates/ra_assists/src/assists/add_explicit_type.rs b/crates/ra_assists/src/assists/add_explicit_type.rs index 2443d5541..2cb9d2f48 100644 --- a/crates/ra_assists/src/assists/add_explicit_type.rs +++ b/crates/ra_assists/src/assists/add_explicit_type.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use hir::{db::HirDatabase, HirDisplay}; | 1 | use hir::HirDisplay; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | ast::{self, AstNode, LetStmt, NameOwner, TypeAscriptionOwner}, | 3 | ast::{self, AstNode, LetStmt, NameOwner, TypeAscriptionOwner}, |
4 | TextRange, | 4 | TextRange, |
@@ -21,7 +21,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
21 | // let x: i32 = 92; | 21 | // let x: i32 = 92; |
22 | // } | 22 | // } |
23 | // ``` | 23 | // ``` |
24 | pub(crate) fn add_explicit_type(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 24 | pub(crate) fn add_explicit_type(ctx: AssistCtx) -> Option<Assist> { |
25 | let stmt = ctx.find_node_at_offset::<LetStmt>()?; | 25 | let stmt = ctx.find_node_at_offset::<LetStmt>()?; |
26 | let expr = stmt.initializer()?; | 26 | let expr = stmt.initializer()?; |
27 | let pat = stmt.pat()?; | 27 | let pat = stmt.pat()?; |
diff --git a/crates/ra_assists/src/assists/add_impl.rs b/crates/ra_assists/src/assists/add_impl.rs index 4b326c837..241b085fd 100644 --- a/crates/ra_assists/src/assists/add_impl.rs +++ b/crates/ra_assists/src/assists/add_impl.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use format_buf::format; | 1 | use format_buf::format; |
2 | use hir::db::HirDatabase; | 2 | |
3 | use join_to_string::join; | 3 | use join_to_string::join; |
4 | use ra_syntax::{ | 4 | use ra_syntax::{ |
5 | ast::{self, AstNode, NameOwner, TypeParamsOwner}, | 5 | ast::{self, AstNode, NameOwner, TypeParamsOwner}, |
@@ -27,7 +27,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
27 | // | 27 | // |
28 | // } | 28 | // } |
29 | // ``` | 29 | // ``` |
30 | pub(crate) fn add_impl(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 30 | pub(crate) fn add_impl(ctx: AssistCtx) -> Option<Assist> { |
31 | let nominal = ctx.find_node_at_offset::<ast::NominalDef>()?; | 31 | let nominal = ctx.find_node_at_offset::<ast::NominalDef>()?; |
32 | let name = nominal.name()?; | 32 | let name = nominal.name()?; |
33 | ctx.add_assist(AssistId("add_impl"), format!("Implement {}", name.text().as_str()), |edit| { | 33 | ctx.add_assist(AssistId("add_impl"), format!("Implement {}", name.text().as_str()), |edit| { |
diff --git a/crates/ra_assists/src/assists/add_import.rs b/crates/ra_assists/src/assists/add_import.rs index fc038df78..f03dddac8 100644 --- a/crates/ra_assists/src/assists/add_import.rs +++ b/crates/ra_assists/src/assists/add_import.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use hir::{self, db::HirDatabase, ModPath}; | 1 | use hir::{self, ModPath}; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | ast::{self, NameOwner}, | 3 | ast::{self, NameOwner}, |
4 | AstNode, Direction, SmolStr, | 4 | AstNode, Direction, SmolStr, |
@@ -50,7 +50,7 @@ pub fn auto_import_text_edit( | |||
50 | // | 50 | // |
51 | // fn process(map: HashMap<String, String>) {} | 51 | // fn process(map: HashMap<String, String>) {} |
52 | // ``` | 52 | // ``` |
53 | pub(crate) fn add_import(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 53 | pub(crate) fn add_import(ctx: AssistCtx) -> Option<Assist> { |
54 | let path: ast::Path = ctx.find_node_at_offset()?; | 54 | let path: ast::Path = ctx.find_node_at_offset()?; |
55 | // We don't want to mess with use statements | 55 | // We don't want to mess with use statements |
56 | if path.syntax().ancestors().find_map(ast::UseItem::cast).is_some() { | 56 | if path.syntax().ancestors().find_map(ast::UseItem::cast).is_some() { |
diff --git a/crates/ra_assists/src/assists/add_missing_impl_members.rs b/crates/ra_assists/src/assists/add_missing_impl_members.rs index e4c22ad55..448697d31 100644 --- a/crates/ra_assists/src/assists/add_missing_impl_members.rs +++ b/crates/ra_assists/src/assists/add_missing_impl_members.rs | |||
@@ -43,7 +43,7 @@ enum AddMissingImplMembersMode { | |||
43 | // | 43 | // |
44 | // } | 44 | // } |
45 | // ``` | 45 | // ``` |
46 | pub(crate) fn add_missing_impl_members(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 46 | pub(crate) fn add_missing_impl_members(ctx: AssistCtx) -> Option<Assist> { |
47 | add_missing_impl_members_inner( | 47 | add_missing_impl_members_inner( |
48 | ctx, | 48 | ctx, |
49 | AddMissingImplMembersMode::NoDefaultMethods, | 49 | AddMissingImplMembersMode::NoDefaultMethods, |
@@ -84,7 +84,7 @@ pub(crate) fn add_missing_impl_members(ctx: AssistCtx<impl HirDatabase>) -> Opti | |||
84 | // | 84 | // |
85 | // } | 85 | // } |
86 | // ``` | 86 | // ``` |
87 | pub(crate) fn add_missing_default_members(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 87 | pub(crate) fn add_missing_default_members(ctx: AssistCtx) -> Option<Assist> { |
88 | add_missing_impl_members_inner( | 88 | add_missing_impl_members_inner( |
89 | ctx, | 89 | ctx, |
90 | AddMissingImplMembersMode::DefaultMethodsOnly, | 90 | AddMissingImplMembersMode::DefaultMethodsOnly, |
@@ -94,7 +94,7 @@ pub(crate) fn add_missing_default_members(ctx: AssistCtx<impl HirDatabase>) -> O | |||
94 | } | 94 | } |
95 | 95 | ||
96 | fn add_missing_impl_members_inner( | 96 | fn add_missing_impl_members_inner( |
97 | ctx: AssistCtx<impl HirDatabase>, | 97 | ctx: AssistCtx, |
98 | mode: AddMissingImplMembersMode, | 98 | mode: AddMissingImplMembersMode, |
99 | assist_id: &'static str, | 99 | assist_id: &'static str, |
100 | label: &'static str, | 100 | label: &'static str, |
diff --git a/crates/ra_assists/src/assists/add_new.rs b/crates/ra_assists/src/assists/add_new.rs index 8db63f762..a08639311 100644 --- a/crates/ra_assists/src/assists/add_new.rs +++ b/crates/ra_assists/src/assists/add_new.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use format_buf::format; | 1 | use format_buf::format; |
2 | use hir::{db::HirDatabase, InFile}; | 2 | use hir::InFile; |
3 | use join_to_string::join; | 3 | use join_to_string::join; |
4 | use ra_syntax::{ | 4 | use ra_syntax::{ |
5 | ast::{ | 5 | ast::{ |
@@ -31,7 +31,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
31 | // } | 31 | // } |
32 | // | 32 | // |
33 | // ``` | 33 | // ``` |
34 | pub(crate) fn add_new(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 34 | pub(crate) fn add_new(ctx: AssistCtx) -> Option<Assist> { |
35 | let strukt = ctx.find_node_at_offset::<ast::StructDef>()?; | 35 | let strukt = ctx.find_node_at_offset::<ast::StructDef>()?; |
36 | 36 | ||
37 | // We want to only apply this to non-union structs with named fields | 37 | // We want to only apply this to non-union structs with named fields |
@@ -128,10 +128,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String { | |||
128 | // | 128 | // |
129 | // FIXME: change the new fn checking to a more semantic approach when that's more | 129 | // FIXME: change the new fn checking to a more semantic approach when that's more |
130 | // viable (e.g. we process proc macros, etc) | 130 | // viable (e.g. we process proc macros, etc) |
131 | fn find_struct_impl( | 131 | fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option<Option<ast::ImplBlock>> { |
132 | ctx: &AssistCtx<impl HirDatabase>, | ||
133 | strukt: &ast::StructDef, | ||
134 | ) -> Option<Option<ast::ImplBlock>> { | ||
135 | let db = ctx.db; | 132 | let db = ctx.db; |
136 | let module = strukt.syntax().ancestors().find(|node| { | 133 | let module = strukt.syntax().ancestors().find(|node| { |
137 | ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) | 134 | ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) |
diff --git a/crates/ra_assists/src/assists/apply_demorgan.rs b/crates/ra_assists/src/assists/apply_demorgan.rs index 666dce4e6..dac6280ad 100644 --- a/crates/ra_assists/src/assists/apply_demorgan.rs +++ b/crates/ra_assists/src/assists/apply_demorgan.rs | |||
@@ -1,5 +1,4 @@ | |||
1 | use super::invert_if::invert_boolean_expression; | 1 | use super::invert_if::invert_boolean_expression; |
2 | use hir::db::HirDatabase; | ||
3 | use ra_syntax::ast::{self, AstNode}; | 2 | use ra_syntax::ast::{self, AstNode}; |
4 | 3 | ||
5 | use crate::{Assist, AssistCtx, AssistId}; | 4 | use crate::{Assist, AssistCtx, AssistId}; |
@@ -23,7 +22,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
23 | // if !(x == 4 && y) {} | 22 | // if !(x == 4 && y) {} |
24 | // } | 23 | // } |
25 | // ``` | 24 | // ``` |
26 | pub(crate) fn apply_demorgan(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 25 | pub(crate) fn apply_demorgan(ctx: AssistCtx) -> Option<Assist> { |
27 | let expr = ctx.find_node_at_offset::<ast::BinExpr>()?; | 26 | let expr = ctx.find_node_at_offset::<ast::BinExpr>()?; |
28 | let op = expr.op_kind()?; | 27 | let op = expr.op_kind()?; |
29 | let op_range = expr.op_token()?.text_range(); | 28 | let op_range = expr.op_token()?.text_range(); |
diff --git a/crates/ra_assists/src/assists/auto_import.rs b/crates/ra_assists/src/assists/auto_import.rs index 2068256b0..219051063 100644 --- a/crates/ra_assists/src/assists/auto_import.rs +++ b/crates/ra_assists/src/assists/auto_import.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use hir::{db::HirDatabase, ModPath}; | 1 | use hir::ModPath; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | ast::{self, AstNode}, | 3 | ast::{self, AstNode}, |
4 | SyntaxNode, | 4 | SyntaxNode, |
@@ -6,8 +6,9 @@ use ra_syntax::{ | |||
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
8 | assist_ctx::{ActionBuilder, Assist, AssistCtx}, | 8 | assist_ctx::{ActionBuilder, Assist, AssistCtx}, |
9 | auto_import_text_edit, AssistId, ImportsLocator, | 9 | auto_import_text_edit, AssistId, |
10 | }; | 10 | }; |
11 | use ra_ide_db::imports_locator::ImportsLocatorIde; | ||
11 | 12 | ||
12 | // Assist: auto_import | 13 | // Assist: auto_import |
13 | // | 14 | // |
@@ -26,10 +27,7 @@ use crate::{ | |||
26 | // let map = HashMap<|>::new(); | 27 | // let map = HashMap<|>::new(); |
27 | // } | 28 | // } |
28 | // ``` | 29 | // ``` |
29 | pub(crate) fn auto_import<F: ImportsLocator>( | 30 | pub(crate) fn auto_import(ctx: AssistCtx) -> Option<Assist> { |
30 | ctx: AssistCtx<impl HirDatabase>, | ||
31 | imports_locator: &mut F, | ||
32 | ) -> Option<Assist> { | ||
33 | let path_to_import: ast::Path = ctx.find_node_at_offset()?; | 31 | let path_to_import: ast::Path = ctx.find_node_at_offset()?; |
34 | let path_to_import_syntax = path_to_import.syntax(); | 32 | let path_to_import_syntax = path_to_import.syntax(); |
35 | if path_to_import_syntax.ancestors().find_map(ast::UseItem::cast).is_some() { | 33 | if path_to_import_syntax.ancestors().find_map(ast::UseItem::cast).is_some() { |
@@ -52,6 +50,8 @@ pub(crate) fn auto_import<F: ImportsLocator>( | |||
52 | return None; | 50 | return None; |
53 | } | 51 | } |
54 | 52 | ||
53 | let mut imports_locator = ImportsLocatorIde::new(ctx.db); | ||
54 | |||
55 | let proposed_imports = imports_locator | 55 | let proposed_imports = imports_locator |
56 | .find_imports(&name_to_import) | 56 | .find_imports(&name_to_import) |
57 | .into_iter() | 57 | .into_iter() |
@@ -81,16 +81,12 @@ fn import_to_action(import: ModPath, position: &SyntaxNode, anchor: &SyntaxNode) | |||
81 | #[cfg(test)] | 81 | #[cfg(test)] |
82 | mod tests { | 82 | mod tests { |
83 | use super::*; | 83 | use super::*; |
84 | use crate::helpers::{ | 84 | use crate::helpers::{check_assist, check_assist_not_applicable}; |
85 | check_assist_with_imports_locator, check_assist_with_imports_locator_not_applicable, | ||
86 | TestImportsLocator, | ||
87 | }; | ||
88 | 85 | ||
89 | #[test] | 86 | #[test] |
90 | fn applicable_when_found_an_import() { | 87 | fn applicable_when_found_an_import() { |
91 | check_assist_with_imports_locator( | 88 | check_assist( |
92 | auto_import, | 89 | auto_import, |
93 | TestImportsLocator::new, | ||
94 | r" | 90 | r" |
95 | <|>PubStruct | 91 | <|>PubStruct |
96 | 92 | ||
@@ -112,9 +108,8 @@ mod tests { | |||
112 | 108 | ||
113 | #[test] | 109 | #[test] |
114 | fn auto_imports_are_merged() { | 110 | fn auto_imports_are_merged() { |
115 | check_assist_with_imports_locator( | 111 | check_assist( |
116 | auto_import, | 112 | auto_import, |
117 | TestImportsLocator::new, | ||
118 | r" | 113 | r" |
119 | use PubMod::PubStruct1; | 114 | use PubMod::PubStruct1; |
120 | 115 | ||
@@ -148,9 +143,8 @@ mod tests { | |||
148 | 143 | ||
149 | #[test] | 144 | #[test] |
150 | fn applicable_when_found_multiple_imports() { | 145 | fn applicable_when_found_multiple_imports() { |
151 | check_assist_with_imports_locator( | 146 | check_assist( |
152 | auto_import, | 147 | auto_import, |
153 | TestImportsLocator::new, | ||
154 | r" | 148 | r" |
155 | PubSt<|>ruct | 149 | PubSt<|>ruct |
156 | 150 | ||
@@ -184,9 +178,8 @@ mod tests { | |||
184 | 178 | ||
185 | #[test] | 179 | #[test] |
186 | fn not_applicable_for_already_imported_types() { | 180 | fn not_applicable_for_already_imported_types() { |
187 | check_assist_with_imports_locator_not_applicable( | 181 | check_assist_not_applicable( |
188 | auto_import, | 182 | auto_import, |
189 | TestImportsLocator::new, | ||
190 | r" | 183 | r" |
191 | use PubMod::PubStruct; | 184 | use PubMod::PubStruct; |
192 | 185 | ||
@@ -201,9 +194,8 @@ mod tests { | |||
201 | 194 | ||
202 | #[test] | 195 | #[test] |
203 | fn not_applicable_for_types_with_private_paths() { | 196 | fn not_applicable_for_types_with_private_paths() { |
204 | check_assist_with_imports_locator_not_applicable( | 197 | check_assist_not_applicable( |
205 | auto_import, | 198 | auto_import, |
206 | TestImportsLocator::new, | ||
207 | r" | 199 | r" |
208 | PrivateStruct<|> | 200 | PrivateStruct<|> |
209 | 201 | ||
@@ -216,9 +208,8 @@ mod tests { | |||
216 | 208 | ||
217 | #[test] | 209 | #[test] |
218 | fn not_applicable_when_no_imports_found() { | 210 | fn not_applicable_when_no_imports_found() { |
219 | check_assist_with_imports_locator_not_applicable( | 211 | check_assist_not_applicable( |
220 | auto_import, | 212 | auto_import, |
221 | TestImportsLocator::new, | ||
222 | " | 213 | " |
223 | PubStruct<|>", | 214 | PubStruct<|>", |
224 | ); | 215 | ); |
@@ -226,9 +217,8 @@ mod tests { | |||
226 | 217 | ||
227 | #[test] | 218 | #[test] |
228 | fn not_applicable_in_import_statements() { | 219 | fn not_applicable_in_import_statements() { |
229 | check_assist_with_imports_locator_not_applicable( | 220 | check_assist_not_applicable( |
230 | auto_import, | 221 | auto_import, |
231 | TestImportsLocator::new, | ||
232 | r" | 222 | r" |
233 | use PubStruct<|>; | 223 | use PubStruct<|>; |
234 | 224 | ||
@@ -240,9 +230,8 @@ mod tests { | |||
240 | 230 | ||
241 | #[test] | 231 | #[test] |
242 | fn function_import() { | 232 | fn function_import() { |
243 | check_assist_with_imports_locator( | 233 | check_assist( |
244 | auto_import, | 234 | auto_import, |
245 | TestImportsLocator::new, | ||
246 | r" | 235 | r" |
247 | test_function<|> | 236 | test_function<|> |
248 | 237 | ||
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 @@ | |||
1 | use hir::db::HirDatabase; | ||
2 | use ra_syntax::{ | 1 | use 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 | // ``` |
25 | pub(crate) fn change_visibility(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 24 | pub(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 | ||
32 | fn add_vis(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 31 | fn 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 | ||
78 | fn change_vis(ctx: AssistCtx<impl HirDatabase>, vis: ast::Visibility) -> Option<Assist> { | 77 | fn 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"), |
diff --git a/crates/ra_assists/src/assists/early_return.rs b/crates/ra_assists/src/assists/early_return.rs index 487ee9eef..7d510b055 100644 --- a/crates/ra_assists/src/assists/early_return.rs +++ b/crates/ra_assists/src/assists/early_return.rs | |||
@@ -1,6 +1,5 @@ | |||
1 | use std::{iter::once, ops::RangeInclusive}; | 1 | use std::{iter::once, ops::RangeInclusive}; |
2 | 2 | ||
3 | use hir::db::HirDatabase; | ||
4 | use ra_syntax::{ | 3 | use ra_syntax::{ |
5 | algo::replace_children, | 4 | algo::replace_children, |
6 | ast::{self, edit::IndentLevel, make, Block, Pat::TupleStructPat}, | 5 | ast::{self, edit::IndentLevel, make, Block, Pat::TupleStructPat}, |
@@ -36,7 +35,7 @@ use crate::{ | |||
36 | // bar(); | 35 | // bar(); |
37 | // } | 36 | // } |
38 | // ``` | 37 | // ``` |
39 | pub(crate) fn convert_to_guarded_return(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 38 | pub(crate) fn convert_to_guarded_return(ctx: AssistCtx) -> Option<Assist> { |
40 | let if_expr: ast::IfExpr = ctx.find_node_at_offset()?; | 39 | let if_expr: ast::IfExpr = ctx.find_node_at_offset()?; |
41 | if if_expr.else_branch().is_some() { | 40 | if if_expr.else_branch().is_some() { |
42 | return None; | 41 | return None; |
diff --git a/crates/ra_assists/src/assists/fill_match_arms.rs b/crates/ra_assists/src/assists/fill_match_arms.rs index 01758d23a..0908fc246 100644 --- a/crates/ra_assists/src/assists/fill_match_arms.rs +++ b/crates/ra_assists/src/assists/fill_match_arms.rs | |||
@@ -31,7 +31,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
31 | // } | 31 | // } |
32 | // } | 32 | // } |
33 | // ``` | 33 | // ``` |
34 | pub(crate) fn fill_match_arms(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 34 | pub(crate) fn fill_match_arms(ctx: AssistCtx) -> Option<Assist> { |
35 | let match_expr = ctx.find_node_at_offset::<ast::MatchExpr>()?; | 35 | let match_expr = ctx.find_node_at_offset::<ast::MatchExpr>()?; |
36 | let match_arm_list = match_expr.match_arm_list()?; | 36 | let match_arm_list = match_expr.match_arm_list()?; |
37 | 37 | ||
diff --git a/crates/ra_assists/src/assists/flip_binexpr.rs b/crates/ra_assists/src/assists/flip_binexpr.rs index 2074087cd..bfcc09e90 100644 --- a/crates/ra_assists/src/assists/flip_binexpr.rs +++ b/crates/ra_assists/src/assists/flip_binexpr.rs | |||
@@ -1,4 +1,3 @@ | |||
1 | use hir::db::HirDatabase; | ||
2 | use ra_syntax::ast::{AstNode, BinExpr, BinOp}; | 1 | use ra_syntax::ast::{AstNode, BinExpr, BinOp}; |
3 | 2 | ||
4 | use crate::{Assist, AssistCtx, AssistId}; | 3 | use crate::{Assist, AssistCtx, AssistId}; |
@@ -18,7 +17,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
18 | // let _ = 2 + 90; | 17 | // let _ = 2 + 90; |
19 | // } | 18 | // } |
20 | // ``` | 19 | // ``` |
21 | pub(crate) fn flip_binexpr(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 20 | pub(crate) fn flip_binexpr(ctx: AssistCtx) -> Option<Assist> { |
22 | let expr = ctx.find_node_at_offset::<BinExpr>()?; | 21 | let expr = ctx.find_node_at_offset::<BinExpr>()?; |
23 | let lhs = expr.lhs()?.syntax().clone(); | 22 | let lhs = expr.lhs()?.syntax().clone(); |
24 | let rhs = expr.rhs()?.syntax().clone(); | 23 | let rhs = expr.rhs()?.syntax().clone(); |
diff --git a/crates/ra_assists/src/assists/flip_comma.rs b/crates/ra_assists/src/assists/flip_comma.rs index dd0c405ed..1dacf29f8 100644 --- a/crates/ra_assists/src/assists/flip_comma.rs +++ b/crates/ra_assists/src/assists/flip_comma.rs | |||
@@ -1,4 +1,3 @@ | |||
1 | use hir::db::HirDatabase; | ||
2 | use ra_syntax::{algo::non_trivia_sibling, Direction, T}; | 1 | use ra_syntax::{algo::non_trivia_sibling, Direction, T}; |
3 | 2 | ||
4 | use crate::{Assist, AssistCtx, AssistId}; | 3 | use crate::{Assist, AssistCtx, AssistId}; |
@@ -18,7 +17,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
18 | // ((3, 4), (1, 2)); | 17 | // ((3, 4), (1, 2)); |
19 | // } | 18 | // } |
20 | // ``` | 19 | // ``` |
21 | pub(crate) fn flip_comma(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 20 | pub(crate) fn flip_comma(ctx: AssistCtx) -> Option<Assist> { |
22 | let comma = ctx.find_token_at_offset(T![,])?; | 21 | let comma = ctx.find_token_at_offset(T![,])?; |
23 | let prev = non_trivia_sibling(comma.clone().into(), Direction::Prev)?; | 22 | let prev = non_trivia_sibling(comma.clone().into(), Direction::Prev)?; |
24 | let next = non_trivia_sibling(comma.clone().into(), Direction::Next)?; | 23 | let next = non_trivia_sibling(comma.clone().into(), Direction::Next)?; |
diff --git a/crates/ra_assists/src/assists/flip_trait_bound.rs b/crates/ra_assists/src/assists/flip_trait_bound.rs index 50b3fa492..f56769624 100644 --- a/crates/ra_assists/src/assists/flip_trait_bound.rs +++ b/crates/ra_assists/src/assists/flip_trait_bound.rs | |||
@@ -1,4 +1,3 @@ | |||
1 | use hir::db::HirDatabase; | ||
2 | use ra_syntax::{ | 1 | use ra_syntax::{ |
3 | algo::non_trivia_sibling, | 2 | algo::non_trivia_sibling, |
4 | ast::{self, AstNode}, | 3 | ast::{self, AstNode}, |
@@ -18,7 +17,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
18 | // ``` | 17 | // ``` |
19 | // fn foo<T: Copy + Clone>() { } | 18 | // fn foo<T: Copy + Clone>() { } |
20 | // ``` | 19 | // ``` |
21 | pub(crate) fn flip_trait_bound(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 20 | pub(crate) fn flip_trait_bound(ctx: AssistCtx) -> Option<Assist> { |
22 | // We want to replicate the behavior of `flip_binexpr` by only suggesting | 21 | // We want to replicate the behavior of `flip_binexpr` by only suggesting |
23 | // the assist when the cursor is on a `+` | 22 | // the assist when the cursor is on a `+` |
24 | let plus = ctx.find_token_at_offset(T![+])?; | 23 | let plus = ctx.find_token_at_offset(T![+])?; |
diff --git a/crates/ra_assists/src/assists/inline_local_variable.rs b/crates/ra_assists/src/assists/inline_local_variable.rs index 83527d904..91b588243 100644 --- a/crates/ra_assists/src/assists/inline_local_variable.rs +++ b/crates/ra_assists/src/assists/inline_local_variable.rs | |||
@@ -1,4 +1,3 @@ | |||
1 | use hir::db::HirDatabase; | ||
2 | use ra_syntax::{ | 1 | use ra_syntax::{ |
3 | ast::{self, AstNode, AstToken}, | 2 | ast::{self, AstNode, AstToken}, |
4 | TextRange, | 3 | TextRange, |
@@ -23,7 +22,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
23 | // (1 + 2) * 4; | 22 | // (1 + 2) * 4; |
24 | // } | 23 | // } |
25 | // ``` | 24 | // ``` |
26 | pub(crate) fn inline_local_variable(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 25 | pub(crate) fn inline_local_variable(ctx: AssistCtx) -> Option<Assist> { |
27 | let let_stmt = ctx.find_node_at_offset::<ast::LetStmt>()?; | 26 | let let_stmt = ctx.find_node_at_offset::<ast::LetStmt>()?; |
28 | let bind_pat = match let_stmt.pat()? { | 27 | let bind_pat = match let_stmt.pat()? { |
29 | ast::Pat::BindPat(pat) => pat, | 28 | ast::Pat::BindPat(pat) => pat, |
diff --git a/crates/ra_assists/src/assists/introduce_variable.rs b/crates/ra_assists/src/assists/introduce_variable.rs index 19e211e0f..7312ce687 100644 --- a/crates/ra_assists/src/assists/introduce_variable.rs +++ b/crates/ra_assists/src/assists/introduce_variable.rs | |||
@@ -1,5 +1,4 @@ | |||
1 | use format_buf::format; | 1 | use format_buf::format; |
2 | use hir::db::HirDatabase; | ||
3 | use ra_syntax::{ | 2 | use ra_syntax::{ |
4 | ast::{self, AstNode}, | 3 | ast::{self, AstNode}, |
5 | SyntaxKind::{ | 4 | SyntaxKind::{ |
@@ -28,7 +27,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
28 | // var_name * 4; | 27 | // var_name * 4; |
29 | // } | 28 | // } |
30 | // ``` | 29 | // ``` |
31 | pub(crate) fn introduce_variable(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 30 | pub(crate) fn introduce_variable(ctx: AssistCtx) -> Option<Assist> { |
32 | if ctx.frange.range.is_empty() { | 31 | if ctx.frange.range.is_empty() { |
33 | return None; | 32 | return None; |
34 | } | 33 | } |
diff --git a/crates/ra_assists/src/assists/invert_if.rs b/crates/ra_assists/src/assists/invert_if.rs index 16352c040..694c3642c 100644 --- a/crates/ra_assists/src/assists/invert_if.rs +++ b/crates/ra_assists/src/assists/invert_if.rs | |||
@@ -1,4 +1,3 @@ | |||
1 | use hir::db::HirDatabase; | ||
2 | use ra_syntax::ast::{self, AstNode}; | 1 | use ra_syntax::ast::{self, AstNode}; |
3 | use ra_syntax::T; | 2 | use ra_syntax::T; |
4 | 3 | ||
@@ -23,7 +22,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
23 | // } | 22 | // } |
24 | // ``` | 23 | // ``` |
25 | 24 | ||
26 | pub(crate) fn invert_if(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 25 | pub(crate) fn invert_if(ctx: AssistCtx) -> Option<Assist> { |
27 | let if_keyword = ctx.find_token_at_offset(T![if])?; | 26 | let if_keyword = ctx.find_token_at_offset(T![if])?; |
28 | let expr = ast::IfExpr::cast(if_keyword.parent())?; | 27 | let expr = ast::IfExpr::cast(if_keyword.parent())?; |
29 | let if_range = if_keyword.text_range(); | 28 | let if_range = if_keyword.text_range(); |
diff --git a/crates/ra_assists/src/assists/merge_match_arms.rs b/crates/ra_assists/src/assists/merge_match_arms.rs index 64c9379da..670614dd8 100644 --- a/crates/ra_assists/src/assists/merge_match_arms.rs +++ b/crates/ra_assists/src/assists/merge_match_arms.rs | |||
@@ -1,6 +1,5 @@ | |||
1 | use std::iter::successors; | 1 | use std::iter::successors; |
2 | 2 | ||
3 | use hir::db::HirDatabase; | ||
4 | use ra_syntax::{ | 3 | use ra_syntax::{ |
5 | ast::{self, AstNode}, | 4 | ast::{self, AstNode}, |
6 | Direction, TextUnit, | 5 | Direction, TextUnit, |
@@ -32,7 +31,7 @@ use crate::{Assist, AssistCtx, AssistId, TextRange}; | |||
32 | // } | 31 | // } |
33 | // } | 32 | // } |
34 | // ``` | 33 | // ``` |
35 | pub(crate) fn merge_match_arms(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 34 | pub(crate) fn merge_match_arms(ctx: AssistCtx) -> Option<Assist> { |
36 | let current_arm = ctx.find_node_at_offset::<ast::MatchArm>()?; | 35 | let current_arm = ctx.find_node_at_offset::<ast::MatchArm>()?; |
37 | // Don't try to handle arms with guards for now - can add support for this later | 36 | // Don't try to handle arms with guards for now - can add support for this later |
38 | if current_arm.guard().is_some() { | 37 | if current_arm.guard().is_some() { |
diff --git a/crates/ra_assists/src/assists/move_bounds.rs b/crates/ra_assists/src/assists/move_bounds.rs index 355adddc3..90793b5fc 100644 --- a/crates/ra_assists/src/assists/move_bounds.rs +++ b/crates/ra_assists/src/assists/move_bounds.rs | |||
@@ -1,4 +1,3 @@ | |||
1 | use hir::db::HirDatabase; | ||
2 | use ra_syntax::{ | 1 | use ra_syntax::{ |
3 | ast::{self, edit, make, AstNode, NameOwner, TypeBoundsOwner}, | 2 | ast::{self, edit, make, AstNode, NameOwner, TypeBoundsOwner}, |
4 | SyntaxElement, | 3 | SyntaxElement, |
@@ -22,7 +21,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
22 | // f(x) | 21 | // f(x) |
23 | // } | 22 | // } |
24 | // ``` | 23 | // ``` |
25 | pub(crate) fn move_bounds_to_where_clause(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 24 | pub(crate) fn move_bounds_to_where_clause(ctx: AssistCtx) -> Option<Assist> { |
26 | let type_param_list = ctx.find_node_at_offset::<ast::TypeParamList>()?; | 25 | let type_param_list = ctx.find_node_at_offset::<ast::TypeParamList>()?; |
27 | 26 | ||
28 | let mut type_params = type_param_list.type_params(); | 27 | let mut type_params = type_param_list.type_params(); |
diff --git a/crates/ra_assists/src/assists/move_guard.rs b/crates/ra_assists/src/assists/move_guard.rs index 41a31e677..2b91ce7c4 100644 --- a/crates/ra_assists/src/assists/move_guard.rs +++ b/crates/ra_assists/src/assists/move_guard.rs | |||
@@ -1,4 +1,3 @@ | |||
1 | use hir::db::HirDatabase; | ||
2 | use ra_syntax::{ | 1 | use ra_syntax::{ |
3 | ast, | 2 | ast, |
4 | ast::{AstNode, AstToken, IfExpr, MatchArm}, | 3 | ast::{AstNode, AstToken, IfExpr, MatchArm}, |
@@ -32,7 +31,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
32 | // } | 31 | // } |
33 | // } | 32 | // } |
34 | // ``` | 33 | // ``` |
35 | pub(crate) fn move_guard_to_arm_body(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 34 | pub(crate) fn move_guard_to_arm_body(ctx: AssistCtx) -> Option<Assist> { |
36 | let match_arm = ctx.find_node_at_offset::<MatchArm>()?; | 35 | let match_arm = ctx.find_node_at_offset::<MatchArm>()?; |
37 | let guard = match_arm.guard()?; | 36 | let guard = match_arm.guard()?; |
38 | let space_before_guard = guard.syntax().prev_sibling_or_token(); | 37 | let space_before_guard = guard.syntax().prev_sibling_or_token(); |
@@ -89,7 +88,7 @@ pub(crate) fn move_guard_to_arm_body(ctx: AssistCtx<impl HirDatabase>) -> Option | |||
89 | // } | 88 | // } |
90 | // } | 89 | // } |
91 | // ``` | 90 | // ``` |
92 | pub(crate) fn move_arm_cond_to_match_guard(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 91 | pub(crate) fn move_arm_cond_to_match_guard(ctx: AssistCtx) -> Option<Assist> { |
93 | let match_arm: MatchArm = ctx.find_node_at_offset::<MatchArm>()?; | 92 | let match_arm: MatchArm = ctx.find_node_at_offset::<MatchArm>()?; |
94 | let last_match_pat = match_arm.pats().last()?; | 93 | let last_match_pat = match_arm.pats().last()?; |
95 | 94 | ||
diff --git a/crates/ra_assists/src/assists/raw_string.rs b/crates/ra_assists/src/assists/raw_string.rs index e79c51673..2c0a1e126 100644 --- a/crates/ra_assists/src/assists/raw_string.rs +++ b/crates/ra_assists/src/assists/raw_string.rs | |||
@@ -1,4 +1,3 @@ | |||
1 | use hir::db::HirDatabase; | ||
2 | use ra_syntax::{ | 1 | use ra_syntax::{ |
3 | ast, AstToken, | 2 | ast, AstToken, |
4 | SyntaxKind::{RAW_STRING, STRING}, | 3 | SyntaxKind::{RAW_STRING, STRING}, |
@@ -22,7 +21,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
22 | // r#"Hello, World!"#; | 21 | // r#"Hello, World!"#; |
23 | // } | 22 | // } |
24 | // ``` | 23 | // ``` |
25 | pub(crate) fn make_raw_string(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 24 | pub(crate) fn make_raw_string(ctx: AssistCtx) -> Option<Assist> { |
26 | let token = ctx.find_token_at_offset(STRING).and_then(ast::String::cast)?; | 25 | let token = ctx.find_token_at_offset(STRING).and_then(ast::String::cast)?; |
27 | let value = token.value()?; | 26 | let value = token.value()?; |
28 | ctx.add_assist(AssistId("make_raw_string"), "Rewrite as raw string", |edit| { | 27 | ctx.add_assist(AssistId("make_raw_string"), "Rewrite as raw string", |edit| { |
@@ -51,7 +50,7 @@ pub(crate) fn make_raw_string(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist | |||
51 | // "Hello, \"World!\""; | 50 | // "Hello, \"World!\""; |
52 | // } | 51 | // } |
53 | // ``` | 52 | // ``` |
54 | pub(crate) fn make_usual_string(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 53 | pub(crate) fn make_usual_string(ctx: AssistCtx) -> Option<Assist> { |
55 | let token = ctx.find_token_at_offset(RAW_STRING).and_then(ast::RawString::cast)?; | 54 | let token = ctx.find_token_at_offset(RAW_STRING).and_then(ast::RawString::cast)?; |
56 | let value = token.value()?; | 55 | let value = token.value()?; |
57 | ctx.add_assist(AssistId("make_usual_string"), "Rewrite as regular string", |edit| { | 56 | ctx.add_assist(AssistId("make_usual_string"), "Rewrite as regular string", |edit| { |
@@ -77,7 +76,7 @@ pub(crate) fn make_usual_string(ctx: AssistCtx<impl HirDatabase>) -> Option<Assi | |||
77 | // r##"Hello, World!"##; | 76 | // r##"Hello, World!"##; |
78 | // } | 77 | // } |
79 | // ``` | 78 | // ``` |
80 | pub(crate) fn add_hash(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 79 | pub(crate) fn add_hash(ctx: AssistCtx) -> Option<Assist> { |
81 | let token = ctx.find_token_at_offset(RAW_STRING)?; | 80 | let token = ctx.find_token_at_offset(RAW_STRING)?; |
82 | ctx.add_assist(AssistId("add_hash"), "Add # to raw string", |edit| { | 81 | ctx.add_assist(AssistId("add_hash"), "Add # to raw string", |edit| { |
83 | edit.target(token.text_range()); | 82 | edit.target(token.text_range()); |
@@ -101,7 +100,7 @@ pub(crate) fn add_hash(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | |||
101 | // r"Hello, World!"; | 100 | // r"Hello, World!"; |
102 | // } | 101 | // } |
103 | // ``` | 102 | // ``` |
104 | pub(crate) fn remove_hash(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 103 | pub(crate) fn remove_hash(ctx: AssistCtx) -> Option<Assist> { |
105 | let token = ctx.find_token_at_offset(RAW_STRING)?; | 104 | let token = ctx.find_token_at_offset(RAW_STRING)?; |
106 | let text = token.text().as_str(); | 105 | let text = token.text().as_str(); |
107 | if text.starts_with("r\"") { | 106 | if text.starts_with("r\"") { |
diff --git a/crates/ra_assists/src/assists/remove_dbg.rs b/crates/ra_assists/src/assists/remove_dbg.rs index cf211ab84..5085649b4 100644 --- a/crates/ra_assists/src/assists/remove_dbg.rs +++ b/crates/ra_assists/src/assists/remove_dbg.rs | |||
@@ -1,4 +1,3 @@ | |||
1 | use hir::db::HirDatabase; | ||
2 | use ra_syntax::{ | 1 | use ra_syntax::{ |
3 | ast::{self, AstNode}, | 2 | ast::{self, AstNode}, |
4 | TextUnit, T, | 3 | TextUnit, T, |
@@ -21,7 +20,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
21 | // 92; | 20 | // 92; |
22 | // } | 21 | // } |
23 | // ``` | 22 | // ``` |
24 | pub(crate) fn remove_dbg(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 23 | pub(crate) fn remove_dbg(ctx: AssistCtx) -> Option<Assist> { |
25 | let macro_call = ctx.find_node_at_offset::<ast::MacroCall>()?; | 24 | let macro_call = ctx.find_node_at_offset::<ast::MacroCall>()?; |
26 | 25 | ||
27 | if !is_valid_macrocall(¯o_call, "dbg")? { | 26 | if !is_valid_macrocall(¯o_call, "dbg")? { |
diff --git a/crates/ra_assists/src/assists/replace_if_let_with_match.rs b/crates/ra_assists/src/assists/replace_if_let_with_match.rs index c8b13b7b3..e6cd50bc1 100644 --- a/crates/ra_assists/src/assists/replace_if_let_with_match.rs +++ b/crates/ra_assists/src/assists/replace_if_let_with_match.rs | |||
@@ -1,4 +1,3 @@ | |||
1 | use hir::db::HirDatabase; | ||
2 | use ra_fmt::unwrap_trivial_block; | 1 | use ra_fmt::unwrap_trivial_block; |
3 | use ra_syntax::{ | 2 | use ra_syntax::{ |
4 | ast::{self, make}, | 3 | ast::{self, make}, |
@@ -34,7 +33,7 @@ use ast::edit::IndentLevel; | |||
34 | // } | 33 | // } |
35 | // } | 34 | // } |
36 | // ``` | 35 | // ``` |
37 | pub(crate) fn replace_if_let_with_match(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 36 | pub(crate) fn replace_if_let_with_match(ctx: AssistCtx) -> Option<Assist> { |
38 | let if_expr: ast::IfExpr = ctx.find_node_at_offset()?; | 37 | let if_expr: ast::IfExpr = ctx.find_node_at_offset()?; |
39 | let cond = if_expr.condition()?; | 38 | let cond = if_expr.condition()?; |
40 | let pat = cond.pat()?; | 39 | let pat = cond.pat()?; |
diff --git a/crates/ra_assists/src/assists/split_import.rs b/crates/ra_assists/src/assists/split_import.rs index 6038c4858..2c3f07a79 100644 --- a/crates/ra_assists/src/assists/split_import.rs +++ b/crates/ra_assists/src/assists/split_import.rs | |||
@@ -1,6 +1,5 @@ | |||
1 | use std::iter::successors; | 1 | use std::iter::successors; |
2 | 2 | ||
3 | use hir::db::HirDatabase; | ||
4 | use ra_syntax::{ast, AstNode, TextUnit, T}; | 3 | use ra_syntax::{ast, AstNode, TextUnit, T}; |
5 | 4 | ||
6 | use crate::{Assist, AssistCtx, AssistId}; | 5 | use crate::{Assist, AssistCtx, AssistId}; |
@@ -16,7 +15,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
16 | // ``` | 15 | // ``` |
17 | // use std::{collections::HashMap}; | 16 | // use std::{collections::HashMap}; |
18 | // ``` | 17 | // ``` |
19 | pub(crate) fn split_import(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 18 | pub(crate) fn split_import(ctx: AssistCtx) -> Option<Assist> { |
20 | let colon_colon = ctx.find_token_at_offset(T![::])?; | 19 | let colon_colon = ctx.find_token_at_offset(T![::])?; |
21 | let path = ast::Path::cast(colon_colon.parent())?; | 20 | let path = ast::Path::cast(colon_colon.parent())?; |
22 | let top_path = successors(Some(path), |it| it.parent_path()).last()?; | 21 | let top_path = successors(Some(path), |it| it.parent_path()).last()?; |