aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/diagnostics/fixes/replace_with_find_map.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-05-18 03:02:34 +0100
committerGitHub <[email protected]>2021-05-18 03:02:34 +0100
commite3d0d89d7e3e253234271008df9324ec1faf1746 (patch)
tree13c4972204ac32dd1a1702c254ffef4b85a76bf3 /crates/ide/src/diagnostics/fixes/replace_with_find_map.rs
parentc04eaa1f37f31d7125372ba14da3d5059297e8b2 (diff)
parente0b01f34bb994ca8959f3040dbacafc6c56e4778 (diff)
Merge #8345
8345: Add pub mod option for UnlinkedFile r=rainy-me a=rainy-me close #8228 This is a draft that changes `Diagnostic` to contain multiple fixes. Pre analysis is in https://github.com/rust-analyzer/rust-analyzer/issues/8228#issuecomment-812887085 Because this solution is straightforward so I decided to type it out for discussion. Currently the `check_fix` is not able to test the situation when multiple fixes available. <del>Also because `Insert 'mod x;'` and `Insert 'pub mod x;'` are so similar, I don't know how to test them correctly and want some suggestions.</del>. I added `check_fixes` to allow checking mutiple possible fixes. In additional, instead of append after possible existing `mod y`, I think it's possible to Insert `pub mod x;` after `pub mod y`. Should I implement this too? Co-authored-by: rainy-me <[email protected]>
Diffstat (limited to 'crates/ide/src/diagnostics/fixes/replace_with_find_map.rs')
-rw-r--r--crates/ide/src/diagnostics/fixes/replace_with_find_map.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/ide/src/diagnostics/fixes/replace_with_find_map.rs b/crates/ide/src/diagnostics/fixes/replace_with_find_map.rs
index b0ef7b44a..444bf563b 100644
--- a/crates/ide/src/diagnostics/fixes/replace_with_find_map.rs
+++ b/crates/ide/src/diagnostics/fixes/replace_with_find_map.rs
@@ -7,14 +7,14 @@ use syntax::{
7}; 7};
8use text_edit::TextEdit; 8use text_edit::TextEdit;
9 9
10use crate::diagnostics::{fix, DiagnosticWithFix}; 10use crate::diagnostics::{fix, DiagnosticWithFixes};
11 11
12impl DiagnosticWithFix for ReplaceFilterMapNextWithFindMap { 12impl DiagnosticWithFixes for ReplaceFilterMapNextWithFindMap {
13 fn fix( 13 fn fixes(
14 &self, 14 &self,
15 sema: &Semantics<RootDatabase>, 15 sema: &Semantics<RootDatabase>,
16 _resolve: &AssistResolveStrategy, 16 _resolve: &AssistResolveStrategy,
17 ) -> Option<Assist> { 17 ) -> Option<Vec<Assist>> {
18 let root = sema.db.parse_or_expand(self.file)?; 18 let root = sema.db.parse_or_expand(self.file)?;
19 let next_expr = self.next_expr.to_node(&root); 19 let next_expr = self.next_expr.to_node(&root);
20 let next_call = ast::MethodCallExpr::cast(next_expr.syntax().clone())?; 20 let next_call = ast::MethodCallExpr::cast(next_expr.syntax().clone())?;
@@ -32,12 +32,12 @@ impl DiagnosticWithFix for ReplaceFilterMapNextWithFindMap {
32 32
33 let source_change = SourceChange::from_text_edit(self.file.original_file(sema.db), edit); 33 let source_change = SourceChange::from_text_edit(self.file.original_file(sema.db), edit);
34 34
35 Some(fix( 35 Some(vec![fix(
36 "replace_with_find_map", 36 "replace_with_find_map",
37 "Replace filter_map(..).next() with find_map()", 37 "Replace filter_map(..).next() with find_map()",
38 source_change, 38 source_change,
39 trigger_range, 39 trigger_range,
40 )) 40 )])
41 } 41 }
42} 42}
43 43