1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:17:35 +00:00

Everywhere: Rename {Deprecated => Byte}String

This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
Ali Mohammad Pur 2023-12-16 17:49:34 +03:30 committed by Ali Mohammad Pur
parent 38d62563b3
commit 5e1499d104
1615 changed files with 10257 additions and 10257 deletions

View file

@ -135,7 +135,7 @@ Gfx::IntRect DiffViewer::separator_rect() const
frame_inner_rect().height() };
}
void DiffViewer::set_content(DeprecatedString const& original, DeprecatedString const& diff)
void DiffViewer::set_content(ByteString const& original, ByteString const& diff)
{
m_original_lines = split_to_lines(original);
m_hunks = Diff::parse_hunks(diff).release_value_but_fixme_should_propagate_errors();
@ -151,7 +151,7 @@ DiffViewer::DiffViewer()
setup_properties();
}
DiffViewer::DiffViewer(DeprecatedString const& original, DeprecatedString const& diff)
DiffViewer::DiffViewer(ByteString const& original, ByteString const& diff)
: m_original_lines(split_to_lines(original))
, m_hunks(Diff::parse_hunks(diff).release_value_but_fixme_should_propagate_errors())
{
@ -165,10 +165,10 @@ void DiffViewer::setup_properties()
set_foreground_role(ColorRole::BaseText);
}
Vector<DeprecatedString> DiffViewer::split_to_lines(DeprecatedString const& text)
Vector<ByteString> DiffViewer::split_to_lines(ByteString const& text)
{
// NOTE: This is slightly different than text.split('\n')
Vector<DeprecatedString> lines;
Vector<ByteString> lines;
size_t next_line_start_index = 0;
for (size_t i = 0; i < text.length(); ++i) {
if (text[i] == '\n') {

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Vector.h>
#include <LibDiff/Hunks.h>
#include <LibGUI/AbstractScrollableWidget.h>
@ -18,10 +18,10 @@ class DiffViewer final : public GUI::AbstractScrollableWidget {
public:
virtual ~DiffViewer() override = default;
void set_content(DeprecatedString const& original, DeprecatedString const& diff);
void set_content(ByteString const& original, ByteString const& diff);
private:
DiffViewer(DeprecatedString const& original, DeprecatedString const& diff);
DiffViewer(ByteString const& original, ByteString const& diff);
DiffViewer();
void setup_properties();
@ -45,7 +45,7 @@ private:
void draw_line(GUI::Painter&, StringView line, size_t y_offset, LinePosition, LineType);
static Vector<DeprecatedString> split_to_lines(DeprecatedString const& text);
static Vector<ByteString> split_to_lines(ByteString const& text);
static Gfx::Color red_background();
static Gfx::Color green_background();
@ -55,7 +55,7 @@ private:
Gfx::IntRect separator_rect() const;
Vector<DeprecatedString> m_original_lines;
Vector<ByteString> m_original_lines;
Vector<Diff::Hunk> m_hunks;
};
}

View file

@ -8,12 +8,12 @@
namespace HackStudio {
NonnullRefPtr<GitFilesModel> GitFilesModel::create(Vector<DeprecatedString>&& files)
NonnullRefPtr<GitFilesModel> GitFilesModel::create(Vector<ByteString>&& files)
{
return adopt_ref(*new GitFilesModel(move(files)));
}
GitFilesModel::GitFilesModel(Vector<DeprecatedString>&& files)
GitFilesModel::GitFilesModel(Vector<ByteString>&& files)
: m_files(move(files))
{
}

View file

@ -14,7 +14,7 @@ namespace HackStudio {
class GitFilesModel final : public GUI::Model {
public:
static NonnullRefPtr<GitFilesModel> create(Vector<DeprecatedString>&& files);
static NonnullRefPtr<GitFilesModel> create(Vector<ByteString>&& files);
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return m_files.size(); }
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return 1; }
@ -26,7 +26,7 @@ public:
virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex&) const override;
private:
explicit GitFilesModel(Vector<DeprecatedString>&& files);
Vector<DeprecatedString> m_files;
explicit GitFilesModel(Vector<ByteString>&& files);
Vector<ByteString> m_files;
};
}

View file

@ -54,7 +54,7 @@ void GitFilesView::mousedown_event(GUI::MouseEvent& event)
auto data = model()->index(item_index, model_column()).data();
VERIFY(data.is_string());
m_action_callback(data.to_deprecated_string());
m_action_callback(data.to_byte_string());
}
};

View file

@ -13,7 +13,7 @@
namespace HackStudio {
// A "GitFileAction" is either the staging or the unstaging of a file.
using GitFileActionCallback = Function<void(DeprecatedString const& file)>;
using GitFileActionCallback = Function<void(ByteString const& file)>;
class GitFilesView : public GUI::ListView {
C_OBJECT(GitFilesView)

View file

@ -9,7 +9,7 @@
namespace HackStudio {
GitRepo::CreateResult GitRepo::try_to_create(DeprecatedString const& repository_root)
GitRepo::CreateResult GitRepo::try_to_create(ByteString const& repository_root)
{
if (!git_is_installed()) {
return { CreateResult::Type::GitProgramNotFound, nullptr };
@ -21,7 +21,7 @@ GitRepo::CreateResult GitRepo::try_to_create(DeprecatedString const& repository_
return { CreateResult::Type::Success, adopt_ref(*new GitRepo(repository_root)) };
}
RefPtr<GitRepo> GitRepo::initialize_repository(DeprecatedString const& repository_root)
RefPtr<GitRepo> GitRepo::initialize_repository(ByteString const& repository_root)
{
auto res = command_wrapper({ "init" }, repository_root);
if (!res.has_value())
@ -31,7 +31,7 @@ RefPtr<GitRepo> GitRepo::initialize_repository(DeprecatedString const& repositor
return adopt_ref(*new GitRepo(repository_root));
}
Vector<DeprecatedString> GitRepo::unstaged_files() const
Vector<ByteString> GitRepo::unstaged_files() const
{
auto modified = modified_files();
auto untracked = untracked_files();
@ -39,7 +39,7 @@ Vector<DeprecatedString> GitRepo::unstaged_files() const
return modified;
}
//
Vector<DeprecatedString> GitRepo::staged_files() const
Vector<ByteString> GitRepo::staged_files() const
{
auto raw_result = command({ "diff", "--cached", "--name-only" });
if (!raw_result.has_value())
@ -47,7 +47,7 @@ Vector<DeprecatedString> GitRepo::staged_files() const
return parse_files_list(*raw_result);
}
Vector<DeprecatedString> GitRepo::modified_files() const
Vector<ByteString> GitRepo::modified_files() const
{
auto raw_result = command({ "ls-files", "--modified", "--exclude-standard" });
if (!raw_result.has_value())
@ -55,7 +55,7 @@ Vector<DeprecatedString> GitRepo::modified_files() const
return parse_files_list(*raw_result);
}
Vector<DeprecatedString> GitRepo::untracked_files() const
Vector<ByteString> GitRepo::untracked_files() const
{
auto raw_result = command({ "ls-files", "--others", "--exclude-standard" });
if (!raw_result.has_value())
@ -63,27 +63,27 @@ Vector<DeprecatedString> GitRepo::untracked_files() const
return parse_files_list(*raw_result);
}
Vector<DeprecatedString> GitRepo::parse_files_list(DeprecatedString const& raw_result)
Vector<ByteString> GitRepo::parse_files_list(ByteString const& raw_result)
{
auto lines = raw_result.split('\n');
Vector<DeprecatedString> files;
Vector<ByteString> files;
for (auto const& line : lines) {
files.empend(line);
}
return files;
}
Optional<DeprecatedString> GitRepo::command(Vector<DeprecatedString> const& command_parts) const
Optional<ByteString> GitRepo::command(Vector<ByteString> const& command_parts) const
{
return command_wrapper(command_parts, m_repository_root);
}
Optional<DeprecatedString> GitRepo::command_wrapper(Vector<DeprecatedString> const& command_parts, DeprecatedString const& chdir)
Optional<ByteString> GitRepo::command_wrapper(Vector<ByteString> const& command_parts, ByteString const& chdir)
{
auto const result = Core::command("git", command_parts, LexicalPath(chdir));
if (result.is_error() || result.value().exit_code != 0)
return {};
return DeprecatedString(result.value().output.bytes());
return ByteString(result.value().output.bytes());
}
bool GitRepo::git_is_installed()
@ -91,37 +91,37 @@ bool GitRepo::git_is_installed()
return command_wrapper({ "--help" }, "/").has_value();
}
bool GitRepo::git_repo_exists(DeprecatedString const& repo_root)
bool GitRepo::git_repo_exists(ByteString const& repo_root)
{
return command_wrapper({ "status" }, repo_root).has_value();
}
bool GitRepo::stage(DeprecatedString const& file)
bool GitRepo::stage(ByteString const& file)
{
return command({ "add", file }).has_value();
}
bool GitRepo::unstage(DeprecatedString const& file)
bool GitRepo::unstage(ByteString const& file)
{
return command({ "reset", "HEAD", "--", file }).has_value();
}
bool GitRepo::commit(DeprecatedString const& message)
bool GitRepo::commit(ByteString const& message)
{
return command({ "commit", "-m", message }).has_value();
}
Optional<DeprecatedString> GitRepo::original_file_content(DeprecatedString const& file) const
Optional<ByteString> GitRepo::original_file_content(ByteString const& file) const
{
return command({ "show", DeprecatedString::formatted("HEAD:{}", file) });
return command({ "show", ByteString::formatted("HEAD:{}", file) });
}
Optional<DeprecatedString> GitRepo::unstaged_diff(DeprecatedString const& file) const
Optional<ByteString> GitRepo::unstaged_diff(ByteString const& file) const
{
return command({ "diff", "-U0", file.characters() });
}
bool GitRepo::is_tracked(DeprecatedString const& file) const
bool GitRepo::is_tracked(ByteString const& file) const
{
auto res = command({ "ls-files", file });
if (!res.has_value())

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/LexicalPath.h>
#include <AK/Optional.h>
#include <AK/RefCounted.h>
@ -28,37 +28,37 @@ public:
RefPtr<GitRepo> repo;
};
static CreateResult try_to_create(DeprecatedString const& repository_root);
static RefPtr<GitRepo> initialize_repository(DeprecatedString const& repository_root);
static CreateResult try_to_create(ByteString const& repository_root);
static RefPtr<GitRepo> initialize_repository(ByteString const& repository_root);
bool stage(DeprecatedString const& file);
bool unstage(DeprecatedString const& file);
bool commit(DeprecatedString const& message);
bool is_tracked(DeprecatedString const& file) const;
bool stage(ByteString const& file);
bool unstage(ByteString const& file);
bool commit(ByteString const& message);
bool is_tracked(ByteString const& file) const;
Vector<DeprecatedString> unstaged_files() const;
Vector<DeprecatedString> staged_files() const;
Optional<DeprecatedString> original_file_content(DeprecatedString const& file) const;
Optional<DeprecatedString> unstaged_diff(DeprecatedString const& file) const;
Vector<ByteString> unstaged_files() const;
Vector<ByteString> staged_files() const;
Optional<ByteString> original_file_content(ByteString const& file) const;
Optional<ByteString> unstaged_diff(ByteString const& file) const;
private:
static bool git_is_installed();
static bool git_repo_exists(DeprecatedString const& repo_root);
static bool git_repo_exists(ByteString const& repo_root);
static Optional<DeprecatedString> command_wrapper(Vector<DeprecatedString> const& command_parts, DeprecatedString const& chdir);
static Vector<DeprecatedString> parse_files_list(DeprecatedString const&);
static Optional<ByteString> command_wrapper(Vector<ByteString> const& command_parts, ByteString const& chdir);
static Vector<ByteString> parse_files_list(ByteString const&);
explicit GitRepo(DeprecatedString const& repository_root)
explicit GitRepo(ByteString const& repository_root)
: m_repository_root(repository_root)
{
}
Vector<DeprecatedString> modified_files() const;
Vector<DeprecatedString> untracked_files() const;
Vector<ByteString> modified_files() const;
Vector<ByteString> untracked_files() const;
Optional<DeprecatedString> command(Vector<DeprecatedString> const& command_parts) const;
Optional<ByteString> command(Vector<ByteString> const& command_parts) const;
DeprecatedString m_repository_root;
ByteString m_repository_root;
};
}

View file

@ -118,7 +118,7 @@ void GitWidget::refresh()
m_staged_files->set_model(GitFilesModel::create(m_git_repo->staged_files()));
}
void GitWidget::stage_file(DeprecatedString const& file)
void GitWidget::stage_file(ByteString const& file)
{
dbgln("staging: {}", file);
bool rc = m_git_repo->stage(file);
@ -126,7 +126,7 @@ void GitWidget::stage_file(DeprecatedString const& file)
refresh();
}
void GitWidget::unstage_file(DeprecatedString const& file)
void GitWidget::unstage_file(ByteString const& file)
{
dbgln("unstaging: {}", file);
bool rc = m_git_repo->unstage(file);
@ -154,7 +154,7 @@ void GitWidget::set_view_diff_callback(ViewDiffCallback callback)
m_view_diff_callback = move(callback);
}
void GitWidget::show_diff(DeprecatedString const& file_path)
void GitWidget::show_diff(ByteString const& file_path)
{
if (!m_git_repo->is_tracked(file_path)) {
auto file = Core::File::open(file_path, Core::File::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
@ -168,7 +168,7 @@ void GitWidget::show_diff(DeprecatedString const& file_path)
m_view_diff_callback(original_content.value(), diff.value());
}
void GitWidget::change_repo(DeprecatedString const& repo_root)
void GitWidget::change_repo(ByteString const& repo_root)
{
m_repo_root = repo_root;
m_git_repo = nullptr;

View file

@ -14,7 +14,7 @@
namespace HackStudio {
using ViewDiffCallback = Function<void(DeprecatedString const& original_content, DeprecatedString const& diff)>;
using ViewDiffCallback = Function<void(ByteString const& original_content, ByteString const& diff)>;
class GitWidget final : public GUI::Widget {
C_OBJECT(GitWidget)
@ -24,19 +24,19 @@ public:
void refresh();
void set_view_diff_callback(ViewDiffCallback callback);
bool initialized() const { return !m_git_repo.is_null(); }
void change_repo(DeprecatedString const& repo_root);
void change_repo(ByteString const& repo_root);
private:
explicit GitWidget();
bool initialize();
bool initialize_if_needed();
void stage_file(DeprecatedString const&);
void unstage_file(DeprecatedString const&);
void stage_file(ByteString const&);
void unstage_file(ByteString const&);
void commit();
void show_diff(DeprecatedString const&);
void show_diff(ByteString const&);
DeprecatedString m_repo_root;
ByteString m_repo_root;
RefPtr<GitFilesView> m_unstaged_files;
RefPtr<GitFilesView> m_staged_files;
RefPtr<GitRepo> m_git_repo;