From 71d2d81dcc879bbb7898df11ac00578e93b27ab5 Mon Sep 17 00:00:00 2001 From: Emil Lauridsen Date: Wed, 25 Dec 2019 19:56:07 +0100 Subject: Some documentatioN --- crates/ra_lsp_server/src/cargo_check.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'crates') 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 @@ +//! cargo_check provides the functionality needed to run `cargo check` or +//! another compatible command (f.x. clippy) in a background thread and provide +//! LSP diagnostics based on the output of the command. use crate::world::Options; use cargo_metadata::{ diagnostic::{ @@ -23,6 +26,9 @@ use std::{ time::Instant, }; +/// CheckWatcher wraps the shared state and communication machinery used for +/// running `cargo check` (or other compatible command) and providing +/// diagnostics based on the output. #[derive(Debug)] pub struct CheckWatcher { pub task_recv: Receiver, @@ -55,6 +61,7 @@ impl CheckWatcher { CheckWatcher { task_recv, cmd_send, handle, shared } } + /// Schedule a re-start of the cargo check worker. pub fn update(&self) { self.cmd_send.send(CheckCommand::Update).unwrap(); } @@ -85,6 +92,8 @@ impl CheckWatcherSharedState { } } + /// Clear the cached diagnostics, and schedule updating diagnostics by the + /// server, to clear stale results. pub fn clear(&mut self, task_send: &Sender) { let cleared_files: Vec = self.diagnostic_collection.keys().cloned().collect(); @@ -139,11 +148,15 @@ impl CheckWatcherSharedState { #[derive(Debug)] pub enum CheckTask { + /// Request a update of the given files diagnostics Update(Url), + + /// Request check progress notification to client Status(WorkDoneProgress), } pub enum CheckCommand { + /// Request re-start of check thread Update, } -- cgit v1.2.3