diff options
-rw-r--r-- | crates/ide/src/diagnostics/fixes.rs | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/crates/ide/src/diagnostics/fixes.rs b/crates/ide/src/diagnostics/fixes.rs index a73c0778b..5828ea35a 100644 --- a/crates/ide/src/diagnostics/fixes.rs +++ b/crates/ide/src/diagnostics/fixes.rs | |||
@@ -1,6 +1,5 @@ | |||
1 | //! Provides a way to attach fixes to the diagnostics. | 1 | //! Provides a way to attach fixes to the diagnostics. |
2 | //! The same module also has all curret custom fixes for the diagnostics implemented. | 2 | //! The same module also has all curret custom fixes for the diagnostics implemented. |
3 | use ast::MethodCallExpr; | ||
4 | use hir::{ | 3 | use hir::{ |
5 | db::AstDatabase, | 4 | db::AstDatabase, |
6 | diagnostics::{ | 5 | diagnostics::{ |
@@ -14,11 +13,7 @@ use ide_db::{ | |||
14 | source_change::{FileSystemEdit, SourceChange}, | 13 | source_change::{FileSystemEdit, SourceChange}, |
15 | RootDatabase, | 14 | RootDatabase, |
16 | }; | 15 | }; |
17 | use syntax::{ | 16 | use syntax::{AstNode, TextRange, algo, ast::{self, ArgListOwner, edit::IndentLevel, make}}; |
18 | algo, | ||
19 | ast::{self, edit::IndentLevel, make, ArgList}, | ||
20 | AstNode, TextRange, | ||
21 | }; | ||
22 | use text_edit::TextEdit; | 17 | use text_edit::TextEdit; |
23 | 18 | ||
24 | use crate::{diagnostics::Fix, references::rename::rename_with_semantics, FilePosition}; | 19 | use crate::{diagnostics::Fix, references::rename::rename_with_semantics, FilePosition}; |
@@ -149,11 +144,11 @@ impl DiagnosticWithFix for ReplaceFilterMapNextWithFindMap { | |||
149 | fn fix(&self, sema: &Semantics<RootDatabase>) -> Option<Fix> { | 144 | fn fix(&self, sema: &Semantics<RootDatabase>) -> Option<Fix> { |
150 | let root = sema.db.parse_or_expand(self.file)?; | 145 | let root = sema.db.parse_or_expand(self.file)?; |
151 | let next_expr = self.next_expr.to_node(&root); | 146 | let next_expr = self.next_expr.to_node(&root); |
152 | let next_call = MethodCallExpr::cast(next_expr.syntax().clone())?; | 147 | let next_call = ast::MethodCallExpr::cast(next_expr.syntax().clone())?; |
153 | 148 | ||
154 | let filter_map_call = MethodCallExpr::cast(next_call.receiver()?.syntax().clone())?; | 149 | let filter_map_call = ast::MethodCallExpr::cast(next_call.receiver()?.syntax().clone())?; |
155 | let filter_map_name_range = filter_map_call.name_ref()?.ident_token()?.text_range(); | 150 | let filter_map_name_range = filter_map_call.name_ref()?.ident_token()?.text_range(); |
156 | let filter_map_args = filter_map_call.syntax().children().find_map(ArgList::cast)?; | 151 | let filter_map_args = filter_map_call.arg_list()?; |
157 | 152 | ||
158 | let range_to_replace = | 153 | let range_to_replace = |
159 | TextRange::new(filter_map_name_range.start(), next_expr.syntax().text_range().end()); | 154 | TextRange::new(filter_map_name_range.start(), next_expr.syntax().text_range().end()); |