1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +00:00

HackStudio: Abstract away language-server details

This commit moves all the logic that deals with the language server
(from HackStudio) into a LanguageClient class, provides some functions
to make constructing them easier, and makes all language servers use a
singular IPC definition.
Also fixes the FIXME about making the autocompletion async.
This makes adding language servers in the future significantly less
duplicate-y, and significantly easier :^)
This commit is contained in:
AnotherTest 2020-10-02 03:01:33 +03:30 committed by Andreas Kling
parent 44f9637e20
commit ac5e08a541
17 changed files with 291 additions and 118 deletions

View file

@ -28,16 +28,16 @@
#include <AK/HashMap.h>
#include <AK/LexicalPath.h>
#include <DevTools/HackStudio/LanguageServers/Cpp/CppLanguageClientEndpoint.h>
#include <DevTools/HackStudio/LanguageServers/Cpp/CppLanguageServerEndpoint.h>
#include <DevTools/HackStudio/LanguageServers/LanguageClientEndpoint.h>
#include <DevTools/HackStudio/LanguageServers/LanguageServerEndpoint.h>
#include <LibGUI/TextDocument.h>
#include <LibIPC/ClientConnection.h>
namespace LanguageServers::Cpp {
class ClientConnection final
: public IPC::ClientConnection<CppLanguageClientEndpoint, CppLanguageServerEndpoint>
, public CppLanguageServerEndpoint {
: public IPC::ClientConnection<LanguageClientEndpoint, LanguageServerEndpoint>
, public LanguageServerEndpoint {
C_OBJECT(ClientConnection);
public:
@ -47,12 +47,12 @@ public:
virtual void die() override;
private:
virtual OwnPtr<Messages::CppLanguageServer::GreetResponse> handle(const Messages::CppLanguageServer::Greet&) override;
virtual void handle(const Messages::CppLanguageServer::FileOpened&) override;
virtual void handle(const Messages::CppLanguageServer::FileEditInsertText&) override;
virtual void handle(const Messages::CppLanguageServer::FileEditRemoveText&) override;
virtual void handle(const Messages::CppLanguageServer::SetFileContent&) override;
virtual OwnPtr<Messages::CppLanguageServer::AutoCompleteSuggestionsResponse> handle(const Messages::CppLanguageServer::AutoCompleteSuggestions&) override;
virtual OwnPtr<Messages::LanguageServer::GreetResponse> handle(const Messages::LanguageServer::Greet&) override;
virtual void handle(const Messages::LanguageServer::FileOpened&) override;
virtual void handle(const Messages::LanguageServer::FileEditInsertText&) override;
virtual void handle(const Messages::LanguageServer::FileEditRemoveText&) override;
virtual void handle(const Messages::LanguageServer::SetFileContent&) override;
virtual void handle(const Messages::LanguageServer::AutoCompleteSuggestions&) override;
RefPtr<GUI::TextDocument> document_for(const String& file_name);