summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-12-06 01:12:49 +0000
committerAndreas Kling <kling@serenityos.org>2022-12-06 08:54:33 +0100
commit57dc179b1fce5d4b7171311b04667debfe693095 (patch)
treea459d1aef92dc4e49bbf03b32621b1e7e30d4e64 /Userland/Libraries/LibCpp
parent6e19ab2bbce0b113b628e6f8e9b5c0640053933e (diff)
downloadserenity-57dc179b1fce5d4b7171311b04667debfe693095.zip
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.
Diffstat (limited to 'Userland/Libraries/LibCpp')
-rw-r--r--Userland/Libraries/LibCpp/AST.cpp30
-rw-r--r--Userland/Libraries/LibCpp/AST.h10
-rw-r--r--Userland/Libraries/LibCpp/Parser.cpp12
-rw-r--r--Userland/Libraries/LibCpp/Preprocessor.cpp4
-rw-r--r--Userland/Libraries/LibCpp/SemanticSyntaxHighlighter.cpp4
-rw-r--r--Userland/Libraries/LibCpp/SyntaxHighlighter.cpp2
-rw-r--r--Userland/Libraries/LibCpp/Token.cpp4
-rw-r--r--Userland/Libraries/LibCpp/Token.h4
8 files changed, 35 insertions, 35 deletions
diff --git a/Userland/Libraries/LibCpp/AST.cpp b/Userland/Libraries/LibCpp/AST.cpp
index 7ac8a12aa7..21419bd889 100644
--- a/Userland/Libraries/LibCpp/AST.cpp
+++ b/Userland/Libraries/LibCpp/AST.cpp
@@ -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;
}
diff --git a/Userland/Libraries/LibCpp/AST.h b/Userland/Libraries/LibCpp/AST.h
index 7d4f48b0a2..095306e585 100644
--- a/Userland/Libraries/LibCpp/AST.h
+++ b/Userland/Libraries/LibCpp/AST.h
@@ -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)
diff --git a/Userland/Libraries/LibCpp/Parser.cpp b/Userland/Libraries/LibCpp/Parser.cpp
index b6a2a6ffa7..9976c73ac7 100644
--- a/Userland/Libraries/LibCpp/Parser.cpp
+++ b/Userland/Libraries/LibCpp/Parser.cpp
@@ -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) {
diff --git a/Userland/Libraries/LibCpp/Preprocessor.cpp b/Userland/Libraries/LibCpp/Preprocessor.cpp
index efd78d11ba..a5b3815e56 100644
--- a/Userland/Libraries/LibCpp/Preprocessor.cpp
+++ b/Userland/Libraries/LibCpp/Preprocessor.cpp
@@ -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();
}
};
diff --git a/Userland/Libraries/LibCpp/SemanticSyntaxHighlighter.cpp b/Userland/Libraries/LibCpp/SemanticSyntaxHighlighter.cpp
index f477fdb917..27a7e47ee0 100644
--- a/Userland/Libraries/LibCpp/SemanticSyntaxHighlighter.cpp
+++ b/Userland/Libraries/LibCpp/SemanticSyntaxHighlighter.cpp
@@ -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();
diff --git a/Userland/Libraries/LibCpp/SyntaxHighlighter.cpp b/Userland/Libraries/LibCpp/SyntaxHighlighter.cpp
index b62c3c33b8..9e56602987 100644
--- a/Userland/Libraries/LibCpp/SyntaxHighlighter.cpp
+++ b/Userland/Libraries/LibCpp/SyntaxHighlighter.cpp
@@ -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 });
diff --git a/Userland/Libraries/LibCpp/Token.cpp b/Userland/Libraries/LibCpp/Token.cpp
index 5d6d96b736..60b5a1fb8a 100644
--- a/Userland/Libraries/LibCpp/Token.cpp
+++ b/Userland/Libraries/LibCpp/Token.cpp
@@ -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);
}
diff --git a/Userland/Libraries/LibCpp/Token.h b/Userland/Libraries/LibCpp/Token.h
index 42916b9bd4..7986aaa9c8 100644
--- a/Userland/Libraries/LibCpp/Token.h
+++ b/Userland/Libraries/LibCpp/Token.h
@@ -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; }