mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +00:00
Some documentatioN
This commit is contained in:
parent
069c165536
commit
71d2d81dcc
@ -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 crate::world::Options;
|
||||||
use cargo_metadata::{
|
use cargo_metadata::{
|
||||||
diagnostic::{
|
diagnostic::{
|
||||||
@ -23,6 +26,9 @@ use std::{
|
|||||||
time::Instant,
|
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)]
|
#[derive(Debug)]
|
||||||
pub struct CheckWatcher {
|
pub struct CheckWatcher {
|
||||||
pub task_recv: Receiver<CheckTask>,
|
pub task_recv: Receiver<CheckTask>,
|
||||||
@ -55,6 +61,7 @@ impl CheckWatcher {
|
|||||||
CheckWatcher { task_recv, cmd_send, handle, shared }
|
CheckWatcher { task_recv, cmd_send, handle, shared }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Schedule a re-start of the cargo check worker.
|
||||||
pub fn update(&self) {
|
pub fn update(&self) {
|
||||||
self.cmd_send.send(CheckCommand::Update).unwrap();
|
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<CheckTask>) {
|
pub fn clear(&mut self, task_send: &Sender<CheckTask>) {
|
||||||
let cleared_files: Vec<Url> = self.diagnostic_collection.keys().cloned().collect();
|
let cleared_files: Vec<Url> = self.diagnostic_collection.keys().cloned().collect();
|
||||||
|
|
||||||
@ -139,11 +148,15 @@ impl CheckWatcherSharedState {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum CheckTask {
|
pub enum CheckTask {
|
||||||
|
/// Request a update of the given files diagnostics
|
||||||
Update(Url),
|
Update(Url),
|
||||||
|
|
||||||
|
/// Request check progress notification to client
|
||||||
Status(WorkDoneProgress),
|
Status(WorkDoneProgress),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum CheckCommand {
|
pub enum CheckCommand {
|
||||||
|
/// Request re-start of check thread
|
||||||
Update,
|
Update,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user