diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-15 01:10:58 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-15 01:10:58 +0100 |
commit | 05db35dafb47db355e202c9176bd8a752b7390d7 (patch) | |
tree | 885d5729e6223132f571e12688fc3f2c20c4ab55 /crates/rust-analyzer/src/main_loop.rs | |
parent | 12d82687cd600ec81bf3027661135e5f0d4ad4bd (diff) | |
parent | 08027c307556c8500ca6e44c432a08f83d33d1c3 (diff) |
Merge #4460
4460: Remove flycheck -> LSP dependency r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/rust-analyzer/src/main_loop.rs')
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 67 |
1 files changed, 53 insertions, 14 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 13d305b97..15e5bb354 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -25,7 +25,7 @@ use lsp_types::{ | |||
25 | WorkDoneProgressBegin, WorkDoneProgressCreateParams, WorkDoneProgressEnd, | 25 | WorkDoneProgressBegin, WorkDoneProgressCreateParams, WorkDoneProgressEnd, |
26 | WorkDoneProgressReport, | 26 | WorkDoneProgressReport, |
27 | }; | 27 | }; |
28 | use ra_flycheck::{url_from_path_with_drive_lowercasing, CheckTask}; | 28 | use ra_flycheck::{CheckTask, Status}; |
29 | use ra_ide::{Canceled, FileId, LibraryData, LineIndex, SourceRootId}; | 29 | use ra_ide::{Canceled, FileId, LibraryData, LineIndex, SourceRootId}; |
30 | use ra_prof::profile; | 30 | use ra_prof::profile; |
31 | use ra_project_model::{PackageRoot, ProjectWorkspace}; | 31 | use ra_project_model::{PackageRoot, ProjectWorkspace}; |
@@ -37,7 +37,7 @@ use threadpool::ThreadPool; | |||
37 | 37 | ||
38 | use crate::{ | 38 | use crate::{ |
39 | config::{Config, FilesWatcher}, | 39 | config::{Config, FilesWatcher}, |
40 | diagnostics::DiagnosticTask, | 40 | diagnostics::{to_proto::url_from_path_with_drive_lowercasing, DiagnosticTask}, |
41 | from_proto, lsp_ext, | 41 | from_proto, lsp_ext, |
42 | main_loop::{ | 42 | main_loop::{ |
43 | pending_requests::{PendingRequest, PendingRequests}, | 43 | pending_requests::{PendingRequest, PendingRequests}, |
@@ -736,22 +736,61 @@ fn on_check_task( | |||
736 | task_sender.send(Task::Diagnostic(DiagnosticTask::ClearCheck))?; | 736 | task_sender.send(Task::Diagnostic(DiagnosticTask::ClearCheck))?; |
737 | } | 737 | } |
738 | 738 | ||
739 | CheckTask::AddDiagnostic { url, diagnostic, fixes } => { | 739 | CheckTask::AddDiagnostic { workspace_root, diagnostic } => { |
740 | let path = url.to_file_path().map_err(|()| format!("invalid uri: {}", url))?; | 740 | let diagnostics = crate::diagnostics::to_proto::map_rust_diagnostic_to_lsp( |
741 | let file_id = match world_state.vfs.read().path2file(&path) { | 741 | &diagnostic, |
742 | Some(file) => FileId(file.0), | 742 | &workspace_root, |
743 | None => { | 743 | ); |
744 | log::error!("File with cargo diagnostic not found in VFS: {}", path.display()); | 744 | for diag in diagnostics { |
745 | return Ok(()); | 745 | let path = diag |
746 | } | 746 | .location |
747 | }; | 747 | .uri |
748 | .to_file_path() | ||
749 | .map_err(|()| format!("invalid uri: {}", diag.location.uri))?; | ||
750 | let file_id = match world_state.vfs.read().path2file(&path) { | ||
751 | Some(file) => FileId(file.0), | ||
752 | None => { | ||
753 | log::error!( | ||
754 | "File with cargo diagnostic not found in VFS: {}", | ||
755 | path.display() | ||
756 | ); | ||
757 | return Ok(()); | ||
758 | } | ||
759 | }; | ||
748 | 760 | ||
749 | task_sender | 761 | task_sender.send(Task::Diagnostic(DiagnosticTask::AddCheck( |
750 | .send(Task::Diagnostic(DiagnosticTask::AddCheck(file_id, diagnostic, fixes)))?; | 762 | file_id, |
763 | diag.diagnostic, | ||
764 | diag.fixes.into_iter().map(|it| it.into()).collect(), | ||
765 | )))?; | ||
766 | } | ||
751 | } | 767 | } |
752 | 768 | ||
753 | CheckTask::Status(progress) => { | 769 | CheckTask::Status(status) => { |
754 | if world_state.config.client_caps.work_done_progress { | 770 | if world_state.config.client_caps.work_done_progress { |
771 | let progress = match status { | ||
772 | Status::Being => { | ||
773 | lsp_types::WorkDoneProgress::Begin(lsp_types::WorkDoneProgressBegin { | ||
774 | title: "Running `cargo check`".to_string(), | ||
775 | cancellable: Some(false), | ||
776 | message: None, | ||
777 | percentage: None, | ||
778 | }) | ||
779 | } | ||
780 | Status::Progress(target) => { | ||
781 | lsp_types::WorkDoneProgress::Report(lsp_types::WorkDoneProgressReport { | ||
782 | cancellable: Some(false), | ||
783 | message: Some(target), | ||
784 | percentage: None, | ||
785 | }) | ||
786 | } | ||
787 | Status::End => { | ||
788 | lsp_types::WorkDoneProgress::End(lsp_types::WorkDoneProgressEnd { | ||
789 | message: None, | ||
790 | }) | ||
791 | } | ||
792 | }; | ||
793 | |||
755 | let params = lsp_types::ProgressParams { | 794 | let params = lsp_types::ProgressParams { |
756 | token: lsp_types::ProgressToken::String( | 795 | token: lsp_types::ProgressToken::String( |
757 | "rustAnalyzer/cargoWatcher".to_string(), | 796 | "rustAnalyzer/cargoWatcher".to_string(), |