|
1 | 1 | //! This module provides the functionality needed to convert diagnostics from |
2 | 2 | //! `cargo check` json format to the LSP diagnostic format. |
3 | | -use cargo_metadata::diagnostic::{ |
4 | | - Applicability, Diagnostic as RustDiagnostic, DiagnosticLevel, DiagnosticSpan, |
5 | | - DiagnosticSpanMacroExpansion, |
6 | | -}; |
7 | | -use lsp_types::{ |
8 | | - CodeAction, Diagnostic, DiagnosticRelatedInformation, DiagnosticSeverity, DiagnosticTag, |
9 | | - Location, NumberOrString, Position, Range, TextEdit, Url, WorkspaceEdit, |
10 | | -}; |
11 | 3 | use std::{ |
12 | 4 | collections::HashMap, |
13 | 5 | fmt::Write, |
14 | 6 | path::{Component, Path, PathBuf, Prefix}, |
15 | 7 | str::FromStr, |
16 | 8 | }; |
17 | 9 |
|
| 10 | +use lsp_types::{ |
| 11 | + CodeAction, Diagnostic, DiagnosticRelatedInformation, DiagnosticSeverity, DiagnosticTag, |
| 12 | + Location, NumberOrString, Position, Range, TextEdit, Url, WorkspaceEdit, |
| 13 | +}; |
| 14 | +use ra_flycheck::{Applicability, DiagnosticLevel, DiagnosticSpan, DiagnosticSpanMacroExpansion}; |
| 15 | + |
18 | 16 | /// Converts a Rust level string to a LSP severity |
19 | 17 | fn map_level_to_severity(val: DiagnosticLevel) -> Option<DiagnosticSeverity> { |
20 | 18 | match val { |
@@ -91,7 +89,7 @@ fn map_secondary_span_to_related( |
91 | 89 | } |
92 | 90 |
|
93 | 91 | /// Determines if diagnostic is related to unused code |
94 | | -fn is_unused_or_unnecessary(rd: &RustDiagnostic) -> bool { |
| 92 | +fn is_unused_or_unnecessary(rd: &ra_flycheck::Diagnostic) -> bool { |
95 | 93 | if let Some(code) = &rd.code { |
96 | 94 | match code.code.as_str() { |
97 | 95 | "dead_code" | "unknown_lints" | "unreachable_code" | "unused_attributes" |
@@ -122,7 +120,7 @@ enum MappedRustChildDiagnostic { |
122 | 120 | } |
123 | 121 |
|
124 | 122 | fn map_rust_child_diagnostic( |
125 | | - rd: &RustDiagnostic, |
| 123 | + rd: &ra_flycheck::Diagnostic, |
126 | 124 | workspace_root: &PathBuf, |
127 | 125 | ) -> MappedRustChildDiagnostic { |
128 | 126 | let spans: Vec<&DiagnosticSpan> = rd.spans.iter().filter(|s| s.is_primary).collect(); |
@@ -179,7 +177,7 @@ pub(crate) struct MappedRustDiagnostic { |
179 | 177 | /// |
180 | 178 | /// If the diagnostic has no primary span this will return `None` |
181 | 179 | pub(crate) fn map_rust_diagnostic_to_lsp( |
182 | | - rd: &RustDiagnostic, |
| 180 | + rd: &ra_flycheck::Diagnostic, |
183 | 181 | workspace_root: &PathBuf, |
184 | 182 | ) -> Vec<MappedRustDiagnostic> { |
185 | 183 | let primary_spans: Vec<&DiagnosticSpan> = rd.spans.iter().filter(|s| s.is_primary).collect(); |
|
0 commit comments