aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/diagnostics/fixes/remove_semicolon.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/remove_semicolon.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/remove_semicolon.rs')
-rw-r--r--crates/ide/src/diagnostics/fixes/remove_semicolon.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ide/src/diagnostics/fixes/remove_semicolon.rs b/crates/ide/src/diagnostics/fixes/remove_semicolon.rs
index 45471da41..f1724d479 100644
--- a/crates/ide/src/diagnostics/fixes/remove_semicolon.rs
+++ b/crates/ide/src/diagnostics/fixes/remove_semicolon.rs
@@ -4,14 +4,14 @@ use ide_db::{source_change::SourceChange, RootDatabase};
4use syntax::{ast, AstNode}; 4use syntax::{ast, AstNode};
5use text_edit::TextEdit; 5use text_edit::TextEdit;
6 6
7use crate::diagnostics::{fix, DiagnosticWithFix}; 7use crate::diagnostics::{fix, DiagnosticWithFixes};
8 8
9impl DiagnosticWithFix for RemoveThisSemicolon { 9impl DiagnosticWithFixes for RemoveThisSemicolon {
10 fn fix( 10 fn fixes(
11 &self, 11 &self,
12 sema: &Semantics<RootDatabase>, 12 sema: &Semantics<RootDatabase>,
13 _resolve: &AssistResolveStrategy, 13 _resolve: &AssistResolveStrategy,
14 ) -> Option<Assist> { 14 ) -> Option<Vec<Assist>> {
15 let root = sema.db.parse_or_expand(self.file)?; 15 let root = sema.db.parse_or_expand(self.file)?;
16 16
17 let semicolon = self 17 let semicolon = self
@@ -26,7 +26,7 @@ impl DiagnosticWithFix for RemoveThisSemicolon {
26 let edit = TextEdit::delete(semicolon); 26 let edit = TextEdit::delete(semicolon);
27 let source_change = SourceChange::from_text_edit(self.file.original_file(sema.db), edit); 27 let source_change = SourceChange::from_text_edit(self.file.original_file(sema.db), edit);
28 28
29 Some(fix("remove_semicolon", "Remove this semicolon", source_change, semicolon)) 29 Some(vec![fix("remove_semicolon", "Remove this semicolon", source_change, semicolon)])
30 } 30 }
31} 31}
32 32