diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_flycheck/src/lib.rs | 13 | ||||
-rw-r--r-- | crates/rust-analyzer/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/rust-analyzer/src/diagnostics/to_proto.rs | 20 |
3 files changed, 15 insertions, 19 deletions
diff --git a/crates/ra_flycheck/src/lib.rs b/crates/ra_flycheck/src/lib.rs index 178485c9e..541179920 100644 --- a/crates/ra_flycheck/src/lib.rs +++ b/crates/ra_flycheck/src/lib.rs | |||
@@ -12,6 +12,11 @@ use std::{ | |||
12 | use cargo_metadata::Message; | 12 | use cargo_metadata::Message; |
13 | use crossbeam_channel::{never, select, unbounded, Receiver, RecvError, Sender}; | 13 | use crossbeam_channel::{never, select, unbounded, Receiver, RecvError, Sender}; |
14 | 14 | ||
15 | pub use cargo_metadata::diagnostic::{ | ||
16 | Applicability, Diagnostic, DiagnosticLevel, DiagnosticSpan, | ||
17 | DiagnosticSpanMacroExpansion, | ||
18 | }; | ||
19 | |||
15 | #[derive(Clone, Debug, PartialEq, Eq)] | 20 | #[derive(Clone, Debug, PartialEq, Eq)] |
16 | pub enum FlycheckConfig { | 21 | pub enum FlycheckConfig { |
17 | CargoCommand { command: String, all_targets: bool, all_features: bool, extra_args: Vec<String> }, | 22 | CargoCommand { command: String, all_targets: bool, all_features: bool, extra_args: Vec<String> }, |
@@ -52,7 +57,7 @@ pub enum CheckTask { | |||
52 | ClearDiagnostics, | 57 | ClearDiagnostics, |
53 | 58 | ||
54 | /// Request adding a diagnostic with fixes included to a file | 59 | /// Request adding a diagnostic with fixes included to a file |
55 | AddDiagnostic { workspace_root: PathBuf, diagnostic: cargo_metadata::diagnostic::Diagnostic }, | 60 | AddDiagnostic { workspace_root: PathBuf, diagnostic: Diagnostic }, |
56 | 61 | ||
57 | /// Request check progress notification to client | 62 | /// Request check progress notification to client |
58 | Status(Status), | 63 | Status(Status), |
@@ -239,12 +244,6 @@ impl FlycheckThread { | |||
239 | } | 244 | } |
240 | } | 245 | } |
241 | 246 | ||
242 | // #[derive(Debug)] | ||
243 | // pub struct DiagnosticWithFixes { | ||
244 | // diagnostic: Diagnostic, | ||
245 | // fixes: Vec<CodeAction>, | ||
246 | // } | ||
247 | |||
248 | enum CheckEvent { | 247 | enum CheckEvent { |
249 | Begin, | 248 | Begin, |
250 | Msg(cargo_metadata::Message), | 249 | Msg(cargo_metadata::Message), |
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 21e705597..9b2d29b1d 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml | |||
@@ -29,7 +29,6 @@ rustc-hash = "1.1.0" | |||
29 | serde = { version = "1.0.106", features = ["derive"] } | 29 | serde = { version = "1.0.106", features = ["derive"] } |
30 | serde_json = "1.0.48" | 30 | serde_json = "1.0.48" |
31 | threadpool = "1.7.1" | 31 | threadpool = "1.7.1" |
32 | cargo_metadata = "0.10.0" | ||
33 | 32 | ||
34 | stdx = { path = "../stdx" } | 33 | stdx = { path = "../stdx" } |
35 | 34 | ||
diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs index 0c8108591..5c8d86eb5 100644 --- a/crates/rust-analyzer/src/diagnostics/to_proto.rs +++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs | |||
@@ -1,13 +1,5 @@ | |||
1 | //! This module provides the functionality needed to convert diagnostics from | 1 | //! This module provides the functionality needed to convert diagnostics from |
2 | //! `cargo check` json format to the LSP diagnostic format. | 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 | use std::{ | 3 | use std::{ |
12 | collections::HashMap, | 4 | collections::HashMap, |
13 | fmt::Write, | 5 | fmt::Write, |
@@ -15,6 +7,12 @@ use std::{ | |||
15 | str::FromStr, | 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 | /// Converts a Rust level string to a LSP severity | 16 | /// Converts a Rust level string to a LSP severity |
19 | fn map_level_to_severity(val: DiagnosticLevel) -> Option<DiagnosticSeverity> { | 17 | fn map_level_to_severity(val: DiagnosticLevel) -> Option<DiagnosticSeverity> { |
20 | match val { | 18 | match val { |
@@ -91,7 +89,7 @@ fn map_secondary_span_to_related( | |||
91 | } | 89 | } |
92 | 90 | ||
93 | /// Determines if diagnostic is related to unused code | 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 | if let Some(code) = &rd.code { | 93 | if let Some(code) = &rd.code { |
96 | match code.code.as_str() { | 94 | match code.code.as_str() { |
97 | "dead_code" | "unknown_lints" | "unreachable_code" | "unused_attributes" | 95 | "dead_code" | "unknown_lints" | "unreachable_code" | "unused_attributes" |
@@ -122,7 +120,7 @@ enum MappedRustChildDiagnostic { | |||
122 | } | 120 | } |
123 | 121 | ||
124 | fn map_rust_child_diagnostic( | 122 | fn map_rust_child_diagnostic( |
125 | rd: &RustDiagnostic, | 123 | rd: &ra_flycheck::Diagnostic, |
126 | workspace_root: &PathBuf, | 124 | workspace_root: &PathBuf, |
127 | ) -> MappedRustChildDiagnostic { | 125 | ) -> MappedRustChildDiagnostic { |
128 | let spans: Vec<&DiagnosticSpan> = rd.spans.iter().filter(|s| s.is_primary).collect(); | 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 | /// If the diagnostic has no primary span this will return `None` | 178 | /// If the diagnostic has no primary span this will return `None` |
181 | pub(crate) fn map_rust_diagnostic_to_lsp( | 179 | pub(crate) fn map_rust_diagnostic_to_lsp( |
182 | rd: &RustDiagnostic, | 180 | rd: &ra_flycheck::Diagnostic, |
183 | workspace_root: &PathBuf, | 181 | workspace_root: &PathBuf, |
184 | ) -> Vec<MappedRustDiagnostic> { | 182 | ) -> Vec<MappedRustDiagnostic> { |
185 | let primary_spans: Vec<&DiagnosticSpan> = rd.spans.iter().filter(|s| s.is_primary).collect(); | 183 | let primary_spans: Vec<&DiagnosticSpan> = rd.spans.iter().filter(|s| s.is_primary).collect(); |