1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 23:28:11 +00:00

AK+Everywhere: Remove the null state of DeprecatedString

This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>

Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
This commit is contained in:
Ali Mohammad Pur 2023-10-10 15:00:58 +03:30 committed by Ali Mohammad Pur
parent daf6d8173c
commit aeee98b3a1
189 changed files with 597 additions and 652 deletions

View file

@ -186,8 +186,8 @@ public:
ResultType type() const { return m_type; }
bool select_from_table() const { return !m_table_name.is_null(); }
DeprecatedString const& table_name() const { return m_table_name; }
bool select_from_table() const { return m_table_name.has_value(); }
Optional<DeprecatedString> const& table_name() const { return m_table_name; }
bool select_from_expression() const { return !m_expression.is_null(); }
RefPtr<Expression> const& expression() const { return m_expression; }
@ -196,7 +196,7 @@ public:
private:
ResultType m_type { ResultType::All };
DeprecatedString m_table_name {};
Optional<DeprecatedString> m_table_name {};
RefPtr<Expression> m_expression {};
DeprecatedString m_column_alias {};

View file

@ -566,16 +566,16 @@ RefPtr<Expression> Parser::parse_bind_parameter_expression()
return {};
}
RefPtr<Expression> Parser::parse_column_name_expression(DeprecatedString with_parsed_identifier, bool with_parsed_period)
RefPtr<Expression> Parser::parse_column_name_expression(Optional<DeprecatedString> with_parsed_identifier, bool with_parsed_period)
{
if (with_parsed_identifier.is_null() && !match(TokenType::Identifier))
if (!with_parsed_identifier.has_value() && !match(TokenType::Identifier))
return {};
DeprecatedString first_identifier;
if (with_parsed_identifier.is_null())
if (!with_parsed_identifier.has_value())
first_identifier = consume(TokenType::Identifier).value();
else
first_identifier = move(with_parsed_identifier);
first_identifier = with_parsed_identifier.release_value();
DeprecatedString schema_name;
DeprecatedString table_name;
@ -1010,17 +1010,17 @@ NonnullRefPtr<ResultColumn> Parser::parse_result_column()
// If we match an identifier now, we don't know whether it is a table-name of the form "table-name.*", or if it is the start of a
// column-name-expression, until we try to parse the asterisk. So if we consume an identifier and a period, but don't find an
// asterisk, hold onto that information to form a column-name-expression later.
DeprecatedString table_name;
Optional<DeprecatedString> table_name;
bool parsed_period = false;
if (match(TokenType::Identifier)) {
table_name = consume().value();
parsed_period = consume_if(TokenType::Period);
if (parsed_period && consume_if(TokenType::Asterisk))
return create_ast_node<ResultColumn>(move(table_name));
return create_ast_node<ResultColumn>(table_name.release_value());
}
auto expression = table_name.is_null()
auto expression = !table_name.has_value()
? parse_expression()
: static_cast<NonnullRefPtr<Expression>>(*parse_column_name_expression(move(table_name), parsed_period));

View file

@ -74,7 +74,7 @@ private:
bool match_secondary_expression() const;
RefPtr<Expression> parse_literal_value_expression();
RefPtr<Expression> parse_bind_parameter_expression();
RefPtr<Expression> parse_column_name_expression(DeprecatedString with_parsed_identifier = {}, bool with_parsed_period = false);
RefPtr<Expression> parse_column_name_expression(Optional<DeprecatedString> with_parsed_identifier = {}, bool with_parsed_period = false);
RefPtr<Expression> parse_unary_operator_expression();
RefPtr<Expression> parse_binary_operator_expression(NonnullRefPtr<Expression> lhs);
RefPtr<Expression> parse_chained_expression(bool surrounded_by_parentheses = true);