mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:47:35 +00:00
Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -26,7 +26,7 @@ void ConnectionFromClient::die()
|
|||
exit(0);
|
||||
}
|
||||
|
||||
void ConnectionFromClient::greet(DeprecatedString const& project_root)
|
||||
void ConnectionFromClient::greet(ByteString const& project_root)
|
||||
{
|
||||
m_filedb.set_project_root(project_root);
|
||||
if (unveil(project_root.characters(), "r") < 0) {
|
||||
|
@ -39,7 +39,7 @@ void ConnectionFromClient::greet(DeprecatedString const& project_root)
|
|||
}
|
||||
}
|
||||
|
||||
void ConnectionFromClient::file_opened(DeprecatedString const& filename, IPC::File const& file)
|
||||
void ConnectionFromClient::file_opened(ByteString const& filename, IPC::File const& file)
|
||||
{
|
||||
if (m_filedb.is_open(filename)) {
|
||||
return;
|
||||
|
@ -48,7 +48,7 @@ void ConnectionFromClient::file_opened(DeprecatedString const& filename, IPC::Fi
|
|||
m_autocomplete_engine->file_opened(filename);
|
||||
}
|
||||
|
||||
void ConnectionFromClient::file_edit_insert_text(DeprecatedString const& filename, DeprecatedString const& text, i32 start_line, i32 start_column)
|
||||
void ConnectionFromClient::file_edit_insert_text(ByteString const& filename, ByteString const& text, i32 start_line, i32 start_column)
|
||||
{
|
||||
dbgln_if(LANGUAGE_SERVER_DEBUG, "InsertText for file: {}", filename);
|
||||
dbgln_if(LANGUAGE_SERVER_DEBUG, "Text: {}", text);
|
||||
|
@ -57,7 +57,7 @@ void ConnectionFromClient::file_edit_insert_text(DeprecatedString const& filenam
|
|||
m_autocomplete_engine->on_edit(filename);
|
||||
}
|
||||
|
||||
void ConnectionFromClient::file_edit_remove_text(DeprecatedString const& filename, i32 start_line, i32 start_column, i32 end_line, i32 end_column)
|
||||
void ConnectionFromClient::file_edit_remove_text(ByteString 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);
|
||||
|
@ -80,7 +80,7 @@ void ConnectionFromClient::auto_complete_suggestions(CodeComprehension::ProjectL
|
|||
async_auto_complete_suggestions(move(suggestions));
|
||||
}
|
||||
|
||||
void ConnectionFromClient::set_file_content(DeprecatedString const& filename, DeprecatedString const& content)
|
||||
void ConnectionFromClient::set_file_content(ByteString const& filename, ByteString const& content)
|
||||
{
|
||||
dbgln_if(LANGUAGE_SERVER_DEBUG, "SetFileContent: {}", filename);
|
||||
auto document = m_filedb.get_document(filename);
|
||||
|
@ -139,7 +139,7 @@ void ConnectionFromClient::get_parameters_hint(CodeComprehension::ProjectLocatio
|
|||
async_parameters_hint_result(params->params, params->current_index);
|
||||
}
|
||||
|
||||
void ConnectionFromClient::get_tokens_info(DeprecatedString const& filename)
|
||||
void ConnectionFromClient::get_tokens_info(ByteString const& filename)
|
||||
{
|
||||
dbgln_if(LANGUAGE_SERVER_DEBUG, "GetTokenInfo: {}", filename);
|
||||
auto document = m_filedb.get_document(filename);
|
||||
|
|
|
@ -27,15 +27,15 @@ public:
|
|||
virtual void die() override;
|
||||
|
||||
protected:
|
||||
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 greet(ByteString const&) override;
|
||||
virtual void file_opened(ByteString const&, IPC::File const&) override;
|
||||
virtual void file_edit_insert_text(ByteString const&, ByteString const&, i32, i32) override;
|
||||
virtual void file_edit_remove_text(ByteString const&, i32, i32, i32, i32) override;
|
||||
virtual void set_file_content(ByteString const&, ByteString 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(DeprecatedString const&) override;
|
||||
virtual void get_tokens_info(ByteString const&) override;
|
||||
|
||||
FileDB m_filedb;
|
||||
OwnPtr<CodeComprehension::CodeComprehensionEngine> m_autocomplete_engine;
|
||||
|
|
|
@ -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](DeprecatedString const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
|
||||
m_autocomplete_engine->set_declarations_of_document_callback = [this](ByteString const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
|
||||
async_declarations_in_document(filename, move(declarations));
|
||||
};
|
||||
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](DeprecatedString const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
|
||||
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](ByteString const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
|
||||
async_todo_entries_in_document(filename, move(todo_entries));
|
||||
};
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
namespace LanguageServers {
|
||||
|
||||
RefPtr<const GUI::TextDocument> FileDB::get_document(DeprecatedString const& filename) const
|
||||
RefPtr<const GUI::TextDocument> FileDB::get_document(ByteString const& filename) const
|
||||
{
|
||||
auto absolute_path = to_absolute_path(filename);
|
||||
auto document_optional = m_open_files.get(absolute_path);
|
||||
|
@ -23,7 +23,7 @@ RefPtr<const GUI::TextDocument> FileDB::get_document(DeprecatedString const& fil
|
|||
return *document_optional.value();
|
||||
}
|
||||
|
||||
RefPtr<GUI::TextDocument> FileDB::get_document(DeprecatedString const& filename)
|
||||
RefPtr<GUI::TextDocument> FileDB::get_document(ByteString const& filename)
|
||||
{
|
||||
auto document = reinterpret_cast<FileDB const*>(this)->get_document(filename);
|
||||
if (document.is_null())
|
||||
|
@ -31,7 +31,7 @@ RefPtr<GUI::TextDocument> FileDB::get_document(DeprecatedString const& filename)
|
|||
return adopt_ref(*const_cast<GUI::TextDocument*>(document.leak_ref()));
|
||||
}
|
||||
|
||||
Optional<DeprecatedString> FileDB::get_or_read_from_filesystem(StringView filename) const
|
||||
Optional<ByteString> FileDB::get_or_read_from_filesystem(StringView filename) const
|
||||
{
|
||||
auto absolute_path = to_absolute_path(filename);
|
||||
auto document = get_document(absolute_path);
|
||||
|
@ -46,12 +46,12 @@ Optional<DeprecatedString> FileDB::get_or_read_from_filesystem(StringView filena
|
|||
return document_or_error.value()->text();
|
||||
}
|
||||
|
||||
bool FileDB::is_open(DeprecatedString const& filename) const
|
||||
bool FileDB::is_open(ByteString const& filename) const
|
||||
{
|
||||
return m_open_files.contains(to_absolute_path(filename));
|
||||
}
|
||||
|
||||
bool FileDB::add(DeprecatedString const& filename, int fd)
|
||||
bool FileDB::add(ByteString const& filename, int fd)
|
||||
{
|
||||
auto document_or_error = create_from_fd(fd);
|
||||
if (document_or_error.is_error()) {
|
||||
|
@ -63,17 +63,17 @@ bool FileDB::add(DeprecatedString const& filename, int fd)
|
|||
return true;
|
||||
}
|
||||
|
||||
DeprecatedString FileDB::to_absolute_path(DeprecatedString const& filename) const
|
||||
ByteString FileDB::to_absolute_path(ByteString const& filename) const
|
||||
{
|
||||
if (LexicalPath { filename }.is_absolute()) {
|
||||
return filename;
|
||||
}
|
||||
if (!m_project_root.has_value())
|
||||
return filename;
|
||||
return LexicalPath { DeprecatedString::formatted("{}/{}", *m_project_root, filename) }.string();
|
||||
return LexicalPath { ByteString::formatted("{}/{}", *m_project_root, filename) }.string();
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<GUI::TextDocument>> FileDB::create_from_filesystem(DeprecatedString const& filename) const
|
||||
ErrorOr<NonnullRefPtr<GUI::TextDocument>> FileDB::create_from_filesystem(ByteString const& filename) const
|
||||
{
|
||||
auto file = TRY(Core::File::open(to_absolute_path(filename), Core::File::OpenMode::Read));
|
||||
return create_from_file(move(file));
|
||||
|
@ -110,7 +110,7 @@ ErrorOr<NonnullRefPtr<GUI::TextDocument>> FileDB::create_from_file(NonnullOwnPtr
|
|||
return document;
|
||||
}
|
||||
|
||||
void FileDB::on_file_edit_insert_text(DeprecatedString const& filename, DeprecatedString const& inserted_text, size_t start_line, size_t start_column)
|
||||
void FileDB::on_file_edit_insert_text(ByteString const& filename, ByteString const& inserted_text, size_t start_line, size_t start_column)
|
||||
{
|
||||
VERIFY(is_open(filename));
|
||||
auto document = get_document(filename);
|
||||
|
@ -121,7 +121,7 @@ void FileDB::on_file_edit_insert_text(DeprecatedString const& filename, Deprecat
|
|||
dbgln_if(FILE_CONTENT_DEBUG, "{}", document->text());
|
||||
}
|
||||
|
||||
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)
|
||||
void FileDB::on_file_edit_remove_text(ByteString 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
|
||||
|
@ -138,7 +138,7 @@ void FileDB::on_file_edit_remove_text(DeprecatedString const& filename, size_t s
|
|||
dbgln_if(FILE_CONTENT_DEBUG, "{}", document->text());
|
||||
}
|
||||
|
||||
RefPtr<GUI::TextDocument> FileDB::create_with_content(DeprecatedString const& content)
|
||||
RefPtr<GUI::TextDocument> FileDB::create_with_content(ByteString const& content)
|
||||
{
|
||||
StringView content_view(content);
|
||||
auto document = GUI::TextDocument::create(&s_default_document_client);
|
||||
|
@ -146,7 +146,7 @@ RefPtr<GUI::TextDocument> FileDB::create_with_content(DeprecatedString const& co
|
|||
return document;
|
||||
}
|
||||
|
||||
bool FileDB::add(DeprecatedString const& filename, DeprecatedString const& content)
|
||||
bool FileDB::add(ByteString const& filename, ByteString const& content)
|
||||
{
|
||||
auto document = create_with_content(content);
|
||||
if (!document) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <LibCodeComprehension/FileDB.h>
|
||||
|
@ -17,28 +17,28 @@ namespace LanguageServers {
|
|||
class FileDB final : public CodeComprehension::FileDB {
|
||||
public:
|
||||
FileDB() = default;
|
||||
virtual Optional<DeprecatedString> get_or_read_from_filesystem(StringView filename) const override;
|
||||
virtual Optional<ByteString> get_or_read_from_filesystem(StringView filename) const override;
|
||||
|
||||
RefPtr<const GUI::TextDocument> get_document(DeprecatedString const& filename) const;
|
||||
RefPtr<GUI::TextDocument> get_document(DeprecatedString const& filename);
|
||||
RefPtr<const GUI::TextDocument> get_document(ByteString const& filename) const;
|
||||
RefPtr<GUI::TextDocument> get_document(ByteString const& filename);
|
||||
|
||||
bool add(DeprecatedString const& filename, int fd);
|
||||
bool add(DeprecatedString const& filename, DeprecatedString const& content);
|
||||
bool add(ByteString const& filename, int fd);
|
||||
bool add(ByteString const& filename, ByteString const& content);
|
||||
|
||||
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;
|
||||
void on_file_edit_insert_text(ByteString const& filename, ByteString const& inserted_text, size_t start_line, size_t start_column);
|
||||
void on_file_edit_remove_text(ByteString const& filename, size_t start_line, size_t start_column, size_t end_line, size_t end_column);
|
||||
ByteString to_absolute_path(ByteString const& filename) const;
|
||||
bool is_open(ByteString const& filename) const;
|
||||
|
||||
private:
|
||||
ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_filesystem(DeprecatedString const& filename) const;
|
||||
ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_filesystem(ByteString const& filename) const;
|
||||
ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_fd(int fd) const;
|
||||
ErrorOr<NonnullRefPtr<GUI::TextDocument>> create_from_file(NonnullOwnPtr<Core::File>) const;
|
||||
static RefPtr<GUI::TextDocument> create_with_content(DeprecatedString const&);
|
||||
static RefPtr<GUI::TextDocument> create_with_content(ByteString const&);
|
||||
|
||||
private:
|
||||
HashMap<DeprecatedString, NonnullRefPtr<GUI::TextDocument>> m_open_files;
|
||||
Optional<DeprecatedString> m_project_root;
|
||||
HashMap<ByteString, NonnullRefPtr<GUI::TextDocument>> m_open_files;
|
||||
Optional<ByteString> m_project_root;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ endpoint LanguageClient
|
|||
{
|
||||
auto_complete_suggestions(Vector<CodeComprehension::AutocompleteResultEntry> suggestions) =|
|
||||
declaration_location(CodeComprehension::ProjectLocation location) =|
|
||||
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) =|
|
||||
declarations_in_document(ByteString filename, Vector<CodeComprehension::Declaration> declarations) =|
|
||||
todo_entries_in_document(ByteString filename, Vector<CodeComprehension::TodoEntry> todo_entries) =|
|
||||
parameters_hint_result(Vector<ByteString> params, int current_index) =|
|
||||
tokens_info_result(Vector<CodeComprehension::TokenInfo> tokens_info) =|
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
endpoint LanguageServer
|
||||
{
|
||||
greet(DeprecatedString project_root) =|
|
||||
greet(ByteString project_root) =|
|
||||
|
||||
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) =|
|
||||
file_opened(ByteString filename, IPC::File file) =|
|
||||
file_edit_insert_text(ByteString filename, ByteString text, i32 start_line, i32 start_column) =|
|
||||
file_edit_remove_text(ByteString filename, i32 start_line, i32 start_column, i32 end_line, i32 end_column) =|
|
||||
set_file_content(ByteString filename, ByteString content) =|
|
||||
|
||||
auto_complete_suggestions(CodeComprehension::ProjectLocation location) =|
|
||||
find_declaration(CodeComprehension::ProjectLocation location) =|
|
||||
get_parameters_hint(CodeComprehension::ProjectLocation location) =|
|
||||
get_tokens_info(DeprecatedString filename) =|
|
||||
get_tokens_info(ByteString filename) =|
|
||||
|
||||
}
|
||||
|
|
|
@ -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](DeprecatedString const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
|
||||
m_autocomplete_engine->set_declarations_of_document_callback = [this](ByteString const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
|
||||
async_declarations_in_document(filename, move(declarations));
|
||||
};
|
||||
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](DeprecatedString const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
|
||||
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](ByteString const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
|
||||
async_todo_entries_in_document(filename, move(todo_entries));
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue