mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +00:00
Everywhere: Use '_{short_,}string' literals more
This mostly updates code what was written before but merged after these were added.
This commit is contained in:
parent
d0ba5f2ed7
commit
51c3967516
15 changed files with 94 additions and 95 deletions
|
@ -645,7 +645,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_complete_command()
|
|||
auto position = peek().position;
|
||||
auto syntax_error = make_ref_counted<AST::SyntaxError>(
|
||||
position.value_or(empty_position()),
|
||||
String::from_utf8("Extra tokens after complete command"sv).release_value_but_fixme_should_propagate_errors());
|
||||
"Extra tokens after complete command"_string.release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
if (list)
|
||||
list->set_is_syntax_error(*syntax_error);
|
||||
|
@ -923,13 +923,13 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_while_clause()
|
|||
if (!condition)
|
||||
condition = make_ref_counted<AST::SyntaxError>(
|
||||
peek().position.value_or(empty_position()),
|
||||
String::from_utf8("Expected condition after 'while'"sv).release_value_but_fixme_should_propagate_errors());
|
||||
"Expected condition after 'while'"_string.release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
auto do_group = TRY(parse_do_group());
|
||||
if (!do_group)
|
||||
do_group = make_ref_counted<AST::SyntaxError>(
|
||||
peek().position.value_or(empty_position()),
|
||||
String::from_utf8("Expected 'do' after 'while'"sv).release_value_but_fixme_should_propagate_errors());
|
||||
"Expected 'do' after 'while'"_string.release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
// while foo; bar -> loop { if foo { bar } else { break } }
|
||||
return make_ref_counted<AST::ForLoop>(
|
||||
|
@ -957,13 +957,13 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_until_clause()
|
|||
if (!condition)
|
||||
condition = make_ref_counted<AST::SyntaxError>(
|
||||
peek().position.value_or(empty_position()),
|
||||
String::from_utf8("Expected condition after 'until'"sv).release_value_but_fixme_should_propagate_errors());
|
||||
"Expected condition after 'until'"_string.release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
auto do_group = TRY(parse_do_group());
|
||||
if (!do_group)
|
||||
do_group = make_ref_counted<AST::SyntaxError>(
|
||||
peek().position.value_or(empty_position()),
|
||||
String::from_utf8("Expected 'do' after 'until'"sv).release_value_but_fixme_should_propagate_errors());
|
||||
"Expected 'do' after 'until'"_string.release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
// until foo; bar -> loop { if foo { break } else { bar } }
|
||||
return make_ref_counted<AST::ForLoop>(
|
||||
|
@ -1164,7 +1164,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_if_clause()
|
|||
skip();
|
||||
auto main_condition = TRY(parse_compound_list());
|
||||
if (!main_condition)
|
||||
main_condition = make_ref_counted<AST::SyntaxError>(empty_position(), String::from_utf8("Expected compound list after 'if'"sv).release_value_but_fixme_should_propagate_errors());
|
||||
main_condition = make_ref_counted<AST::SyntaxError>(empty_position(), "Expected compound list after 'if'"_string.release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
RefPtr<AST::SyntaxError> syntax_error;
|
||||
if (peek().type != Token::Type::Then) {
|
||||
|
@ -1177,7 +1177,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_if_clause()
|
|||
|
||||
auto main_consequence = TRY(parse_compound_list());
|
||||
if (!main_consequence)
|
||||
main_consequence = make_ref_counted<AST::SyntaxError>(empty_position(), String::from_utf8("Expected compound list after 'then'"sv).release_value_but_fixme_should_propagate_errors());
|
||||
main_consequence = make_ref_counted<AST::SyntaxError>(empty_position(), "Expected compound list after 'then'"_string.release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
auto node = make_ref_counted<AST::IfCond>(start_position, Optional<AST::Position>(), main_condition.release_nonnull(), main_consequence.release_nonnull(), nullptr);
|
||||
auto active_node = node;
|
||||
|
@ -1186,7 +1186,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_if_clause()
|
|||
skip();
|
||||
auto condition = TRY(parse_compound_list());
|
||||
if (!condition)
|
||||
condition = make_ref_counted<AST::SyntaxError>(empty_position(), String::from_utf8("Expected compound list after 'elif'"sv).release_value_but_fixme_should_propagate_errors());
|
||||
condition = make_ref_counted<AST::SyntaxError>(empty_position(), "Expected compound list after 'elif'"_string.release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
if (peek().type != Token::Type::Then) {
|
||||
if (!syntax_error)
|
||||
|
@ -1199,7 +1199,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_if_clause()
|
|||
|
||||
auto consequence = TRY(parse_compound_list());
|
||||
if (!consequence)
|
||||
consequence = make_ref_counted<AST::SyntaxError>(empty_position(), String::from_utf8("Expected compound list after 'then'"sv).release_value_but_fixme_should_propagate_errors());
|
||||
consequence = make_ref_counted<AST::SyntaxError>(empty_position(), "Expected compound list after 'then'"_string.release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
auto new_node = make_ref_counted<AST::IfCond>(start_position, Optional<AST::Position>(), condition.release_nonnull(), consequence.release_nonnull(), nullptr);
|
||||
|
||||
|
@ -1213,7 +1213,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_if_clause()
|
|||
skip();
|
||||
active_node->false_branch() = TRY(parse_compound_list());
|
||||
if (!active_node->false_branch())
|
||||
active_node->false_branch() = make_ref_counted<AST::SyntaxError>(empty_position(), String::from_utf8("Expected compound list after 'else'"sv).release_value_but_fixme_should_propagate_errors());
|
||||
active_node->false_branch() = make_ref_counted<AST::SyntaxError>(empty_position(), "Expected compound list after 'else'"_string.release_value_but_fixme_should_propagate_errors());
|
||||
break;
|
||||
case Token::Type::Fi:
|
||||
needs_fi = false;
|
||||
|
@ -1254,10 +1254,10 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_subshell()
|
|||
|
||||
auto list = TRY(parse_compound_list());
|
||||
if (!list)
|
||||
error = make_ref_counted<AST::SyntaxError>(peek().position.value_or(empty_position()), String::from_utf8("Expected compound list after ("sv).release_value_but_fixme_should_propagate_errors());
|
||||
error = make_ref_counted<AST::SyntaxError>(peek().position.value_or(empty_position()), "Expected compound list after ("_string.release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
if (peek().type != Token::Type::CloseParen)
|
||||
error = make_ref_counted<AST::SyntaxError>(peek().position.value_or(empty_position()), String::from_utf8("Expected ) after compound list"sv).release_value_but_fixme_should_propagate_errors());
|
||||
error = make_ref_counted<AST::SyntaxError>(peek().position.value_or(empty_position()), "Expected ) after compound list"_string.release_value_but_fixme_should_propagate_errors());
|
||||
else
|
||||
skip();
|
||||
|
||||
|
@ -1337,7 +1337,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_for_clause()
|
|||
name_position = peek().position;
|
||||
name = consume().value;
|
||||
} else {
|
||||
name = String::from_utf8_short_string("it"sv);
|
||||
name = "it"_short_string;
|
||||
error(peek(), "Expected a variable name, not {}", peek().type_name());
|
||||
}
|
||||
|
||||
|
@ -1533,7 +1533,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_word()
|
|||
case ResolvedParameterExpansion::Op::GetLastBackgroundPid:
|
||||
node = make_ref_counted<AST::SyntaxError>(
|
||||
token.position.value_or(empty_position()),
|
||||
TRY(String::from_utf8("$! not implemented"sv)));
|
||||
TRY("$! not implemented"_string));
|
||||
break;
|
||||
case ResolvedParameterExpansion::Op::GetPositionalParameterList:
|
||||
node = make_ref_counted<AST::SpecialVariable>(
|
||||
|
@ -1543,7 +1543,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_word()
|
|||
case ResolvedParameterExpansion::Op::GetCurrentOptionFlags:
|
||||
node = make_ref_counted<AST::SyntaxError>(
|
||||
token.position.value_or(empty_position()),
|
||||
TRY(String::from_utf8("The current option flags are not available in parameter expansions"sv)));
|
||||
TRY("The current option flags are not available in parameter expansions"_string));
|
||||
break;
|
||||
case ResolvedParameterExpansion::Op::GetPositionalParameterCount:
|
||||
node = make_ref_counted<AST::SpecialVariable>(
|
||||
|
@ -1558,7 +1558,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_word()
|
|||
case ResolvedParameterExpansion::Op::GetPositionalParameterListAsString:
|
||||
node = make_ref_counted<AST::SyntaxError>(
|
||||
token.position.value_or(empty_position()),
|
||||
TRY(String::from_utf8("$* not implemented"sv)));
|
||||
TRY("$* not implemented"_string));
|
||||
break;
|
||||
case ResolvedParameterExpansion::Op::GetShellProcessId:
|
||||
node = make_ref_counted<AST::SpecialVariable>(
|
||||
|
@ -1592,7 +1592,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_word()
|
|||
node = make_ref_counted<AST::ImmediateExpression>(
|
||||
token.position.value_or(empty_position()),
|
||||
AST::NameWithPosition {
|
||||
TRY(String::from_utf8("reexpand"sv)),
|
||||
TRY("reexpand"_string),
|
||||
token.position.value_or(empty_position()),
|
||||
},
|
||||
Vector { node.release_nonnull() },
|
||||
|
@ -1808,7 +1808,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_simple_command()
|
|||
// env (assignments) (command)
|
||||
nodes.append(make_ref_counted<AST::BarewordLiteral>(
|
||||
empty_position(),
|
||||
String::from_utf8_short_string("env"sv)));
|
||||
"env"_short_string));
|
||||
|
||||
nodes.append(
|
||||
make_ref_counted<AST::BarewordLiteral>(
|
||||
|
@ -1911,7 +1911,7 @@ ErrorOr<RefPtr<AST::Node>> Parser::parse_io_here(AST::Position start_position, O
|
|||
|
||||
auto end_keyword = consume();
|
||||
if (!is_one_of(end_keyword.type, Token::Type::Word, Token::Type::Token))
|
||||
return make_ref_counted<AST::SyntaxError>(io_operator_token.position.value_or(start_position), String::from_utf8("Expected a heredoc keyword"sv).release_value_but_fixme_should_propagate_errors(), true);
|
||||
return make_ref_counted<AST::SyntaxError>(io_operator_token.position.value_or(start_position), "Expected a heredoc keyword"_string.release_value_but_fixme_should_propagate_errors(), true);
|
||||
|
||||
auto [end_keyword_text, allow_interpolation] = Lexer::process_heredoc_key(end_keyword);
|
||||
RefPtr<AST::SyntaxError> error;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue