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

AK+Everywhere: Rename String to DeprecatedString

We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
This commit is contained in:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -37,14 +37,14 @@ class UnregisteredWidget final : public GUI::Widget {
C_OBJECT(UnregisteredWidget);
private:
UnregisteredWidget(String const& class_name);
UnregisteredWidget(DeprecatedString const& class_name);
virtual void paint_event(GUI::PaintEvent& event) override;
String m_text;
DeprecatedString m_text;
};
UnregisteredWidget::UnregisteredWidget(String const& class_name)
UnregisteredWidget::UnregisteredWidget(DeprecatedString const& class_name)
{
StringBuilder builder;
builder.append(class_name);
@ -104,7 +104,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
editor->set_automatic_indentation_enabled(true);
editor->set_ruler_visible(true);
String file_path;
DeprecatedString file_path;
auto update_title = [&] {
StringBuilder builder;
if (file_path.is_empty())
@ -121,7 +121,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
editor->on_change = [&] {
preview->remove_all_children();
preview->load_from_gml(editor->text(), [](const String& class_name) -> RefPtr<Core::Object> {
preview->load_from_gml(editor->text(), [](const DeprecatedString& class_name) -> RefPtr<Core::Object> {
return UnregisteredWidget::construct(class_name);
});
};
@ -212,7 +212,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
} else {
GUI::MessageBox::show(
window,
String::formatted("GML could not be formatted: {}", formatted_gml_or_error.error()),
DeprecatedString::formatted("GML could not be formatted: {}", formatted_gml_or_error.error()),
"Error"sv,
GUI::MessageBox::Type::Error);
}
@ -286,7 +286,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->show();
if (String(path).is_empty()) {
if (DeprecatedString(path).is_empty()) {
editor->set_text(R"~~~(@GUI::Frame {
layout: @GUI::VerticalBoxLayout {
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/Types.h>
#include <LibCpp/Parser.h>
#include <LibGUI/AutocompleteProvider.h>

View file

@ -9,7 +9,7 @@
namespace HackStudio {
NonnullRefPtr<CodeDocument> CodeDocument::create(String const& file_path, Client* client)
NonnullRefPtr<CodeDocument> CodeDocument::create(DeprecatedString const& file_path, Client* client)
{
return adopt_ref(*new CodeDocument(file_path, client));
}
@ -19,7 +19,7 @@ NonnullRefPtr<CodeDocument> CodeDocument::create(Client* client)
return adopt_ref(*new CodeDocument(client));
}
CodeDocument::CodeDocument(String const& file_path, Client* client)
CodeDocument::CodeDocument(DeprecatedString const& file_path, Client* client)
: TextDocument(client)
, m_file_path(file_path)
{

View file

@ -16,7 +16,7 @@ namespace HackStudio {
class CodeDocument final : public GUI::TextDocument {
public:
virtual ~CodeDocument() override = default;
static NonnullRefPtr<CodeDocument> create(String const& file_path, Client* client = nullptr);
static NonnullRefPtr<CodeDocument> create(DeprecatedString const& file_path, Client* client = nullptr);
static NonnullRefPtr<CodeDocument> create(Client* client = nullptr);
Vector<size_t> const& breakpoint_lines() const { return m_breakpoint_lines; }
@ -24,18 +24,18 @@ public:
Optional<size_t> execution_position() const { return m_execution_position; }
void set_execution_position(size_t line) { m_execution_position = line; }
void clear_execution_position() { m_execution_position.clear(); }
String const& file_path() const { return m_file_path; }
String const& language_name() const { return m_language_name; };
DeprecatedString const& file_path() const { return m_file_path; }
DeprecatedString const& language_name() const { return m_language_name; };
Language language() const { return m_language; }
virtual bool is_code_document() const override final { return true; }
private:
explicit CodeDocument(String const& file_path, Client* client = nullptr);
explicit CodeDocument(DeprecatedString const& file_path, Client* client = nullptr);
explicit CodeDocument(Client* client = nullptr);
String m_file_path;
String m_language_name;
DeprecatedString m_file_path;
DeprecatedString m_language_name;
Language m_language { Language::Unknown };
Vector<size_t> m_breakpoint_lines;
Optional<size_t> m_execution_position;

View file

@ -46,7 +46,7 @@ Vector<BacktraceModel::FrameInfo> BacktraceModel::create_backtrace(Debug::Proces
// We need to go back to the 'call' instruction to get accurate source position information.
if (frame_index > 0)
--current_instruction;
String name = lib->debug_info->elf().symbolicate(current_instruction - lib->base_address);
DeprecatedString name = lib->debug_info->elf().symbolicate(current_instruction - lib->base_address);
if (name.is_null()) {
dbgln("BacktraceModel: couldn't find containing function for address: {:p} (library={})", current_instruction, lib->name);
name = "<missing>";

View file

@ -27,7 +27,7 @@ public:
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return m_frames.size(); }
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return 1; }
virtual String column_name(int) const override
virtual DeprecatedString column_name(int) const override
{
return "";
}
@ -37,7 +37,7 @@ public:
virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex&) const override;
struct FrameInfo {
String function_name;
DeprecatedString function_name;
FlatPtr instruction_address { 0 };
FlatPtr frame_base { 0 };
Optional<Debug::DebugInfo::SourcePosition> m_source_position;

View file

@ -6,8 +6,8 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/Function.h>
#include <AK/String.h>
#include <AK/Types.h>
namespace HackStudio {
@ -17,5 +17,5 @@ enum class BreakpointChange {
Removed,
};
using BreakpointChangeCallback = Function<void(String const& file, size_t line, BreakpointChange)>;
using BreakpointChangeCallback = Function<void(DeprecatedString const& file, size_t line, BreakpointChange)>;
}

View file

@ -105,7 +105,7 @@ RefPtr<GUI::Menu> DebugInfoWidget::get_context_menu_for_variable(const GUI::Mode
auto* variable = static_cast<Debug::DebugInfo::VariableInfo const*>(index.internal_data());
if (does_variable_support_writing(variable)) {
context_menu->add_action(GUI::Action::create("Change value", [&](auto&) {
String value;
DeprecatedString value;
if (GUI::InputBox::show(window(), value, "Enter new value:"sv, "Set variable value"sv) == GUI::InputBox::ExecResult::OK) {
auto& model = static_cast<VariablesModel&>(*m_variables_view->model());
model.set_variable_value(index, value, window());

View file

@ -18,7 +18,7 @@ Debugger& Debugger::the()
}
void Debugger::initialize(
String source_root,
DeprecatedString source_root,
Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback,
Function<void()> on_continue_callback,
Function<void()> on_exit_callback)
@ -32,7 +32,7 @@ bool Debugger::is_initialized()
}
Debugger::Debugger(
String source_root,
DeprecatedString source_root,
Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback,
Function<void()> on_continue_callback,
Function<void()> on_exit_callback)
@ -45,7 +45,7 @@ Debugger::Debugger(
pthread_cond_init(&m_ui_action_cond, nullptr);
}
void Debugger::on_breakpoint_change(String const& file, size_t line, BreakpointChange change_type)
void Debugger::on_breakpoint_change(DeprecatedString const& file, size_t line, BreakpointChange change_type)
{
auto position = create_source_position(file, line);
@ -77,7 +77,7 @@ void Debugger::on_breakpoint_change(String const& file, size_t line, BreakpointC
}
}
bool Debugger::set_execution_position(String const& file, size_t line)
bool Debugger::set_execution_position(DeprecatedString const& file, size_t line)
{
auto position = create_source_position(file, line);
auto session = Debugger::the().session();
@ -92,11 +92,11 @@ bool Debugger::set_execution_position(String const& file, size_t line)
return true;
}
Debug::DebugInfo::SourcePosition Debugger::create_source_position(String const& file, size_t line)
Debug::DebugInfo::SourcePosition Debugger::create_source_position(DeprecatedString const& file, size_t line)
{
if (file.starts_with('/'))
return { file, line + 1 };
return { LexicalPath::canonicalized_path(String::formatted("{}/{}", m_source_root, file)), line + 1 };
return { LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", m_source_root, file)), line + 1 };
}
intptr_t Debugger::start_static()

View file

@ -26,18 +26,18 @@ public:
};
static void initialize(
String source_root,
DeprecatedString source_root,
Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback,
Function<void()> on_continue_callback,
Function<void()> on_exit_callback);
static bool is_initialized();
void on_breakpoint_change(String const& file, size_t line, BreakpointChange change_type);
bool set_execution_position(String const& file, size_t line);
void on_breakpoint_change(DeprecatedString const& file, size_t line, BreakpointChange change_type);
bool set_execution_position(DeprecatedString const& file, size_t line);
void set_executable_path(String const& path) { m_executable_path = path; }
void set_source_root(String const& source_root) { m_source_root = source_root; }
void set_executable_path(DeprecatedString const& path) { m_executable_path = path; }
void set_source_root(DeprecatedString const& source_root) { m_source_root = source_root; }
Debug::DebugSession* session() { return m_debug_session.ptr(); }
@ -90,12 +90,12 @@ private:
};
explicit Debugger(
String source_root,
DeprecatedString source_root,
Function<HasControlPassedToUser(PtraceRegisters const&)> on_stop_callback,
Function<void()> on_continue_callback,
Function<void()> on_exit_callback);
Debug::DebugInfo::SourcePosition create_source_position(String const& file, size_t line);
Debug::DebugInfo::SourcePosition create_source_position(DeprecatedString const& file, size_t line);
void start();
int debugger_loop();
@ -107,7 +107,7 @@ private:
void insert_temporary_breakpoint_at_return_address(PtraceRegisters const&);
OwnPtr<Debug::DebugSession> m_debug_session;
String m_source_root;
DeprecatedString m_source_root;
DebuggingState m_state;
pthread_mutex_t m_ui_action_mutex {};
@ -116,7 +116,7 @@ private:
Vector<Debug::DebugInfo::SourcePosition> m_breakpoints;
String m_executable_path;
DeprecatedString m_executable_path;
Function<HasControlPassedToUser(PtraceRegisters const&)> m_on_stopped_callback;
Function<void()> m_on_continue_callback;

View file

@ -73,7 +73,7 @@ int DisassemblyModel::row_count(const GUI::ModelIndex&) const
return m_instructions.size();
}
String DisassemblyModel::column_name(int column) const
DeprecatedString DisassemblyModel::column_name(int column) const
{
switch (column) {
case Column::Address:
@ -94,7 +94,7 @@ GUI::Variant DisassemblyModel::data(const GUI::ModelIndex& index, GUI::ModelRole
if (role == GUI::ModelRole::Display) {
if (index.column() == Column::Address)
return String::formatted("{:p}", insn.address);
return DeprecatedString::formatted("{:p}", insn.address);
if (index.column() == Column::InstructionBytes) {
StringBuilder builder;
for (auto ch : insn.bytes)

View file

@ -22,7 +22,7 @@ namespace HackStudio {
struct InstructionData {
X86::Instruction insn;
String disassembly;
DeprecatedString disassembly;
StringView bytes;
FlatPtr address { 0 };
};
@ -45,7 +45,7 @@ public:
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; }
virtual String column_name(int) const override;
virtual DeprecatedString column_name(int) const override;
virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
private:

View file

@ -73,7 +73,7 @@ void DisassemblyWidget::show_disassembly()
m_unavailable_disassembly_widget->set_visible(false);
}
void DisassemblyWidget::hide_disassembly(String const& reason)
void DisassemblyWidget::hide_disassembly(DeprecatedString const& reason)
{
m_top_container->set_visible(false);
m_disassembly_view->set_visible(false);

View file

@ -21,18 +21,18 @@ class UnavailableDisassemblyWidget final : public GUI::Frame {
public:
virtual ~UnavailableDisassemblyWidget() override { }
String const& reason() const { return m_reason; }
void set_reason(String const& text) { m_reason = text; }
DeprecatedString const& reason() const { return m_reason; }
void set_reason(DeprecatedString const& text) { m_reason = text; }
private:
UnavailableDisassemblyWidget(String const& reason)
UnavailableDisassemblyWidget(DeprecatedString const& reason)
: m_reason(reason)
{
}
virtual void paint_event(GUI::PaintEvent& event) override;
String m_reason;
DeprecatedString m_reason;
};
class DisassemblyWidget final : public GUI::Widget {
@ -47,7 +47,7 @@ private:
DisassemblyWidget();
void show_disassembly();
void hide_disassembly(String const&);
void hide_disassembly(DeprecatedString const&);
RefPtr<GUI::Widget> m_top_container;
RefPtr<GUI::TableView> m_disassembly_view;

View file

@ -112,7 +112,7 @@ int RegistersModel::row_count(const GUI::ModelIndex&) const
return m_registers.size();
}
String RegistersModel::column_name(int column) const
DeprecatedString RegistersModel::column_name(int column) const
{
switch (column) {
case Column::Register:
@ -140,7 +140,7 @@ GUI::Variant RegistersModel::data(const GUI::ModelIndex& index, GUI::ModelRole r
if (index.column() == Column::Register)
return reg.name;
if (index.column() == Column::Value)
return String::formatted("{:p}", reg.value);
return DeprecatedString::formatted("{:p}", reg.value);
return {};
}
return {};

View file

@ -14,7 +14,7 @@
namespace HackStudio {
struct RegisterData {
String name;
DeprecatedString name;
FlatPtr value;
bool changed { false };
};
@ -41,7 +41,7 @@ public:
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; }
virtual String column_name(int) const override;
virtual DeprecatedString column_name(int) const override;
virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
PtraceRegisters const& raw_registers() const { return m_raw_registers; }

View file

@ -55,7 +55,7 @@ int VariablesModel::row_count(const GUI::ModelIndex& index) const
return node->members.size();
}
static String variable_value_as_string(Debug::DebugInfo::VariableInfo const& variable)
static DeprecatedString variable_value_as_string(Debug::DebugInfo::VariableInfo const& variable)
{
if (variable.location_type != Debug::DebugInfo::VariableInfo::LocationType::Address)
return "N/A";
@ -69,20 +69,20 @@ static String variable_value_as_string(Debug::DebugInfo::VariableInfo const& var
return enumerator->constant_data.as_u32 == enumerator_value;
});
if (it.is_end())
return String::formatted("Unknown ({})", value.value());
return String::formatted("{}::{}", variable.type_name, (*it)->name);
return DeprecatedString::formatted("Unknown ({})", value.value());
return DeprecatedString::formatted("{}::{}", variable.type_name, (*it)->name);
}
if (variable.type_name == "int") {
auto value = Debugger::the().session()->peek(variable_address);
VERIFY(value.has_value());
return String::formatted("{}", static_cast<int>(value.value()));
return DeprecatedString::formatted("{}", static_cast<int>(value.value()));
}
if (variable.type_name == "char") {
auto value = Debugger::the().session()->peek(variable_address);
VERIFY(value.has_value());
return String::formatted("'{0:c}'", (char)value.value());
return DeprecatedString::formatted("'{0:c}'", (char)value.value());
}
if (variable.type_name == "bool") {
@ -91,13 +91,13 @@ static String variable_value_as_string(Debug::DebugInfo::VariableInfo const& var
return (value.value() & 1) ? "true" : "false";
}
return String::formatted("type: {} @ {:p}, ", variable.type_name, variable_address);
return DeprecatedString::formatted("type: {} @ {:p}, ", variable.type_name, variable_address);
}
static Optional<u32> string_to_variable_value(StringView string_value, Debug::DebugInfo::VariableInfo const& variable)
{
if (variable.is_enum_type()) {
auto prefix_string = String::formatted("{}::", variable.type_name);
auto prefix_string = DeprecatedString::formatted("{}::", variable.type_name);
auto string_to_use = string_value;
if (string_value.starts_with(prefix_string))
string_to_use = string_value.substring_view(prefix_string.length(), string_value.length() - prefix_string.length());
@ -143,7 +143,7 @@ void VariablesModel::set_variable_value(const GUI::ModelIndex& index, StringView
GUI::MessageBox::show(
parent_window,
String::formatted("String value \"{}\" could not be converted to a value of type {}.", string_value, variable->type_name),
DeprecatedString::formatted("String value \"{}\" could not be converted to a value of type {}.", string_value, variable->type_name),
"Set value failed"sv,
GUI::MessageBox::Type::Error);
}
@ -154,7 +154,7 @@ GUI::Variant VariablesModel::data(const GUI::ModelIndex& index, GUI::ModelRole r
switch (role) {
case GUI::ModelRole::Display: {
auto value_as_string = variable_value_as_string(*variable);
return String::formatted("{}: {}", variable->name, value_as_string);
return DeprecatedString::formatted("{}: {}", variable->name, value_as_string);
}
case GUI::ModelRole::Icon:
return m_variable_icon;

View file

@ -32,7 +32,7 @@ GitCommitDialog::GitCommitDialog(GUI::Window* parent)
auto line = m_message_editor->cursor().line() + 1;
auto col = m_message_editor->cursor().column();
m_line_and_col_label->set_text(String::formatted("Line: {}, Col: {}", line, col));
m_line_and_col_label->set_text(DeprecatedString::formatted("Line: {}, Col: {}", line, col));
};
m_commit_button->set_enabled(!m_message_editor->text().is_empty() && on_commit);

View file

@ -15,7 +15,7 @@
namespace HackStudio {
using OnCommitCallback = Function<void(String const& message)>;
using OnCommitCallback = Function<void(DeprecatedString const& message)>;
class GitCommitDialog final : public GUI::Dialog {
C_OBJECT(GitCommitDialog);

View file

@ -10,8 +10,8 @@
#include <DevTools/HackStudio/Dialogs/NewProjectDialogGML.h>
#include <DevTools/HackStudio/ProjectTemplate.h>
#include <AK/DeprecatedString.h>
#include <AK/LexicalPath.h>
#include <AK/String.h>
#include <LibCore/Directory.h>
#include <LibCore/File.h>
#include <LibGUI/BoxLayout.h>
@ -89,7 +89,7 @@ NewProjectDialog::NewProjectDialog(GUI::Window* parent)
m_browse_button = *find_descendant_of_type_named<GUI::Button>("browse_button");
m_browse_button->on_click = [this](auto) {
Optional<String> path = GUI::FilePicker::get_open_filepath(this, {}, Core::StandardPaths::home_directory(), true);
Optional<DeprecatedString> path = GUI::FilePicker::get_open_filepath(this, {}, Core::StandardPaths::home_directory(), true);
if (path.has_value())
m_create_in_input->set_text(path.value().view());
};
@ -131,7 +131,7 @@ void NewProjectDialog::update_dialog()
m_ok_button->set_enabled(m_input_valid);
}
Optional<String> NewProjectDialog::get_available_project_name()
Optional<DeprecatedString> NewProjectDialog::get_available_project_name()
{
auto create_in = m_create_in_input->text();
auto chosen_name = m_name_input->text();
@ -148,16 +148,16 @@ Optional<String> NewProjectDialog::get_available_project_name()
for (int i = 0; i < 1000; i++) {
auto candidate = (i == 0)
? chosen_name
: String::formatted("{}-{}", chosen_name, i);
: DeprecatedString::formatted("{}-{}", chosen_name, i);
if (!Core::File::exists(String::formatted("{}/{}", create_in, candidate)))
if (!Core::File::exists(DeprecatedString::formatted("{}/{}", create_in, candidate)))
return candidate;
}
return {};
}
Optional<String> NewProjectDialog::get_project_full_path()
Optional<DeprecatedString> NewProjectDialog::get_project_full_path()
{
// Do not permit forward-slashes in project names
if (m_name_input->text().contains('/'))
@ -189,13 +189,13 @@ void NewProjectDialog::do_create_project()
auto create_in = m_create_in_input->text();
if (!Core::File::exists(create_in) || !Core::File::is_directory(create_in)) {
auto result = GUI::MessageBox::show(this, String::formatted("The directory {} does not exist yet, would you like to create it?", create_in), "New project"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
auto result = GUI::MessageBox::show(this, DeprecatedString::formatted("The directory {} does not exist yet, would you like to create it?", create_in), "New project"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
if (result != GUI::MessageBox::ExecResult::Yes)
return;
auto created = Core::Directory::create(maybe_project_full_path.value(), Core::Directory::CreateDirectories::Yes);
if (created.is_error()) {
GUI::MessageBox::show_error(this, String::formatted("Could not create directory {}", create_in));
GUI::MessageBox::show_error(this, DeprecatedString::formatted("Could not create directory {}", create_in));
return;
}
}
@ -206,7 +206,7 @@ void NewProjectDialog::do_create_project()
m_created_project_path = maybe_project_full_path.value();
done(ExecResult::OK);
} else {
GUI::MessageBox::show_error(this, String::formatted("Could not create project: {}", creation_result.error()));
GUI::MessageBox::show_error(this, DeprecatedString::formatted("Could not create project: {}", creation_result.error()));
}
}

View file

@ -24,15 +24,15 @@ class NewProjectDialog : public GUI::Dialog {
public:
static ExecResult show(GUI::Window* parent_window);
Optional<String> created_project_path() const { return m_created_project_path; }
Optional<DeprecatedString> created_project_path() const { return m_created_project_path; }
private:
NewProjectDialog(GUI::Window* parent);
virtual ~NewProjectDialog() override = default;
void update_dialog();
Optional<String> get_available_project_name();
Optional<String> get_project_full_path();
Optional<DeprecatedString> get_available_project_name();
Optional<DeprecatedString> get_project_full_path();
void do_create_project();
@ -53,7 +53,7 @@ private:
RefPtr<GUI::Button> m_cancel_button;
RefPtr<GUI::Button> m_browse_button;
Optional<String> m_created_project_path;
Optional<DeprecatedString> m_created_project_path;
};
}

View file

@ -53,7 +53,7 @@ int ProjectTemplatesModel::column_count(const GUI::ModelIndex&) const
return Column::__Count;
}
String ProjectTemplatesModel::column_name(int column) const
DeprecatedString ProjectTemplatesModel::column_name(int column) const
{
switch (column) {
case Column::Icon:

View file

@ -36,7 +36,7 @@ public:
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
virtual String column_name(int) const override;
virtual DeprecatedString column_name(int) const override;
virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
void update();

View file

@ -183,9 +183,9 @@ void Editor::paint_event(GUI::PaintEvent& event)
}
}
static HashMap<String, String>& man_paths()
static HashMap<DeprecatedString, DeprecatedString>& man_paths()
{
static HashMap<String, String> paths;
static HashMap<DeprecatedString, DeprecatedString> paths;
if (paths.is_empty()) {
auto json = Config::read_string("HackStudio"sv, "Global"sv, "DocumentationSearchPaths"sv);
AK::JsonParser parser(json);
@ -214,7 +214,7 @@ static HashMap<String, String>& man_paths()
return paths;
}
void Editor::show_documentation_tooltip_if_available(String const& hovered_token, Gfx::IntPoint const& screen_location)
void Editor::show_documentation_tooltip_if_available(DeprecatedString const& hovered_token, Gfx::IntPoint const& screen_location)
{
auto it = man_paths().find(hovered_token);
if (it == man_paths().end()) {
@ -406,11 +406,11 @@ void Editor::leave_event(Core::Event& event)
GUI::TextEditor::leave_event(event);
}
static HashMap<String, String>& include_paths()
static HashMap<DeprecatedString, DeprecatedString>& include_paths()
{
static HashMap<String, String> paths;
static HashMap<DeprecatedString, DeprecatedString> paths;
auto add_directory = [](String base, Optional<String> recursive, auto handle_directory) -> void {
auto add_directory = [](DeprecatedString base, Optional<DeprecatedString> recursive, auto handle_directory) -> void {
Core::DirIterator it(recursive.value_or(base), Core::DirIterator::Flags::SkipDots);
while (it.has_next()) {
auto path = it.next_full_path();
@ -434,7 +434,7 @@ static HashMap<String, String>& include_paths()
return paths;
}
void Editor::navigate_to_include_if_available(String path)
void Editor::navigate_to_include_if_available(DeprecatedString path)
{
auto it = include_paths().find(path);
if (it == include_paths().end()) {
@ -609,7 +609,7 @@ void Editor::on_identifier_click(const GUI::TextDocumentSpan& span)
if (!m_language_client)
return;
m_language_client->on_declaration_found = [](String const& file, size_t line, size_t column) {
m_language_client->on_declaration_found = [](DeprecatedString const& file, size_t line, size_t column) {
HackStudio::open_file(file, line, column);
};
m_language_client->search_declaration(code_document().file_path(), span.range.start().line(), span.range.start().column());
@ -713,7 +713,7 @@ void Editor::handle_function_parameters_hint_request()
if (!m_language_client)
return;
m_language_client->on_function_parameters_hint_result = [this](Vector<String> const& params, size_t argument_index) {
m_language_client->on_function_parameters_hint_result = [this](Vector<DeprecatedString> const& params, size_t argument_index) {
dbgln("on_function_parameters_hint_result");
StringBuilder html;

View file

@ -29,7 +29,7 @@ public:
virtual ~Editor() override = default;
Function<void()> on_focus;
Function<void(String)> on_open;
Function<void(DeprecatedString)> on_open;
EditorWrapper& wrapper();
EditorWrapper const& wrapper() const;
@ -71,8 +71,8 @@ private:
virtual void leave_event(Core::Event&) override;
virtual void keydown_event(GUI::KeyEvent&) override;
void show_documentation_tooltip_if_available(String const&, Gfx::IntPoint const& screen_location);
void navigate_to_include_if_available(String);
void show_documentation_tooltip_if_available(DeprecatedString const&, Gfx::IntPoint const& screen_location);
void navigate_to_include_if_available(DeprecatedString);
void on_navigatable_link_click(const GUI::TextDocumentSpan&);
void on_identifier_click(const GUI::TextDocumentSpan&);
@ -111,7 +111,7 @@ private:
explicit Editor();
String m_last_parsed_token;
DeprecatedString m_last_parsed_token;
GUI::TextPosition m_previous_text_position { 0, 0 };
bool m_hovering_editor { false };
bool m_hovering_clickable { false };

View file

@ -34,7 +34,7 @@ EditorWrapper::EditorWrapper()
set_current_editor_wrapper(this);
};
m_editor->on_open = [](String const& path) {
m_editor->on_open = [](DeprecatedString const& path) {
open_file(path);
};
@ -63,7 +63,7 @@ void EditorWrapper::set_mode_non_displayable()
editor().document().set_text("The contents of this file could not be displayed. Is it a binary file?"sv);
}
void EditorWrapper::set_filename(String const& filename)
void EditorWrapper::set_filename(DeprecatedString const& filename)
{
m_filename = filename;
update_title();
@ -74,7 +74,7 @@ void EditorWrapper::save()
{
if (filename().is_empty()) {
auto file_picker_action = GUI::CommonActions::make_save_as_action([&](auto&) {
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window(), "file"sv, "txt"sv, project_root().value());
Optional<DeprecatedString> save_path = GUI::FilePicker::get_save_filepath(window(), "file"sv, "txt"sv, project_root().value());
set_filename(save_path.value());
});
file_picker_action->activate();
@ -90,7 +90,7 @@ void EditorWrapper::update_diff()
m_hunks = Diff::parse_hunks(m_git_repo->unstaged_diff(filename()).value());
}
void EditorWrapper::set_project_root(String const& project_root)
void EditorWrapper::set_project_root(DeprecatedString const& project_root)
{
m_project_root = project_root;
auto result = GitRepo::try_to_create(*m_project_root);

View file

@ -37,12 +37,12 @@ public:
void set_mode_displayable();
void set_mode_non_displayable();
void set_debug_mode(bool);
void set_filename(String const&);
String const& filename() const { return m_filename; }
String const& filename_title() const { return m_filename_title; }
void set_filename(DeprecatedString const&);
DeprecatedString const& filename() const { return m_filename; }
DeprecatedString const& filename_title() const { return m_filename_title; }
Optional<String> const& project_root() const { return m_project_root; }
void set_project_root(String const& project_root);
Optional<DeprecatedString> const& project_root() const { return m_project_root; }
void set_project_root(DeprecatedString const& project_root);
GitRepo const* git_repo() const { return m_git_repo; }
@ -59,11 +59,11 @@ private:
void update_title();
String m_filename;
String m_filename_title;
DeprecatedString m_filename;
DeprecatedString m_filename_title;
RefPtr<Editor> m_editor;
Optional<String> m_project_root;
Optional<DeprecatedString> m_project_root;
RefPtr<GitRepo> m_git_repo;
Vector<Diff::Hunk> m_hunks;
};

View file

@ -17,9 +17,9 @@
namespace HackStudio {
struct Match {
String filename;
DeprecatedString filename;
GUI::TextRange range;
String text;
DeprecatedString text;
};
class SearchResultsModel final : public GUI::Model {
@ -39,7 +39,7 @@ public:
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return m_matches.size(); }
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; }
virtual String column_name(int column) const override
virtual DeprecatedString column_name(int column) const override
{
switch (column) {
case Column::Filename:

View file

@ -10,13 +10,13 @@
namespace HackStudio {
GMLPreviewWidget::GMLPreviewWidget(String const& gml_content)
GMLPreviewWidget::GMLPreviewWidget(DeprecatedString const& gml_content)
{
set_layout<GUI::VerticalBoxLayout>();
load_gml(gml_content);
}
void GMLPreviewWidget::load_gml(String const& gml)
void GMLPreviewWidget::load_gml(DeprecatedString const& gml)
{
remove_all_children();
@ -27,8 +27,8 @@ void GMLPreviewWidget::load_gml(String const& gml)
return;
}
load_from_gml(gml, [](String const& name) -> RefPtr<Core::Object> {
return GUI::Label::construct(String::formatted("{} is not registered as a GML element!", name));
load_from_gml(gml, [](DeprecatedString const& name) -> RefPtr<Core::Object> {
return GUI::Label::construct(DeprecatedString::formatted("{} is not registered as a GML element!", name));
});
if (children().is_empty()) {

View file

@ -14,10 +14,10 @@ namespace HackStudio {
class GMLPreviewWidget final : public GUI::Widget {
C_OBJECT(GMLPreviewWidget)
public:
void load_gml(String const&);
void load_gml(DeprecatedString const&);
private:
explicit GMLPreviewWidget(String const&);
explicit GMLPreviewWidget(DeprecatedString const&);
};
}

View file

@ -71,7 +71,7 @@ void DiffViewer::paint_event(GUI::PaintEvent& event)
}
}
void DiffViewer::draw_line(GUI::Painter& painter, String const& line, size_t y_offset, LinePosition line_position, LineType line_type)
void DiffViewer::draw_line(GUI::Painter& painter, DeprecatedString const& line, size_t y_offset, LinePosition line_position, LineType line_type)
{
size_t line_width = font().width(line);
@ -131,7 +131,7 @@ Gfx::IntRect DiffViewer::separator_rect() const
frame_inner_rect().height() };
}
void DiffViewer::set_content(String const& original, String const& diff)
void DiffViewer::set_content(DeprecatedString const& original, DeprecatedString const& diff)
{
m_original_lines = split_to_lines(original);
m_hunks = Diff::parse_hunks(diff);
@ -147,7 +147,7 @@ DiffViewer::DiffViewer()
setup_properties();
}
DiffViewer::DiffViewer(String const& original, String const& diff)
DiffViewer::DiffViewer(DeprecatedString const& original, DeprecatedString const& diff)
: m_original_lines(split_to_lines(original))
, m_hunks(Diff::parse_hunks(diff))
{
@ -161,10 +161,10 @@ void DiffViewer::setup_properties()
set_foreground_role(ColorRole::BaseText);
}
Vector<String> DiffViewer::split_to_lines(String const& text)
Vector<DeprecatedString> DiffViewer::split_to_lines(DeprecatedString const& text)
{
// NOTE: This is slightly different than text.split('\n')
Vector<String> lines;
Vector<DeprecatedString> 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/String.h>
#include <AK/DeprecatedString.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(String const& original, String const& diff);
void set_content(DeprecatedString const& original, DeprecatedString const& diff);
private:
DiffViewer(String const& original, String const& diff);
DiffViewer(DeprecatedString const& original, DeprecatedString const& diff);
DiffViewer();
void setup_properties();
@ -43,9 +43,9 @@ private:
Missing,
};
void draw_line(GUI::Painter&, String const& line, size_t y_offset, LinePosition, LineType);
void draw_line(GUI::Painter&, DeprecatedString const& line, size_t y_offset, LinePosition, LineType);
static Vector<String> split_to_lines(String const& text);
static Vector<DeprecatedString> split_to_lines(DeprecatedString const& text);
static Gfx::Color red_background();
static Gfx::Color green_background();
@ -55,7 +55,7 @@ private:
Gfx::IntRect separator_rect() const;
Vector<String> m_original_lines;
Vector<DeprecatedString> m_original_lines;
Vector<Diff::Hunk> m_hunks;
};
}

View file

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

View file

@ -14,12 +14,12 @@ namespace HackStudio {
class GitFilesModel final : public GUI::Model {
public:
static NonnullRefPtr<GitFilesModel> create(Vector<String>&& files);
static NonnullRefPtr<GitFilesModel> create(Vector<DeprecatedString>&& 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; }
virtual String column_name(int) const override
virtual DeprecatedString column_name(int) const override
{
return "";
}
@ -29,7 +29,7 @@ public:
virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex&) const override;
private:
explicit GitFilesModel(Vector<String>&& files);
Vector<String> m_files;
explicit GitFilesModel(Vector<DeprecatedString>&& files);
Vector<DeprecatedString> m_files;
};
}

View file

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

View file

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

View file

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

View file

@ -21,7 +21,7 @@
namespace HackStudio {
GitWidget::GitWidget(String const& repo_root)
GitWidget::GitWidget(DeprecatedString const& repo_root)
: m_repo_root(repo_root)
{
set_layout<GUI::HorizontalBoxLayout>();
@ -117,7 +117,7 @@ void GitWidget::refresh()
m_staged_files->set_model(GitFilesModel::create(m_git_repo->staged_files()));
}
void GitWidget::stage_file(String const& file)
void GitWidget::stage_file(DeprecatedString const& file)
{
dbgln("staging: {}", file);
bool rc = m_git_repo->stage(file);
@ -125,7 +125,7 @@ void GitWidget::stage_file(String const& file)
refresh();
}
void GitWidget::unstage_file(String const& file)
void GitWidget::unstage_file(DeprecatedString const& file)
{
dbgln("unstaging: {}", file);
bool rc = m_git_repo->unstage(file);
@ -153,7 +153,7 @@ void GitWidget::set_view_diff_callback(ViewDiffCallback callback)
m_view_diff_callback = move(callback);
}
void GitWidget::show_diff(String const& file_path)
void GitWidget::show_diff(DeprecatedString const& file_path)
{
if (!m_git_repo->is_tracked(file_path)) {
auto file = Core::File::construct(file_path);
@ -163,7 +163,7 @@ void GitWidget::show_diff(String const& file_path)
}
auto content = file->read_all();
String content_string((char*)content.data(), content.size());
DeprecatedString content_string((char*)content.data(), content.size());
m_view_diff_callback("", Diff::generate_only_additions(content_string));
return;
}
@ -173,7 +173,7 @@ void GitWidget::show_diff(String const& file_path)
m_view_diff_callback(original_content.value(), diff.value());
}
void GitWidget::change_repo(String const& repo_root)
void GitWidget::change_repo(DeprecatedString const& repo_root)
{
m_repo_root = repo_root;
m_git_repo = nullptr;

View file

@ -14,7 +14,7 @@
namespace HackStudio {
using ViewDiffCallback = Function<void(String const& original_content, String const& diff)>;
using ViewDiffCallback = Function<void(DeprecatedString const& original_content, DeprecatedString 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(String const& repo_root);
void change_repo(DeprecatedString const& repo_root);
private:
explicit GitWidget(String const& repo_root);
explicit GitWidget(DeprecatedString const& repo_root);
bool initialize();
bool initialize_if_needed();
void stage_file(String const&);
void unstage_file(String const&);
void stage_file(DeprecatedString const&);
void unstage_file(DeprecatedString const&);
void commit();
void show_diff(String const&);
void show_diff(DeprecatedString const&);
String m_repo_root;
DeprecatedString m_repo_root;
RefPtr<GitFilesView> m_unstaged_files;
RefPtr<GitFilesView> m_staged_files;
RefPtr<GitRepo> m_git_repo;

View file

@ -9,17 +9,17 @@
#include "EditorWrapper.h"
#include "LanguageClients/ConnectionsToServer.h"
#include "Project.h"
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <LibGUI/TextEditor.h>
namespace HackStudio {
GUI::TextEditor& current_editor();
void open_file(String const&);
void open_file(DeprecatedString const&);
RefPtr<EditorWrapper> current_editor_wrapper();
void open_file(String const&, size_t line, size_t column);
void open_file(DeprecatedString const&, size_t line, size_t column);
Project& project();
String currently_open_file();
DeprecatedString currently_open_file();
void set_current_editor_wrapper(RefPtr<EditorWrapper>);
void update_editor_window_title();
void for_each_open_file(Function<void(ProjectFile const&)>);

View file

@ -78,7 +78,7 @@
namespace HackStudio {
HackStudioWidget::HackStudioWidget(String path_to_project)
HackStudioWidget::HackStudioWidget(DeprecatedString path_to_project)
: m_editor_font(read_editor_font_from_config())
{
set_fill_with_background_color(true);
@ -175,7 +175,7 @@ HackStudioWidget::HackStudioWidget(String path_to_project)
return;
if (event.event_path.starts_with(project().root_path())) {
String relative_path = LexicalPath::relative_path(event.event_path, project().root_path());
DeprecatedString relative_path = LexicalPath::relative_path(event.event_path, project().root_path());
handle_external_file_deletion(relative_path);
} else {
handle_external_file_deletion(event.event_path);
@ -213,7 +213,7 @@ void HackStudioWidget::on_action_tab_change()
}
}
Vector<String> HackStudioWidget::read_recent_projects()
Vector<DeprecatedString> HackStudioWidget::read_recent_projects()
{
auto json = Config::read_string("HackStudio"sv, "Global"sv, "RecentProjects"sv);
AK::JsonParser parser(json);
@ -225,7 +225,7 @@ Vector<String> HackStudioWidget::read_recent_projects()
if (!value.is_array())
return {};
Vector<String> paths;
Vector<DeprecatedString> paths;
for (auto& json_value : value.as_array().values()) {
if (!json_value.is_string())
return {};
@ -235,7 +235,7 @@ Vector<String> HackStudioWidget::read_recent_projects()
return paths;
}
void HackStudioWidget::open_project(String const& root_path)
void HackStudioWidget::open_project(DeprecatedString const& root_path)
{
if (warn_unsaved_changes("There are unsaved changes, do you want to save before closing current project?") == ContinueDecision::No)
return;
@ -283,16 +283,16 @@ void HackStudioWidget::open_project(String const& root_path)
update_recent_projects_submenu();
}
Vector<String> HackStudioWidget::selected_file_paths() const
Vector<DeprecatedString> HackStudioWidget::selected_file_paths() const
{
Vector<String> files;
Vector<DeprecatedString> files;
m_project_tree_view->selection().for_each_index([&](const GUI::ModelIndex& index) {
String sub_path = index.data().as_string();
DeprecatedString sub_path = index.data().as_string();
GUI::ModelIndex parent_or_invalid = index.parent();
while (parent_or_invalid.is_valid()) {
sub_path = String::formatted("{}/{}", parent_or_invalid.data().as_string(), sub_path);
sub_path = DeprecatedString::formatted("{}/{}", parent_or_invalid.data().as_string(), sub_path);
parent_or_invalid = parent_or_invalid.parent();
}
@ -302,9 +302,9 @@ Vector<String> HackStudioWidget::selected_file_paths() const
return files;
}
bool HackStudioWidget::open_file(String const& full_filename, size_t line, size_t column)
bool HackStudioWidget::open_file(DeprecatedString const& full_filename, size_t line, size_t column)
{
String filename = full_filename;
DeprecatedString filename = full_filename;
if (full_filename.starts_with(project().root_path())) {
filename = LexicalPath::relative_path(full_filename, project().root_path());
}
@ -369,7 +369,7 @@ bool HackStudioWidget::open_file(String const& full_filename, size_t line, size_
set_edit_mode(EditMode::Text);
String relative_file_path = filename;
DeprecatedString relative_file_path = filename;
if (filename.starts_with(m_project->root_path()))
relative_file_path = filename.substring(m_project->root_path().length() + 1);
@ -388,16 +388,16 @@ bool HackStudioWidget::open_file(String const& full_filename, size_t line, size_
return true;
}
void HackStudioWidget::close_file_in_all_editors(String const& filename)
void HackStudioWidget::close_file_in_all_editors(DeprecatedString const& filename)
{
m_open_files.remove(filename);
m_open_files_vector.remove_all_matching(
[&filename](String const& element) { return element == filename; });
[&filename](DeprecatedString const& element) { return element == filename; });
for (auto& editor_wrapper : m_all_editor_wrappers) {
Editor& editor = editor_wrapper.editor();
String editor_file_path = editor.code_document().file_path();
String relative_editor_file_path = LexicalPath::relative_path(editor_file_path, project().root_path());
DeprecatedString editor_file_path = editor.code_document().file_path();
DeprecatedString relative_editor_file_path = LexicalPath::relative_path(editor_file_path, project().root_path());
if (relative_editor_file_path == filename) {
if (m_open_files_vector.is_empty()) {
@ -514,41 +514,41 @@ NonnullRefPtr<GUI::Menu> HackStudioWidget::create_project_tree_view_context_menu
return project_tree_view_context_menu;
}
NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_file_action(String const& label, String const& icon, String const& extension)
NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_file_action(DeprecatedString const& label, DeprecatedString const& icon, DeprecatedString const& extension)
{
return GUI::Action::create(label, Gfx::Bitmap::try_load_from_file(icon).release_value_but_fixme_should_propagate_errors(), [this, extension](const GUI::Action&) {
String filename;
DeprecatedString filename;
if (GUI::InputBox::show(window(), filename, "Enter name of new file:"sv, "Add new file to project"sv) != GUI::InputBox::ExecResult::OK)
return;
if (!extension.is_empty() && !filename.ends_with(String::formatted(".{}", extension))) {
filename = String::formatted("{}.{}", filename, extension);
if (!extension.is_empty() && !filename.ends_with(DeprecatedString::formatted(".{}", extension))) {
filename = DeprecatedString::formatted("{}.{}", filename, extension);
}
auto path_to_selected = selected_file_paths();
String filepath;
DeprecatedString filepath;
if (!path_to_selected.is_empty()) {
VERIFY(Core::File::exists(path_to_selected.first()));
LexicalPath selected(path_to_selected.first());
String dir_path;
DeprecatedString dir_path;
if (Core::File::is_directory(selected.string()))
dir_path = selected.string();
else
dir_path = selected.dirname();
filepath = String::formatted("{}/", dir_path);
filepath = DeprecatedString::formatted("{}/", dir_path);
}
filepath = String::formatted("{}{}", filepath, filename);
filepath = DeprecatedString::formatted("{}{}", filepath, filename);
auto file = Core::File::construct(filepath);
if (!file->open((Core::OpenMode)(Core::OpenMode::WriteOnly | Core::OpenMode::MustBeNew))) {
GUI::MessageBox::show(window(), String::formatted("Failed to create '{}'", filepath), "Error"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), DeprecatedString::formatted("Failed to create '{}'", filepath), "Error"sv, GUI::MessageBox::Type::Error);
return;
}
open_file(filepath);
@ -558,7 +558,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_file_action(String const
NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_directory_action()
{
return GUI::Action::create("&Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"sv).release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) {
String directory_name;
DeprecatedString directory_name;
if (GUI::InputBox::show(window(), directory_name, "Enter name of new directory:"sv, "Add new folder to project"sv) != GUI::InputBox::ExecResult::OK)
return;
@ -567,17 +567,17 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_directory_action()
if (!path_to_selected.is_empty()) {
LexicalPath selected(path_to_selected.first());
String dir_path;
DeprecatedString dir_path;
if (Core::File::is_directory(selected.string()))
dir_path = selected.string();
else
dir_path = selected.dirname();
directory_name = String::formatted("{}/{}", dir_path, directory_name);
directory_name = DeprecatedString::formatted("{}/{}", dir_path, directory_name);
}
auto formatted_dir_name = LexicalPath::canonicalized_path(String::formatted("{}/{}", m_project->model().root_path(), directory_name));
auto formatted_dir_name = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", m_project->model().root_path(), directory_name));
int rc = mkdir(formatted_dir_name.characters(), 0755);
if (rc < 0) {
GUI::MessageBox::show(window(), "Failed to create new directory"sv, "Error"sv, GUI::MessageBox::Type::Error);
@ -616,7 +616,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_copy_relative_path_action()
auto copy_relative_path_action = GUI::Action::create("Copy &Relative Path", [this](const GUI::Action&) {
auto paths = selected_file_paths();
VERIFY(!paths.is_empty());
auto paths_string = String::join('\n', paths);
auto paths_string = DeprecatedString::join('\n', paths);
GUI::Clipboard::the().set_plain_text(paths_string);
});
copy_relative_path_action->set_enabled(true);
@ -630,10 +630,10 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_copy_full_path_action()
auto copy_full_path_action = GUI::Action::create("Copy &Full Path", [this](const GUI::Action&) {
auto paths = selected_file_paths();
VERIFY(!paths.is_empty());
Vector<String> full_paths;
Vector<DeprecatedString> full_paths;
for (auto& path : paths)
full_paths.append(get_absolute_path(path));
auto paths_string = String::join('\n', full_paths);
auto paths_string = DeprecatedString::join('\n', full_paths);
GUI::Clipboard::the().set_plain_text(paths_string);
});
copy_full_path_action->set_enabled(true);
@ -649,12 +649,12 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action()
if (files.is_empty())
return;
String message;
DeprecatedString message;
if (files.size() == 1) {
LexicalPath file(files[0]);
message = String::formatted("Really remove {} from disk?", file.basename());
message = DeprecatedString::formatted("Really remove {} from disk?", file.basename());
} else {
message = String::formatted("Really remove {} files from disk?", files.size());
message = DeprecatedString::formatted("Really remove {} files from disk?", files.size());
}
auto result = GUI::MessageBox::show(window(),
@ -669,7 +669,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action()
struct stat st;
if (lstat(file.characters(), &st) < 0) {
GUI::MessageBox::show(window(),
String::formatted("lstat ({}) failed: {}", file, strerror(errno)),
DeprecatedString::formatted("lstat ({}) failed: {}", file, strerror(errno)),
"Removal failed"sv,
GUI::MessageBox::Type::Error);
break;
@ -680,12 +680,12 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_delete_action()
auto& error = result.error();
if (is_directory) {
GUI::MessageBox::show(window(),
String::formatted("Removing directory {} from the project failed: {}", error.file, static_cast<Error const&>(error)),
DeprecatedString::formatted("Removing directory {} from the project failed: {}", error.file, static_cast<Error const&>(error)),
"Removal failed"sv,
GUI::MessageBox::Type::Error);
} else {
GUI::MessageBox::show(window(),
String::formatted("Removing file {} from the project failed: {}", error.file, static_cast<Error const&>(error)),
DeprecatedString::formatted("Removing file {} from the project failed: {}", error.file, static_cast<Error const&>(error)),
"Removal failed"sv,
GUI::MessageBox::Type::Error);
}
@ -890,7 +890,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_save_as_action()
auto const old_filename = current_editor_wrapper().filename();
LexicalPath const old_path(old_filename);
Optional<String> save_path = GUI::FilePicker::get_save_filepath(window(),
Optional<DeprecatedString> save_path = GUI::FilePicker::get_save_filepath(window(),
old_filename.is_null() ? "Untitled"sv : old_path.title(),
old_filename.is_null() ? "txt"sv : old_path.extension(),
Core::File::absolute_path(old_path.dirname()));
@ -898,7 +898,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_save_as_action()
return;
}
String const relative_file_path = LexicalPath::relative_path(save_path.value(), m_project->root_path());
DeprecatedString const relative_file_path = LexicalPath::relative_path(save_path.value(), m_project->root_path());
if (current_editor_wrapper().filename().is_null()) {
current_editor_wrapper().set_filename(relative_file_path);
} else {
@ -987,7 +987,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_debug_action()
{
return GUI::Action::create("&Debug", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-run.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
if (!Core::File::exists(get_project_executable_path())) {
GUI::MessageBox::show(window(), String::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), DeprecatedString::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error"sv, GUI::MessageBox::Type::Error);
return;
}
if (Debugger::the().session()) {
@ -1078,7 +1078,7 @@ void HackStudioWidget::initialize_debugger()
});
}
String HackStudioWidget::get_full_path_of_serenity_source(String const& file)
DeprecatedString HackStudioWidget::get_full_path_of_serenity_source(DeprecatedString const& file)
{
auto path_parts = LexicalPath(file).parts();
while (!path_parts.is_empty() && path_parts[0] == "..") {
@ -1088,10 +1088,10 @@ String HackStudioWidget::get_full_path_of_serenity_source(String const& file)
relative_path_builder.join('/', path_parts);
constexpr char SERENITY_LIBS_PREFIX[] = "/usr/src/serenity";
LexicalPath serenity_sources_base(SERENITY_LIBS_PREFIX);
return String::formatted("{}/{}", serenity_sources_base, relative_path_builder.to_string());
return DeprecatedString::formatted("{}/{}", serenity_sources_base, relative_path_builder.to_string());
}
String HackStudioWidget::get_absolute_path(String const& path) const
DeprecatedString HackStudioWidget::get_absolute_path(DeprecatedString const& path) const
{
// TODO: We can probably do a more specific condition here, something like
// "if (file.starts_with("../Libraries/") || file.starts_with("../AK/"))"
@ -1101,9 +1101,9 @@ String HackStudioWidget::get_absolute_path(String const& path) const
return m_project->to_absolute_path(path);
}
RefPtr<EditorWrapper> HackStudioWidget::get_editor_of_file(String const& filename)
RefPtr<EditorWrapper> HackStudioWidget::get_editor_of_file(DeprecatedString const& filename)
{
String file_path = filename;
DeprecatedString file_path = filename;
if (filename.starts_with("../"sv)) {
file_path = get_full_path_of_serenity_source(filename);
@ -1114,19 +1114,19 @@ RefPtr<EditorWrapper> HackStudioWidget::get_editor_of_file(String const& filenam
return current_editor_wrapper();
}
String HackStudioWidget::get_project_executable_path() const
DeprecatedString HackStudioWidget::get_project_executable_path() const
{
// FIXME: Dumb heuristic ahead!
// e.g /my/project => /my/project/project
// TODO: Perhaps a Makefile rule for getting the value of $(PROGRAM) would be better?
return String::formatted("{}/{}", m_project->root_path(), LexicalPath::basename(m_project->root_path()));
return DeprecatedString::formatted("{}/{}", m_project->root_path(), LexicalPath::basename(m_project->root_path()));
}
void HackStudioWidget::build()
{
auto result = m_project_builder->build(active_file());
if (result.is_error()) {
GUI::MessageBox::show(window(), String::formatted("{}", result.error()), "Build failed"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), DeprecatedString::formatted("{}", result.error()), "Build failed"sv, GUI::MessageBox::Type::Error);
m_build_action->set_enabled(true);
m_stop_action->set_enabled(false);
} else {
@ -1138,7 +1138,7 @@ void HackStudioWidget::run()
{
auto result = m_project_builder->run(active_file());
if (result.is_error()) {
GUI::MessageBox::show(window(), String::formatted("{}", result.error()), "Run failed"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), DeprecatedString::formatted("{}", result.error()), "Run failed"sv, GUI::MessageBox::Type::Error);
m_run_action->set_enabled(true);
m_stop_action->set_enabled(false);
} else {
@ -1172,7 +1172,7 @@ void HackStudioWidget::set_current_editor_wrapper(RefPtr<EditorWrapper> editor_w
update_statusbar();
}
void HackStudioWidget::file_renamed(String const& old_name, String const& new_name)
void HackStudioWidget::file_renamed(DeprecatedString const& old_name, DeprecatedString const& new_name)
{
auto editor_or_none = m_all_editor_wrappers.first_matching([&old_name](auto const& editor) {
return editor->filename() == old_name;
@ -1242,7 +1242,7 @@ void HackStudioWidget::configure_project_tree_view()
void HackStudioWidget::create_open_files_view(GUI::Widget& parent)
{
m_open_files_view = parent.add<GUI::ListView>();
auto open_files_model = GUI::ItemListModel<String>::create(m_open_files_vector);
auto open_files_model = GUI::ItemListModel<DeprecatedString>::create(m_open_files_vector);
m_open_files_view->set_model(open_files_model);
m_open_files_view->on_activation = [this](auto& index) {
@ -1554,17 +1554,17 @@ void HackStudioWidget::update_statusbar()
{
StringBuilder builder;
if (current_editor().has_selection()) {
String selected_text = current_editor().selected_text();
DeprecatedString selected_text = current_editor().selected_text();
auto word_count = current_editor().number_of_selected_words();
builder.appendff("Selected: {} {} ({} {})", selected_text.length(), selected_text.length() == 1 ? "character" : "characters", word_count, word_count != 1 ? "words" : "word");
}
m_statusbar->set_text(0, builder.to_string());
m_statusbar->set_text(1, current_editor_wrapper().editor().code_document().language_name());
m_statusbar->set_text(2, String::formatted("Ln {}, Col {}", current_editor().cursor().line() + 1, current_editor().cursor().column()));
m_statusbar->set_text(2, DeprecatedString::formatted("Ln {}, Col {}", current_editor().cursor().line() + 1, current_editor().cursor().column()));
}
void HackStudioWidget::handle_external_file_deletion(String const& filepath)
void HackStudioWidget::handle_external_file_deletion(DeprecatedString const& filepath)
{
close_file_in_all_editors(filepath);
}
@ -1602,7 +1602,7 @@ HackStudioWidget::~HackStudioWidget()
stop_debugger_if_running();
}
HackStudioWidget::ContinueDecision HackStudioWidget::warn_unsaved_changes(String const& prompt)
HackStudioWidget::ContinueDecision HackStudioWidget::warn_unsaved_changes(DeprecatedString const& prompt)
{
if (!any_document_is_dirty())
return ContinueDecision::Yes;
@ -1647,7 +1647,7 @@ void HackStudioWidget::update_tree_view()
void HackStudioWidget::update_window_title()
{
window()->set_title(String::formatted("{} - {} - Hack Studio", m_current_editor_wrapper->filename_title(), m_project->name()));
window()->set_title(DeprecatedString::formatted("{} - {} - Hack Studio", m_current_editor_wrapper->filename_title(), m_project->name()));
window()->set_modified(any_document_is_dirty());
}
@ -1725,7 +1725,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_open_project_configuration_a
if (!Core::File::exists(absolute_config_file_path)) {
if (Core::File::exists(parent_directory) && !Core::File::is_directory(parent_directory)) {
GUI::MessageBox::show_error(window(), String::formatted("Cannot create the '{}' directory because there is already a file with that name", parent_directory));
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Cannot create the '{}' directory because there is already a file with that name", parent_directory));
return;
}
@ -1787,7 +1787,7 @@ void HackStudioWidget::change_editor_font(RefPtr<Gfx::Font> font)
Config::write_i32("HackStudio"sv, "EditorFont"sv, "Size"sv, m_editor_font->presentation_size());
}
void HackStudioWidget::open_coredump(String const& coredump_path)
void HackStudioWidget::open_coredump(DeprecatedString const& coredump_path)
{
open_project("/usr/src/serenity");
m_mode = Mode::Coredump;

View file

@ -38,8 +38,8 @@ class HackStudioWidget : public GUI::Widget {
public:
virtual ~HackStudioWidget() override;
bool open_file(String const& filename, size_t line = 0, size_t column = 0);
void close_file_in_all_editors(String const& filename);
bool open_file(DeprecatedString const& filename, size_t line = 0, size_t column = 0);
void close_file_in_all_editors(DeprecatedString const& filename);
void update_actions();
Project& project();
@ -53,7 +53,7 @@ public:
GUI::TabWidget& current_editor_tab_widget();
GUI::TabWidget const& current_editor_tab_widget() const;
String const& active_file() const { return m_current_editor_wrapper->filename(); }
DeprecatedString const& active_file() const { return m_current_editor_wrapper->filename(); }
void initialize_menubar(GUI::Window&);
Locator& locator()
@ -66,18 +66,18 @@ public:
No,
Yes
};
ContinueDecision warn_unsaved_changes(String const& prompt);
ContinueDecision warn_unsaved_changes(DeprecatedString const& prompt);
enum class Mode {
Code,
Coredump
};
void open_coredump(String const& coredump_path);
void open_coredump(DeprecatedString const& coredump_path);
void for_each_open_file(Function<void(ProjectFile const&)>);
bool semantic_syntax_highlighting_is_enabled() const;
static Vector<String> read_recent_projects();
static Vector<DeprecatedString> read_recent_projects();
void update_current_editor_title();
void update_window_title();
@ -85,12 +85,12 @@ public:
private:
static constexpr size_t recent_projects_history_size = 15;
static String get_full_path_of_serenity_source(String const& file);
String get_absolute_path(String const&) const;
Vector<String> selected_file_paths() const;
static DeprecatedString get_full_path_of_serenity_source(DeprecatedString const& file);
DeprecatedString get_absolute_path(DeprecatedString const&) const;
Vector<DeprecatedString> selected_file_paths() const;
HackStudioWidget(String path_to_project);
void open_project(String const& root_path);
HackStudioWidget(DeprecatedString path_to_project);
void open_project(DeprecatedString const& root_path);
enum class EditMode {
Text,
@ -100,7 +100,7 @@ private:
void set_edit_mode(EditMode);
NonnullRefPtr<GUI::Menu> create_project_tree_view_context_menu();
NonnullRefPtr<GUI::Action> create_new_file_action(String const& label, String const& icon, String const& extension);
NonnullRefPtr<GUI::Action> create_new_file_action(DeprecatedString const& label, DeprecatedString const& icon, DeprecatedString const& extension);
NonnullRefPtr<GUI::Action> create_new_directory_action();
NonnullRefPtr<GUI::Action> create_open_selected_action();
NonnullRefPtr<GUI::Action> create_open_selected_in_new_tab_action();
@ -131,15 +131,15 @@ private:
void add_new_editor_tab_widget(GUI::Widget& parent);
void add_new_editor(GUI::TabWidget& parent);
RefPtr<EditorWrapper> get_editor_of_file(String const& filename);
String get_project_executable_path() const;
RefPtr<EditorWrapper> get_editor_of_file(DeprecatedString const& filename);
DeprecatedString get_project_executable_path() const;
void on_action_tab_change();
void reveal_action_tab(GUI::Widget&);
void initialize_debugger();
void update_statusbar();
void handle_external_file_deletion(String const& filepath);
void handle_external_file_deletion(DeprecatedString const& filepath);
void stop_debugger_if_running();
void close_current_project();
@ -164,10 +164,10 @@ private:
void update_gml_preview();
void update_tree_view();
void on_cursor_change();
void file_renamed(String const& old_name, String const& new_name);
void file_renamed(DeprecatedString const& old_name, DeprecatedString const& new_name);
struct ProjectLocation {
String filename;
DeprecatedString filename;
size_t line { 0 };
size_t column { 0 };
};
@ -180,9 +180,9 @@ private:
NonnullRefPtrVector<GUI::TabWidget> m_all_editor_tab_widgets;
RefPtr<GUI::TabWidget> m_current_editor_tab_widget;
HashMap<String, NonnullRefPtr<ProjectFile>> m_open_files;
HashMap<DeprecatedString, NonnullRefPtr<ProjectFile>> m_open_files;
RefPtr<Core::FileWatcher> m_file_watcher;
Vector<String> m_open_files_vector; // NOTE: This contains the keys from m_open_files and m_file_watchers
Vector<DeprecatedString> m_open_files_vector; // NOTE: This contains the keys from m_open_files and m_file_watchers
OwnPtr<Project> m_project;

View file

@ -37,7 +37,7 @@ Language language_from_file(LexicalPath const& file)
return Language::Unknown;
}
Language language_from_name(String const& name)
Language language_from_name(DeprecatedString const& name)
{
if (name == "Cpp")
return Language::Cpp;
@ -51,7 +51,7 @@ Language language_from_name(String const& name)
return Language::Unknown;
}
String language_name_from_file(LexicalPath const& file)
DeprecatedString language_name_from_file(LexicalPath const& file)
{
if (file.title() == "COMMIT_EDITMSG")
return "GitCommit";

View file

@ -6,8 +6,8 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/LexicalPath.h>
#include <AK/String.h>
namespace HackStudio {
enum class Language {
@ -24,7 +24,7 @@ enum class Language {
};
Language language_from_file(LexicalPath const&);
Language language_from_name(String const&);
String language_name_from_file(LexicalPath const&);
Language language_from_name(DeprecatedString const&);
DeprecatedString language_name_from_file(LexicalPath const&);
}

View file

@ -8,7 +8,7 @@
#include "HackStudio.h"
#include "ProjectDeclarations.h"
#include "ToDoEntries.h"
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/Vector.h>
#include <LibGUI/Notification.h>
@ -32,7 +32,7 @@ void ConnectionToServer::declaration_location(CodeComprehension::ProjectLocation
m_current_language_client->declaration_found(location.file, location.line, location.column);
}
void ConnectionToServer::parameters_hint_result(Vector<String> const& params, int argument_index)
void ConnectionToServer::parameters_hint_result(Vector<DeprecatedString> const& params, int argument_index)
{
if (!m_current_language_client) {
dbgln("Language Server connection has no attached language client");
@ -60,35 +60,35 @@ void ConnectionToServer::die()
m_wrapper->on_crash();
}
void LanguageClient::open_file(String const& path, int fd)
void LanguageClient::open_file(DeprecatedString const& path, int fd)
{
if (!m_connection_wrapper.connection())
return;
m_connection_wrapper.connection()->async_file_opened(path, fd);
}
void LanguageClient::set_file_content(String const& path, String const& content)
void LanguageClient::set_file_content(DeprecatedString const& path, DeprecatedString const& content)
{
if (!m_connection_wrapper.connection())
return;
m_connection_wrapper.connection()->async_set_file_content(path, content);
}
void LanguageClient::insert_text(String const& path, String const& text, size_t line, size_t column)
void LanguageClient::insert_text(DeprecatedString const& path, DeprecatedString const& text, size_t line, size_t column)
{
if (!m_connection_wrapper.connection())
return;
m_connection_wrapper.connection()->async_file_edit_insert_text(path, text, line, column);
}
void LanguageClient::remove_text(String const& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column)
void LanguageClient::remove_text(DeprecatedString const& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column)
{
if (!m_connection_wrapper.connection())
return;
m_connection_wrapper.connection()->async_file_edit_remove_text(path, from_line, from_column, to_line, to_column);
}
void LanguageClient::request_autocomplete(String const& path, size_t cursor_line, size_t cursor_column)
void LanguageClient::request_autocomplete(DeprecatedString const& path, size_t cursor_line, size_t cursor_column)
{
if (!m_connection_wrapper.connection())
return;
@ -118,19 +118,19 @@ bool LanguageClient::is_active_client() const
return m_connection_wrapper.connection()->active_client() == this;
}
HashMap<String, NonnullOwnPtr<ConnectionToServerWrapper>> ConnectionToServerInstances::s_instance_for_language;
HashMap<DeprecatedString, NonnullOwnPtr<ConnectionToServerWrapper>> ConnectionToServerInstances::s_instance_for_language;
void ConnectionToServer::declarations_in_document(String const& filename, Vector<CodeComprehension::Declaration> const& declarations)
void ConnectionToServer::declarations_in_document(DeprecatedString const& filename, Vector<CodeComprehension::Declaration> const& declarations)
{
ProjectDeclarations::the().set_declared_symbols(filename, declarations);
}
void ConnectionToServer::todo_entries_in_document(String const& filename, Vector<CodeComprehension::TodoEntry> const& todo_entries)
void ConnectionToServer::todo_entries_in_document(DeprecatedString const& filename, Vector<CodeComprehension::TodoEntry> const& todo_entries)
{
ToDoEntries::the().set_entries(filename, move(todo_entries));
}
void LanguageClient::search_declaration(String const& path, size_t line, size_t column)
void LanguageClient::search_declaration(DeprecatedString const& path, size_t line, size_t column)
{
if (!m_connection_wrapper.connection())
return;
@ -138,7 +138,7 @@ void LanguageClient::search_declaration(String const& path, size_t line, size_t
m_connection_wrapper.connection()->async_find_declaration(CodeComprehension::ProjectLocation { path, line, column });
}
void LanguageClient::get_parameters_hint(String const& path, size_t line, size_t column)
void LanguageClient::get_parameters_hint(DeprecatedString const& path, size_t line, size_t column)
{
if (!m_connection_wrapper.connection())
return;
@ -146,7 +146,7 @@ void LanguageClient::get_parameters_hint(String const& path, size_t line, size_t
m_connection_wrapper.connection()->async_get_parameters_hint(CodeComprehension::ProjectLocation { path, line, column });
}
void LanguageClient::get_tokens_info(String const& filename)
void LanguageClient::get_tokens_info(DeprecatedString const& filename)
{
if (!m_connection_wrapper.connection())
return;
@ -154,7 +154,7 @@ void LanguageClient::get_tokens_info(String const& filename)
m_connection_wrapper.connection()->async_get_tokens_info(filename);
}
void LanguageClient::declaration_found(String const& file, size_t line, size_t column) const
void LanguageClient::declaration_found(DeprecatedString const& file, size_t line, size_t column) const
{
if (!on_declaration_found) {
dbgln("on_declaration_found callback is not set");
@ -163,7 +163,7 @@ void LanguageClient::declaration_found(String const& file, size_t line, size_t c
on_declaration_found(file, line, column);
}
void LanguageClient::parameters_hint_result(Vector<String> const& params, size_t argument_index) const
void LanguageClient::parameters_hint_result(Vector<DeprecatedString> const& params, size_t argument_index) const
{
if (!on_function_parameters_hint_result) {
dbgln("on_function_parameters_hint_result callback is not set");
@ -172,17 +172,17 @@ void LanguageClient::parameters_hint_result(Vector<String> const& params, size_t
on_function_parameters_hint_result(params, argument_index);
}
void ConnectionToServerInstances::set_instance_for_language(String const& language_name, NonnullOwnPtr<ConnectionToServerWrapper>&& connection_wrapper)
void ConnectionToServerInstances::set_instance_for_language(DeprecatedString const& language_name, NonnullOwnPtr<ConnectionToServerWrapper>&& connection_wrapper)
{
s_instance_for_language.set(language_name, move(connection_wrapper));
}
void ConnectionToServerInstances::remove_instance_for_language(String const& language_name)
void ConnectionToServerInstances::remove_instance_for_language(DeprecatedString const& language_name)
{
s_instance_for_language.remove(language_name);
}
ConnectionToServerWrapper* ConnectionToServerInstances::get_instance_wrapper(String const& language_name)
ConnectionToServerWrapper* ConnectionToServerInstances::get_instance_wrapper(DeprecatedString const& language_name)
{
if (auto instance = s_instance_for_language.get(language_name); instance.has_value()) {
return const_cast<ConnectionToServerWrapper*>(instance.value());
@ -219,11 +219,11 @@ void ConnectionToServerWrapper::show_crash_notification() const
auto notification = GUI::Notification::construct();
notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png"sv).release_value_but_fixme_should_propagate_errors());
notification->set_title("Oops!");
notification->set_text(String::formatted("LanguageServer has crashed"));
notification->set_text(DeprecatedString::formatted("LanguageServer has crashed"));
notification->show();
}
ConnectionToServerWrapper::ConnectionToServerWrapper(String const& language_name, Function<NonnullRefPtr<ConnectionToServer>()> connection_creator)
ConnectionToServerWrapper::ConnectionToServerWrapper(DeprecatedString const& language_name, Function<NonnullRefPtr<ConnectionToServer>()> connection_creator)
: m_language(language_from_name(language_name))
, m_connection_creator(move(connection_creator))
{

View file

@ -31,7 +31,7 @@ class ConnectionToServer
friend class ConnectionToServerWrapper;
public:
ConnectionToServer(NonnullOwnPtr<Core::Stream::LocalSocket> socket, String const& project_path)
ConnectionToServer(NonnullOwnPtr<Core::Stream::LocalSocket> socket, DeprecatedString const& project_path)
: IPC::ConnectionToServer<LanguageClientEndpoint, LanguageServerEndpoint>(*this, move(socket))
{
m_project_path = project_path;
@ -39,7 +39,7 @@ public:
}
WeakPtr<LanguageClient> language_client() { return m_current_language_client; }
String const& project_path() const { return m_project_path; }
DeprecatedString const& project_path() const { return m_project_path; }
virtual void die() override;
@ -48,13 +48,13 @@ public:
protected:
virtual void auto_complete_suggestions(Vector<CodeComprehension::AutocompleteResultEntry> const&) override;
virtual void declaration_location(CodeComprehension::ProjectLocation const&) override;
virtual void declarations_in_document(String const&, Vector<CodeComprehension::Declaration> const&) override;
virtual void todo_entries_in_document(String const&, Vector<CodeComprehension::TodoEntry> const&) override;
virtual void parameters_hint_result(Vector<String> const&, int index) override;
virtual void declarations_in_document(DeprecatedString const&, Vector<CodeComprehension::Declaration> const&) override;
virtual void todo_entries_in_document(DeprecatedString const&, Vector<CodeComprehension::TodoEntry> const&) override;
virtual void parameters_hint_result(Vector<DeprecatedString> const&, int index) override;
virtual void tokens_info_result(Vector<CodeComprehension::TokenInfo> const&) override;
void set_wrapper(ConnectionToServerWrapper& wrapper) { m_wrapper = &wrapper; }
String m_project_path;
DeprecatedString m_project_path;
WeakPtr<LanguageClient> m_current_language_client;
ConnectionToServerWrapper* m_wrapper { nullptr };
};
@ -63,11 +63,11 @@ class ConnectionToServerWrapper {
AK_MAKE_NONCOPYABLE(ConnectionToServerWrapper);
public:
explicit ConnectionToServerWrapper(String const& language_name, Function<NonnullRefPtr<ConnectionToServer>()> connection_creator);
explicit ConnectionToServerWrapper(DeprecatedString const& language_name, Function<NonnullRefPtr<ConnectionToServer>()> connection_creator);
~ConnectionToServerWrapper() = default;
template<typename LanguageServerType>
static ConnectionToServerWrapper& get_or_create(String const& project_path);
static ConnectionToServerWrapper& get_or_create(DeprecatedString const& project_path);
Language language() const { return m_language; }
ConnectionToServer* connection();
@ -93,13 +93,13 @@ private:
class ConnectionToServerInstances {
public:
static void set_instance_for_language(String const& language_name, NonnullOwnPtr<ConnectionToServerWrapper>&& connection_wrapper);
static void remove_instance_for_language(String const& language_name);
static void set_instance_for_language(DeprecatedString const& language_name, NonnullOwnPtr<ConnectionToServerWrapper>&& connection_wrapper);
static void remove_instance_for_language(DeprecatedString const& language_name);
static ConnectionToServerWrapper* get_instance_wrapper(String const& language_name);
static ConnectionToServerWrapper* get_instance_wrapper(DeprecatedString const& language_name);
private:
static HashMap<String, NonnullOwnPtr<ConnectionToServerWrapper>> s_instance_for_language;
static HashMap<DeprecatedString, NonnullOwnPtr<ConnectionToServerWrapper>> s_instance_for_language;
};
class LanguageClient : public Weakable<LanguageClient> {
@ -128,23 +128,23 @@ public:
Language language() const { return m_connection_wrapper.language(); }
void set_active_client();
bool is_active_client() const;
virtual void open_file(String const& path, int fd);
virtual void set_file_content(String const& path, String const& content);
virtual void insert_text(String const& path, String const& text, size_t line, size_t column);
virtual void remove_text(String const& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column);
virtual void request_autocomplete(String const& path, size_t cursor_line, size_t cursor_column);
virtual void search_declaration(String const& path, size_t line, size_t column);
virtual void get_parameters_hint(String const& path, size_t line, size_t column);
virtual void get_tokens_info(String const& filename);
virtual void open_file(DeprecatedString const& path, int fd);
virtual void set_file_content(DeprecatedString const& path, DeprecatedString const& content);
virtual void insert_text(DeprecatedString const& path, DeprecatedString const& text, size_t line, size_t column);
virtual void remove_text(DeprecatedString const& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column);
virtual void request_autocomplete(DeprecatedString const& path, size_t cursor_line, size_t cursor_column);
virtual void search_declaration(DeprecatedString const& path, size_t line, size_t column);
virtual void get_parameters_hint(DeprecatedString const& path, size_t line, size_t column);
virtual void get_tokens_info(DeprecatedString const& filename);
void provide_autocomplete_suggestions(Vector<CodeComprehension::AutocompleteResultEntry> const&) const;
void declaration_found(String const& file, size_t line, size_t column) const;
void parameters_hint_result(Vector<String> const& params, size_t argument_index) const;
void declaration_found(DeprecatedString const& file, size_t line, size_t column) const;
void parameters_hint_result(Vector<DeprecatedString> const& params, size_t argument_index) const;
// Callbacks that get called when the result of a language server query is ready
Function<void(Vector<CodeComprehension::AutocompleteResultEntry>)> on_autocomplete_suggestions;
Function<void(String const&, size_t, size_t)> on_declaration_found;
Function<void(Vector<String> const&, size_t)> on_function_parameters_hint_result;
Function<void(DeprecatedString const&, size_t, size_t)> on_declaration_found;
Function<void(Vector<DeprecatedString> const&, size_t)> on_function_parameters_hint_result;
Function<void(Vector<CodeComprehension::TokenInfo> const&)> on_tokens_info_result;
private:
@ -153,13 +153,13 @@ private:
};
template<typename ConnectionToServerT>
static inline NonnullOwnPtr<LanguageClient> get_language_client(String const& project_path)
static inline NonnullOwnPtr<LanguageClient> get_language_client(DeprecatedString const& project_path)
{
return make<LanguageClient>(ConnectionToServerWrapper::get_or_create<ConnectionToServerT>(project_path));
}
template<typename LanguageServerType>
ConnectionToServerWrapper& ConnectionToServerWrapper::get_or_create(String const& project_path)
ConnectionToServerWrapper& ConnectionToServerWrapper::get_or_create(DeprecatedString const& project_path)
{
auto* wrapper = ConnectionToServerInstances::get_instance_wrapper(LanguageServerType::language_name());
if (wrapper)

View file

@ -12,22 +12,22 @@
#include <DevTools/HackStudio/LanguageServers/LanguageServerEndpoint.h>
#include <LibIPC/ConnectionToServer.h>
#define LANGUAGE_CLIENT(language_name_, socket_name) \
namespace language_name_ { \
class ConnectionToServer final : public HackStudio::ConnectionToServer { \
IPC_CLIENT_CONNECTION(ConnectionToServer, "/tmp/session/%sid/portal/language/" socket_name) \
public: \
static char const* language_name() \
{ \
return #language_name_; \
} \
\
private: \
ConnectionToServer(NonnullOwnPtr<Core::Stream::LocalSocket> socket, String const& project_path) \
: HackStudio::ConnectionToServer(move(socket), project_path) \
{ \
} \
}; \
#define LANGUAGE_CLIENT(language_name_, socket_name) \
namespace language_name_ { \
class ConnectionToServer final : public HackStudio::ConnectionToServer { \
IPC_CLIENT_CONNECTION(ConnectionToServer, "/tmp/session/%sid/portal/language/" socket_name) \
public: \
static char const* language_name() \
{ \
return #language_name_; \
} \
\
private: \
ConnectionToServer(NonnullOwnPtr<Core::Stream::LocalSocket> socket, DeprecatedString const& project_path) \
: HackStudio::ConnectionToServer(move(socket), project_path) \
{ \
} \
}; \
}
namespace LanguageClients {

View file

@ -27,7 +27,7 @@ void ConnectionFromClient::die()
exit(0);
}
void ConnectionFromClient::greet(String const& project_root)
void ConnectionFromClient::greet(DeprecatedString const& project_root)
{
m_filedb.set_project_root(project_root);
if (unveil(project_root.characters(), "r") < 0) {
@ -40,7 +40,7 @@ void ConnectionFromClient::greet(String const& project_root)
}
}
void ConnectionFromClient::file_opened(String const& filename, IPC::File const& file)
void ConnectionFromClient::file_opened(DeprecatedString const& filename, IPC::File const& file)
{
if (m_filedb.is_open(filename)) {
return;
@ -49,7 +49,7 @@ void ConnectionFromClient::file_opened(String const& filename, IPC::File const&
m_autocomplete_engine->file_opened(filename);
}
void ConnectionFromClient::file_edit_insert_text(String const& filename, String const& text, i32 start_line, i32 start_column)
void ConnectionFromClient::file_edit_insert_text(DeprecatedString const& filename, DeprecatedString const& text, i32 start_line, i32 start_column)
{
dbgln_if(LANGUAGE_SERVER_DEBUG, "InsertText for file: {}", filename);
dbgln_if(LANGUAGE_SERVER_DEBUG, "Text: {}", text);
@ -58,7 +58,7 @@ void ConnectionFromClient::file_edit_insert_text(String const& filename, String
m_autocomplete_engine->on_edit(filename);
}
void ConnectionFromClient::file_edit_remove_text(String const& filename, i32 start_line, i32 start_column, i32 end_line, i32 end_column)
void ConnectionFromClient::file_edit_remove_text(DeprecatedString const& filename, i32 start_line, i32 start_column, i32 end_line, i32 end_column)
{
dbgln_if(LANGUAGE_SERVER_DEBUG, "RemoveText for file: {}", filename);
dbgln_if(LANGUAGE_SERVER_DEBUG, "[{}:{} - {}:{}]", start_line, start_column, end_line, end_column);
@ -81,7 +81,7 @@ void ConnectionFromClient::auto_complete_suggestions(CodeComprehension::ProjectL
async_auto_complete_suggestions(move(suggestions));
}
void ConnectionFromClient::set_file_content(String const& filename, String const& content)
void ConnectionFromClient::set_file_content(DeprecatedString const& filename, DeprecatedString const& content)
{
dbgln_if(LANGUAGE_SERVER_DEBUG, "SetFileContent: {}", filename);
auto document = m_filedb.get_document(filename);
@ -140,7 +140,7 @@ void ConnectionFromClient::get_parameters_hint(CodeComprehension::ProjectLocatio
async_parameters_hint_result(params->params, params->current_index);
}
void ConnectionFromClient::get_tokens_info(String const& filename)
void ConnectionFromClient::get_tokens_info(DeprecatedString const& filename)
{
dbgln_if(LANGUAGE_SERVER_DEBUG, "GetTokenInfo: {}", filename);
auto document = m_filedb.get_document(filename);

View file

@ -27,15 +27,15 @@ public:
virtual void die() override;
protected:
virtual void greet(String const&) override;
virtual void file_opened(String const&, IPC::File const&) override;
virtual void file_edit_insert_text(String const&, String const&, i32, i32) override;
virtual void file_edit_remove_text(String const&, i32, i32, i32, i32) override;
virtual void set_file_content(String const&, String const&) override;
virtual void greet(DeprecatedString const&) override;
virtual void file_opened(DeprecatedString const&, IPC::File const&) override;
virtual void file_edit_insert_text(DeprecatedString const&, DeprecatedString const&, i32, i32) override;
virtual void file_edit_remove_text(DeprecatedString const&, i32, i32, i32, i32) override;
virtual void set_file_content(DeprecatedString const&, DeprecatedString const&) override;
virtual void auto_complete_suggestions(CodeComprehension::ProjectLocation const&) override;
virtual void find_declaration(CodeComprehension::ProjectLocation const&) override;
virtual void get_parameters_hint(CodeComprehension::ProjectLocation const&) override;
virtual void get_tokens_info(String const&) override;
virtual void get_tokens_info(DeprecatedString const&) override;
FileDB m_filedb;
OwnPtr<CodeComprehension::CodeComprehensionEngine> m_autocomplete_engine;

View file

@ -19,10 +19,10 @@ private:
: LanguageServers::ConnectionFromClient(move(socket))
{
m_autocomplete_engine = adopt_own(*new CodeComprehension::Cpp::CppComprehensionEngine(m_filedb));
m_autocomplete_engine->set_declarations_of_document_callback = [this](String const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
m_autocomplete_engine->set_declarations_of_document_callback = [this](DeprecatedString const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
async_declarations_in_document(filename, move(declarations));
};
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](String const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](DeprecatedString const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
async_todo_entries_in_document(filename, move(todo_entries));
};
}

View file

@ -12,7 +12,7 @@
namespace LanguageServers {
RefPtr<const GUI::TextDocument> FileDB::get_document(String const& filename) const
RefPtr<const GUI::TextDocument> FileDB::get_document(DeprecatedString const& filename) const
{
auto absolute_path = to_absolute_path(filename);
auto document_optional = m_open_files.get(absolute_path);
@ -22,7 +22,7 @@ RefPtr<const GUI::TextDocument> FileDB::get_document(String const& filename) con
return *document_optional.value();
}
RefPtr<GUI::TextDocument> FileDB::get_document(String const& filename)
RefPtr<GUI::TextDocument> FileDB::get_document(DeprecatedString const& filename)
{
auto document = reinterpret_cast<FileDB const*>(this)->get_document(filename);
if (document.is_null())
@ -30,7 +30,7 @@ RefPtr<GUI::TextDocument> FileDB::get_document(String const& filename)
return adopt_ref(*const_cast<GUI::TextDocument*>(document.leak_ref()));
}
Optional<String> FileDB::get_or_read_from_filesystem(StringView filename) const
Optional<DeprecatedString> FileDB::get_or_read_from_filesystem(StringView filename) const
{
auto absolute_path = to_absolute_path(filename);
auto document = get_document(absolute_path);
@ -43,12 +43,12 @@ Optional<String> FileDB::get_or_read_from_filesystem(StringView filename) const
return {};
}
bool FileDB::is_open(String const& filename) const
bool FileDB::is_open(DeprecatedString const& filename) const
{
return m_open_files.contains(to_absolute_path(filename));
}
bool FileDB::add(String const& filename, int fd)
bool FileDB::add(DeprecatedString const& filename, int fd)
{
auto document = create_from_fd(fd);
if (!document)
@ -58,17 +58,17 @@ bool FileDB::add(String const& filename, int fd)
return true;
}
String FileDB::to_absolute_path(String const& filename) const
DeprecatedString FileDB::to_absolute_path(DeprecatedString const& filename) const
{
if (LexicalPath { filename }.is_absolute()) {
return filename;
}
if (m_project_root.is_null())
return filename;
return LexicalPath { String::formatted("{}/{}", m_project_root, filename) }.string();
return LexicalPath { DeprecatedString::formatted("{}/{}", m_project_root, filename) }.string();
}
RefPtr<GUI::TextDocument> FileDB::create_from_filesystem(String const& filename) const
RefPtr<GUI::TextDocument> FileDB::create_from_filesystem(DeprecatedString const& filename) const
{
auto file = Core::File::open(to_absolute_path(filename), Core::OpenMode::ReadOnly);
if (file.is_error()) {
@ -116,7 +116,7 @@ RefPtr<GUI::TextDocument> FileDB::create_from_file(Core::File& file) const
return document;
}
void FileDB::on_file_edit_insert_text(String const& filename, String const& inserted_text, size_t start_line, size_t start_column)
void FileDB::on_file_edit_insert_text(DeprecatedString const& filename, DeprecatedString const& inserted_text, size_t start_line, size_t start_column)
{
VERIFY(is_open(filename));
auto document = get_document(filename);
@ -127,7 +127,7 @@ void FileDB::on_file_edit_insert_text(String const& filename, String const& inse
dbgln_if(FILE_CONTENT_DEBUG, "{}", document->text());
}
void FileDB::on_file_edit_remove_text(String const& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column)
void FileDB::on_file_edit_remove_text(DeprecatedString const& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column)
{
// TODO: If file is not open - need to get its contents
// Otherwise- somehow verify that respawned language server is synced with all file contents
@ -144,7 +144,7 @@ void FileDB::on_file_edit_remove_text(String const& filename, size_t start_line,
dbgln_if(FILE_CONTENT_DEBUG, "{}", document->text());
}
RefPtr<GUI::TextDocument> FileDB::create_with_content(String const& content)
RefPtr<GUI::TextDocument> FileDB::create_with_content(DeprecatedString const& content)
{
StringView content_view(content);
auto document = GUI::TextDocument::create(&s_default_document_client);
@ -152,7 +152,7 @@ RefPtr<GUI::TextDocument> FileDB::create_with_content(String const& content)
return document;
}
bool FileDB::add(String const& filename, String const& content)
bool FileDB::add(DeprecatedString const& filename, DeprecatedString const& content)
{
auto document = create_with_content(content);
if (!document) {

View file

@ -6,9 +6,9 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/NonnullRefPtr.h>
#include <AK/String.h>
#include <LibCodeComprehension/FileDB.h>
#include <LibGUI/TextDocument.h>
@ -17,28 +17,28 @@ namespace LanguageServers {
class FileDB final : public CodeComprehension::FileDB {
public:
FileDB() = default;
virtual Optional<String> get_or_read_from_filesystem(StringView filename) const override;
virtual Optional<DeprecatedString> get_or_read_from_filesystem(StringView filename) const override;
RefPtr<const GUI::TextDocument> get_document(String const& filename) const;
RefPtr<GUI::TextDocument> get_document(String const& filename);
RefPtr<const GUI::TextDocument> get_document(DeprecatedString const& filename) const;
RefPtr<GUI::TextDocument> get_document(DeprecatedString const& filename);
bool add(String const& filename, int fd);
bool add(String const& filename, String const& content);
bool add(DeprecatedString const& filename, int fd);
bool add(DeprecatedString const& filename, DeprecatedString const& content);
void on_file_edit_insert_text(String const& filename, String const& inserted_text, size_t start_line, size_t start_column);
void on_file_edit_remove_text(String const& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column);
String to_absolute_path(String const& filename) const;
bool is_open(String const& filename) const;
void on_file_edit_insert_text(DeprecatedString const& filename, DeprecatedString const& inserted_text, size_t start_line, size_t start_column);
void on_file_edit_remove_text(DeprecatedString const& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column);
DeprecatedString to_absolute_path(DeprecatedString const& filename) const;
bool is_open(DeprecatedString const& filename) const;
private:
RefPtr<GUI::TextDocument> create_from_filesystem(String const& filename) const;
RefPtr<GUI::TextDocument> create_from_filesystem(DeprecatedString const& filename) const;
RefPtr<GUI::TextDocument> create_from_fd(int fd) const;
RefPtr<GUI::TextDocument> create_from_file(Core::File&) const;
static RefPtr<GUI::TextDocument> create_with_content(String const&);
static RefPtr<GUI::TextDocument> create_with_content(DeprecatedString const&);
private:
HashMap<String, NonnullRefPtr<GUI::TextDocument>> m_open_files;
String m_project_root;
HashMap<DeprecatedString, NonnullRefPtr<GUI::TextDocument>> m_open_files;
DeprecatedString m_project_root;
};
}

View file

@ -2,8 +2,8 @@ endpoint LanguageClient
{
auto_complete_suggestions(Vector<CodeComprehension::AutocompleteResultEntry> suggestions) =|
declaration_location(CodeComprehension::ProjectLocation location) =|
declarations_in_document(String filename, Vector<CodeComprehension::Declaration> declarations) =|
todo_entries_in_document(String filename, Vector<CodeComprehension::TodoEntry> todo_entries) =|
parameters_hint_result(Vector<String> params, int current_index) =|
declarations_in_document(DeprecatedString filename, Vector<CodeComprehension::Declaration> declarations) =|
todo_entries_in_document(DeprecatedString filename, Vector<CodeComprehension::TodoEntry> todo_entries) =|
parameters_hint_result(Vector<DeprecatedString> params, int current_index) =|
tokens_info_result(Vector<CodeComprehension::TokenInfo> tokens_info) =|
}

View file

@ -1,15 +1,15 @@
endpoint LanguageServer
{
greet(String project_root) =|
greet(DeprecatedString project_root) =|
file_opened(String filename, IPC::File file) =|
file_edit_insert_text(String filename, String text, i32 start_line, i32 start_column) =|
file_edit_remove_text(String filename, i32 start_line, i32 start_column, i32 end_line, i32 end_column) =|
set_file_content(String filename, String content) =|
file_opened(DeprecatedString filename, IPC::File file) =|
file_edit_insert_text(DeprecatedString filename, DeprecatedString text, i32 start_line, i32 start_column) =|
file_edit_remove_text(DeprecatedString filename, i32 start_line, i32 start_column, i32 end_line, i32 end_column) =|
set_file_content(DeprecatedString filename, DeprecatedString content) =|
auto_complete_suggestions(CodeComprehension::ProjectLocation location) =|
find_declaration(CodeComprehension::ProjectLocation location) =|
get_parameters_hint(CodeComprehension::ProjectLocation location) =|
get_tokens_info(String filename) =|
get_tokens_info(DeprecatedString filename) =|
}

View file

@ -20,10 +20,10 @@ private:
: LanguageServers::ConnectionFromClient(move(socket))
{
m_autocomplete_engine = make<CodeComprehension::Shell::ShellComprehensionEngine>(m_filedb);
m_autocomplete_engine->set_declarations_of_document_callback = [this](String const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
m_autocomplete_engine->set_declarations_of_document_callback = [this](DeprecatedString const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
async_declarations_in_document(filename, move(declarations));
};
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](String const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](DeprecatedString const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
async_todo_entries_in_document(filename, move(todo_entries));
};
}

View file

@ -21,13 +21,13 @@ namespace HackStudio {
class LocatorSuggestionModel final : public GUI::Model {
public:
struct Suggestion {
static Suggestion create_filename(String const& filename);
static Suggestion create_filename(DeprecatedString const& filename);
static Suggestion create_symbol_declaration(CodeComprehension::Declaration const&);
bool is_filename() const { return as_filename.has_value(); }
bool is_symbol_declaration() const { return as_symbol_declaration.has_value(); }
Optional<String> as_filename;
Optional<DeprecatedString> as_filename;
Optional<CodeComprehension::Declaration> as_symbol_declaration;
};
@ -62,7 +62,7 @@ public:
if (index.column() == Column::Name) {
if (suggestion.as_symbol_declaration.value().scope.is_null())
return suggestion.as_symbol_declaration.value().name;
return String::formatted("{}::{}", suggestion.as_symbol_declaration.value().scope, suggestion.as_symbol_declaration.value().name);
return DeprecatedString::formatted("{}::{}", suggestion.as_symbol_declaration.value().scope, suggestion.as_symbol_declaration.value().name);
}
if (index.column() == Column::Filename)
return suggestion.as_symbol_declaration.value().position.file;
@ -82,7 +82,7 @@ private:
Vector<Suggestion> m_suggestions;
};
LocatorSuggestionModel::Suggestion LocatorSuggestionModel::Suggestion::create_filename(String const& filename)
LocatorSuggestionModel::Suggestion LocatorSuggestionModel::Suggestion::create_filename(DeprecatedString const& filename)
{
LocatorSuggestionModel::Suggestion s;
s.as_filename = filename;

View file

@ -10,13 +10,13 @@
namespace HackStudio {
Project::Project(String const& root_path)
Project::Project(DeprecatedString const& root_path)
: m_root_path(root_path)
{
m_model = GUI::FileSystemModel::create(root_path, GUI::FileSystemModel::Mode::FilesAndDirectories);
}
OwnPtr<Project> Project::open_with_root_path(String const& root_path)
OwnPtr<Project> Project::open_with_root_path(DeprecatedString const& root_path)
{
if (!Core::File::is_directory(root_path))
return {};
@ -45,18 +45,18 @@ void Project::for_each_text_file(Function<void(ProjectFile const&)> callback) co
});
}
NonnullRefPtr<ProjectFile> Project::create_file(String const& path) const
NonnullRefPtr<ProjectFile> Project::create_file(DeprecatedString const& path) const
{
auto full_path = to_absolute_path(path);
return ProjectFile::construct_with_name(full_path);
}
String Project::to_absolute_path(String const& path) const
DeprecatedString Project::to_absolute_path(DeprecatedString const& path) const
{
if (LexicalPath { path }.is_absolute()) {
return path;
}
return LexicalPath { String::formatted("{}/{}", m_root_path, path) }.string();
return LexicalPath { DeprecatedString::formatted("{}/{}", m_root_path, path) }.string();
}
bool Project::project_is_serenity() const

View file

@ -20,28 +20,28 @@ class Project {
AK_MAKE_NONMOVABLE(Project);
public:
static OwnPtr<Project> open_with_root_path(String const& root_path);
static OwnPtr<Project> open_with_root_path(DeprecatedString const& root_path);
GUI::FileSystemModel& model() { return *m_model; }
const GUI::FileSystemModel& model() const { return *m_model; }
String name() const { return LexicalPath::basename(m_root_path); }
String root_path() const { return m_root_path; }
DeprecatedString name() const { return LexicalPath::basename(m_root_path); }
DeprecatedString root_path() const { return m_root_path; }
NonnullRefPtr<ProjectFile> create_file(String const& path) const;
NonnullRefPtr<ProjectFile> create_file(DeprecatedString const& path) const;
void for_each_text_file(Function<void(ProjectFile const&)>) const;
String to_absolute_path(String const&) const;
DeprecatedString to_absolute_path(DeprecatedString const&) const;
bool project_is_serenity() const;
static constexpr auto config_file_path = ".hackstudio/config.json"sv;
NonnullOwnPtr<ProjectConfig> config() const;
private:
explicit Project(String const& root_path);
explicit Project(DeprecatedString const& root_path);
RefPtr<GUI::FileSystemModel> m_model;
String m_root_path;
DeprecatedString m_root_path;
};
}

View file

@ -35,7 +35,7 @@ ErrorOr<void> ProjectBuilder::build(StringView active_file)
return Error::from_string_literal("no active file");
if (active_file.ends_with(".js"sv)) {
TRY(m_terminal->run_command(String::formatted("js -A {}", active_file)));
TRY(m_terminal->run_command(DeprecatedString::formatted("js -A {}", active_file)));
return {};
}
@ -61,7 +61,7 @@ ErrorOr<void> ProjectBuilder::run(StringView active_file)
return Error::from_string_literal("no active file");
if (active_file.ends_with(".js"sv)) {
TRY(m_terminal->run_command(String::formatted("js {}", active_file)));
TRY(m_terminal->run_command(DeprecatedString::formatted("js {}", active_file)));
return {};
}
@ -105,11 +105,11 @@ ErrorOr<void> ProjectBuilder::update_active_file(StringView active_file)
ErrorOr<void> ProjectBuilder::build_serenity_component()
{
TRY(verify_make_is_installed());
TRY(m_terminal->run_command(String::formatted("make {}", m_serenity_component_name), build_directory(), TerminalWrapper::WaitForExit::Yes, "Make failed"sv));
TRY(m_terminal->run_command(DeprecatedString::formatted("make {}", m_serenity_component_name), build_directory(), TerminalWrapper::WaitForExit::Yes, "Make failed"sv));
return {};
}
ErrorOr<String> ProjectBuilder::component_name(StringView cmake_file_path)
ErrorOr<DeprecatedString> ProjectBuilder::component_name(StringView cmake_file_path)
{
auto content = TRY(Core::File::open(cmake_file_path, Core::OpenMode::ReadOnly))->read_all();
@ -118,7 +118,7 @@ ErrorOr<String> ProjectBuilder::component_name(StringView cmake_file_path)
if (!component_name.search(StringView { content }, result))
return Error::from_string_literal("component not found");
return String { result.capture_group_matches.at(0).at(0).view.string_view() };
return DeprecatedString { result.capture_group_matches.at(0).at(0).view.string_view() };
}
ErrorOr<void> ProjectBuilder::initialize_build_directory()
@ -136,15 +136,15 @@ ErrorOr<void> ProjectBuilder::initialize_build_directory()
auto cmake_file = TRY(Core::File::open(cmake_file_path, Core::OpenMode::WriteOnly));
cmake_file->write(generate_cmake_file_content());
TRY(m_terminal->run_command(String::formatted("cmake -S {} -DHACKSTUDIO_BUILD=ON -DHACKSTUDIO_BUILD_CMAKE_FILE={}"
" -DENABLE_UNICODE_DATABASE_DOWNLOAD=OFF",
TRY(m_terminal->run_command(DeprecatedString::formatted("cmake -S {} -DHACKSTUDIO_BUILD=ON -DHACKSTUDIO_BUILD_CMAKE_FILE={}"
" -DENABLE_UNICODE_DATABASE_DOWNLOAD=OFF",
m_project_root, cmake_file_path),
build_directory(), TerminalWrapper::WaitForExit::Yes, "CMake error"sv));
return {};
}
Optional<String> ProjectBuilder::find_cmake_file_for(StringView file_path) const
Optional<DeprecatedString> ProjectBuilder::find_cmake_file_for(StringView file_path) const
{
auto directory = LexicalPath::dirname(file_path);
while (!directory.is_empty()) {
@ -156,7 +156,7 @@ Optional<String> ProjectBuilder::find_cmake_file_for(StringView file_path) const
return {};
}
String ProjectBuilder::generate_cmake_file_content() const
DeprecatedString ProjectBuilder::generate_cmake_file_content() const
{
StringBuilder builder;
builder.appendff("add_subdirectory({})\n", LexicalPath::dirname(m_serenity_component_cmake_file));
@ -173,20 +173,20 @@ String ProjectBuilder::generate_cmake_file_content() const
// all of their direct dependencies in the CMakeLists file.
// For example, a target may directly use LibGFX but only specify LibGUI as a dependency (which in turn depends on LibGFX).
// In this example, if we don't specify the dependencies of LibGUI in the CMake file, linking will fail because of undefined LibGFX symbols.
builder.appendff("target_link_libraries({} INTERFACE {})\n", library.key, String::join(' ', library.value->dependencies));
builder.appendff("target_link_libraries({} INTERFACE {})\n", library.key, DeprecatedString::join(' ', library.value->dependencies));
}
return builder.to_string();
}
HashMap<String, NonnullOwnPtr<ProjectBuilder::LibraryInfo>> ProjectBuilder::get_defined_libraries()
HashMap<DeprecatedString, NonnullOwnPtr<ProjectBuilder::LibraryInfo>> ProjectBuilder::get_defined_libraries()
{
HashMap<String, NonnullOwnPtr<ProjectBuilder::LibraryInfo>> libraries;
HashMap<DeprecatedString, NonnullOwnPtr<ProjectBuilder::LibraryInfo>> libraries;
for_each_library_definition([&libraries](String name, String path) {
for_each_library_definition([&libraries](DeprecatedString name, DeprecatedString path) {
libraries.set(name, make<ProjectBuilder::LibraryInfo>(move(path)));
});
for_each_library_dependencies([&libraries](String name, Vector<StringView> const& dependencies) {
for_each_library_dependencies([&libraries](DeprecatedString name, Vector<StringView> const& dependencies) {
auto library = libraries.get(name);
if (!library.has_value())
return;
@ -198,9 +198,9 @@ HashMap<String, NonnullOwnPtr<ProjectBuilder::LibraryInfo>> ProjectBuilder::get_
return libraries;
}
void ProjectBuilder::for_each_library_definition(Function<void(String, String)> func)
void ProjectBuilder::for_each_library_definition(Function<void(DeprecatedString, DeprecatedString)> func)
{
Vector<String> arguments = { "-c", "find Userland -name CMakeLists.txt | xargs grep serenity_lib" };
Vector<DeprecatedString> arguments = { "-c", "find Userland -name CMakeLists.txt | xargs grep serenity_lib" };
auto res = Core::command("/bin/sh", arguments, {});
if (res.is_error()) {
warnln("{}", res.error());
@ -217,7 +217,7 @@ void ProjectBuilder::for_each_library_definition(Function<void(String, String)>
auto library_name = result.capture_group_matches.at(0).at(0).view.string_view();
auto library_obj_name = result.capture_group_matches.at(0).at(1).view.string_view();
auto so_path = String::formatted("{}.so", LexicalPath::join("/usr/lib"sv, String::formatted("lib{}", library_obj_name)).string());
auto so_path = DeprecatedString::formatted("{}.so", LexicalPath::join("/usr/lib"sv, DeprecatedString::formatted("lib{}", library_obj_name)).string());
func(library_name, so_path);
}
@ -225,9 +225,9 @@ void ProjectBuilder::for_each_library_definition(Function<void(String, String)>
func("ssp", "/usr/lib/libssp.a");
}
void ProjectBuilder::for_each_library_dependencies(Function<void(String, Vector<StringView>)> func)
void ProjectBuilder::for_each_library_dependencies(Function<void(DeprecatedString, Vector<StringView>)> func)
{
Vector<String> arguments = { "-c", "find Userland/Libraries -name CMakeLists.txt | xargs grep target_link_libraries" };
Vector<DeprecatedString> arguments = { "-c", "find Userland/Libraries -name CMakeLists.txt | xargs grep target_link_libraries" };
auto res = Core::command("/bin/sh", arguments, {});
if (res.is_error()) {
warnln("{}", res.error());
@ -266,7 +266,7 @@ ErrorOr<void> ProjectBuilder::verify_make_is_installed()
return Error::from_string_literal("Make port is not installed");
}
String ProjectBuilder::build_directory() const
DeprecatedString ProjectBuilder::build_directory() const
{
return LexicalPath::join(m_project_root, "Build"sv).string();
}

View file

@ -33,27 +33,27 @@ private:
ErrorOr<void> build_serenity_component();
ErrorOr<void> run_serenity_component();
ErrorOr<void> initialize_build_directory();
Optional<String> find_cmake_file_for(StringView file_path) const;
String generate_cmake_file_content() const;
Optional<DeprecatedString> find_cmake_file_for(StringView file_path) const;
DeprecatedString generate_cmake_file_content() const;
ErrorOr<void> update_active_file(StringView active_file);
String build_directory() const;
DeprecatedString build_directory() const;
struct LibraryInfo {
String path;
Vector<String> dependencies {};
DeprecatedString path;
Vector<DeprecatedString> dependencies {};
};
static HashMap<String, NonnullOwnPtr<LibraryInfo>> get_defined_libraries();
static void for_each_library_definition(Function<void(String, String)>);
static void for_each_library_dependencies(Function<void(String, Vector<StringView>)>);
static ErrorOr<String> component_name(StringView cmake_file_path);
static HashMap<DeprecatedString, NonnullOwnPtr<LibraryInfo>> get_defined_libraries();
static void for_each_library_definition(Function<void(DeprecatedString, DeprecatedString)>);
static void for_each_library_dependencies(Function<void(DeprecatedString, Vector<StringView>)>);
static ErrorOr<DeprecatedString> component_name(StringView cmake_file_path);
static ErrorOr<void> verify_cmake_is_installed();
static ErrorOr<void> verify_make_is_installed();
String m_project_root;
DeprecatedString m_project_root;
Project const& m_project;
NonnullRefPtr<TerminalWrapper> m_terminal;
IsSerenityRepo m_is_serenity { IsSerenityRepo::No };
String m_serenity_component_cmake_file;
String m_serenity_component_name;
DeprecatedString m_serenity_component_cmake_file;
DeprecatedString m_serenity_component_name;
};
}

View file

@ -15,7 +15,7 @@ ProjectConfig::ProjectConfig(JsonObject config)
{
}
ErrorOr<NonnullOwnPtr<ProjectConfig>> ProjectConfig::try_load_project_config(String path)
ErrorOr<NonnullOwnPtr<ProjectConfig>> ProjectConfig::try_load_project_config(DeprecatedString path)
{
auto file = TRY(Core::File::open(path, Core::OpenMode::ReadOnly));
auto file_contents = file->read_all();
@ -34,7 +34,7 @@ NonnullOwnPtr<ProjectConfig> ProjectConfig::create_empty()
return adopt_own(*new ProjectConfig(empty));
}
Optional<String> ProjectConfig::read_key(String key_name) const
Optional<DeprecatedString> ProjectConfig::read_key(DeprecatedString key_name) const
{
auto const& value = m_config.get(key_name);
if (!value.is_string())

View file

@ -16,16 +16,16 @@ namespace HackStudio {
class ProjectConfig {
public:
static ErrorOr<NonnullOwnPtr<ProjectConfig>> try_load_project_config(String path);
static ErrorOr<NonnullOwnPtr<ProjectConfig>> try_load_project_config(DeprecatedString path);
static NonnullOwnPtr<ProjectConfig> create_empty();
ProjectConfig(JsonObject);
Optional<String> build_command() const { return read_key("build_command"); }
Optional<String> run_command() const { return read_key("run_command"); }
Optional<DeprecatedString> build_command() const { return read_key("build_command"); }
Optional<DeprecatedString> run_command() const { return read_key("run_command"); }
private:
Optional<String> read_key(String key_name) const;
Optional<DeprecatedString> read_key(DeprecatedString key_name) const;
JsonObject m_config;
};

View file

@ -11,7 +11,7 @@ HackStudio::ProjectDeclarations& HackStudio::ProjectDeclarations::the()
static ProjectDeclarations s_instance;
return s_instance;
}
void HackStudio::ProjectDeclarations::set_declared_symbols(String const& filename, Vector<CodeComprehension::Declaration> const& declarations)
void HackStudio::ProjectDeclarations::set_declared_symbols(DeprecatedString const& filename, Vector<CodeComprehension::Declaration> const& declarations)
{
m_document_to_declarations.set(filename, declarations);
if (on_update)

View file

@ -6,10 +6,10 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/Function.h>
#include <AK/HashMap.h>
#include <AK/Noncopyable.h>
#include <AK/String.h>
#include <LibGUI/AutocompleteProvider.h>
#include <LibGUI/Icon.h>
@ -23,7 +23,7 @@ public:
template<typename Func>
void for_each_declared_symbol(Func);
void set_declared_symbols(String const& filename, Vector<CodeComprehension::Declaration> const&);
void set_declared_symbols(DeprecatedString const& filename, Vector<CodeComprehension::Declaration> const&);
static Optional<GUI::Icon> get_icon_for(CodeComprehension::DeclarationType);
@ -31,7 +31,7 @@ public:
private:
ProjectDeclarations() = default;
HashMap<String, Vector<CodeComprehension::Declaration>> m_document_to_declarations;
HashMap<DeprecatedString, Vector<CodeComprehension::Declaration>> m_document_to_declarations;
};
template<typename Func>

View file

@ -9,7 +9,7 @@
namespace HackStudio {
ProjectFile::ProjectFile(String const& name)
ProjectFile::ProjectFile(DeprecatedString const& name)
: m_name(name)
{
}

View file

@ -8,20 +8,20 @@
#include "CodeDocument.h"
#include <AK/ByteBuffer.h>
#include <AK/DeprecatedString.h>
#include <AK/NonnullRefPtr.h>
#include <AK/RefCounted.h>
#include <AK/String.h>
namespace HackStudio {
class ProjectFile : public RefCounted<ProjectFile> {
public:
static NonnullRefPtr<ProjectFile> construct_with_name(String const& name)
static NonnullRefPtr<ProjectFile> construct_with_name(DeprecatedString const& name)
{
return adopt_ref(*new ProjectFile(name));
}
String const& name() const { return m_name; }
DeprecatedString const& name() const { return m_name; }
bool could_render_text() const { return m_could_render_text; }
GUI::TextDocument& document() const;
@ -33,10 +33,10 @@ public:
void horizontal_scroll_value(int);
private:
explicit ProjectFile(String const& name);
explicit ProjectFile(DeprecatedString const& name);
void create_document_if_needed() const;
String m_name;
DeprecatedString m_name;
mutable RefPtr<CodeDocument> m_document;
mutable bool m_could_render_text { false };
int m_vertical_scroll_value { 0 };

View file

@ -5,8 +5,8 @@
*/
#include "ProjectTemplate.h"
#include <AK/DeprecatedString.h>
#include <AK/LexicalPath.h>
#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <LibCore/ConfigFile.h>
#include <LibCore/DirIterator.h>
@ -19,7 +19,7 @@
namespace HackStudio {
ProjectTemplate::ProjectTemplate(String const& id, String const& name, String const& description, const GUI::Icon& icon, int priority)
ProjectTemplate::ProjectTemplate(DeprecatedString const& id, DeprecatedString const& name, DeprecatedString const& description, const GUI::Icon& icon, int priority)
: m_id(id)
, m_name(name)
, m_description(description)
@ -28,7 +28,7 @@ ProjectTemplate::ProjectTemplate(String const& id, String const& name, String co
{
}
RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(String const& manifest_path)
RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(DeprecatedString const& manifest_path)
{
auto maybe_config = Core::ConfigFile::open(manifest_path);
if (maybe_config.is_error())
@ -50,7 +50,7 @@ RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(String const& manife
// Fallback to a generic executable icon if one isn't found
auto icon = GUI::Icon::default_icon("filetype-executable"sv);
auto bitmap_path_32 = String::formatted("/res/icons/hackstudio/templates-32x32/{}.png", config->read_entry("HackStudioTemplate", "IconName32x"));
auto bitmap_path_32 = DeprecatedString::formatted("/res/icons/hackstudio/templates-32x32/{}.png", config->read_entry("HackStudioTemplate", "IconName32x"));
if (Core::File::exists(bitmap_path_32)) {
auto bitmap_or_error = Gfx::Bitmap::try_load_from_file(bitmap_path_32);
@ -61,11 +61,11 @@ RefPtr<ProjectTemplate> ProjectTemplate::load_from_manifest(String const& manife
return adopt_ref(*new ProjectTemplate(id, name, description, icon, priority));
}
Result<void, String> ProjectTemplate::create_project(String const& name, String const& path)
Result<void, DeprecatedString> ProjectTemplate::create_project(DeprecatedString const& name, DeprecatedString const& path)
{
// Check if a file or directory already exists at the project path
if (Core::File::exists(path))
return String("File or directory already exists at specified location.");
return DeprecatedString("File or directory already exists at specified location.");
dbgln("Creating project at path '{}' with name '{}'", path, name);
@ -75,19 +75,19 @@ Result<void, String> ProjectTemplate::create_project(String const& name, String
auto result = Core::File::copy_file_or_directory(path, content_path());
dbgln("Copying {} -> {}", content_path(), path);
if (result.is_error())
return String::formatted("Failed to copy template contents. Error code: {}", static_cast<Error const&>(result.error()));
return DeprecatedString::formatted("Failed to copy template contents. Error code: {}", static_cast<Error const&>(result.error()));
} else {
dbgln("No template content directory found for '{}', creating an empty directory for the project.", m_id);
int rc;
if ((rc = mkdir(path.characters(), 0755)) < 0) {
return String::formatted("Failed to mkdir empty project directory, error: {}, rc: {}.", strerror(errno), rc);
return DeprecatedString::formatted("Failed to mkdir empty project directory, error: {}, rc: {}.", strerror(errno), rc);
}
}
// Check for an executable post-create script in $TEMPLATES_DIR/$ID.postcreate,
// and run it with the path and name
auto postcreate_script_path = LexicalPath::canonicalized_path(String::formatted("{}/{}.postcreate", templates_path(), m_id));
auto postcreate_script_path = LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}.postcreate", templates_path(), m_id));
struct stat postcreate_st;
int result = stat(postcreate_script_path.characters(), &postcreate_st);
if (result == 0 && (postcreate_st.st_mode & S_IXOTH) == S_IXOTH) {
@ -101,19 +101,19 @@ Result<void, String> ProjectTemplate::create_project(String const& name, String
if ((errno = posix_spawn(&child_pid, postcreate_script_path.characters(), nullptr, nullptr, const_cast<char**>(argv), environ))) {
perror("posix_spawn");
return String("Failed to spawn project post-create script.");
return DeprecatedString("Failed to spawn project post-create script.");
}
// Command spawned, wait for exit.
int status;
if (waitpid(child_pid, &status, 0) < 0)
return String("Failed to spawn project post-create script.");
return DeprecatedString("Failed to spawn project post-create script.");
int child_error = WEXITSTATUS(status);
dbgln("Post-create script exited with code {}", child_error);
if (child_error != 0)
return String("Project post-creation script exited with non-zero error code.");
return DeprecatedString("Project post-creation script exited with non-zero error code.");
}
return {};

View file

@ -7,10 +7,10 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/DeprecatedString.h>
#include <AK/LexicalPath.h>
#include <AK/RefCounted.h>
#include <AK/Result.h>
#include <AK/String.h>
#include <AK/Weakable.h>
#include <LibGUI/Icon.h>
@ -18,28 +18,28 @@ namespace HackStudio {
class ProjectTemplate : public RefCounted<ProjectTemplate> {
public:
static String templates_path() { return "/res/devel/templates"; }
static DeprecatedString templates_path() { return "/res/devel/templates"; }
static RefPtr<ProjectTemplate> load_from_manifest(String const& manifest_path);
static RefPtr<ProjectTemplate> load_from_manifest(DeprecatedString const& manifest_path);
explicit ProjectTemplate(String const& id, String const& name, String const& description, const GUI::Icon& icon, int priority);
explicit ProjectTemplate(DeprecatedString const& id, DeprecatedString const& name, DeprecatedString const& description, const GUI::Icon& icon, int priority);
Result<void, String> create_project(String const& name, String const& path);
Result<void, DeprecatedString> create_project(DeprecatedString const& name, DeprecatedString const& path);
String const& id() const { return m_id; }
String const& name() const { return m_name; }
String const& description() const { return m_description; }
DeprecatedString const& id() const { return m_id; }
DeprecatedString const& name() const { return m_name; }
DeprecatedString const& description() const { return m_description; }
const GUI::Icon& icon() const { return m_icon; }
const String content_path() const
const DeprecatedString content_path() const
{
return LexicalPath::canonicalized_path(String::formatted("{}/{}", templates_path(), m_id));
return LexicalPath::canonicalized_path(DeprecatedString::formatted("{}/{}", templates_path(), m_id));
}
int priority() const { return m_priority; }
private:
String m_id;
String m_name;
String m_description;
DeprecatedString m_id;
DeprecatedString m_name;
DeprecatedString m_description;
GUI::Icon m_icon;
int m_priority { 0 };
};

View file

@ -6,7 +6,7 @@
*/
#include "TerminalWrapper.h"
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <LibCore/System.h>
#include <LibGUI/Application.h>
#include <LibGUI/BoxLayout.h>
@ -24,7 +24,7 @@
namespace HackStudio {
ErrorOr<void> TerminalWrapper::run_command(String const& command, Optional<String> working_directory, WaitForExit wait_for_exit, Optional<StringView> failure_message)
ErrorOr<void> TerminalWrapper::run_command(DeprecatedString const& command, Optional<DeprecatedString> working_directory, WaitForExit wait_for_exit, Optional<StringView> failure_message)
{
if (m_pid != -1) {
GUI::MessageBox::show(window(),
@ -92,11 +92,11 @@ ErrorOr<int> TerminalWrapper::setup_master_pseudoterminal(WaitForChildOnExit wai
int wstatus = result.release_value().status;
if (WIFEXITED(wstatus)) {
m_terminal_widget->inject_string(String::formatted("\033[{};1m(Command exited with code {})\033[0m\r\n", wstatus == 0 ? 32 : 31, WEXITSTATUS(wstatus)));
m_terminal_widget->inject_string(DeprecatedString::formatted("\033[{};1m(Command exited with code {})\033[0m\r\n", wstatus == 0 ? 32 : 31, WEXITSTATUS(wstatus)));
} else if (WIFSTOPPED(wstatus)) {
m_terminal_widget->inject_string("\033[34;1m(Command stopped!)\033[0m\r\n"sv);
} else if (WIFSIGNALED(wstatus)) {
m_terminal_widget->inject_string(String::formatted("\033[34;1m(Command signaled with {}!)\033[0m\r\n", strsignal(WTERMSIG(wstatus))));
m_terminal_widget->inject_string(DeprecatedString::formatted("\033[34;1m(Command signaled with {}!)\033[0m\r\n", strsignal(WTERMSIG(wstatus))));
}
m_child_exit_status = WEXITSTATUS(wstatus);

View file

@ -21,7 +21,7 @@ public:
No,
Yes
};
ErrorOr<void> run_command(String const&, Optional<String> working_directory = {}, WaitForExit = WaitForExit::No, Optional<StringView> failure_message = {});
ErrorOr<void> run_command(DeprecatedString const&, Optional<DeprecatedString> working_directory = {}, WaitForExit = WaitForExit::No, Optional<StringView> failure_message = {});
ErrorOr<void> kill_running_command();
void clear_including_history();

View file

@ -14,7 +14,7 @@ ToDoEntries& HackStudio::ToDoEntries::the()
return s_instance;
}
void ToDoEntries::set_entries(String const& filename, Vector<CodeComprehension::TodoEntry> const&& entries)
void ToDoEntries::set_entries(DeprecatedString const& filename, Vector<CodeComprehension::TodoEntry> const&& entries)
{
m_document_to_entries.set(filename, move(entries));
if (on_update)

View file

@ -6,10 +6,10 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/Function.h>
#include <AK/HashMap.h>
#include <AK/Noncopyable.h>
#include <AK/String.h>
#include <LibCpp/Parser.h>
namespace HackStudio {
@ -20,7 +20,7 @@ class ToDoEntries {
public:
static ToDoEntries& the();
void set_entries(String const& filename, Vector<CodeComprehension::TodoEntry> const&& entries);
void set_entries(DeprecatedString const& filename, Vector<CodeComprehension::TodoEntry> const&& entries);
Vector<CodeComprehension::TodoEntry> get_entries();
@ -30,7 +30,7 @@ public:
private:
ToDoEntries() = default;
HashMap<String, Vector<CodeComprehension::TodoEntry>> m_document_to_entries;
HashMap<DeprecatedString, Vector<CodeComprehension::TodoEntry>> m_document_to_entries;
};
}

View file

@ -30,7 +30,7 @@ public:
virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override { return m_matches.size(); }
virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override { return Column::__Count; }
virtual String column_name(int column) const override
virtual DeprecatedString column_name(int column) const override
{
switch (column) {
case Column::Filename:
@ -63,9 +63,9 @@ public:
case Column::Text:
return match.content;
case Column::Line:
return String::formatted("{}", match.line + 1);
return DeprecatedString::formatted("{}", match.line + 1);
case Column::Column:
return String::formatted("{}", match.column);
return DeprecatedString::formatted("{}", match.column);
}
}
return {};

View file

@ -32,7 +32,7 @@ static WeakPtr<HackStudioWidget> s_hack_studio_widget;
static bool make_is_available();
static void notify_make_not_available();
static void update_path_environment_variable();
static Optional<String> last_opened_project_path();
static Optional<DeprecatedString> last_opened_project_path();
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
@ -71,7 +71,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto hack_studio_widget = TRY(window->try_set_main_widget<HackStudioWidget>(project_path));
s_hack_studio_widget = hack_studio_widget;
window->set_title(String::formatted("{} - Hack Studio", hack_studio_widget->project().name()));
window->set_title(DeprecatedString::formatted("{} - Hack Studio", hack_studio_widget->project().name()));
hack_studio_widget->initialize_menubar(*window);
@ -132,7 +132,7 @@ static void update_path_environment_variable()
setenv("PATH", path.to_string().characters(), true);
}
static Optional<String> last_opened_project_path()
static Optional<DeprecatedString> last_opened_project_path()
{
auto projects = HackStudioWidget::read_recent_projects();
if (projects.size() == 0)
@ -151,12 +151,12 @@ GUI::TextEditor& current_editor()
return s_hack_studio_widget->current_editor();
}
void open_file(String const& filename)
void open_file(DeprecatedString const& filename)
{
s_hack_studio_widget->open_file(filename);
}
void open_file(String const& filename, size_t line, size_t column)
void open_file(DeprecatedString const& filename, size_t line, size_t column)
{
s_hack_studio_widget->open_file(filename, line, column);
}
@ -173,7 +173,7 @@ Project& project()
return s_hack_studio_widget->project();
}
String currently_open_file()
DeprecatedString currently_open_file()
{
if (!s_hack_studio_widget)
return {};

View file

@ -6,9 +6,9 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/JsonObject.h>
#include <AK/NonnullOwnPtrVector.h>
#include <AK/String.h>
namespace Inspector {
@ -25,8 +25,8 @@ public:
FlatPtr address { 0 };
FlatPtr parent_address { 0 };
String class_name;
String name;
DeprecatedString class_name;
DeprecatedString name;
JsonObject json;

View file

@ -87,7 +87,7 @@ GUI::Variant RemoteObjectGraphModel::data(const GUI::ModelIndex& index, GUI::Mod
return m_object_icon;
}
if (role == GUI::ModelRole::Display)
return String::formatted("{}({:p})", remote_object->class_name, remote_object->address);
return DeprecatedString::formatted("{}({:p})", remote_object->class_name, remote_object->address);
return {};
}

View file

@ -33,7 +33,7 @@ int RemoteObjectPropertyModel::row_count(const GUI::ModelIndex& index) const
}
}
String RemoteObjectPropertyModel::column_name(int column) const
DeprecatedString RemoteObjectPropertyModel::column_name(int column) const
{
switch (column) {
case Column::Name:
@ -57,9 +57,9 @@ GUI::Variant RemoteObjectPropertyModel::data(const GUI::ModelIndex& index, GUI::
case Column::Value: {
auto data = path->resolve(m_object.json);
if (data.is_array())
return String::formatted("<Array with {} element{}", data.as_array().size(), data.as_array().size() == 1 ? ">" : "s>");
return DeprecatedString::formatted("<Array with {} element{}", data.as_array().size(), data.as_array().size() == 1 ? ">" : "s>");
if (data.is_object())
return String::formatted("<Object with {} entr{}", data.as_object().size(), data.as_object().size() == 1 ? "y>" : "ies>");
return DeprecatedString::formatted("<Object with {} entr{}", data.as_object().size(), data.as_object().size() == 1 ? "y>" : "ies>");
return data;
}
}
@ -90,7 +90,7 @@ GUI::ModelIndex RemoteObjectPropertyModel::index(int row, int column, const GUI:
path->extend(parent_path);
int row_index = n;
if (value.is_object()) {
String property_name;
DeprecatedString property_name;
auto& object = value.as_object();
object.for_each_member([&](auto& name, auto&) {
if (row_index > 0) {

View file

@ -31,7 +31,7 @@ public:
virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override;
virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; }
virtual String column_name(int) const override;
virtual DeprecatedString column_name(int) const override;
virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
virtual void set_data(const GUI::ModelIndex&, const GUI::Variant&) override;
virtual bool is_editable(const GUI::ModelIndex& index) const override { return index.column() == Column::Value; }

View file

@ -22,7 +22,7 @@ public:
void update();
pid_t pid() const { return m_pid; }
String const& process_name() const { return m_process_name; }
DeprecatedString const& process_name() const { return m_process_name; }
RemoteObjectGraphModel& object_graph_model() { return *m_object_graph_model; }
NonnullOwnPtrVector<RemoteObject> const& roots() const { return m_roots; }
@ -42,7 +42,7 @@ private:
void send_request(JsonObject const&);
pid_t m_pid { -1 };
String m_process_name;
DeprecatedString m_process_name;
NonnullRefPtr<RemoteObjectGraphModel> m_object_graph_model;
NonnullOwnPtrVector<RemoteObject> m_roots;
RefPtr<InspectorServerClient> m_client;

View file

@ -56,7 +56,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 0;
pid = process_chooser->pid();
} else {
auto pid_opt = String(arguments.strings[1]).to_int();
auto pid_opt = DeprecatedString(arguments.strings[1]).to_int();
if (!pid_opt.has_value())
print_usage_and_exit();
pid = pid_opt.value();
@ -74,7 +74,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
RemoteProcess remote_process(pid);
if (!remote_process.is_inspectable()) {
GUI::MessageBox::show(window, String::formatted("Process pid={} is not inspectable", remote_process.pid()), "Error"sv, GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window, DeprecatedString::formatted("Process pid={} is not inspectable", remote_process.pid()), "Error"sv, GUI::MessageBox::Type::Error);
if (gui_mode) {
goto choose_pid;
} else {
@ -107,7 +107,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
remote_process.on_update = [&] {
if (!remote_process.process_name().is_null())
window->set_title(String::formatted("{} ({}) - Inspector", remote_process.process_name(), remote_process.pid()));
window->set_title(DeprecatedString::formatted("{} ({}) - Inspector", remote_process.process_name(), remote_process.pid()));
};
auto& tree_view = splitter.add<GUI::TreeView>();

View file

@ -48,7 +48,7 @@ DisassemblyModel::DisassemblyModel(Profile& profile, ProfileNode& node)
if (elf == nullptr)
return;
if (g_kernel_debug_info == nullptr)
g_kernel_debug_info = make<Debug::DebugInfo>(g_kernel_debuginfo_object->elf, String::empty(), base_address);
g_kernel_debug_info = make<Debug::DebugInfo>(g_kernel_debuginfo_object->elf, DeprecatedString::empty(), base_address);
debug_info = g_kernel_debug_info.ptr();
} else {
auto const& process = node.process();
@ -128,7 +128,7 @@ int DisassemblyModel::row_count(GUI::ModelIndex const&) const
return m_instructions.size();
}
String DisassemblyModel::column_name(int column) const
DeprecatedString DisassemblyModel::column_name(int column) const
{
switch (column) {
case Column::SampleCount:
@ -192,7 +192,7 @@ GUI::Variant DisassemblyModel::data(GUI::ModelIndex const& index, GUI::ModelRole
}
if (index.column() == Column::Address)
return String::formatted("{:p}", insn.address);
return DeprecatedString::formatted("{:p}", insn.address);
if (index.column() == Column::InstructionBytes) {
StringBuilder builder;

View file

@ -18,7 +18,7 @@ class ProfileNode;
struct InstructionData {
X86::Instruction insn;
String disassembly;
DeprecatedString disassembly;
StringView bytes;
FlatPtr address { 0 };
u32 event_count { 0 };
@ -46,7 +46,7 @@ public:
virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override;
virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override { return Column::__Count; }
virtual String column_name(int) const override;
virtual DeprecatedString column_name(int) const override;
virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override;
virtual bool is_column_sortable(int) const override { return false; }

View file

@ -22,7 +22,7 @@ FileEventModel::~FileEventModel()
{
}
FileEventNode& FileEventNode::find_or_create_node(String const& searched_path)
FileEventNode& FileEventNode::find_or_create_node(DeprecatedString const& searched_path)
{
// TODO: Optimize this function.
@ -61,7 +61,7 @@ FileEventNode& FileEventNode::find_or_create_node(String const& searched_path)
}
}
FileEventNode& FileEventNode::create_recursively(String new_path)
FileEventNode& FileEventNode::create_recursively(DeprecatedString new_path)
{
auto const lex_path = LexicalPath(new_path);
auto parts = lex_path.parts();
@ -142,7 +142,7 @@ int FileEventModel::column_count(GUI::ModelIndex const&) const
return Column::__Count;
}
String FileEventModel::column_name(int column) const
DeprecatedString FileEventModel::column_name(int column) const
{
switch (column) {
case Column::Path:

View file

@ -6,9 +6,9 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/Function.h>
#include <AK/LexicalPath.h>
#include <AK/String.h>
#include <LibGUI/Model.h>
namespace Profiler {
@ -17,23 +17,23 @@ class Profile;
class FileEventNode : public RefCounted<FileEventNode> {
public:
static NonnullRefPtr<FileEventNode> create(String const& path, FileEventNode* parent = nullptr)
static NonnullRefPtr<FileEventNode> create(DeprecatedString const& path, FileEventNode* parent = nullptr)
{
return adopt_ref(*new FileEventNode(path, parent));
}
FileEventNode& find_or_create_node(String const&);
FileEventNode& find_or_create_node(DeprecatedString const&);
Vector<NonnullRefPtr<FileEventNode>>& children() { return m_children; }
Vector<NonnullRefPtr<FileEventNode>> const& children() const { return m_children; }
FileEventNode* parent() { return m_parent; };
FileEventNode& create_recursively(String);
FileEventNode& create_recursively(DeprecatedString);
void for_each_parent_node(Function<void(FileEventNode&)> callback);
String const& path() const { return m_path; }
DeprecatedString const& path() const { return m_path; }
void increment_count() { m_count++; }
u64 count() const { return m_count; }
@ -42,13 +42,13 @@ public:
u64 duration() const { return m_duration; }
private:
FileEventNode(String const& path, FileEventNode* parent = nullptr)
FileEventNode(DeprecatedString const& path, FileEventNode* parent = nullptr)
: m_path(path)
, m_count(0)
, m_duration(0)
, m_parent(parent) {};
String m_path;
DeprecatedString m_path;
u64 m_count;
u64 m_duration;
@ -74,7 +74,7 @@ public:
virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override;
virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override;
virtual String column_name(int) const override;
virtual DeprecatedString column_name(int) const override;
virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override;
virtual GUI::ModelIndex index(int row, int column, GUI::ModelIndex const& parent = GUI::ModelIndex()) const override;
virtual GUI::ModelIndex parent_index(GUI::ModelIndex const&) const override;

View file

@ -89,7 +89,7 @@ void FlameGraphView::mousemove_event(GUI::MouseEvent& event)
if (on_hover_change)
on_hover_change();
String label = "";
DeprecatedString label = "";
if (m_hovered_bar != nullptr && m_hovered_bar->index.is_valid()) {
label = bar_label(*m_hovered_bar);
}
@ -175,10 +175,10 @@ void FlameGraphView::paint_event(GUI::PaintEvent& event)
}
}
String FlameGraphView::bar_label(StackBar const& bar) const
DeprecatedString FlameGraphView::bar_label(StackBar const& bar) const
{
auto label_index = bar.index.sibling_at_column(m_text_column);
String label = "All";
DeprecatedString label = "All";
if (label_index.is_valid()) {
label = m_model.data(label_index).to_string();
}

View file

@ -46,7 +46,7 @@ private:
bool selected;
};
String bar_label(StackBar const&) const;
DeprecatedString bar_label(StackBar const&) const;
void layout_bars();
void layout_children(GUI::ModelIndex& parent, int depth, int left, int right, Vector<GUI::ModelIndex>& selected);

View file

@ -29,7 +29,7 @@ int IndividualSampleModel::column_count(GUI::ModelIndex const&) const
return Column::__Count;
}
String IndividualSampleModel::column_name(int column) const
DeprecatedString IndividualSampleModel::column_name(int column) const
{
switch (column) {
case Column::Address:
@ -50,7 +50,7 @@ GUI::Variant IndividualSampleModel::data(GUI::ModelIndex const& index, GUI::Mode
if (role == GUI::ModelRole::Display) {
if (index.column() == Column::Address)
return String::formatted("{:p}", frame.address);
return DeprecatedString::formatted("{:p}", frame.address);
if (index.column() == Column::Symbol) {
return frame.symbol;

View file

@ -31,7 +31,7 @@ public:
virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override;
virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override;
virtual String column_name(int) const override;
virtual DeprecatedString column_name(int) const override;
virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override;
private:

View file

@ -41,9 +41,9 @@ void Process::handle_thread_exit(pid_t tid, EventSerialNumber serial)
thread->end_valid = serial;
}
HashMap<String, OwnPtr<MappedObject>> g_mapped_object_cache;
HashMap<DeprecatedString, OwnPtr<MappedObject>> g_mapped_object_cache;
static MappedObject* get_or_create_mapped_object(String const& path)
static MappedObject* get_or_create_mapped_object(DeprecatedString const& path)
{
if (auto it = g_mapped_object_cache.find(path); it != g_mapped_object_cache.end())
return it->value.ptr();
@ -67,7 +67,7 @@ static MappedObject* get_or_create_mapped_object(String const& path)
return ptr;
}
void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, String const& name)
void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, DeprecatedString const& name)
{
StringView path;
if (name.contains("Loader.so"sv))
@ -82,25 +82,25 @@ void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, String const& name)
// associated base address and size as new regions are discovered.
// We don't allocate a temporary String object if an entry already exists.
// This assumes that String::hash and StringView::hash return the same result.
// This assumes that DeprecatedString::hash and StringView::hash return the same result.
auto string_view_compare = [&path](auto& entry) { return path == entry.key.view(); };
if (auto existing_it = m_libraries.find(path.hash(), string_view_compare); existing_it != m_libraries.end()) {
auto& entry = *existing_it->value;
entry.base = min(entry.base, base);
entry.size = max(entry.size + size, base - entry.base + size);
} else {
String path_string = path.to_string();
String full_path;
DeprecatedString path_string = path.to_string();
DeprecatedString full_path;
if (path_string.starts_with('/'))
full_path = path_string;
else if (Core::File::looks_like_shared_library(path_string))
full_path = String::formatted("/usr/lib/{}", path);
full_path = DeprecatedString::formatted("/usr/lib/{}", path);
else
full_path = path_string;
auto* mapped_object = get_or_create_mapped_object(full_path);
if (!mapped_object) {
full_path = String::formatted("/usr/local/lib/{}", path);
full_path = DeprecatedString::formatted("/usr/local/lib/{}", path);
mapped_object = get_or_create_mapped_object(full_path);
if (!mapped_object)
return;
@ -112,14 +112,14 @@ void LibraryMetadata::handle_mmap(FlatPtr base, size_t size, String const& name)
Debug::DebugInfo const& LibraryMetadata::Library::load_debug_info(FlatPtr base_address) const
{
if (debug_info == nullptr)
debug_info = make<Debug::DebugInfo>(object->elf, String::empty(), base_address);
debug_info = make<Debug::DebugInfo>(object->elf, DeprecatedString::empty(), base_address);
return *debug_info.ptr();
}
String LibraryMetadata::Library::symbolicate(FlatPtr ptr, u32* offset) const
DeprecatedString LibraryMetadata::Library::symbolicate(FlatPtr ptr, u32* offset) const
{
if (!object)
return String::formatted("?? <{:p}>", ptr);
return DeprecatedString::formatted("?? <{:p}>", ptr);
return object->elf.symbolicate(ptr - base, offset);
}

View file

@ -21,27 +21,27 @@ struct MappedObject {
ELF::Image elf;
};
extern HashMap<String, OwnPtr<MappedObject>> g_mapped_object_cache;
extern HashMap<DeprecatedString, OwnPtr<MappedObject>> g_mapped_object_cache;
class LibraryMetadata {
public:
struct Library {
FlatPtr base;
size_t size;
String name;
DeprecatedString name;
MappedObject* object { nullptr };
// This is loaded lazily because we only need it in disassembly view
mutable OwnPtr<Debug::DebugInfo> debug_info;
String symbolicate(FlatPtr, u32* offset) const;
DeprecatedString symbolicate(FlatPtr, u32* offset) const;
Debug::DebugInfo const& load_debug_info(FlatPtr base_address) const;
};
void handle_mmap(FlatPtr base, size_t size, String const& name);
void handle_mmap(FlatPtr base, size_t size, DeprecatedString const& name);
Library const* library_containing(FlatPtr) const;
private:
mutable HashMap<String, NonnullOwnPtr<Library>> m_libraries;
mutable HashMap<DeprecatedString, NonnullOwnPtr<Library>> m_libraries;
};
struct Thread {
@ -57,8 +57,8 @@ struct Thread {
struct Process {
pid_t pid {};
String executable;
String basename;
DeprecatedString executable;
DeprecatedString basename;
HashMap<int, Vector<Thread>> threads {};
LibraryMetadata library_metadata {};
EventSerialNumber start_valid;

View file

@ -257,7 +257,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
if (!strings_value || !strings_value->is_array())
return Error::from_string_literal("Malformed profile (strings is not an array)");
HashMap<FlatPtr, String> profile_strings;
HashMap<FlatPtr, DeprecatedString> profile_strings;
for (FlatPtr string_id = 0; string_id < strings_value->as_array().size(); ++string_id) {
auto const& value = strings_value->as_array().at(string_id);
profile_strings.set(string_id, value.to_string());
@ -302,7 +302,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
} else if (type_string == "signpost"sv) {
auto string_id = perf_event.get("arg1"sv).to_number<FlatPtr>();
event.data = Event::SignpostData {
.string = profile_strings.get(string_id).value_or(String::formatted("Signpost #{}", string_id)),
.string = profile_strings.get(string_id).value_or(DeprecatedString::formatted("Signpost #{}", string_id)),
.arg = perf_event.get("arg2"sv).to_number<FlatPtr>(),
};
} else if (type_string == "mmap"sv) {
@ -411,13 +411,13 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
auto ptr = frame.to_number<u64>();
u32 offset = 0;
FlyString object_name;
String symbol;
DeprecatedString symbol;
if (maybe_kernel_base.has_value() && ptr >= maybe_kernel_base.value()) {
if (g_kernel_debuginfo_object.has_value()) {
symbol = g_kernel_debuginfo_object->elf.symbolicate(ptr - maybe_kernel_base.value(), &offset);
} else {
symbol = String::formatted("?? <{:p}>", ptr);
symbol = DeprecatedString::formatted("?? <{:p}>", ptr);
}
} else {
auto it = current_processes.find(event.pid);
@ -429,7 +429,7 @@ ErrorOr<NonnullOwnPtr<Profile>> Profile::load_from_perfcore_file(StringView path
object_name = library->name;
symbol = library->symbolicate(ptr, &offset);
} else {
symbol = String::formatted("?? <{:p}>", ptr);
symbol = DeprecatedString::formatted("?? <{:p}>", ptr);
}
}
@ -610,7 +610,7 @@ ProfileNode::ProfileNode(Process const& process)
{
}
ProfileNode::ProfileNode(Process const& process, FlyString const& object_name, String symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t pid)
ProfileNode::ProfileNode(Process const& process, FlyString const& object_name, DeprecatedString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t pid)
: m_process(process)
, m_symbol(move(symbol))
, m_pid(pid)
@ -618,7 +618,7 @@ ProfileNode::ProfileNode(Process const& process, FlyString const& object_name, S
, m_offset(offset)
, m_timestamp(timestamp)
{
String object;
DeprecatedString object;
if (object_name.ends_with(": .text"sv)) {
object = object_name.view().substring_view(0, object_name.length() - 7);
} else {

View file

@ -34,7 +34,7 @@ extern OwnPtr<Debug::DebugInfo> g_kernel_debug_info;
class ProfileNode : public RefCounted<ProfileNode> {
public:
static NonnullRefPtr<ProfileNode> create(Process const& process, FlyString const& object_name, String symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t pid)
static NonnullRefPtr<ProfileNode> create(Process const& process, FlyString const& object_name, DeprecatedString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t pid)
{
return adopt_ref(*new ProfileNode(process, object_name, move(symbol), address, offset, timestamp, pid));
}
@ -54,7 +54,7 @@ public:
void did_see_event(size_t event_index) { m_seen_events.set(event_index, true); }
FlyString const& object_name() const { return m_object_name; }
String const& symbol() const { return m_symbol; }
DeprecatedString const& symbol() const { return m_symbol; }
FlatPtr address() const { return m_address; }
u32 offset() const { return m_offset; }
u64 timestamp() const { return m_timestamp; }
@ -74,7 +74,7 @@ public:
m_children.append(child);
}
ProfileNode& find_or_create_child(FlyString const& object_name, String symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t pid)
ProfileNode& find_or_create_child(FlyString const& object_name, DeprecatedString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t pid)
{
for (size_t i = 0; i < m_children.size(); ++i) {
auto& child = m_children[i];
@ -112,13 +112,13 @@ public:
private:
explicit ProfileNode(Process const&);
explicit ProfileNode(Process const&, FlyString const& object_name, String symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t);
explicit ProfileNode(Process const&, FlyString const& object_name, DeprecatedString symbol, FlatPtr address, u32 offset, u64 timestamp, pid_t);
bool m_root { false };
Process const& m_process;
ProfileNode* m_parent { nullptr };
FlyString m_object_name;
String m_symbol;
DeprecatedString m_symbol;
pid_t m_pid { 0 };
FlatPtr m_address { 0 };
u32 m_offset { 0 };
@ -167,7 +167,7 @@ public:
struct Frame {
FlyString object_name;
String symbol;
DeprecatedString symbol;
FlatPtr address { 0 };
u32 offset { 0 };
};
@ -195,14 +195,14 @@ public:
};
struct SignpostData {
String string;
DeprecatedString string;
FlatPtr arg {};
};
struct MmapData {
FlatPtr ptr {};
size_t size {};
String name;
DeprecatedString name;
};
struct MunmapData {
@ -212,11 +212,11 @@ public:
struct ProcessCreateData {
pid_t parent_pid { 0 };
String executable;
DeprecatedString executable;
};
struct ProcessExecData {
String executable;
DeprecatedString executable;
};
struct ThreadCreateData {
@ -226,7 +226,7 @@ public:
struct ReadData {
int fd;
size_t size;
String path;
DeprecatedString path;
size_t start_timestamp;
bool success;
};

View file

@ -72,7 +72,7 @@ int ProfileModel::column_count(GUI::ModelIndex const&) const
return Column::__Count;
}
String ProfileModel::column_name(int column) const
DeprecatedString ProfileModel::column_name(int column) const
{
switch (column) {
case Column::SampleCount:
@ -117,7 +117,7 @@ GUI::Variant ProfileModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol
* 100.f
/ static_cast<float>(m_profile.filtered_event_indices().size())
* percent_digits_rounding);
return String::formatted(
return DeprecatedString::formatted(
"{}.{:02}",
percentage_full_precision / percent_digits_rounding,
percentage_full_precision % percent_digits_rounding);
@ -136,7 +136,7 @@ GUI::Variant ProfileModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol
return node->object_name();
if (index.column() == Column::StackFrame) {
if (node->is_root()) {
return String::formatted("{} ({})", node->process().basename, node->process().pid);
return DeprecatedString::formatted("{} ({})", node->process().basename, node->process().pid);
}
return node->symbol();
}
@ -146,7 +146,7 @@ GUI::Variant ProfileModel::data(GUI::ModelIndex const& index, GUI::ModelRole rol
auto const* library = node->process().library_metadata.library_containing(node->address());
if (!library)
return "";
return String::formatted("{:p} (offset {:p})", node->address(), node->address() - library->base);
return DeprecatedString::formatted("{:p} (offset {:p})", node->address(), node->address() - library->base);
}
return {};
}

View file

@ -37,7 +37,7 @@ public:
virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override;
virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override;
virtual String column_name(int) const override;
virtual DeprecatedString column_name(int) const override;
virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override;
virtual GUI::ModelIndex index(int row, int column, GUI::ModelIndex const& parent = GUI::ModelIndex()) const override;
virtual GUI::ModelIndex parent_index(GUI::ModelIndex const&) const override;

View file

@ -28,7 +28,7 @@ int SamplesModel::column_count(GUI::ModelIndex const&) const
return Column::__Count;
}
String SamplesModel::column_name(int column) const
DeprecatedString SamplesModel::column_name(int column) const
{
switch (column) {
case Column::SampleIndex:

View file

@ -36,7 +36,7 @@ public:
virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override;
virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override;
virtual String column_name(int) const override;
virtual DeprecatedString column_name(int) const override;
virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override;
virtual bool is_column_sortable(int) const override { return false; }

View file

@ -26,7 +26,7 @@ int SignpostsModel::column_count(GUI::ModelIndex const&) const
return Column::__Count;
}
String SignpostsModel::column_name(int column) const
DeprecatedString SignpostsModel::column_name(int column) const
{
switch (column) {
case Column::SignpostIndex:

View file

@ -35,7 +35,7 @@ public:
virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override;
virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override;
virtual String column_name(int) const override;
virtual DeprecatedString column_name(int) const override;
virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override;
virtual bool is_column_sortable(int) const override { return false; }

View file

@ -18,7 +18,7 @@ namespace Profiler {
class SourceFile final {
public:
struct Line {
String content;
DeprecatedString content;
size_t num_samples { 0 };
};
@ -26,7 +26,7 @@ public:
SourceFile(StringView filename)
{
String source_file_name = filename.replace("../../"sv, source_root_path, ReplaceMode::FirstOnly);
DeprecatedString source_file_name = filename.replace("../../"sv, source_root_path, ReplaceMode::FirstOnly);
auto try_read_lines = [&]() -> ErrorOr<void> {
auto unbuffered_file = TRY(Core::Stream::File::open(source_file_name, Core::Stream::OpenMode::Read));
@ -71,7 +71,7 @@ SourceModel::SourceModel(Profile& profile, ProfileNode& node)
return;
base_address = maybe_kernel_base.release_value();
if (g_kernel_debug_info == nullptr)
g_kernel_debug_info = make<Debug::DebugInfo>(g_kernel_debuginfo_object->elf, String::empty(), base_address);
g_kernel_debug_info = make<Debug::DebugInfo>(g_kernel_debuginfo_object->elf, DeprecatedString::empty(), base_address);
debug_info = g_kernel_debug_info.ptr();
} else {
auto const& process = node.process();
@ -87,7 +87,7 @@ SourceModel::SourceModel(Profile& profile, ProfileNode& node)
VERIFY(debug_info != nullptr);
// Try to read all source files contributing to the selected function and aggregate the samples by line.
HashMap<String, SourceFile> source_files;
HashMap<DeprecatedString, SourceFile> source_files;
for (auto const& pair : node.events_per_address()) {
auto position = debug_info->get_source_position(pair.key - base_address);
if (position.has_value()) {
@ -123,7 +123,7 @@ int SourceModel::row_count(GUI::ModelIndex const&) const
return m_source_lines.size();
}
String SourceModel::column_name(int column) const
DeprecatedString SourceModel::column_name(int column) const
{
switch (column) {
case Column::SampleCount:

View file

@ -16,9 +16,9 @@ class ProfileNode;
struct SourceLineData {
u32 event_count { 0 };
float percent { 0 };
String location;
DeprecatedString location;
u32 line_number { 0 };
String source_code;
DeprecatedString source_code;
};
class SourceModel final : public GUI::Model {
@ -38,7 +38,7 @@ public:
virtual int row_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override;
virtual int column_count(GUI::ModelIndex const& = GUI::ModelIndex()) const override { return Column::__Count; }
virtual String column_name(int) const override;
virtual DeprecatedString column_name(int) const override;
virtual GUI::Variant data(GUI::ModelIndex const&, GUI::ModelRole) const override;
virtual bool is_column_sortable(int) const override { return false; }

Some files were not shown because too many files have changed in this diff Show more