diff options
author | Aleksey Kladov <[email protected]> | 2021-06-13 19:09:03 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-06-13 19:09:03 +0100 |
commit | fc30c5ccbeba2a102922da497809dd3f812544c4 (patch) | |
tree | ed3067580e998f04e94bfb93508fe3f12c851c3b /crates/ide/src/diagnostics.rs | |
parent | 2ad78924621420cb323efdeb3d875ca3f47d940f (diff) |
internal: refactor incorrect case diagnostics
Diffstat (limited to 'crates/ide/src/diagnostics.rs')
-rw-r--r-- | crates/ide/src/diagnostics.rs | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index 814e64ae4..f084f7b06 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs | |||
@@ -6,6 +6,7 @@ | |||
6 | 6 | ||
7 | mod break_outside_of_loop; | 7 | mod break_outside_of_loop; |
8 | mod inactive_code; | 8 | mod inactive_code; |
9 | mod incorrect_case; | ||
9 | mod macro_error; | 10 | mod macro_error; |
10 | mod mismatched_arg_count; | 11 | mod mismatched_arg_count; |
11 | mod missing_fields; | 12 | mod missing_fields; |
@@ -135,7 +136,6 @@ pub struct DiagnosticsConfig { | |||
135 | struct DiagnosticsContext<'a> { | 136 | struct DiagnosticsContext<'a> { |
136 | config: &'a DiagnosticsConfig, | 137 | config: &'a DiagnosticsConfig, |
137 | sema: Semantics<'a, RootDatabase>, | 138 | sema: Semantics<'a, RootDatabase>, |
138 | #[allow(unused)] | ||
139 | resolve: &'a AssistResolveStrategy, | 139 | resolve: &'a AssistResolveStrategy, |
140 | } | 140 | } |
141 | 141 | ||
@@ -165,9 +165,6 @@ pub(crate) fn diagnostics( | |||
165 | } | 165 | } |
166 | let res = RefCell::new(res); | 166 | let res = RefCell::new(res); |
167 | let sink_builder = DiagnosticSinkBuilder::new() | 167 | let sink_builder = DiagnosticSinkBuilder::new() |
168 | .on::<hir::diagnostics::IncorrectCase, _>(|d| { | ||
169 | res.borrow_mut().push(warning_with_fix(d, &sema, resolve)); | ||
170 | }) | ||
171 | .on::<UnlinkedFile, _>(|d| { | 168 | .on::<UnlinkedFile, _>(|d| { |
172 | // Limit diagnostic to the first few characters in the file. This matches how VS Code | 169 | // Limit diagnostic to the first few characters in the file. This matches how VS Code |
173 | // renders it with the full span, but on other editors, and is less invasive. | 170 | // renders it with the full span, but on other editors, and is less invasive. |
@@ -216,6 +213,7 @@ pub(crate) fn diagnostics( | |||
216 | #[rustfmt::skip] | 213 | #[rustfmt::skip] |
217 | let d = match diag { | 214 | let d = match diag { |
218 | AnyDiagnostic::BreakOutsideOfLoop(d) => break_outside_of_loop::break_outside_of_loop(&ctx, &d), | 215 | AnyDiagnostic::BreakOutsideOfLoop(d) => break_outside_of_loop::break_outside_of_loop(&ctx, &d), |
216 | AnyDiagnostic::IncorrectCase(d) => incorrect_case::incorrect_case(&ctx, &d), | ||
219 | AnyDiagnostic::MacroError(d) => macro_error::macro_error(&ctx, &d), | 217 | AnyDiagnostic::MacroError(d) => macro_error::macro_error(&ctx, &d), |
220 | AnyDiagnostic::MismatchedArgCount(d) => mismatched_arg_count::mismatched_arg_count(&ctx, &d), | 218 | AnyDiagnostic::MismatchedArgCount(d) => mismatched_arg_count::mismatched_arg_count(&ctx, &d), |
221 | AnyDiagnostic::MissingFields(d) => missing_fields::missing_fields(&ctx, &d), | 219 | AnyDiagnostic::MissingFields(d) => missing_fields::missing_fields(&ctx, &d), |
@@ -250,16 +248,6 @@ pub(crate) fn diagnostics( | |||
250 | res | 248 | res |
251 | } | 249 | } |
252 | 250 | ||
253 | fn warning_with_fix<D: DiagnosticWithFixes>( | ||
254 | d: &D, | ||
255 | sema: &Semantics<RootDatabase>, | ||
256 | resolve: &AssistResolveStrategy, | ||
257 | ) -> Diagnostic { | ||
258 | Diagnostic::hint(sema.diagnostics_display_range(d.display_source()).range, d.message()) | ||
259 | .with_fixes(d.fixes(sema, resolve)) | ||
260 | .with_code(Some(d.code())) | ||
261 | } | ||
262 | |||
263 | fn check_unnecessary_braces_in_use_statement( | 251 | fn check_unnecessary_braces_in_use_statement( |
264 | acc: &mut Vec<Diagnostic>, | 252 | acc: &mut Vec<Diagnostic>, |
265 | file_id: FileId, | 253 | file_id: FileId, |