From 5a184fe85517507fd3b07c6fb36b017e558665f7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 25 Jun 2020 08:59:55 +0200 Subject: Unify style --- crates/ra_flycheck/src/lib.rs | 6 +++--- crates/rust-analyzer/src/cli/load_cargo.rs | 2 +- crates/rust-analyzer/src/global_state.rs | 4 ++-- crates/vfs-notify/src/lib.rs | 26 +++++++++++++------------- 4 files changed, 19 insertions(+), 19 deletions(-) (limited to 'crates') diff --git a/crates/ra_flycheck/src/lib.rs b/crates/ra_flycheck/src/lib.rs index 063603b45..af75adbe2 100644 --- a/crates/ra_flycheck/src/lib.rs +++ b/crates/ra_flycheck/src/lib.rs @@ -56,13 +56,13 @@ pub struct FlycheckHandle { impl FlycheckHandle { pub fn spawn( + sender: Box, config: FlycheckConfig, workspace_root: PathBuf, - sender: Box, ) -> FlycheckHandle { let (cmd_send, cmd_recv) = unbounded::(); let handle = jod_thread::spawn(move || { - FlycheckActor::new(config, workspace_root, sender).run(&cmd_recv); + FlycheckActor::new(sender, config, workspace_root).run(&cmd_recv); }); FlycheckHandle { cmd_send, handle } } @@ -114,9 +114,9 @@ struct FlycheckActor { impl FlycheckActor { fn new( + sender: Box, config: FlycheckConfig, workspace_root: PathBuf, - sender: Box, ) -> FlycheckActor { FlycheckActor { sender, diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs index 92e9b60fc..c5cf5ff27 100644 --- a/crates/rust-analyzer/src/cli/load_cargo.rs +++ b/crates/rust-analyzer/src/cli/load_cargo.rs @@ -28,7 +28,7 @@ pub fn load_cargo( let mut vfs = vfs::Vfs::default(); let mut loader = { let loader = - vfs_notify::LoaderHandle::spawn(Box::new(move |msg| sender.send(msg).unwrap())); + vfs_notify::NotifyHandle::spawn(Box::new(move |msg| sender.send(msg).unwrap())); Box::new(loader) }; diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index 42edadd70..c022ff705 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs @@ -37,7 +37,7 @@ fn create_flycheck( let (sender, receiver) = unbounded(); let sender = Box::new(move |msg| sender.send(msg).unwrap()); let cargo_project_root = cargo.workspace_root().to_path_buf(); - let flycheck = FlycheckHandle::spawn(config.clone(), cargo_project_root.into(), sender); + let flycheck = FlycheckHandle::spawn(sender, config.clone(), cargo_project_root.into()); Some((flycheck, receiver)) } ProjectWorkspace::Json { .. } => { @@ -121,7 +121,7 @@ impl GlobalState { }; let mut loader = { - let loader = vfs_notify::LoaderHandle::spawn(Box::new(move |msg| { + let loader = vfs_notify::NotifyHandle::spawn(Box::new(move |msg| { task_sender.send(msg).unwrap() })); Box::new(loader) diff --git a/crates/vfs-notify/src/lib.rs b/crates/vfs-notify/src/lib.rs index a2f4e0c5b..282cf0358 100644 --- a/crates/vfs-notify/src/lib.rs +++ b/crates/vfs-notify/src/lib.rs @@ -20,7 +20,7 @@ use walkdir::WalkDir; use crate::include::Include; #[derive(Debug)] -pub struct LoaderHandle { +pub struct NotifyHandle { // Relative order of fields below is significant. sender: crossbeam_channel::Sender, _thread: jod_thread::JoinHandle, @@ -32,12 +32,12 @@ enum Message { Invalidate(AbsPathBuf), } -impl loader::Handle for LoaderHandle { - fn spawn(sender: loader::Sender) -> LoaderHandle { - let actor = LoaderActor::new(sender); +impl loader::Handle for NotifyHandle { + fn spawn(sender: loader::Sender) -> NotifyHandle { + let actor = NotifyActor::new(sender); let (sender, receiver) = unbounded::(); let thread = jod_thread::spawn(move || actor.run(receiver)); - LoaderHandle { sender, _thread: thread } + NotifyHandle { sender, _thread: thread } } fn set_config(&mut self, config: loader::Config) { self.sender.send(Message::Config(config)).unwrap() @@ -52,10 +52,10 @@ impl loader::Handle for LoaderHandle { type NotifyEvent = notify::Result; -struct LoaderActor { +struct NotifyActor { + sender: loader::Sender, config: Vec<(AbsPathBuf, Include, bool)>, watched_paths: FxHashSet, - sender: loader::Sender, // Drop order of fields bellow is significant, watcher: Option, watcher_receiver: Receiver, @@ -67,19 +67,19 @@ enum Event { NotifyEvent(NotifyEvent), } -impl LoaderActor { - fn new(sender: loader::Sender) -> LoaderActor { +impl NotifyActor { + fn new(sender: loader::Sender) -> NotifyActor { let (watcher_sender, watcher_receiver) = unbounded(); let watcher = log_notify_error(Watcher::new_immediate(move |event| { watcher_sender.send(event).unwrap() })); - LoaderActor { - watcher, - watcher_receiver, - watched_paths: FxHashSet::default(), + NotifyActor { sender, config: Vec::new(), + watched_paths: FxHashSet::default(), + watcher, + watcher_receiver, } } -- cgit v1.2.3