mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:17:44 +00:00
Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
This commit is contained in:
parent
6e19ab2bbc
commit
57dc179b1f
597 changed files with 1973 additions and 1972 deletions
|
@ -72,10 +72,10 @@ void Type::dump(FILE* output, size_t indent) const
|
|||
{
|
||||
ASTNode::dump(output, indent);
|
||||
print_indent(output, indent + 1);
|
||||
outln(output, "{}", to_string());
|
||||
outln(output, "{}", to_deprecated_string());
|
||||
}
|
||||
|
||||
DeprecatedString NamedType::to_string() const
|
||||
DeprecatedString NamedType::to_deprecated_string() const
|
||||
{
|
||||
DeprecatedString qualifiers_string;
|
||||
if (!qualifiers().is_empty())
|
||||
|
@ -90,33 +90,33 @@ DeprecatedString NamedType::to_string() const
|
|||
return DeprecatedString::formatted("{}{}", qualifiers_string, name);
|
||||
}
|
||||
|
||||
DeprecatedString Pointer::to_string() const
|
||||
DeprecatedString Pointer::to_deprecated_string() const
|
||||
{
|
||||
if (!m_pointee)
|
||||
return {};
|
||||
StringBuilder builder;
|
||||
builder.append(m_pointee->to_string());
|
||||
builder.append(m_pointee->to_deprecated_string());
|
||||
builder.append('*');
|
||||
return builder.to_string();
|
||||
return builder.to_deprecated_string();
|
||||
}
|
||||
|
||||
DeprecatedString Reference::to_string() const
|
||||
DeprecatedString Reference::to_deprecated_string() const
|
||||
{
|
||||
if (!m_referenced_type)
|
||||
return {};
|
||||
StringBuilder builder;
|
||||
builder.append(m_referenced_type->to_string());
|
||||
builder.append(m_referenced_type->to_deprecated_string());
|
||||
if (m_kind == Kind::Lvalue)
|
||||
builder.append('&');
|
||||
else
|
||||
builder.append("&&"sv);
|
||||
return builder.to_string();
|
||||
return builder.to_deprecated_string();
|
||||
}
|
||||
|
||||
DeprecatedString FunctionType::to_string() const
|
||||
DeprecatedString FunctionType::to_deprecated_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(m_return_type->to_string());
|
||||
builder.append(m_return_type->to_deprecated_string());
|
||||
builder.append('(');
|
||||
bool first = true;
|
||||
for (auto& parameter : m_parameters) {
|
||||
|
@ -125,14 +125,14 @@ DeprecatedString FunctionType::to_string() const
|
|||
else
|
||||
builder.append(", "sv);
|
||||
if (parameter.type())
|
||||
builder.append(parameter.type()->to_string());
|
||||
builder.append(parameter.type()->to_deprecated_string());
|
||||
if (parameter.name() && !parameter.full_name().is_empty()) {
|
||||
builder.append(' ');
|
||||
builder.append(parameter.full_name());
|
||||
}
|
||||
}
|
||||
builder.append(')');
|
||||
return builder.to_string();
|
||||
return builder.to_deprecated_string();
|
||||
}
|
||||
|
||||
void Parameter::dump(FILE* output, size_t indent) const
|
||||
|
@ -552,7 +552,7 @@ StringView Name::full_name() const
|
|||
builder.appendff("{}::", scope.name());
|
||||
}
|
||||
}
|
||||
m_full_name = DeprecatedString::formatted("{}{}", builder.to_string(), m_name.is_null() ? ""sv : m_name->name());
|
||||
m_full_name = DeprecatedString::formatted("{}{}", builder.to_deprecated_string(), m_name.is_null() ? ""sv : m_name->name());
|
||||
return *m_full_name;
|
||||
}
|
||||
|
||||
|
@ -565,10 +565,10 @@ StringView TemplatizedName::full_name() const
|
|||
name.append(Name::full_name());
|
||||
name.append('<');
|
||||
for (auto& type : m_template_arguments) {
|
||||
name.append(type.to_string());
|
||||
name.append(type.to_deprecated_string());
|
||||
}
|
||||
name.append('>');
|
||||
m_full_name = name.to_string();
|
||||
m_full_name = name.to_deprecated_string();
|
||||
return *m_full_name;
|
||||
}
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@ public:
|
|||
virtual bool is_type() const override { return true; }
|
||||
virtual bool is_templatized() const { return false; }
|
||||
virtual bool is_named_type() const { return false; }
|
||||
virtual DeprecatedString to_string() const = 0;
|
||||
virtual DeprecatedString to_deprecated_string() const = 0;
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
|
||||
bool is_auto() const { return m_is_auto; }
|
||||
|
@ -251,7 +251,7 @@ class NamedType : public Type {
|
|||
public:
|
||||
virtual ~NamedType() override = default;
|
||||
virtual StringView class_name() const override { return "NamedType"sv; }
|
||||
virtual DeprecatedString to_string() const override;
|
||||
virtual DeprecatedString to_deprecated_string() const override;
|
||||
virtual bool is_named_type() const override { return true; }
|
||||
|
||||
NamedType(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
|
@ -271,7 +271,7 @@ public:
|
|||
virtual ~Pointer() override = default;
|
||||
virtual StringView class_name() const override { return "Pointer"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
virtual DeprecatedString to_deprecated_string() const override;
|
||||
|
||||
Pointer(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Type(parent, start, end, filename)
|
||||
|
@ -290,7 +290,7 @@ public:
|
|||
virtual ~Reference() override = default;
|
||||
virtual StringView class_name() const override { return "Reference"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
virtual DeprecatedString to_deprecated_string() const override;
|
||||
|
||||
enum class Kind {
|
||||
Lvalue,
|
||||
|
@ -317,7 +317,7 @@ public:
|
|||
virtual ~FunctionType() override = default;
|
||||
virtual StringView class_name() const override { return "FunctionType"sv; }
|
||||
virtual void dump(FILE* = stdout, size_t indent = 0) const override;
|
||||
virtual DeprecatedString to_string() const override;
|
||||
virtual DeprecatedString to_deprecated_string() const override;
|
||||
|
||||
FunctionType(ASTNode* parent, Optional<Position> start, Optional<Position> end, DeprecatedString const& filename)
|
||||
: Type(parent, start, end, filename)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <AK/ScopeLogger.h>
|
||||
#include <LibCpp/Lexer.h>
|
||||
|
||||
#define LOG_SCOPE() ScopeLogger<CPP_DEBUG> logger(DeprecatedString::formatted("'{}' - {} ({})", peek().text(), peek().type_as_string(), m_state.token_index))
|
||||
#define LOG_SCOPE() ScopeLogger<CPP_DEBUG> logger(DeprecatedString::formatted("'{}' - {} ({})", peek().text(), peek().type_as_deprecated_string(), m_state.token_index))
|
||||
|
||||
namespace Cpp {
|
||||
|
||||
|
@ -22,7 +22,7 @@ Parser::Parser(Vector<Token> tokens, DeprecatedString const& filename)
|
|||
if constexpr (CPP_DEBUG) {
|
||||
dbgln("Tokens:");
|
||||
for (size_t i = 0; i < m_tokens.size(); ++i) {
|
||||
dbgln("{}- {}", i, m_tokens[i].to_string());
|
||||
dbgln("{}- {}", i, m_tokens[i].to_deprecated_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -579,7 +579,7 @@ NonnullRefPtr<Expression> Parser::parse_secondary_expression(ASTNode& parent, No
|
|||
return func;
|
||||
}
|
||||
default: {
|
||||
error(DeprecatedString::formatted("unexpected operator for expression. operator: {}", peek().to_string()));
|
||||
error(DeprecatedString::formatted("unexpected operator for expression. operator: {}", peek().to_deprecated_string()));
|
||||
auto token = consume();
|
||||
return create_ast_node<InvalidExpression>(parent, token.start(), token.end());
|
||||
}
|
||||
|
@ -880,7 +880,7 @@ DeprecatedString Parser::text_in_range(Position start, Position end) const
|
|||
for (auto token : tokens_in_range(start, end)) {
|
||||
builder.append(token.text());
|
||||
}
|
||||
return builder.to_string();
|
||||
return builder.to_deprecated_string();
|
||||
}
|
||||
|
||||
Vector<Token> Parser::tokens_in_range(Position start, Position end) const
|
||||
|
@ -1008,7 +1008,7 @@ Optional<size_t> Parser::index_of_token_at(Position pos) const
|
|||
void Parser::print_tokens() const
|
||||
{
|
||||
for (auto& token : m_tokens) {
|
||||
outln("{}", token.to_string());
|
||||
outln("{}", token.to_deprecated_string());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1110,7 +1110,7 @@ Token Parser::consume_keyword(DeprecatedString const& keyword)
|
|||
{
|
||||
auto token = consume();
|
||||
if (token.type() != Token::Type::Keyword) {
|
||||
error(DeprecatedString::formatted("unexpected token: {}, expected Keyword", token.to_string()));
|
||||
error(DeprecatedString::formatted("unexpected token: {}, expected Keyword", token.to_deprecated_string()));
|
||||
return token;
|
||||
}
|
||||
if (text_of_token(token) != keyword) {
|
||||
|
|
|
@ -371,7 +371,7 @@ DeprecatedString Preprocessor::remove_escaped_newlines(StringView value)
|
|||
processed_value.append(lexer.consume_until(escaped_newline));
|
||||
lexer.ignore(escaped_newline.length());
|
||||
}
|
||||
return processed_value.to_string();
|
||||
return processed_value.to_deprecated_string();
|
||||
}
|
||||
|
||||
DeprecatedString Preprocessor::evaluate_macro_call(MacroCall const& macro_call, Definition const& definition)
|
||||
|
@ -401,7 +401,7 @@ DeprecatedString Preprocessor::evaluate_macro_call(MacroCall const& macro_call,
|
|||
}
|
||||
});
|
||||
|
||||
return processed_value.to_string();
|
||||
return processed_value.to_deprecated_string();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -27,10 +27,10 @@ void SemanticSyntaxHighlighter::rehighlight(Palette const& palette)
|
|||
StringBuilder previous_tokens_as_lines;
|
||||
|
||||
for (auto& token : current_tokens)
|
||||
current_tokens_as_lines.appendff("{}\n", token.type_as_string());
|
||||
current_tokens_as_lines.appendff("{}\n", token.type_as_deprecated_string());
|
||||
|
||||
for (Cpp::Token const& token : m_saved_tokens)
|
||||
previous_tokens_as_lines.appendff("{}\n", token.type_as_string());
|
||||
previous_tokens_as_lines.appendff("{}\n", token.type_as_deprecated_string());
|
||||
|
||||
auto previous = previous_tokens_as_lines.build();
|
||||
auto current = current_tokens_as_lines.build();
|
||||
|
|
|
@ -63,7 +63,7 @@ void SyntaxHighlighter::rehighlight(Palette const& palette)
|
|||
Vector<GUI::TextDocumentSpan> spans;
|
||||
lexer.lex_iterable([&](auto token) {
|
||||
// FIXME: The +1 for the token end column is a quick hack due to not wanting to modify the lexer (which is also used by the parser). Maybe there's a better way to do this.
|
||||
dbgln_if(SYNTAX_HIGHLIGHTING_DEBUG, "{} @ {}:{} - {}:{}", token.type_as_string(), token.start().line, token.start().column, token.end().line, token.end().column + 1);
|
||||
dbgln_if(SYNTAX_HIGHLIGHTING_DEBUG, "{} @ {}:{} - {}:{}", token.type_as_deprecated_string(), token.start().line, token.start().column, token.end().line, token.end().column + 1);
|
||||
GUI::TextDocumentSpan span;
|
||||
span.range.set_start({ token.start().line, token.start().column });
|
||||
span.range.set_end({ token.end().line, token.end().column + 1 });
|
||||
|
|
|
@ -26,12 +26,12 @@ bool Position::operator<=(Position const& other) const
|
|||
return !(*this > other);
|
||||
}
|
||||
|
||||
DeprecatedString Token::to_string() const
|
||||
DeprecatedString Token::to_deprecated_string() const
|
||||
{
|
||||
return DeprecatedString::formatted("{} {}:{}-{}:{} ({})", type_to_string(m_type), start().line, start().column, end().line, end().column, text());
|
||||
}
|
||||
|
||||
DeprecatedString Token::type_as_string() const
|
||||
DeprecatedString Token::type_as_deprecated_string() const
|
||||
{
|
||||
return type_to_string(m_type);
|
||||
}
|
||||
|
|
|
@ -116,8 +116,8 @@ struct Token {
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
DeprecatedString to_string() const;
|
||||
DeprecatedString type_as_string() const;
|
||||
DeprecatedString to_deprecated_string() const;
|
||||
DeprecatedString type_as_deprecated_string() const;
|
||||
|
||||
Position const& start() const { return m_start; }
|
||||
Position const& end() const { return m_end; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue