mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 02:13:38 +08:00
Reformat CPP files
This commit is contained in:
parent
4f6ad69c8a
commit
64601fd4d3
|
@ -467,9 +467,8 @@ bool autosuggest_validate_from_history(const history_item_t &item,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not handled specially so handle it here.
|
// Not handled specially so handle it here.
|
||||||
bool cmd_ok = builtin_exists(parsed_command)
|
bool cmd_ok = builtin_exists(parsed_command) || function_exists_no_autoload(parsed_command) ||
|
||||||
|| function_exists_no_autoload(parsed_command)
|
path_get_path(parsed_command, nullptr, ctx.vars);
|
||||||
|| path_get_path(parsed_command, nullptr, ctx.vars);
|
|
||||||
|
|
||||||
if (cmd_ok) {
|
if (cmd_ok) {
|
||||||
const path_list_t &paths = item.get_required_paths();
|
const path_list_t &paths = item.get_required_paths();
|
||||||
|
|
|
@ -530,12 +530,10 @@ char_event_t inputter_t::readch(bool allow_commands) {
|
||||||
case readline_cmd_t::func_or: {
|
case readline_cmd_t::func_or: {
|
||||||
// If previous function has right status, we keep reading tokens
|
// If previous function has right status, we keep reading tokens
|
||||||
if (evt.get_readline() == readline_cmd_t::func_and) {
|
if (evt.get_readline() == readline_cmd_t::func_and) {
|
||||||
if (function_status_)
|
if (function_status_) return readch();
|
||||||
return readch();
|
|
||||||
} else {
|
} else {
|
||||||
assert(evt.get_readline() == readline_cmd_t::func_or);
|
assert(evt.get_readline() == readline_cmd_t::func_or);
|
||||||
if (!function_status_)
|
if (!function_status_) return readch();
|
||||||
return readch();
|
|
||||||
}
|
}
|
||||||
// Else we flush remaining tokens
|
// Else we flush remaining tokens
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -1222,47 +1222,43 @@ parser_test_error_bits_t parse_util_detect_errors(const ast::ast_t &ast, const w
|
||||||
// Verify no variable expansions.
|
// Verify no variable expansions.
|
||||||
wcstring storage;
|
wcstring storage;
|
||||||
|
|
||||||
for (const node_t &node : ast) {
|
for (const node_t &node : ast) {
|
||||||
if (const job_continuation_t *jc = node.try_as<job_continuation_t>()) {
|
if (const job_continuation_t *jc = node.try_as<job_continuation_t>()) {
|
||||||
// Somewhat clumsy way of checking for a statement without source in a pipeline.
|
// Somewhat clumsy way of checking for a statement without source in a pipeline.
|
||||||
// See if our pipe has source but our statement does not.
|
// See if our pipe has source but our statement does not.
|
||||||
if (!jc->pipe.unsourced && !jc->statement.try_source_range().has_value()) {
|
if (!jc->pipe.unsourced && !jc->statement.try_source_range().has_value()) {
|
||||||
has_unclosed_pipe = true;
|
has_unclosed_pipe = true;
|
||||||
}
|
|
||||||
} else if (const argument_t *arg = node.try_as<argument_t>()) {
|
|
||||||
const wcstring &arg_src = arg->source(buff_src, &storage);
|
|
||||||
res |= parse_util_detect_errors_in_argument(*arg, arg_src, out_errors);
|
|
||||||
} else if (const ast::job_t *job = node.try_as<ast::job_t>()) {
|
|
||||||
// Disallow background in the following cases:
|
|
||||||
//
|
|
||||||
// foo & ; and bar
|
|
||||||
// foo & ; or bar
|
|
||||||
// if foo & ; end
|
|
||||||
// while foo & ; end
|
|
||||||
// If it's not a background job, nothing to do.
|
|
||||||
if (job->bg) {
|
|
||||||
errored |= detect_errors_in_backgrounded_job(*job, out_errors);
|
|
||||||
}
|
|
||||||
} else if (const ast::decorated_statement_t *stmt =
|
|
||||||
node.try_as<decorated_statement_t>()) {
|
|
||||||
errored |=
|
|
||||||
detect_errors_in_decorated_statement(buff_src, *stmt, &storage, out_errors);
|
|
||||||
} else if (const auto *block = node.try_as<block_statement_t>()) {
|
|
||||||
// If our 'end' had no source, we are unsourced.
|
|
||||||
if (block->end.unsourced) has_unclosed_block = true;
|
|
||||||
errored |=
|
|
||||||
detect_errors_in_block_redirection_list(block->args_or_redirs, out_errors);
|
|
||||||
} else if (const auto *ifs = node.try_as<if_statement_t>()) {
|
|
||||||
// If our 'end' had no source, we are unsourced.
|
|
||||||
if (ifs->end.unsourced) has_unclosed_block = true;
|
|
||||||
errored |= detect_errors_in_block_redirection_list(ifs->args_or_redirs, out_errors);
|
|
||||||
} else if (const auto *switchs = node.try_as<switch_statement_t>()) {
|
|
||||||
// If our 'end' had no source, we are unsourced.
|
|
||||||
if (switchs->end.unsourced) has_unclosed_block = true;
|
|
||||||
errored |=
|
|
||||||
detect_errors_in_block_redirection_list(switchs->args_or_redirs, out_errors);
|
|
||||||
}
|
}
|
||||||
|
} else if (const argument_t *arg = node.try_as<argument_t>()) {
|
||||||
|
const wcstring &arg_src = arg->source(buff_src, &storage);
|
||||||
|
res |= parse_util_detect_errors_in_argument(*arg, arg_src, out_errors);
|
||||||
|
} else if (const ast::job_t *job = node.try_as<ast::job_t>()) {
|
||||||
|
// Disallow background in the following cases:
|
||||||
|
//
|
||||||
|
// foo & ; and bar
|
||||||
|
// foo & ; or bar
|
||||||
|
// if foo & ; end
|
||||||
|
// while foo & ; end
|
||||||
|
// If it's not a background job, nothing to do.
|
||||||
|
if (job->bg) {
|
||||||
|
errored |= detect_errors_in_backgrounded_job(*job, out_errors);
|
||||||
|
}
|
||||||
|
} else if (const ast::decorated_statement_t *stmt = node.try_as<decorated_statement_t>()) {
|
||||||
|
errored |= detect_errors_in_decorated_statement(buff_src, *stmt, &storage, out_errors);
|
||||||
|
} else if (const auto *block = node.try_as<block_statement_t>()) {
|
||||||
|
// If our 'end' had no source, we are unsourced.
|
||||||
|
if (block->end.unsourced) has_unclosed_block = true;
|
||||||
|
errored |= detect_errors_in_block_redirection_list(block->args_or_redirs, out_errors);
|
||||||
|
} else if (const auto *ifs = node.try_as<if_statement_t>()) {
|
||||||
|
// If our 'end' had no source, we are unsourced.
|
||||||
|
if (ifs->end.unsourced) has_unclosed_block = true;
|
||||||
|
errored |= detect_errors_in_block_redirection_list(ifs->args_or_redirs, out_errors);
|
||||||
|
} else if (const auto *switchs = node.try_as<switch_statement_t>()) {
|
||||||
|
// If our 'end' had no source, we are unsourced.
|
||||||
|
if (switchs->end.unsourced) has_unclosed_block = true;
|
||||||
|
errored |= detect_errors_in_block_redirection_list(switchs->args_or_redirs, out_errors);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (errored) res |= PARSER_TEST_ERROR;
|
if (errored) res |= PARSER_TEST_ERROR;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user