Refactor: apply some lints

And reformat touched files; my editor just does that.
This commit is contained in:
Johannes Altmanninger
2020-09-26 14:24:27 +02:00
parent 45e7c709f4
commit 879e80859c
4 changed files with 13 additions and 13 deletions

View File

@@ -399,16 +399,15 @@ maybe_t<int> 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);
}
}

View File

@@ -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();

View File

@@ -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,

View File

@@ -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.