diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/flycheck/Cargo.toml (renamed from crates/ra_flycheck/Cargo.toml) | 2 | ||||
-rw-r--r-- | crates/flycheck/src/lib.rs (renamed from crates/ra_flycheck/src/lib.rs) | 0 | ||||
-rw-r--r-- | crates/rust-analyzer/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/diagnostics/to_proto.rs | 19 | ||||
-rw-r--r-- | crates/rust-analyzer/src/global_state.rs | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 8 |
7 files changed, 18 insertions, 17 deletions
diff --git a/crates/ra_flycheck/Cargo.toml b/crates/flycheck/Cargo.toml index 1aa39bade..dc26b8ce7 100644 --- a/crates/ra_flycheck/Cargo.toml +++ b/crates/flycheck/Cargo.toml | |||
@@ -1,6 +1,6 @@ | |||
1 | [package] | 1 | [package] |
2 | edition = "2018" | 2 | edition = "2018" |
3 | name = "ra_flycheck" | 3 | name = "flycheck" |
4 | version = "0.1.0" | 4 | version = "0.1.0" |
5 | authors = ["rust-analyzer developers"] | 5 | authors = ["rust-analyzer developers"] |
6 | 6 | ||
diff --git a/crates/ra_flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index af75adbe2..af75adbe2 100644 --- a/crates/ra_flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs | |||
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 68d04f3e3..08c67ddd0 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml | |||
@@ -32,7 +32,7 @@ threadpool = "1.7.1" | |||
32 | stdx = { path = "../stdx" } | 32 | stdx = { path = "../stdx" } |
33 | 33 | ||
34 | lsp-server = "0.3.3" | 34 | lsp-server = "0.3.3" |
35 | ra_flycheck = { path = "../ra_flycheck" } | 35 | flycheck = { path = "../flycheck" } |
36 | ra_ide = { path = "../ra_ide" } | 36 | ra_ide = { path = "../ra_ide" } |
37 | ra_prof = { path = "../ra_prof" } | 37 | ra_prof = { path = "../ra_prof" } |
38 | ra_project_model = { path = "../ra_project_model" } | 38 | ra_project_model = { path = "../ra_project_model" } |
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 8f69de968..435bbbb6b 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -10,9 +10,9 @@ | |||
10 | use std::{ffi::OsString, path::PathBuf}; | 10 | use std::{ffi::OsString, path::PathBuf}; |
11 | 11 | ||
12 | use crate::diagnostics::DiagnosticsConfig; | 12 | use crate::diagnostics::DiagnosticsConfig; |
13 | use flycheck::FlycheckConfig; | ||
13 | use lsp_types::ClientCapabilities; | 14 | use lsp_types::ClientCapabilities; |
14 | use ra_db::AbsPathBuf; | 15 | use ra_db::AbsPathBuf; |
15 | use ra_flycheck::FlycheckConfig; | ||
16 | use ra_ide::{AssistConfig, CompletionConfig, HoverConfig, InlayHintsConfig}; | 16 | use ra_ide::{AssistConfig, CompletionConfig, HoverConfig, InlayHintsConfig}; |
17 | use ra_project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest}; | 17 | use ra_project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest}; |
18 | use serde::Deserialize; | 18 | use serde::Deserialize; |
diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs index ba74f15f3..f379f5ed0 100644 --- a/crates/rust-analyzer/src/diagnostics/to_proto.rs +++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs | |||
@@ -2,20 +2,21 @@ | |||
2 | //! `cargo check` json format to the LSP diagnostic format. | 2 | //! `cargo check` json format to the LSP diagnostic format. |
3 | use std::{collections::HashMap, path::Path}; | 3 | use std::{collections::HashMap, path::Path}; |
4 | 4 | ||
5 | use flycheck::{Applicability, DiagnosticLevel, DiagnosticSpan, DiagnosticSpanMacroExpansion}; | ||
5 | use lsp_types::{ | 6 | use lsp_types::{ |
6 | Diagnostic, DiagnosticRelatedInformation, DiagnosticSeverity, DiagnosticTag, Location, | 7 | Diagnostic, DiagnosticRelatedInformation, DiagnosticSeverity, DiagnosticTag, Location, |
7 | NumberOrString, Position, Range, TextEdit, Url, | 8 | NumberOrString, Position, Range, TextEdit, Url, |
8 | }; | 9 | }; |
9 | use ra_flycheck::{Applicability, DiagnosticLevel, DiagnosticSpan, DiagnosticSpanMacroExpansion}; | ||
10 | use stdx::format_to; | 10 | use stdx::format_to; |
11 | 11 | ||
12 | use super::DiagnosticsConfig; | ||
13 | use crate::{lsp_ext, to_proto::url_from_abs_path}; | 12 | use crate::{lsp_ext, to_proto::url_from_abs_path}; |
14 | 13 | ||
14 | use super::DiagnosticsConfig; | ||
15 | |||
15 | /// Determines the LSP severity from a diagnostic | 16 | /// Determines the LSP severity from a diagnostic |
16 | fn map_diagnostic_to_severity( | 17 | fn map_diagnostic_to_severity( |
17 | config: &DiagnosticsConfig, | 18 | config: &DiagnosticsConfig, |
18 | val: &ra_flycheck::Diagnostic, | 19 | val: &flycheck::Diagnostic, |
19 | ) -> Option<DiagnosticSeverity> { | 20 | ) -> Option<DiagnosticSeverity> { |
20 | let res = match val.level { | 21 | let res = match val.level { |
21 | DiagnosticLevel::Ice => DiagnosticSeverity::Error, | 22 | DiagnosticLevel::Ice => DiagnosticSeverity::Error, |
@@ -95,7 +96,7 @@ fn map_secondary_span_to_related( | |||
95 | } | 96 | } |
96 | 97 | ||
97 | /// Determines if diagnostic is related to unused code | 98 | /// Determines if diagnostic is related to unused code |
98 | fn is_unused_or_unnecessary(rd: &ra_flycheck::Diagnostic) -> bool { | 99 | fn is_unused_or_unnecessary(rd: &flycheck::Diagnostic) -> bool { |
99 | match &rd.code { | 100 | match &rd.code { |
100 | Some(code) => match code.code.as_str() { | 101 | Some(code) => match code.code.as_str() { |
101 | "dead_code" | "unknown_lints" | "unreachable_code" | "unused_attributes" | 102 | "dead_code" | "unknown_lints" | "unreachable_code" | "unused_attributes" |
@@ -107,7 +108,7 @@ fn is_unused_or_unnecessary(rd: &ra_flycheck::Diagnostic) -> bool { | |||
107 | } | 108 | } |
108 | 109 | ||
109 | /// Determines if diagnostic is related to deprecated code | 110 | /// Determines if diagnostic is related to deprecated code |
110 | fn is_deprecated(rd: &ra_flycheck::Diagnostic) -> bool { | 111 | fn is_deprecated(rd: &flycheck::Diagnostic) -> bool { |
111 | match &rd.code { | 112 | match &rd.code { |
112 | Some(code) => code.code.as_str() == "deprecated", | 113 | Some(code) => code.code.as_str() == "deprecated", |
113 | None => false, | 114 | None => false, |
@@ -121,7 +122,7 @@ enum MappedRustChildDiagnostic { | |||
121 | } | 122 | } |
122 | 123 | ||
123 | fn map_rust_child_diagnostic( | 124 | fn map_rust_child_diagnostic( |
124 | rd: &ra_flycheck::Diagnostic, | 125 | rd: &flycheck::Diagnostic, |
125 | workspace_root: &Path, | 126 | workspace_root: &Path, |
126 | ) -> MappedRustChildDiagnostic { | 127 | ) -> MappedRustChildDiagnostic { |
127 | let spans: Vec<&DiagnosticSpan> = rd.spans.iter().filter(|s| s.is_primary).collect(); | 128 | let spans: Vec<&DiagnosticSpan> = rd.spans.iter().filter(|s| s.is_primary).collect(); |
@@ -183,7 +184,7 @@ pub(crate) struct MappedRustDiagnostic { | |||
183 | /// If the diagnostic has no primary span this will return `None` | 184 | /// If the diagnostic has no primary span this will return `None` |
184 | pub(crate) fn map_rust_diagnostic_to_lsp( | 185 | pub(crate) fn map_rust_diagnostic_to_lsp( |
185 | config: &DiagnosticsConfig, | 186 | config: &DiagnosticsConfig, |
186 | rd: &ra_flycheck::Diagnostic, | 187 | rd: &flycheck::Diagnostic, |
187 | workspace_root: &Path, | 188 | workspace_root: &Path, |
188 | ) -> Vec<MappedRustDiagnostic> { | 189 | ) -> Vec<MappedRustDiagnostic> { |
189 | let primary_spans: Vec<&DiagnosticSpan> = rd.spans.iter().filter(|s| s.is_primary).collect(); | 190 | let primary_spans: Vec<&DiagnosticSpan> = rd.spans.iter().filter(|s| s.is_primary).collect(); |
@@ -286,8 +287,8 @@ pub(crate) fn map_rust_diagnostic_to_lsp( | |||
286 | mod tests { | 287 | mod tests { |
287 | use super::*; | 288 | use super::*; |
288 | 289 | ||
289 | fn parse_diagnostic(val: &str) -> ra_flycheck::Diagnostic { | 290 | fn parse_diagnostic(val: &str) -> flycheck::Diagnostic { |
290 | serde_json::from_str::<ra_flycheck::Diagnostic>(val).unwrap() | 291 | serde_json::from_str::<flycheck::Diagnostic>(val).unwrap() |
291 | } | 292 | } |
292 | 293 | ||
293 | #[test] | 294 | #[test] |
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index c022ff705..6038bf664 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs | |||
@@ -6,10 +6,10 @@ | |||
6 | use std::{convert::TryFrom, sync::Arc}; | 6 | use std::{convert::TryFrom, sync::Arc}; |
7 | 7 | ||
8 | use crossbeam_channel::{unbounded, Receiver}; | 8 | use crossbeam_channel::{unbounded, Receiver}; |
9 | use flycheck::{CheckTask, FlycheckConfig, FlycheckHandle}; | ||
9 | use lsp_types::Url; | 10 | use lsp_types::Url; |
10 | use parking_lot::RwLock; | 11 | use parking_lot::RwLock; |
11 | use ra_db::{CrateId, SourceRoot, VfsPath}; | 12 | use ra_db::{CrateId, SourceRoot, VfsPath}; |
12 | use ra_flycheck::{CheckTask, FlycheckConfig, FlycheckHandle}; | ||
13 | use ra_ide::{Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId}; | 13 | use ra_ide::{Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId}; |
14 | use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target}; | 14 | use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target}; |
15 | use stdx::format_to; | 15 | use stdx::format_to; |
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index e5f82de5e..0664e4a5a 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -9,10 +9,10 @@ use std::{ | |||
9 | }; | 9 | }; |
10 | 10 | ||
11 | use crossbeam_channel::{never, select, unbounded, RecvError, Sender}; | 11 | use crossbeam_channel::{never, select, unbounded, RecvError, Sender}; |
12 | use flycheck::CheckTask; | ||
12 | use lsp_server::{Connection, ErrorCode, Message, Notification, Request, RequestId, Response}; | 13 | use lsp_server::{Connection, ErrorCode, Message, Notification, Request, RequestId, Response}; |
13 | use lsp_types::{request::Request as _, NumberOrString, TextDocumentContentChangeEvent}; | 14 | use lsp_types::{request::Request as _, NumberOrString, TextDocumentContentChangeEvent}; |
14 | use ra_db::VfsPath; | 15 | use ra_db::VfsPath; |
15 | use ra_flycheck::CheckTask; | ||
16 | use ra_ide::{Canceled, FileId, LineIndex}; | 16 | use ra_ide::{Canceled, FileId, LineIndex}; |
17 | use ra_prof::profile; | 17 | use ra_prof::profile; |
18 | use ra_project_model::{PackageRoot, ProjectWorkspace}; | 18 | use ra_project_model::{PackageRoot, ProjectWorkspace}; |
@@ -629,9 +629,9 @@ fn on_check_task( | |||
629 | 629 | ||
630 | CheckTask::Status(status) => { | 630 | CheckTask::Status(status) => { |
631 | let (state, message) = match status { | 631 | let (state, message) = match status { |
632 | ra_flycheck::Status::Being => (ProgressState::Start, None), | 632 | flycheck::Status::Being => (ProgressState::Start, None), |
633 | ra_flycheck::Status::Progress(target) => (ProgressState::Report, Some(target)), | 633 | flycheck::Status::Progress(target) => (ProgressState::Report, Some(target)), |
634 | ra_flycheck::Status::End => (ProgressState::End, None), | 634 | flycheck::Status::End => (ProgressState::End, None), |
635 | }; | 635 | }; |
636 | 636 | ||
637 | report_progress(global_state, msg_sender, "cargo check", state, message, None); | 637 | report_progress(global_state, msg_sender, "cargo check", state, message, None); |