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

Userland: Update IPC calls to use proxies

This updates all existing code to use the auto-generated client
methods instead of post_message/send_sync.
This commit is contained in:
Gunnar Beutner 2021-05-03 13:33:59 +02:00 committed by Andreas Kling
parent 78803ce384
commit 5bb79ea0a7
63 changed files with 303 additions and 316 deletions

View file

@ -43,14 +43,14 @@ void LanguageClient::open_file(const String& path, int fd)
{
if (!m_connection_wrapper.connection())
return;
m_connection_wrapper.connection()->post_message(Messages::LanguageServer::FileOpened(path, fd));
m_connection_wrapper.connection()->async_file_opened(path, fd);
}
void LanguageClient::set_file_content(const String& path, const String& content)
{
if (!m_connection_wrapper.connection())
return;
m_connection_wrapper.connection()->post_message(Messages::LanguageServer::SetFileContent(path, content));
m_connection_wrapper.connection()->async_set_file_content(path, content);
}
void LanguageClient::insert_text(const String& path, const String& text, size_t line, size_t column)
@ -58,14 +58,14 @@ void LanguageClient::insert_text(const String& path, const String& text, size_t
if (!m_connection_wrapper.connection())
return;
// set_active_client();
m_connection_wrapper.connection()->post_message(Messages::LanguageServer::FileEditInsertText(path, text, line, column));
m_connection_wrapper.connection()->async_file_edit_insert_text(path, text, line, column);
}
void LanguageClient::remove_text(const String& 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()->post_message(Messages::LanguageServer::FileEditRemoveText(path, from_line, from_column, to_line, to_column));
m_connection_wrapper.connection()->async_file_edit_remove_text(path, from_line, from_column, to_line, to_column);
}
void LanguageClient::request_autocomplete(const String& path, size_t cursor_line, size_t cursor_column)
@ -73,7 +73,7 @@ void LanguageClient::request_autocomplete(const String& path, size_t cursor_line
if (!m_connection_wrapper.connection())
return;
set_active_client();
m_connection_wrapper.connection()->post_message(Messages::LanguageServer::AutoCompleteSuggestions(GUI::AutocompleteProvider::ProjectLocation { path, cursor_line, cursor_column }));
m_connection_wrapper.connection()->async_auto_complete_suggestions(GUI::AutocompleteProvider::ProjectLocation { path, cursor_line, cursor_column });
}
void LanguageClient::provide_autocomplete_suggestions(const Vector<GUI::AutocompleteProvider::Entry>& suggestions) const
@ -88,7 +88,7 @@ void LanguageClient::set_autocomplete_mode(const String& mode)
{
if (!m_connection_wrapper.connection())
return;
m_connection_wrapper.connection()->post_message(Messages::LanguageServer::SetAutoCompleteMode(mode));
m_connection_wrapper.connection()->async_set_auto_complete_mode(mode);
}
void LanguageClient::set_active_client()
@ -110,7 +110,7 @@ void LanguageClient::search_declaration(const String& path, size_t line, size_t
if (!m_connection_wrapper.connection())
return;
set_active_client();
m_connection_wrapper.connection()->post_message(Messages::LanguageServer::FindDeclaration(GUI::AutocompleteProvider::ProjectLocation { path, line, column }));
m_connection_wrapper.connection()->async_find_declaration(GUI::AutocompleteProvider::ProjectLocation { path, line, column });
}
void LanguageClient::declaration_found(const String& file, size_t line, size_t column) const
@ -221,7 +221,7 @@ void ServerConnectionWrapper::try_respawn_connection()
project().for_each_text_file([this](const ProjectFile& file) {
if (file.code_document().language() != m_language)
return;
m_connection->post_message(Messages::LanguageServer::SetFileContent(file.code_document().file_path(), file.document().text()));
m_connection->async_set_file_content(file.code_document().file_path(), file.document().text());
});
}

View file

@ -38,7 +38,7 @@ public:
virtual void handshake() override
{
send_sync<Messages::LanguageServer::Greet>(m_project_path);
greet(m_project_path);
}
WeakPtr<LanguageClient> language_client() { return m_current_language_client; }

View file

@ -81,7 +81,7 @@ void ClientConnection::auto_complete_suggestions(GUI::AutocompleteProvider::Proj
GUI::TextPosition autocomplete_position = { (size_t)location.line, (size_t)max(location.column, location.column - 1) };
Vector<GUI::AutocompleteProvider::Entry> suggestions = m_autocomplete_engine->get_suggestions(location.file, autocomplete_position);
post_message(Messages::LanguageClient::AutoCompleteSuggestions(move(suggestions)));
async_auto_complete_suggestions(move(suggestions));
}
void ClientConnection::set_file_content(String const& filename, String const& content)
@ -115,12 +115,12 @@ void ClientConnection::find_declaration(GUI::AutocompleteProvider::ProjectLocati
}
dbgln_if(LANGUAGE_SERVER_DEBUG, "declaration location: {} {}:{}", decl_location.value().file, decl_location.value().line, decl_location.value().column);
post_message(Messages::LanguageClient::DeclarationLocation(GUI::AutocompleteProvider::ProjectLocation { decl_location.value().file, decl_location.value().line, decl_location.value().column }));
async_declaration_location(GUI::AutocompleteProvider::ProjectLocation { decl_location.value().file, decl_location.value().line, decl_location.value().column });
}
void ClientConnection::set_declarations_of_document_callback(ClientConnection& instance, const String& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations)
{
instance.post_message(Messages::LanguageClient::DeclarationsInDocument(filename, move(declarations)));
instance.async_declarations_in_document(filename, move(declarations));
}
}

View file

@ -19,8 +19,7 @@
namespace LanguageServers {
class ClientConnection
: public IPC::ClientConnection<LanguageClientEndpoint, LanguageServerEndpoint>
{
: public IPC::ClientConnection<LanguageClientEndpoint, LanguageServerEndpoint> {
public:
explicit ClientConnection(NonnullRefPtr<Core::LocalSocket>, int client_id);
~ClientConnection() override;

View file

@ -254,9 +254,9 @@ int main(int argc, char** argv)
#include <LibIPC/Decoder.h>
#include <LibIPC/Dictionary.h>
#include <LibIPC/Encoder.h>
#include <LibIPC/Stub.h>
#include <LibIPC/File.h>
#include <LibIPC/Message.h>
#include <LibIPC/Stub.h>
)~~~");
for (auto& endpoint : endpoints) {