aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_lsp_server/src/cargo_check.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/crates/ra_lsp_server/src/cargo_check.rs b/crates/ra_lsp_server/src/cargo_check.rs
index 42e55565f..fa0409ee0 100644
--- a/crates/ra_lsp_server/src/cargo_check.rs
+++ b/crates/ra_lsp_server/src/cargo_check.rs
@@ -1,3 +1,6 @@
1//! cargo_check provides the functionality needed to run `cargo check` or
2//! another compatible command (f.x. clippy) in a background thread and provide
3//! LSP diagnostics based on the output of the command.
1use crate::world::Options; 4use crate::world::Options;
2use cargo_metadata::{ 5use cargo_metadata::{
3 diagnostic::{ 6 diagnostic::{
@@ -23,6 +26,9 @@ use std::{
23 time::Instant, 26 time::Instant,
24}; 27};
25 28
29/// CheckWatcher wraps the shared state and communication machinery used for
30/// running `cargo check` (or other compatible command) and providing
31/// diagnostics based on the output.
26#[derive(Debug)] 32#[derive(Debug)]
27pub struct CheckWatcher { 33pub struct CheckWatcher {
28 pub task_recv: Receiver<CheckTask>, 34 pub task_recv: Receiver<CheckTask>,
@@ -55,6 +61,7 @@ impl CheckWatcher {
55 CheckWatcher { task_recv, cmd_send, handle, shared } 61 CheckWatcher { task_recv, cmd_send, handle, shared }
56 } 62 }
57 63
64 /// Schedule a re-start of the cargo check worker.
58 pub fn update(&self) { 65 pub fn update(&self) {
59 self.cmd_send.send(CheckCommand::Update).unwrap(); 66 self.cmd_send.send(CheckCommand::Update).unwrap();
60 } 67 }
@@ -85,6 +92,8 @@ impl CheckWatcherSharedState {
85 } 92 }
86 } 93 }
87 94
95 /// Clear the cached diagnostics, and schedule updating diagnostics by the
96 /// server, to clear stale results.
88 pub fn clear(&mut self, task_send: &Sender<CheckTask>) { 97 pub fn clear(&mut self, task_send: &Sender<CheckTask>) {
89 let cleared_files: Vec<Url> = self.diagnostic_collection.keys().cloned().collect(); 98 let cleared_files: Vec<Url> = self.diagnostic_collection.keys().cloned().collect();
90 99
@@ -139,11 +148,15 @@ impl CheckWatcherSharedState {
139 148
140#[derive(Debug)] 149#[derive(Debug)]
141pub enum CheckTask { 150pub enum CheckTask {
151 /// Request a update of the given files diagnostics
142 Update(Url), 152 Update(Url),
153
154 /// Request check progress notification to client
143 Status(WorkDoneProgress), 155 Status(WorkDoneProgress),
144} 156}
145 157
146pub enum CheckCommand { 158pub enum CheckCommand {
159 /// Request re-start of check thread
147 Update, 160 Update,
148} 161}
149 162