Skip to content

Commit 14078ed

Browse files
committed
Rename CargoHandle to CommandHandle
This handle wraps an arbitrary command, which might be a rustc command rather than cargo.
1 parent 54c4125 commit 14078ed

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

crates/flycheck/src/lib.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ struct FlycheckActor {
168168
/// doesn't provide a way to read sub-process output without blocking, so we
169169
/// have to wrap sub-processes output handling in a thread and pass messages
170170
/// back over a channel.
171-
cargo_handle: Option<CargoHandle>,
171+
command_handle: Option<CommandHandle>,
172172
}
173173

174174
enum Event {
@@ -184,15 +184,15 @@ impl FlycheckActor {
184184
workspace_root: AbsPathBuf,
185185
) -> FlycheckActor {
186186
tracing::info!(%id, ?workspace_root, "Spawning flycheck");
187-
FlycheckActor { id, sender, config, root: workspace_root, cargo_handle: None }
187+
FlycheckActor { id, sender, config, root: workspace_root, command_handle: None }
188188
}
189189

190190
fn report_progress(&self, progress: Progress) {
191191
self.send(Message::Progress { id: self.id, progress });
192192
}
193193

194194
fn next_event(&self, inbox: &Receiver<StateChange>) -> Option<Event> {
195-
let check_chan = self.cargo_handle.as_ref().map(|cargo| &cargo.receiver);
195+
let check_chan = self.command_handle.as_ref().map(|cargo| &cargo.receiver);
196196
if let Ok(msg) = inbox.try_recv() {
197197
// give restarts a preference so check outputs don't block a restart or stop
198198
return Some(Event::RequestStateChange(msg));
@@ -222,13 +222,13 @@ impl FlycheckActor {
222222

223223
let command = self.check_command();
224224
tracing::debug!(?command, "will restart flycheck");
225-
match CargoHandle::spawn(command) {
226-
Ok(cargo_handle) => {
225+
match CommandHandle::spawn(command) {
226+
Ok(command_handle) => {
227227
tracing::debug!(
228228
command = ?self.check_command(),
229229
"did restart flycheck"
230230
);
231-
self.cargo_handle = Some(cargo_handle);
231+
self.command_handle = Some(command_handle);
232232
self.report_progress(Progress::DidStart);
233233
}
234234
Err(error) => {
@@ -244,8 +244,8 @@ impl FlycheckActor {
244244
tracing::debug!(flycheck_id = self.id, "flycheck finished");
245245

246246
// Watcher finished
247-
let cargo_handle = self.cargo_handle.take().unwrap();
248-
let res = cargo_handle.join();
247+
let command_handle = self.command_handle.take().unwrap();
248+
let res = command_handle.join();
249249
if res.is_err() {
250250
tracing::error!(
251251
"Flycheck failed to run the following command: {:?}",
@@ -284,12 +284,12 @@ impl FlycheckActor {
284284
}
285285

286286
fn cancel_check_process(&mut self) {
287-
if let Some(cargo_handle) = self.cargo_handle.take() {
287+
if let Some(command_handle) = self.command_handle.take() {
288288
tracing::debug!(
289289
command = ?self.check_command(),
290290
"did cancel flycheck"
291291
);
292-
cargo_handle.cancel();
292+
command_handle.cancel();
293293
self.report_progress(Progress::DidCancel);
294294
}
295295
}
@@ -391,16 +391,16 @@ impl Drop for JodGroupChild {
391391
}
392392

393393
/// A handle to a cargo process used for fly-checking.
394-
struct CargoHandle {
394+
struct CommandHandle {
395395
/// The handle to the actual cargo process. As we cannot cancel directly from with
396396
/// a read syscall dropping and therefore terminating the process is our best option.
397397
child: JodGroupChild,
398398
thread: stdx::thread::JoinHandle<io::Result<(bool, String)>>,
399399
receiver: Receiver<CargoMessage>,
400400
}
401401

402-
impl CargoHandle {
403-
fn spawn(mut command: Command) -> std::io::Result<CargoHandle> {
402+
impl CommandHandle {
403+
fn spawn(mut command: Command) -> std::io::Result<CommandHandle> {
404404
command.stdout(Stdio::piped()).stderr(Stdio::piped()).stdin(Stdio::null());
405405
let mut child = command.group_spawn().map(JodGroupChild)?;
406406

@@ -413,7 +413,7 @@ impl CargoHandle {
413413
.name("CargoHandle".to_owned())
414414
.spawn(move || actor.run())
415415
.expect("failed to spawn thread");
416-
Ok(CargoHandle { child, thread, receiver })
416+
Ok(CommandHandle { child, thread, receiver })
417417
}
418418

419419
fn cancel(mut self) {

0 commit comments

Comments
 (0)