From 879e80859ccebfc82c0f687dc7a19f30703e3763 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 26 Sep 2020 14:24:27 +0200 Subject: [PATCH] Refactor: apply some lints And reformat touched files; my editor just does that. --- src/builtin_complete.cpp | 13 ++++++------- src/complete.cpp | 9 +++++---- src/complete.h | 2 +- src/parse_execution.h | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/builtin_complete.cpp b/src/builtin_complete.cpp index de191d4d4..bf1812d8c 100644 --- a/src/builtin_complete.cpp +++ b/src/builtin_complete.cpp @@ -399,16 +399,15 @@ maybe_t builtin_complete(parser_t &parser, io_streams_t &streams, wchar_t * parser.libdata().builtin_complete_current_commandline = false; } - } else if (path.empty() && gnu_opt.empty() - && short_opt.empty() && old_opt.empty() - && !remove && !*comp && !*desc && !*condition - && wrap_targets.empty() && !result_mode.no_files - && !result_mode.force_files && !result_mode.requires_param) { - // No arguments that would add or remove anything specified, so we print the definitions of all matching completions. + } else if (path.empty() && gnu_opt.empty() && short_opt.empty() && old_opt.empty() && !remove && + !*comp && !*desc && !*condition && wrap_targets.empty() && !result_mode.no_files && + !result_mode.force_files && !result_mode.requires_param) { + // No arguments that would add or remove anything specified, so we print the definitions of + // all matching completions. if (cmd_to_complete.empty()) { builtin_complete_print(L"", streams, parser); } else { - for (auto& cmd : cmd_to_complete) { + for (auto &cmd : cmd_to_complete) { builtin_complete_print(cmd, streams, parser); } } diff --git a/src/complete.cpp b/src/complete.cpp index a7327c97c..311563ef0 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -1557,8 +1557,8 @@ void completer_t::perform_for_command(wcstring cmd) { for (const auto &tok : tokens) { // If there was an error, it was in the last token. assert(tok.type == token_type_t::string || tok.type == token_type_t::redirect); } - // If we are completing a variable name or a tilde expansion user name, we do that and return. - // No need for any other completions. + // If we are completing a variable name or a tilde expansion user name, we do that and + // return. No need for any other completions. const wcstring current_token = cur_tok.get_source(cmd); if (cur_tok.location_in_or_at_end_of_source_range(cursor_pos)) { if (try_complete_variable(current_token) || try_complete_user(current_token)) { @@ -1680,7 +1680,8 @@ static void append_switch(wcstring &out, const wcstring &opt) { append_format(out, L" --%ls", opt.c_str()); } -static wcstring completion2string(const complete_entry_opt_t &o, wcstring cmd, bool is_path) { +static wcstring completion2string(const complete_entry_opt_t &o, const wcstring &cmd, + bool is_path) { wcstring out; out.append(L"complete"); @@ -1721,7 +1722,7 @@ static wcstring completion2string(const complete_entry_opt_t &o, wcstring cmd, b } /// Use by the bare `complete`, loaded completions are printed out as commands -wcstring complete_print(wcstring cmd) { +wcstring complete_print(const wcstring &cmd) { wcstring out; out.reserve(40); // just a guess auto completion_set = s_completion_set.acquire(); diff --git a/src/complete.h b/src/complete.h index 31a3fb654..ede677931 100644 --- a/src/complete.h +++ b/src/complete.h @@ -180,7 +180,7 @@ completion_list_t complete(const wcstring &cmd, completion_request_flags_t flags const operation_context_t &ctx); /// Return a list of all current completions. -wcstring complete_print(wcstring cmd=L""); +wcstring complete_print(const wcstring &cmd = L""); /// Tests if the specified option is defined for the specified command. int complete_is_valid_option(const wcstring &str, const wcstring &opt, diff --git a/src/parse_execution.h b/src/parse_execution.h index c62ed961f..3c7428b06 100644 --- a/src/parse_execution.h +++ b/src/parse_execution.h @@ -74,7 +74,7 @@ class parse_execution_context_t { // Utilities wcstring get_source(const ast::node_t &node) const; const ast::decorated_statement_t *infinite_recursive_statement_in_job_list( - const ast::job_list_t &job_list, wcstring *out_func_name) const; + const ast::job_list_t &jobs, wcstring *out_func_name) const; // Expand a command which may contain variables, producing an expand command and possibly // arguments. Prints an error message on error.