aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-04-01 10:09:19 +0100
committerAleksey Kladov <[email protected]>2020-04-01 10:09:19 +0100
commit3990d971e54b69949f26bbbc530fa22fdc2fcd7f (patch)
tree1d21fbf34ed991509197668dcbf58f53e51d07a6
parentdda942debe0ea178f07b75989b2ba6942786e218 (diff)
Crisper name
https://www.flycheck.org/en/latest/
-rw-r--r--crates/ra_flycheck/src/lib.rs20
-rw-r--r--crates/rust-analyzer/src/main_loop.rs10
-rw-r--r--crates/rust-analyzer/src/world.rs14
3 files changed, 22 insertions, 22 deletions
diff --git a/crates/ra_flycheck/src/lib.rs b/crates/ra_flycheck/src/lib.rs
index b6bb9da4b..2990c1f95 100644
--- a/crates/ra_flycheck/src/lib.rs
+++ b/crates/ra_flycheck/src/lib.rs
@@ -29,27 +29,27 @@ pub struct CheckConfig {
29 pub all_targets: bool, 29 pub all_targets: bool,
30} 30}
31 31
32/// CheckWatcher wraps the shared state and communication machinery used for 32/// Flycheck wraps the shared state and communication machinery used for
33/// running `cargo check` (or other compatible command) and providing 33/// running `cargo check` (or other compatible command) and providing
34/// diagnostics based on the output. 34/// diagnostics based on the output.
35/// The spawned thread is shut down when this struct is dropped. 35/// The spawned thread is shut down when this struct is dropped.
36#[derive(Debug)] 36#[derive(Debug)]
37pub struct CheckWatcher { 37pub struct Flycheck {
38 // XXX: drop order is significant 38 // XXX: drop order is significant
39 cmd_send: Sender<CheckCommand>, 39 cmd_send: Sender<CheckCommand>,
40 handle: Option<jod_thread::JoinHandle<()>>, 40 handle: Option<jod_thread::JoinHandle<()>>,
41 pub task_recv: Receiver<CheckTask>, 41 pub task_recv: Receiver<CheckTask>,
42} 42}
43 43
44impl CheckWatcher { 44impl Flycheck {
45 pub fn new(config: CheckConfig, workspace_root: PathBuf) -> CheckWatcher { 45 pub fn new(config: CheckConfig, workspace_root: PathBuf) -> Flycheck {
46 let (task_send, task_recv) = unbounded::<CheckTask>(); 46 let (task_send, task_recv) = unbounded::<CheckTask>();
47 let (cmd_send, cmd_recv) = unbounded::<CheckCommand>(); 47 let (cmd_send, cmd_recv) = unbounded::<CheckCommand>();
48 let handle = jod_thread::spawn(move || { 48 let handle = jod_thread::spawn(move || {
49 let mut check = CheckWatcherThread::new(config, workspace_root); 49 let mut check = FlycheckThread::new(config, workspace_root);
50 check.run(&task_send, &cmd_recv); 50 check.run(&task_send, &cmd_recv);
51 }); 51 });
52 CheckWatcher { task_recv, cmd_send, handle: Some(handle) } 52 Flycheck { task_recv, cmd_send, handle: Some(handle) }
53 } 53 }
54 54
55 /// Schedule a re-start of the cargo check worker. 55 /// Schedule a re-start of the cargo check worker.
@@ -75,7 +75,7 @@ pub enum CheckCommand {
75 Update, 75 Update,
76} 76}
77 77
78struct CheckWatcherThread { 78struct FlycheckThread {
79 options: CheckConfig, 79 options: CheckConfig,
80 workspace_root: PathBuf, 80 workspace_root: PathBuf,
81 last_update_req: Option<Instant>, 81 last_update_req: Option<Instant>,
@@ -89,9 +89,9 @@ struct CheckWatcherThread {
89 check_process: Option<jod_thread::JoinHandle<()>>, 89 check_process: Option<jod_thread::JoinHandle<()>>,
90} 90}
91 91
92impl CheckWatcherThread { 92impl FlycheckThread {
93 fn new(options: CheckConfig, workspace_root: PathBuf) -> CheckWatcherThread { 93 fn new(options: CheckConfig, workspace_root: PathBuf) -> FlycheckThread {
94 CheckWatcherThread { 94 FlycheckThread {
95 options, 95 options,
96 workspace_root, 96 workspace_root,
97 last_update_req: None, 97 last_update_req: None,
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 16d7f1569..79dc03de4 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -243,7 +243,7 @@ pub fn main_loop(
243 Err(RecvError) => return Err("vfs died".into()), 243 Err(RecvError) => return Err("vfs died".into()),
244 }, 244 },
245 recv(libdata_receiver) -> data => Event::Lib(data.unwrap()), 245 recv(libdata_receiver) -> data => Event::Lib(data.unwrap()),
246 recv(world_state.check_watcher.as_ref().map_or(&never(), |it| &it.task_recv)) -> task => match task { 246 recv(world_state.flycheck.as_ref().map_or(&never(), |it| &it.task_recv)) -> task => match task {
247 Ok(task) => Event::CheckWatcher(task), 247 Ok(task) => Event::CheckWatcher(task),
248 Err(RecvError) => return Err("check watcher died".into()), 248 Err(RecvError) => return Err("check watcher died".into()),
249 } 249 }
@@ -484,8 +484,8 @@ fn loop_turn(
484 && loop_state.in_flight_libraries == 0 484 && loop_state.in_flight_libraries == 0
485 { 485 {
486 loop_state.workspace_loaded = true; 486 loop_state.workspace_loaded = true;
487 if let Some(check_watcher) = &world_state.check_watcher { 487 if let Some(flycheck) = &world_state.flycheck {
488 check_watcher.update(); 488 flycheck.update();
489 } 489 }
490 pool.execute({ 490 pool.execute({
491 let subs = loop_state.subscriptions.subscriptions(); 491 let subs = loop_state.subscriptions.subscriptions();
@@ -657,8 +657,8 @@ fn on_notification(
657 }; 657 };
658 let not = match notification_cast::<req::DidSaveTextDocument>(not) { 658 let not = match notification_cast::<req::DidSaveTextDocument>(not) {
659 Ok(_params) => { 659 Ok(_params) => {
660 if let Some(check_watcher) = &state.check_watcher { 660 if let Some(flycheck) = &state.flycheck {
661 check_watcher.update(); 661 flycheck.update();
662 } 662 }
663 return Ok(()); 663 return Ok(());
664 } 664 }
diff --git a/crates/rust-analyzer/src/world.rs b/crates/rust-analyzer/src/world.rs
index 9a4e353fb..7814a682e 100644
--- a/crates/rust-analyzer/src/world.rs
+++ b/crates/rust-analyzer/src/world.rs
@@ -11,7 +11,7 @@ use std::{
11use crossbeam_channel::{unbounded, Receiver}; 11use crossbeam_channel::{unbounded, Receiver};
12use lsp_types::Url; 12use lsp_types::Url;
13use parking_lot::RwLock; 13use parking_lot::RwLock;
14use ra_flycheck::{url_from_path_with_drive_lowercasing, CheckConfig, CheckWatcher}; 14use ra_flycheck::{url_from_path_with_drive_lowercasing, CheckConfig, Flycheck};
15use ra_ide::{ 15use ra_ide::{
16 Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, InlayHintsConfig, LibraryData, 16 Analysis, AnalysisChange, AnalysisHost, CrateGraph, FileId, InlayHintsConfig, LibraryData,
17 SourceRootId, 17 SourceRootId,
@@ -31,7 +31,7 @@ use crate::{
31use ra_db::ExternSourceId; 31use ra_db::ExternSourceId;
32use rustc_hash::{FxHashMap, FxHashSet}; 32use rustc_hash::{FxHashMap, FxHashSet};
33 33
34fn create_watcher(workspaces: &[ProjectWorkspace], config: &Config) -> Option<CheckWatcher> { 34fn create_flycheck(workspaces: &[ProjectWorkspace], config: &Config) -> Option<Flycheck> {
35 let check_config = config.check.as_ref()?; 35 let check_config = config.check.as_ref()?;
36 36
37 // FIXME: Figure out the multi-workspace situation 37 // FIXME: Figure out the multi-workspace situation
@@ -43,7 +43,7 @@ fn create_watcher(workspaces: &[ProjectWorkspace], config: &Config) -> Option<Ch
43 }) 43 })
44 .map(|cargo| { 44 .map(|cargo| {
45 let cargo_project_root = cargo.workspace_root().to_path_buf(); 45 let cargo_project_root = cargo.workspace_root().to_path_buf();
46 Some(CheckWatcher::new(check_config.clone(), cargo_project_root)) 46 Some(Flycheck::new(check_config.clone(), cargo_project_root))
47 }) 47 })
48 .unwrap_or_else(|| { 48 .unwrap_or_else(|| {
49 log::warn!("Cargo check watching only supported for cargo workspaces, disabling"); 49 log::warn!("Cargo check watching only supported for cargo workspaces, disabling");
@@ -78,7 +78,7 @@ pub struct WorldState {
78 pub vfs: Arc<RwLock<Vfs>>, 78 pub vfs: Arc<RwLock<Vfs>>,
79 pub task_receiver: Receiver<VfsTask>, 79 pub task_receiver: Receiver<VfsTask>,
80 pub latest_requests: Arc<RwLock<LatestRequests>>, 80 pub latest_requests: Arc<RwLock<LatestRequests>>,
81 pub check_watcher: Option<CheckWatcher>, 81 pub flycheck: Option<Flycheck>,
82 pub diagnostics: DiagnosticCollection, 82 pub diagnostics: DiagnosticCollection,
83} 83}
84 84
@@ -203,7 +203,7 @@ impl WorldState {
203 }); 203 });
204 change.set_crate_graph(crate_graph); 204 change.set_crate_graph(crate_graph);
205 205
206 let check_watcher = create_watcher(&workspaces, &config); 206 let flycheck = create_flycheck(&workspaces, &config);
207 207
208 let mut analysis_host = AnalysisHost::new(lru_capacity); 208 let mut analysis_host = AnalysisHost::new(lru_capacity);
209 analysis_host.apply_change(change); 209 analysis_host.apply_change(change);
@@ -216,7 +216,7 @@ impl WorldState {
216 vfs: Arc::new(RwLock::new(vfs)), 216 vfs: Arc::new(RwLock::new(vfs)),
217 task_receiver, 217 task_receiver,
218 latest_requests: Default::default(), 218 latest_requests: Default::default(),
219 check_watcher, 219 flycheck,
220 diagnostics: Default::default(), 220 diagnostics: Default::default(),
221 } 221 }
222 } 222 }
@@ -229,7 +229,7 @@ impl WorldState {
229 ) { 229 ) {
230 self.feature_flags = Arc::new(feature_flags); 230 self.feature_flags = Arc::new(feature_flags);
231 self.analysis_host.update_lru_capacity(lru_capacity); 231 self.analysis_host.update_lru_capacity(lru_capacity);
232 self.check_watcher = create_watcher(&self.workspaces, &config); 232 self.flycheck = create_flycheck(&self.workspaces, &config);
233 self.config = config; 233 self.config = config;
234 } 234 }
235 235