aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Ellison <[email protected]>2020-12-30 16:14:35 +0000
committerPhil Ellison <[email protected]>2021-01-23 07:40:25 +0000
commite62e4ed148021a80b3a4672dab10b828fbd712ee (patch)
treee515a5438c3cbe29f755363ee83e23a651666e1b
parent449ced4d218f413e152785fb81d161a6389974f7 (diff)
Address review comments
-rw-r--r--crates/ide/src/diagnostics/fixes.rs13
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.
3use ast::MethodCallExpr;
4use hir::{ 3use 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};
17use syntax::{ 16use syntax::{AstNode, TextRange, algo, ast::{self, ArgListOwner, edit::IndentLevel, make}};
18 algo,
19 ast::{self, edit::IndentLevel, make, ArgList},
20 AstNode, TextRange,
21};
22use text_edit::TextEdit; 17use text_edit::TextEdit;
23 18
24use crate::{diagnostics::Fix, references::rename::rename_with_semantics, FilePosition}; 19use 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());