aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/diagnostics/fixes/change_case.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/change_case.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/change_case.rs')
-rw-r--r--crates/ide/src/diagnostics/fixes/change_case.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ide/src/diagnostics/fixes/change_case.rs b/crates/ide/src/diagnostics/fixes/change_case.rs
index 80aca58a1..42be3375f 100644
--- a/crates/ide/src/diagnostics/fixes/change_case.rs
+++ b/crates/ide/src/diagnostics/fixes/change_case.rs
@@ -4,16 +4,16 @@ use ide_db::{base_db::FilePosition, RootDatabase};
4use syntax::AstNode; 4use syntax::AstNode;
5 5
6use crate::{ 6use crate::{
7 diagnostics::{unresolved_fix, DiagnosticWithFix}, 7 diagnostics::{unresolved_fix, DiagnosticWithFixes},
8 references::rename::rename_with_semantics, 8 references::rename::rename_with_semantics,
9}; 9};
10 10
11impl DiagnosticWithFix for IncorrectCase { 11impl DiagnosticWithFixes for IncorrectCase {
12 fn fix( 12 fn fixes(
13 &self, 13 &self,
14 sema: &Semantics<RootDatabase>, 14 sema: &Semantics<RootDatabase>,
15 resolve: &AssistResolveStrategy, 15 resolve: &AssistResolveStrategy,
16 ) -> Option<Assist> { 16 ) -> Option<Vec<Assist>> {
17 let root = sema.db.parse_or_expand(self.file)?; 17 let root = sema.db.parse_or_expand(self.file)?;
18 let name_node = self.ident.to_node(&root); 18 let name_node = self.ident.to_node(&root);
19 19
@@ -28,7 +28,7 @@ impl DiagnosticWithFix for IncorrectCase {
28 res.source_change = Some(source_change.ok().unwrap_or_default()); 28 res.source_change = Some(source_change.ok().unwrap_or_default());
29 } 29 }
30 30
31 Some(res) 31 Some(vec![res])
32 } 32 }
33} 33}
34 34