aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
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.toml2
-rw-r--r--crates/rust-analyzer/src/config.rs2
-rw-r--r--crates/rust-analyzer/src/diagnostics/to_proto.rs19
-rw-r--r--crates/rust-analyzer/src/global_state.rs2
-rw-r--r--crates/rust-analyzer/src/main_loop.rs8
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]
2edition = "2018" 2edition = "2018"
3name = "ra_flycheck" 3name = "flycheck"
4version = "0.1.0" 4version = "0.1.0"
5authors = ["rust-analyzer developers"] 5authors = ["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"
32stdx = { path = "../stdx" } 32stdx = { path = "../stdx" }
33 33
34lsp-server = "0.3.3" 34lsp-server = "0.3.3"
35ra_flycheck = { path = "../ra_flycheck" } 35flycheck = { path = "../flycheck" }
36ra_ide = { path = "../ra_ide" } 36ra_ide = { path = "../ra_ide" }
37ra_prof = { path = "../ra_prof" } 37ra_prof = { path = "../ra_prof" }
38ra_project_model = { path = "../ra_project_model" } 38ra_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 @@
10use std::{ffi::OsString, path::PathBuf}; 10use std::{ffi::OsString, path::PathBuf};
11 11
12use crate::diagnostics::DiagnosticsConfig; 12use crate::diagnostics::DiagnosticsConfig;
13use flycheck::FlycheckConfig;
13use lsp_types::ClientCapabilities; 14use lsp_types::ClientCapabilities;
14use ra_db::AbsPathBuf; 15use ra_db::AbsPathBuf;
15use ra_flycheck::FlycheckConfig;
16use ra_ide::{AssistConfig, CompletionConfig, HoverConfig, InlayHintsConfig}; 16use ra_ide::{AssistConfig, CompletionConfig, HoverConfig, InlayHintsConfig};
17use ra_project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest}; 17use ra_project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest};
18use serde::Deserialize; 18use 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.
3use std::{collections::HashMap, path::Path}; 3use std::{collections::HashMap, path::Path};
4 4
5use flycheck::{Applicability, DiagnosticLevel, DiagnosticSpan, DiagnosticSpanMacroExpansion};
5use lsp_types::{ 6use 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};
9use ra_flycheck::{Applicability, DiagnosticLevel, DiagnosticSpan, DiagnosticSpanMacroExpansion};
10use stdx::format_to; 10use stdx::format_to;
11 11
12use super::DiagnosticsConfig;
13use crate::{lsp_ext, to_proto::url_from_abs_path}; 12use crate::{lsp_ext, to_proto::url_from_abs_path};
14 13
14use super::DiagnosticsConfig;
15
15/// Determines the LSP severity from a diagnostic 16/// Determines the LSP severity from a diagnostic
16fn map_diagnostic_to_severity( 17fn 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
98fn is_unused_or_unnecessary(rd: &ra_flycheck::Diagnostic) -> bool { 99fn 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
110fn is_deprecated(rd: &ra_flycheck::Diagnostic) -> bool { 111fn 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
123fn map_rust_child_diagnostic( 124fn 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`
184pub(crate) fn map_rust_diagnostic_to_lsp( 185pub(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(
286mod tests { 287mod 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 @@
6use std::{convert::TryFrom, sync::Arc}; 6use std::{convert::TryFrom, sync::Arc};
7 7
8use crossbeam_channel::{unbounded, Receiver}; 8use crossbeam_channel::{unbounded, Receiver};
9use flycheck::{CheckTask, FlycheckConfig, FlycheckHandle};
9use lsp_types::Url; 10use lsp_types::Url;
10use parking_lot::RwLock; 11use parking_lot::RwLock;
11use ra_db::{CrateId, SourceRoot, VfsPath}; 12use ra_db::{CrateId, SourceRoot, VfsPath};
12use ra_flycheck::{CheckTask, FlycheckConfig, FlycheckHandle};
13use ra_ide::{Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId}; 13use ra_ide::{Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId};
14use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target}; 14use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target};
15use stdx::format_to; 15use 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
11use crossbeam_channel::{never, select, unbounded, RecvError, Sender}; 11use crossbeam_channel::{never, select, unbounded, RecvError, Sender};
12use flycheck::CheckTask;
12use lsp_server::{Connection, ErrorCode, Message, Notification, Request, RequestId, Response}; 13use lsp_server::{Connection, ErrorCode, Message, Notification, Request, RequestId, Response};
13use lsp_types::{request::Request as _, NumberOrString, TextDocumentContentChangeEvent}; 14use lsp_types::{request::Request as _, NumberOrString, TextDocumentContentChangeEvent};
14use ra_db::VfsPath; 15use ra_db::VfsPath;
15use ra_flycheck::CheckTask;
16use ra_ide::{Canceled, FileId, LineIndex}; 16use ra_ide::{Canceled, FileId, LineIndex};
17use ra_prof::profile; 17use ra_prof::profile;
18use ra_project_model::{PackageRoot, ProjectWorkspace}; 18use 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);