From 4b069b51e7f165c46b95e76934cff4285b7262b8 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 1 May 2026 14:27:36 +0800 Subject: [PATCH] Remove "get_" prefix from some getters In C++ we can't have a field and method sharing a name, but in Rust we can. For some structs, most getters don't have a "get_", so it's weird that some do. Remove the "get_" prefix where it's obvious enough. While at it, give some related getters better names. --- src/autoload.rs | 2 +- src/bin/fish.rs | 2 +- src/builtins/breakpoint.rs | 2 +- src/builtins/disown.rs | 4 ++-- src/builtins/function.rs | 6 +++--- src/builtins/jobs.rs | 2 +- src/builtins/return.rs | 2 +- src/builtins/source.rs | 2 +- src/builtins/status.rs | 2 +- src/builtins/wait.rs | 2 +- src/complete.rs | 12 ++++++------ src/env/environment.rs | 8 ++++---- src/env/environment_impl.rs | 2 +- src/env/var.rs | 6 +++--- src/env_universal_common.rs | 9 ++------- src/event.rs | 2 +- src/exec.rs | 10 +++++----- src/expand.rs | 2 +- src/function.rs | 2 +- src/input.rs | 2 +- src/input_common.rs | 4 ++-- src/job_group.rs | 2 +- src/parse_execution.rs | 20 ++++++++++---------- src/parser.rs | 26 +++++++++++++------------- src/proc.rs | 36 ++++++++++++++++++------------------ src/reader/reader.rs | 4 ++-- src/tty_handoff.rs | 2 +- 27 files changed, 85 insertions(+), 90 deletions(-) diff --git a/src/autoload.rs b/src/autoload.rs index 30714fe6f..8c214d526 100644 --- a/src/autoload.rs +++ b/src/autoload.rs @@ -126,7 +126,7 @@ pub fn perform_autoload(path: &AutoloadPath, parser: &Parser) { // We do the useful part of what exec_subshell does ourselves // - we source the file. // We don't create a buffer or check ifs or create a read_limit - let prev_statuses = parser.get_last_statuses(); + let prev_statuses = parser.last_statuses(); let _put_back = ScopeGuard::new((), |()| parser.set_last_statuses(prev_statuses)); match path { AutoloadPath::OnDisk(p) => { diff --git a/src/bin/fish.rs b/src/bin/fish.rs index 54e83ea0a..98ab48151 100644 --- a/src/bin/fish.rs +++ b/src/bin/fish.rs @@ -605,7 +605,7 @@ fn throwing_main() -> i32 { let exit_status = if res.is_err() { STATUS_CMD_UNKNOWN } else { - parser.get_last_status() + parser.last_status() }; event::fire( diff --git a/src/builtins/breakpoint.rs b/src/builtins/breakpoint.rs index 01f0fbded..4bd0bd14c 100644 --- a/src/builtins/breakpoint.rs +++ b/src/builtins/breakpoint.rs @@ -38,5 +38,5 @@ pub fn breakpoint(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) let io_chain = &streams.io_chain; reader_read(parser, STDIN_FILENO, io_chain)?; parser.pop_block(bpb); - BuiltinResult::from_dynamic(parser.get_last_status()) + BuiltinResult::from_dynamic(parser.last_status()) } diff --git a/src/builtins/disown.rs b/src/builtins/disown.rs index 608cfdc85..32b21e907 100644 --- a/src/builtins/disown.rs +++ b/src/builtins/disown.rs @@ -18,7 +18,7 @@ fn disown_job(cmd: &wstr, streams: &mut IoStreams, j: &Job) { } // Stopped disowned jobs must be manually signaled; explain how to do so. - let pgid = j.get_pgid(); + let pgid = j.pgid(); if j.is_stopped() { if let Some(pgid) = pgid { let _ = killpg(pgid.as_nix_pid(), Some(Signal::SIGCONT)); @@ -35,7 +35,7 @@ fn disown_job(cmd: &wstr, streams: &mut IoStreams, j: &Job) { // We cannot directly remove the job from the jobs() list as `disown` might be called // within the context of a subjob which will cause the parent job to crash in exec_job(). // Instead, we set a flag and the parser removes the job from the jobs list later. - j.mut_flags().disown_requested = true; + j.flags_mut().disown_requested = true; add_disowned_job(j); } diff --git a/src/builtins/function.rs b/src/builtins/function.rs index 3f66a28f7..62f27a4be 100644 --- a/src/builtins/function.rs +++ b/src/builtins/function.rs @@ -64,7 +64,7 @@ fn job_id_for_pid(pid: Pid, parser: &Parser) -> Option { Some(job.internal_job_id) } else { parser - .get_wait_handles() + .wait_handles() .get_by_pid(pid) .map(|h| h.internal_job_id) } @@ -366,13 +366,13 @@ pub fn function( for ed in &opts.events { match *ed { EventDescription::ProcessExit { pid: Some(pid) } => { - let wh = parser.get_wait_handles().get_by_pid(pid); + let wh = parser.wait_handles().get_by_pid(pid); if let Some(status) = wh.and_then(|wh| wh.status()) { event::fire(parser, event::Event::process_exit(pid, status)); } } EventDescription::JobExit { pid: Some(pid), .. } => { - let wh = parser.get_wait_handles().get_by_pid(pid); + let wh = parser.wait_handles().get_by_pid(pid); if let Some(wh) = wh { if wh.is_completed() { event::fire(parser, event::Event::job_exit(pid, wh.internal_job_id)); diff --git a/src/builtins/jobs.rs b/src/builtins/jobs.rs index c7d705ec0..ffe346400 100644 --- a/src/builtins/jobs.rs +++ b/src/builtins/jobs.rs @@ -44,7 +44,7 @@ fn cpu_use(j: &Job) -> f64 { /// Print information about the specified job. fn builtin_jobs_print(j: &Job, mode: JobsPrintMode, header: bool, streams: &mut IoStreams) { - let pgid = match j.get_pgid() { + let pgid = match j.pgid() { Some(pgid) => pgid.to_string(), None => "-".to_owned(), }; diff --git a/src/builtins/return.rs b/src/builtins/return.rs index ab22b07a2..6e127af51 100644 --- a/src/builtins/return.rs +++ b/src/builtins/return.rs @@ -106,7 +106,7 @@ pub fn parse_return_value( return ControlFlow::Break(Err(STATUS_INVALID_ARGS)); } if optind == args.len() { - ControlFlow::Continue(parser.get_last_status()) + ControlFlow::Continue(parser.last_status()) } else { match fish_wcstoi(args[optind]) { Ok(i) => ControlFlow::Continue(i), diff --git a/src/builtins/source.rs b/src/builtins/source.rs index 23428997b..a887dd64f 100644 --- a/src/builtins/source.rs +++ b/src/builtins/source.rs @@ -87,7 +87,7 @@ pub fn source(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B parser.pop_block(sb); match retval { - Ok(_) => BuiltinResult::from_dynamic(parser.get_last_status()), + Ok(_) => BuiltinResult::from_dynamic(parser.last_status()), Err(err) => { let esc = escape(&func_filename); err_fmt!( diff --git a/src/builtins/status.rs b/src/builtins/status.rs index 7d3a8ed85..b626dd6e1 100644 --- a/src/builtins/status.rs +++ b/src/builtins/status.rs @@ -626,7 +626,7 @@ pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B // streams.out.append_format(L"%d\n", parser.get_lineno(opts.level)); streams .out - .appendln(&parser.get_lineno_for_display().to_wstring()); + .appendln(&parser.lineno_for_display().to_wstring()); } STATUS_IS_INTERACTIVE => { if is_interactive_session() { diff --git a/src/builtins/wait.rs b/src/builtins/wait.rs index 02c47710f..ee763de6b 100644 --- a/src/builtins/wait.rs +++ b/src/builtins/wait.rs @@ -78,7 +78,7 @@ fn find_wait_handles( fn get_all_wait_handles(parser: &Parser) -> Vec { // Get wait handles for reaped jobs. - let mut result = parser.get_wait_handles().get_list(); + let mut result = parser.wait_handles().get_list(); // Get wait handles for running jobs. for j in &*parser.jobs() { diff --git a/src/complete.rs b/src/complete.rs index 8a315c729..d8c26e322 100644 --- a/src/complete.rs +++ b/src/complete.rs @@ -316,12 +316,12 @@ pub fn size(&self) -> usize { } /// Returns the list of completions. - pub fn get_list(&self) -> &[Completion] { + pub fn as_list(&self) -> &[Completion] { &self.completions } /// Returns the list of completions. - pub fn get_list_mut(&mut self) -> &mut [Completion] { + pub fn as_list_mut(&mut self) -> &mut [Completion] { &mut self.completions } @@ -976,7 +976,7 @@ fn complete_cmd_desc(&mut self, s: &wstr) { } let keep_going = - self.completions.get_list().iter().any(|c| { + self.completions.as_list().iter().any(|c| { c.completion.is_empty() || c.completion.as_char_slice().last() != Some(&'/') }); if !keep_going { @@ -1058,7 +1058,7 @@ fn complete_cmd_desc(&mut self, s: &wstr) { // Then do a lookup on every completion and if a match is found, change to the new // description. - for completion in self.completions.get_list_mut() { + for completion in self.completions.as_list_mut() { let el = &completion.completion; if let Some(&desc) = lookup.get(el.as_utfstr()) { completion.description = desc.to_owned(); @@ -1187,7 +1187,7 @@ fn complete_from_args(&mut self, s: &wstr, args: &wstr, desc: &wstr, flags: Comp let mut saved_statuses = None; let mut scope = None; if let Some(parser) = self.ctx.maybe_parser() { - saved_statuses = Some(parser.get_last_statuses()); + saved_statuses = Some(parser.last_statuses()); scope = Some(parser.push_scope(|s| s.is_interactive = false)); } @@ -2113,7 +2113,7 @@ fn mark_completions_duplicating_arguments( arg_strs.sort(); let mut comp_str; - for comp in self.completions.get_list_mut() { + for comp in self.completions.as_list_mut() { comp_str = comp.completion.clone(); if !comp.replaces_token() { comp_str.insert_utfstr(0, prefix); diff --git a/src/env/environment.rs b/src/env/environment.rs index 282ea6ebb..ce70b9b44 100644 --- a/src/env/environment.rs +++ b/src/env/environment.rs @@ -207,12 +207,12 @@ fn lock(&self) -> EnvMutexGuard<'_, EnvStackImpl> { /// Helpers to get and set the proc statuses. /// These correspond to $status and $pipestatus. - pub fn get_last_statuses(&self) -> Statuses { - self.lock().base.get_last_statuses().clone() + pub fn last_statuses(&self) -> Statuses { + self.lock().base.last_statuses().clone() } - pub fn get_last_status(&self) -> c_int { - self.lock().base.get_last_statuses().status + pub fn last_status(&self) -> c_int { + self.lock().base.last_statuses().status } pub fn set_last_statuses(&self, statuses: Statuses) { diff --git a/src/env/environment_impl.rs b/src/env/environment_impl.rs index c51ed3377..ef9abdbd7 100644 --- a/src/env/environment_impl.rs +++ b/src/env/environment_impl.rs @@ -343,7 +343,7 @@ fn new(locals: EnvNodeRef, globals: EnvNodeRef) -> Self { } } - pub fn get_last_statuses(&self) -> &Statuses { + pub fn last_statuses(&self) -> &Statuses { &self.perproc_data.statuses } diff --git a/src/env/var.rs b/src/env/var.rs index 0dc270a17..7cad6b3c8 100644 --- a/src/env/var.rs +++ b/src/env/var.rs @@ -186,13 +186,13 @@ pub fn is_read_only(&self) -> bool { } /// Returns the variable's flags. - pub fn get_flags(&self) -> EnvVarFlags { + pub fn flags(&self) -> EnvVarFlags { self.flags } /// Returns the variable's value as a string. pub fn as_string(&self) -> WString { - join_strings(&self.values, self.get_delimiter()) + join_strings(&self.values, self.delimiter()) } /// Returns the variable's values. @@ -201,7 +201,7 @@ pub fn as_list(&self) -> &[WString] { } /// Returns the delimiter character used when converting from a list to a string. - pub fn get_delimiter(&self) -> char { + pub fn delimiter(&self) -> char { if self.is_pathvar() { PATH_ARRAY_SEP } else { diff --git a/src/env_universal_common.rs b/src/env_universal_common.rs index 8efb6f330..16b5946a5 100644 --- a/src/env_universal_common.rs +++ b/src/env_universal_common.rs @@ -88,7 +88,7 @@ pub fn get(&self, name: &wstr) -> Option { } // Return flags from the variable with the given name. pub fn get_flags(&self, name: &wstr) -> Option { - self.vars.get(name).map(|var| var.get_flags()) + self.vars.get(name).map(|var| var.flags()) } // Sets a variable. pub fn set(&mut self, key: &wstr, var: EnvVar) { @@ -323,12 +323,7 @@ fn serialize_with_vars(vars: &VarTable) -> Vec { .for_each(|(k, v)| { // Append the entry. Note that append_file_entry may fail, // but that only affects one variable; soldier on. - append_file_entry( - v.get_flags(), - k, - &encode_serialized(v.as_list()), - &mut contents, - ); + append_file_entry(v.flags(), k, &encode_serialized(v.as_list()), &mut contents); }); contents diff --git a/src/event.rs b/src/event.rs index 5324a4cf7..380fbf530 100644 --- a/src/event.rs +++ b/src/event.rs @@ -498,7 +498,7 @@ fn fire_internal(parser: &Parser, event: &Event) { // Event handlers are not part of the main flow of code, so they are marked as // non-interactive. let _non_interactive = parser.push_scope(|s| s.is_interactive = false); - let saved_statuses = parser.get_last_statuses(); + let saved_statuses = parser.last_statuses(); let _cleanup = ScopeGuard::new((), |()| { parser.set_last_statuses(saved_statuses); }); diff --git a/src/exec.rs b/src/exec.rs index c32fe4f5d..fc9b870f9 100644 --- a/src/exec.rs +++ b/src/exec.rs @@ -238,7 +238,7 @@ pub fn exec_job(parser: &Parser, job: &Job, block_io: IoChain) -> bool { // If exec_error then a backgrounded job would have been terminated before it was ever assigned // a pgroup, so error out before setting last_pid. if !job.is_foreground() { - if let Some(last_pid) = job.get_last_pid() { + if let Some(last_pid) = job.last_pid() { parser.set_one( L!("last_pid"), ParserEnvSetMode::new(EnvMode::GLOBAL), @@ -669,14 +669,14 @@ fn run_internal_process_or_short_circuit( j.preview(), p.status().status_value() ); - if let Some(statuses) = j.get_statuses() { + if let Some(statuses) = j.statuses() { parser.set_last_statuses(statuses); parser.libdata_mut().status_count += 1; } else if j.flags().negate { // Special handling for `not set var (substitution)`. // If there is no status, but negation was requested, // take the last status and negate it. - let mut last_statuses = parser.get_last_statuses(); + let mut last_statuses = parser.last_statuses(); last_statuses.status = if last_statuses.status == 0 { 1 } else { 0 }; parser.set_last_statuses(last_statuses); } @@ -884,7 +884,7 @@ fn exec_external_command( // or we become the leader. let pgroup_policy = if p.leads_pgrp { PgroupPolicy::Lead - } else if let Some(pgid) = j.group().get_pgid() { + } else if let Some(pgid) = j.group().pgid() { PgroupPolicy::Join(pgid.as_pid_t()) } else { PgroupPolicy::Inherit @@ -1508,7 +1508,7 @@ fn exec_subshell_internal( }; }); - let prev_statuses = parser.get_last_statuses(); + let prev_statuses = parser.last_statuses(); let _put_back = ScopeGuard::new((), |()| { if !apply_exit_status { parser.set_last_statuses(prev_statuses); diff --git a/src/expand.rs b/src/expand.rs index 6d1665e88..c117a4f25 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -723,7 +723,7 @@ fn expand_variables( let delimit = if history.is_some() { ' ' } else { - var.as_ref().unwrap().get_delimiter() + var.as_ref().unwrap().delimiter() }; let mut res = instr[..varexp_char_idx].to_owned(); if !res.is_empty() { diff --git a/src/function.rs b/src/function.rs index 137698eea..064ca84ec 100644 --- a/src/function.rs +++ b/src/function.rs @@ -307,7 +307,7 @@ pub(crate) fn set_desc(name: &wstr, desc: WString, parser: &Parser) { /// is successful. pub fn copy(name: &wstr, new_name: WString, parser: &Parser) -> bool { let filename = parser.current_filename(); - let lineno = parser.get_lineno(); + let lineno = parser.lineno(); let mut funcset = FUNCTION_SET.lock().unwrap(); let Some(props) = funcset.get_props(name) else { diff --git a/src/input.rs b/src/input.rs index 9759ff5a2..4664d9785 100644 --- a/src/input.rs +++ b/src/input.rs @@ -753,7 +753,7 @@ pub fn read_char(&mut self) -> CharEvent { } ReadlineCmd::FuncAnd | ReadlineCmd::FuncOr => { // If previous function has bad status, skip all functions that follow us. - let fs = self.get_function_status(); + let fs = self.function_status(); if (!fs && readline_event.cmd == ReadlineCmd::FuncAnd) || (fs && readline_event.cmd == ReadlineCmd::FuncOr) { diff --git a/src/input_common.rs b/src/input_common.rs index 169836042..1f304676b 100644 --- a/src/input_common.rs +++ b/src/input_common.rs @@ -1642,8 +1642,8 @@ fn uvar_change_notified(&mut self) {} /// The default does nothing. fn ioport_notified(&mut self) {} - /// Reset the function status. - fn get_function_status(&self) -> bool { + /// Get the function status. + fn function_status(&self) -> bool { self.get_input_data().function_status } diff --git a/src/job_group.rs b/src/job_group.rs index 45aa79a57..ecd8715ce 100644 --- a/src/job_group.rs +++ b/src/job_group.rs @@ -153,7 +153,7 @@ pub fn set_pgid(&self, pgid: Pid) { } /// Returns the value of [`JobGroup::pgid`]. This is never fish's own pgid! - pub fn get_pgid(&self) -> Option { + pub fn pgid(&self) -> Option { self.pgid.get().copied() } } diff --git a/src/parse_execution.rs b/src/parse_execution.rs index 9e6e96239..1b4096e11 100644 --- a/src/parse_execution.rs +++ b/src/parse_execution.rs @@ -351,7 +351,7 @@ fn handle_command_not_found( buffer.push_utfstr(&escape(arg)); } let parser = ctx.parser(); - let prev_statuses = parser.get_last_statuses(); + let prev_statuses = parser.last_statuses(); let event = Event::generic(L!("fish_command_not_found").to_owned()); let b = parser.push_block(Block::event_block(event)); @@ -702,7 +702,7 @@ fn populate_not_process( not_statement: &ast::NotStatement, ) -> EndExecutionReason { { - let mut flags = job.mut_flags(); + let mut flags = job.flags_mut(); flags.negate = !flags.negate; } self.populate_job_process( @@ -1023,8 +1023,8 @@ fn run_if_statement( if cond_ret == EndExecutionReason::Ok { cond_ret = self.run_andor_job_list(ctx, &if_clause.andor_tail, associated_block); } - let take_branch = cond_ret == EndExecutionReason::Ok - && ctx.parser().get_last_status() == EXIT_SUCCESS; + let take_branch = + cond_ret == EndExecutionReason::Ok && ctx.parser().last_status() == EXIT_SUCCESS; if take_branch { // Condition succeeded. @@ -1218,7 +1218,7 @@ fn run_while_statement( let cond_saved_status = if first_cond_check { Statuses::just(EXIT_SUCCESS) } else { - ctx.parser().get_last_statuses() + ctx.parser().last_statuses() }; first_cond_check = false; @@ -1233,7 +1233,7 @@ fn run_while_statement( // exit the loop. if cond_ret != EndExecutionReason::Ok { break; - } else if ctx.parser().get_last_status() != EXIT_SUCCESS { + } else if ctx.parser().last_status() != EXIT_SUCCESS { ctx.parser().set_last_statuses(cond_saved_status); break; } @@ -1666,7 +1666,7 @@ fn run_1_job( if !exec_job(parser, &job, self.block_io.clone()) { // No process in the job successfully launched. // Ensure statuses are set (#7540). - if let Some(statuses) = job.get_statuses() { + if let Some(statuses) = job.statuses() { parser.set_last_statuses(statuses); parser.libdata_mut().status_count += 1; } @@ -1712,7 +1712,7 @@ fn test_and_run_1_job_conjunction( // Maybe skip the job if it has a leading and/or. let mut skip = false; if let Some(deco) = &jc.decorator { - let last_status = ctx.parser().get_last_status(); + let last_status = ctx.parser().last_status(); match deco.keyword() { ParseKeyword::And => { // AND. Skip if the last job failed. @@ -1748,7 +1748,7 @@ fn run_job_conjunction( return reason; } // Check the conjunction type. - let last_status = ctx.parser().get_last_status(); + let last_status = ctx.parser().last_status(); let skip = match jc.conjunction.token_type() { ParseTokenType::AndAnd => { // AND. Skip if the last job failed. @@ -1895,7 +1895,7 @@ fn setup_group(&self, ctx: &OperationContext<'_>, j: &mut Job) { )); } j.group().is_foreground.store(!j.is_initially_background()); - j.mut_flags().is_group_root = true; + j.flags_mut().is_group_root = true; } // Return whether we should apply job control to our processes. diff --git a/src/parser.rs b/src/parser.rs index 1d97119d6..def53207c 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -560,7 +560,7 @@ pub fn eval_parsed_source( test_only_suppress_stderr, ) } else { - let status = ProcStatus::from_exit_code(self.get_last_status()); + let status = ProcStatus::from_exit_code(self.last_status()); EvalRes { status, break_expand: false, @@ -703,7 +703,7 @@ pub fn eval_node( if sig != 0 { EvalRes::new(ProcStatus::from_signal(Signal::new(sig))) } else { - let status = ProcStatus::from_exit_code(self.get_last_status()); + let status = ProcStatus::from_exit_code(self.last_status()); let break_expand = reason == EndExecutionReason::Error; EvalRes { status, @@ -755,7 +755,7 @@ pub fn current_line(&self) -> WString { return WString::new(); }; - let lineno = self.get_lineno_for_display(); + let lineno = self.lineno_for_display(); let file = self.current_filename(); let mut prefix = WString::new(); @@ -798,13 +798,13 @@ pub fn current_line(&self) -> WString { } /// Returns the current line number, indexed from 1. - pub fn get_lineno(&self) -> Option { + pub fn lineno(&self) -> Option { self.current_node.borrow().as_ref().and_then(|n| n.lineno()) } /// Returns the current line number, indexed from 1, or zero if not sourced. - pub fn get_lineno_for_display(&self) -> u32 { - self.get_lineno().map_or(0, |n| n.get()) + pub fn lineno_for_display(&self) -> u32 { + self.lineno().map_or(0, |n| n.get()) } pub fn current_node(&self) -> &ScopedRefCell>> { @@ -922,7 +922,7 @@ pub fn libdata_mut(&self) -> RefMut<'_, LibraryData> { } /// Get our wait handle store. - pub fn get_wait_handles(&self) -> Ref<'_, WaitHandleStore> { + pub fn wait_handles(&self) -> Ref<'_, WaitHandleStore> { self.wait_handles.borrow() } pub fn mut_wait_handles(&self) -> RefMut<'_, WaitHandleStore> { @@ -930,11 +930,11 @@ pub fn mut_wait_handles(&self) -> RefMut<'_, WaitHandleStore> { } /// Get and set the last proc statuses. - pub fn get_last_status(&self) -> c_int { - self.vars().get_last_status() + pub fn last_status(&self) -> c_int { + self.vars().last_status() } - pub fn get_last_statuses(&self) -> Statuses { - self.vars().get_last_statuses() + pub fn last_statuses(&self) -> Statuses { + self.vars().last_statuses() } pub fn set_last_statuses(&self, s: Statuses) { self.vars().set_last_statuses(s); @@ -2139,8 +2139,8 @@ fn test_eval_illegal_exit_code() { macro_rules! validate { ($cmd:expr, $result:expr) => { parser.eval($cmd, &IoChain::new()); - let exit_status = parser.get_last_status(); - assert_eq!(exit_status, parser.get_last_status()); + let exit_status = parser.last_status(); + assert_eq!(exit_status, parser.last_status()); }; } diff --git a/src/proc.rs b/src/proc.rs index 2ec99bc66..e85325223 100644 --- a/src/proc.rs +++ b/src/proc.rs @@ -541,7 +541,7 @@ pub fn is_exec(&self) -> bool { } /// Return the wait handle for the process, if it exists. - pub fn get_wait_handle(&self) -> Option { + pub fn wait_handle(&self) -> Option { self.wait_handle.borrow().clone() } @@ -565,7 +565,7 @@ pub fn make_wait_handle(&self, jid: InternalJobId) -> Option { wbasename(&self.actual_cmd.clone()).to_owned(), ))); } - self.get_wait_handle() + self.wait_handle() } } @@ -682,7 +682,7 @@ pub fn can_reap(&self, p: &Process) -> bool { // Can't reap twice. p.is_completed() || // Can't reap the group leader in an under-construction job. - (!self.is_constructed() && self.get_pgid() == p.pid()) + (!self.is_constructed() && self.pgid() == p.pid()) ) } @@ -703,14 +703,14 @@ pub fn preview(&self) -> WString { /// Return our pgid, or none if we don't have one, or are internal to fish /// This never returns fish's own pgroup. - pub fn get_pgid(&self) -> Option { - self.group().get_pgid() + pub fn pgid(&self) -> Option { + self.group().pgid() } /// Return the pid of the last external process in the job. /// This may be none if the job consists of just internal fish functions or builtins. /// This will never be fish's own pid. - pub fn get_last_pid(&self) -> Option { + pub fn last_pid(&self) -> Option { self.external_procs().last().and_then(|proc| proc.pid()) } @@ -726,7 +726,7 @@ pub fn flags(&self) -> Ref<'_, JobFlags> { } /// Access mutable job flags. - pub fn mut_flags(&self) -> RefMut<'_, JobFlags> { + pub fn flags_mut(&self) -> RefMut<'_, JobFlags> { self.job_flags.borrow_mut() } @@ -748,7 +748,7 @@ pub fn is_initially_background(&self) -> bool { /// Mark this job as constructed. The job must not have previously been marked as constructed. pub fn mark_constructed(&self) { assert!(!self.is_constructed(), "Job was already constructed"); - self.mut_flags().constructed = true; + self.flags_mut().constructed = true; } /// Return whether we have internal or external procs, respectively. @@ -848,7 +848,7 @@ pub fn continue_job(&self, parser: &Parser, block_io: Option<&IoChain>) { let procs = self.processes(); let p = procs.last().unwrap(); if p.status().normal_exited() || p.status().signal_exited() { - if let Some(statuses) = self.get_statuses() { + if let Some(statuses) = self.statuses() { parser.set_last_statuses(statuses); parser.libdata_mut().status_count += 1; } @@ -859,7 +859,7 @@ pub fn continue_job(&self, parser: &Parser, block_io: Option<&IoChain>) { /// Prepare to resume a stopped job by sending SIGCONT and clearing the stopped flag. /// Return true on success, false if we failed to send the signal. pub fn resume(&self) -> bool { - self.mut_flags().notified_of_stop = false; + self.flags_mut().notified_of_stop = false; if !self.signal(NixSignal::SIGCONT) { flogf!( proc_pgroup, @@ -879,7 +879,7 @@ pub fn resume(&self) -> bool { /// Send the specified signal to all processes in this job. /// Return true on success, false on failure. pub fn signal(&self, signal: NixSignal) -> bool { - if let Some(pgid) = self.group().get_pgid() { + if let Some(pgid) = self.group().pgid() { if let Err(err) = killpg(pgid.as_nix_pid(), signal) { perror_nix(&format!("killpg({pgid}, {})", signal.as_str()), err); return false; @@ -896,7 +896,7 @@ pub fn signal(&self, signal: NixSignal) -> bool { } /// Returns the statuses for this job. - pub fn get_statuses(&self) -> Option { + pub fn statuses(&self) -> Option { let mut st = Statuses::default(); let mut has_status = false; let mut laststatus = 0; @@ -1132,7 +1132,7 @@ pub fn hup_jobs(jobs: &JobList) { let fish_pgrp = getpgrp(); let mut kill_list = Vec::new(); for j in jobs { - let Some(pgid) = j.get_pgid() else { continue }; + let Some(pgid) = j.pgid() else { continue }; if pgid.as_nix_pid() != fish_pgrp && !j.is_completed() { j.signal(NixSignal::SIGHUP); if j.is_stopped() { @@ -1272,7 +1272,7 @@ fn process_mark_finished_children(parser: &Parser, block_ok: bool, block_io: Opt j.group().set_is_foreground(false); } if status.continued() { - j.mut_flags().notified_of_stop = false; + j.flags_mut().notified_of_stop = false; } if status.normal_exited() || status.signal_exited() { flogf!( @@ -1378,7 +1378,7 @@ fn generate_job_exit_events(j: &Job, out_evts: &mut Vec) { if !j.from_event_handler() || !j.is_foreground() { // job_exit events. if j.posts_job_exit_events() { - if let Some(last_pid) = j.get_last_pid() { + if let Some(last_pid) = j.last_pid() { out_evts.push(Event::job_exit(last_pid, j.internal_job_id)); } } @@ -1441,7 +1441,7 @@ fn job_or_proc_wants_summary(j: &Job) -> bool { fn call_job_summary(parser: &Parser, cmd: &wstr) { let event = Event::generic(L!("fish_job_summary").to_owned()); let b = parser.push_block(Block::event_block(event)); - let saved_status = parser.get_last_statuses(); + let saved_status = parser.last_statuses(); parser.eval(cmd, &IoChain::new()); parser.set_last_statuses(saved_status); parser.pop_block(b); @@ -1546,7 +1546,7 @@ fn save_wait_handle_for_completed_job(job: &Job, store: &mut WaitHandleStore) { // Mark all wait handles as complete (but don't create just for this). for proc in job.processes().iter() { - if let Some(wh) = proc.get_wait_handle() { + if let Some(wh) = proc.wait_handle() { wh.set_status_and_complete(proc.status().status_value()); } } @@ -1590,7 +1590,7 @@ fn process_clean_after_marking(parser: &Parser, interactive: bool) -> bool { && should_process_job(j) && job_wants_summary(j) { - j.mut_flags().notified_of_stop = true; + j.flags_mut().notified_of_stop = true; jobs_to_summarize.push(j.clone()); } } diff --git a/src/reader/reader.rs b/src/reader/reader.rs index 171123968..97847483a 100644 --- a/src/reader/reader.rs +++ b/src/reader/reader.rs @@ -870,7 +870,7 @@ fn read_i(parser: &Parser) { parser.libdata_mut().exit_current_script = false; BufferedOutputter::new(Outputter::stdoutput()).write_command(Osc133CommandFinished { - exit_status: parser.get_last_status(), + exit_status: parser.last_status(), }); event::fire_generic(parser, L!("fish_postexec").to_owned(), vec![command]); // Allow any pending history items to be returned in the history array. @@ -2677,7 +2677,7 @@ fn readline( } fn eval_bind_cmd(&mut self, cmd: &wstr) { - let last_statuses = self.parser.vars().get_last_statuses(); + let last_statuses = self.parser.vars().last_statuses(); // Disable TTY protocols while we run a bind command, because it may call out. let mut scoped_tty = TtyHandoff::new(reader_save_screen_state); scoped_tty.disable_tty_protocols(); diff --git a/src/tty_handoff.rs b/src/tty_handoff.rs index 846be780f..69e9c4b30 100644 --- a/src/tty_handoff.rs +++ b/src/tty_handoff.rs @@ -424,7 +424,7 @@ fn try_transfer(jg: &JobGroup) -> bool { } // Get the pgid; we must have one if we want the terminal. - let pgid = jg.get_pgid().unwrap(); + let pgid = jg.pgid().unwrap(); // It should never be fish's pgroup. let fish_pgrp = getpgrp();