aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_flycheck
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-04-01 10:17:09 +0100
committerGitHub <[email protected]>2020-04-01 10:17:09 +0100
commit8cce752bcb83c86f300c9a8e830dd7d411f6bc48 (patch)
treeeca5f6bd69dc7f7f0df5a3a4ab5ed47f5aa7255e /crates/ra_flycheck
parentfae6cecf5434a865043ec566a6417e9bb28c3a4c (diff)
parentb5306ea70659aad28b1a5de248128b47a5e5f1bf (diff)
Merge #3802
3802: Crisper name r=matklad a=matklad https://www.flycheck.org/en/latest/ bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_flycheck')
-rw-r--r--crates/ra_flycheck/src/lib.rs26
1 files changed, 11 insertions, 15 deletions
diff --git a/crates/ra_flycheck/src/lib.rs b/crates/ra_flycheck/src/lib.rs
index f6f9171ad..75aece45f 100644
--- a/crates/ra_flycheck/src/lib.rs
+++ b/crates/ra_flycheck/src/lib.rs
@@ -24,33 +24,32 @@ pub use crate::conv::url_from_path_with_drive_lowercasing;
24 24
25#[derive(Clone, Debug)] 25#[derive(Clone, Debug)]
26pub struct CheckConfig { 26pub struct CheckConfig {
27 pub enable: bool,
28 pub args: Vec<String>, 27 pub args: Vec<String>,
29 pub command: String, 28 pub command: String,
30 pub all_targets: bool, 29 pub all_targets: bool,
31} 30}
32 31
33/// CheckWatcher wraps the shared state and communication machinery used for 32/// Flycheck wraps the shared state and communication machinery used for
34/// running `cargo check` (or other compatible command) and providing 33/// running `cargo check` (or other compatible command) and providing
35/// diagnostics based on the output. 34/// diagnostics based on the output.
36/// The spawned thread is shut down when this struct is dropped. 35/// The spawned thread is shut down when this struct is dropped.
37#[derive(Debug)] 36#[derive(Debug)]
38pub struct CheckWatcher { 37pub struct Flycheck {
39 // XXX: drop order is significant 38 // XXX: drop order is significant
40 cmd_send: Sender<CheckCommand>, 39 cmd_send: Sender<CheckCommand>,
41 handle: Option<jod_thread::JoinHandle<()>>, 40 handle: jod_thread::JoinHandle<()>,
42 pub task_recv: Receiver<CheckTask>, 41 pub task_recv: Receiver<CheckTask>,
43} 42}
44 43
45impl CheckWatcher { 44impl Flycheck {
46 pub fn new(config: CheckConfig, workspace_root: PathBuf) -> CheckWatcher { 45 pub fn new(config: CheckConfig, workspace_root: PathBuf) -> Flycheck {
47 let (task_send, task_recv) = unbounded::<CheckTask>(); 46 let (task_send, task_recv) = unbounded::<CheckTask>();
48 let (cmd_send, cmd_recv) = unbounded::<CheckCommand>(); 47 let (cmd_send, cmd_recv) = unbounded::<CheckCommand>();
49 let handle = jod_thread::spawn(move || { 48 let handle = jod_thread::spawn(move || {
50 let mut check = CheckWatcherThread::new(config, workspace_root); 49 let mut check = FlycheckThread::new(config, workspace_root);
51 check.run(&task_send, &cmd_recv); 50 check.run(&task_send, &cmd_recv);
52 }); 51 });
53 CheckWatcher { task_recv, cmd_send, handle: Some(handle) } 52 Flycheck { task_recv, cmd_send, handle }
54 } 53 }
55 54
56 /// Schedule a re-start of the cargo check worker. 55 /// Schedule a re-start of the cargo check worker.
@@ -76,7 +75,7 @@ pub enum CheckCommand {
76 Update, 75 Update,
77} 76}
78 77
79struct CheckWatcherThread { 78struct FlycheckThread {
80 options: CheckConfig, 79 options: CheckConfig,
81 workspace_root: PathBuf, 80 workspace_root: PathBuf,
82 last_update_req: Option<Instant>, 81 last_update_req: Option<Instant>,
@@ -90,9 +89,9 @@ struct CheckWatcherThread {
90 check_process: Option<jod_thread::JoinHandle<()>>, 89 check_process: Option<jod_thread::JoinHandle<()>>,
91} 90}
92 91
93impl CheckWatcherThread { 92impl FlycheckThread {
94 fn new(options: CheckConfig, workspace_root: PathBuf) -> CheckWatcherThread { 93 fn new(options: CheckConfig, workspace_root: PathBuf) -> FlycheckThread {
95 CheckWatcherThread { 94 FlycheckThread {
96 options, 95 options,
97 workspace_root, 96 workspace_root,
98 last_update_req: None, 97 last_update_req: None,
@@ -216,9 +215,6 @@ impl CheckWatcherThread {
216 // First, clear and cancel the old thread 215 // First, clear and cancel the old thread
217 self.message_recv = never(); 216 self.message_recv = never();
218 self.check_process = None; 217 self.check_process = None;
219 if !self.options.enable {
220 return;
221 }
222 218
223 let mut args: Vec<String> = vec![ 219 let mut args: Vec<String> = vec![
224 self.options.command.clone(), 220 self.options.command.clone(),