diff --git a/DevTools/HackStudio/CMakeLists.txt b/DevTools/HackStudio/CMakeLists.txt index b8f35978b7..12095a938e 100644 --- a/DevTools/HackStudio/CMakeLists.txt +++ b/DevTools/HackStudio/CMakeLists.txt @@ -23,6 +23,7 @@ set(SOURCES Git/GitRepo.cpp Git/GitWidget.cpp HackStudioWidget.cpp + LanguageClient.cpp Locator.cpp ProcessStateWidget.cpp Project.cpp diff --git a/DevTools/HackStudio/Editor.cpp b/DevTools/HackStudio/Editor.cpp index cfd815ef83..c52a8d1a3b 100644 --- a/DevTools/HackStudio/Editor.cpp +++ b/DevTools/HackStudio/Editor.cpp @@ -473,7 +473,7 @@ void Editor::set_document(GUI::TextDocument& doc) switch (code_document.language()) { case Language::Cpp: set_syntax_highlighter(make()); - cpp_Language_server_connection().post_message(Messages::CppLanguageServer::FileOpened(code_document.file_path().string())); + m_language_client = get_language_client(project().root_directory()); break; case Language::JavaScript: set_syntax_highlighter(make()); @@ -487,6 +487,9 @@ void Editor::set_document(GUI::TextDocument& doc) default: set_syntax_highlighter(nullptr); } + + if (m_language_client) + m_language_client->open_file(code_document.file_path().string()); } Optional Editor::get_autocomplete_request_data() @@ -517,22 +520,25 @@ Optional Editor::get_autocomplete_request_data( void Editor::update_autocomplete(const AutoCompleteRequestData& data) { - if (code_document().language() != Language::Cpp) + if (!m_language_client) return; - auto autocomplete_response = cpp_Language_server_connection().send_sync( + + m_language_client->on_autocomplete_suggestions = [=, this](auto suggestions) { + if (suggestions.is_empty()) { + close_autocomplete(); + return; + } + + show_autocomplete(data); + + m_autocomplete_box->update_suggestions(data.partial_input, move(suggestions)); + m_autocomplete_in_focus = true; + }; + + m_language_client->request_autocomplete( code_document().file_path().string(), data.position.line(), data.position.column()); - ASSERT(autocomplete_response); - - auto suggestions = autocomplete_response->suggestions(); - if (suggestions.is_empty()) { - close_autocomplete(); - return; - } - - m_autocomplete_box->update_suggestions(data.partial_input, move(suggestions)); - m_autocomplete_in_focus = true; } void Editor::show_autocomplete(const AutoCompleteRequestData& data) @@ -549,29 +555,27 @@ void Editor::close_autocomplete() void Editor::on_edit_action(const GUI::Command& command) { - if (code_document().language() != Language::Cpp) + if (!m_language_client) return; if (command.is_insert_text()) { const GUI::InsertTextCommand& insert_command = static_cast(command); - cpp_Language_server_connection().post_message( - Messages::CppLanguageServer::FileEditInsertText( - code_document().file_path().string(), - insert_command.text(), - insert_command.range().start().line(), - insert_command.range().start().column())); + m_language_client->insert_text( + code_document().file_path().string(), + insert_command.text(), + insert_command.range().start().line(), + insert_command.range().start().column()); return; } if (command.is_remove_text()) { const GUI::RemoveTextCommand& remove_command = static_cast(command); - cpp_Language_server_connection().post_message( - Messages::CppLanguageServer::FileEditRemoveText( - code_document().file_path().string(), - remove_command.range().start().line(), - remove_command.range().start().column(), - remove_command.range().end().line(), - remove_command.range().end().column())); + m_language_client->remove_text( + code_document().file_path().string(), + remove_command.range().start().line(), + remove_command.range().start().column(), + remove_command.range().end().line(), + remove_command.range().end().column()); return; } @@ -592,13 +596,11 @@ void Editor::redo() void Editor::flush_file_content_to_langauge_server() { - if (code_document().language() != Language::Cpp) + if (!m_language_client) return; - cpp_Language_server_connection().post_message( - Messages::CppLanguageServer::SetFileContent( - code_document().file_path().string(), - document().text())); + m_language_client->set_file_content( + code_document().file_path().string(), + document().text()); } - } diff --git a/DevTools/HackStudio/Editor.h b/DevTools/HackStudio/Editor.h index 76dce15b56..fb208a2fa0 100644 --- a/DevTools/HackStudio/Editor.h +++ b/DevTools/HackStudio/Editor.h @@ -29,6 +29,7 @@ #include "AutoCompleteBox.h" #include "CodeDocument.h" #include "Debugger/BreakpointCallback.h" +#include "LanguageClient.h" #include #include #include @@ -107,6 +108,8 @@ private: bool m_hovering_link { false }; bool m_holding_ctrl { false }; bool m_autocomplete_in_focus { false }; + + OwnPtr m_language_client; }; } diff --git a/DevTools/HackStudio/HackStudio.h b/DevTools/HackStudio/HackStudio.h index 7aebad117a..85247453d8 100644 --- a/DevTools/HackStudio/HackStudio.h +++ b/DevTools/HackStudio/HackStudio.h @@ -27,7 +27,7 @@ #pragma once #include "EditorWrapper.h" -#include "LanguageClients/Cpp/ServerConnection.h" +#include "LanguageClients/ServerConnections.h" #include "Project.h" #include #include @@ -41,6 +41,5 @@ void open_file(const String&); Project& project(); String currently_open_file(); void set_current_editor_wrapper(RefPtr); -LanguageClients::Cpp::ServerConnection& cpp_Language_server_connection(); } diff --git a/DevTools/HackStudio/LanguageClient.cpp b/DevTools/HackStudio/LanguageClient.cpp new file mode 100644 index 0000000000..36539802d3 --- /dev/null +++ b/DevTools/HackStudio/LanguageClient.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2020, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "LanguageClient.h" +#include +#include + +namespace HackStudio { + +void ServerConnection::handle(const Messages::LanguageClient::AutoCompleteSuggestions& message) +{ + if (m_language_client) + m_language_client->provide_autocomplete_suggestions(message.suggestions()); +} + +void LanguageClient::open_file(const String& path) +{ + m_connection.post_message(Messages::LanguageServer::FileOpened(path)); +} + +void LanguageClient::set_file_content(const String& path, const String& content) +{ + m_connection.post_message(Messages::LanguageServer::SetFileContent(path, content)); +} + +void LanguageClient::insert_text(const String& path, const String& text, size_t line, size_t column) +{ + m_connection.post_message(Messages::LanguageServer::FileEditInsertText(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) +{ + m_connection.post_message(Messages::LanguageServer::FileEditRemoveText(path, from_line, from_column, to_line, to_column)); +} + +void LanguageClient::request_autocomplete(const String& path, size_t cursor_line, size_t cursor_column) +{ + m_connection.post_message(Messages::LanguageServer::AutoCompleteSuggestions(path, cursor_line, cursor_column)); +} + +void LanguageClient::provide_autocomplete_suggestions(const Vector& suggestions) +{ + if (on_autocomplete_suggestions) + on_autocomplete_suggestions(suggestions); + + // Otherwise, drop it on the floor :shrug: +} + +} diff --git a/DevTools/HackStudio/LanguageClient.h b/DevTools/HackStudio/LanguageClient.h new file mode 100644 index 0000000000..905c09c951 --- /dev/null +++ b/DevTools/HackStudio/LanguageClient.h @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2020, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace HackStudio { + +class LanguageClient; + +class ServerConnection + : public IPC::ServerConnection + , public LanguageClientEndpoint { +public: + ServerConnection(const StringView& socket, const StringView& project_path) + : IPC::ServerConnection(*this, socket) + , m_project_path(project_path) + { + } + + void attach(LanguageClient& client) + { + m_language_client = &client; + } + + void detach() + { + m_language_client = nullptr; + } + + virtual void handshake() override + { + auto response = send_sync(m_project_path.string()); + set_my_client_id(response->client_id()); + } + + template + static NonnullRefPtr get_or_create(const String& project_path) + { + static HashMap> s_instances_for_projects; + auto key = LexicalPath { project_path }.string(); + if (auto instance = s_instances_for_projects.get(key); instance.has_value()) + return *instance.value(); + + auto connection = ConcreteType::construct(project_path); + connection->handshake(); + s_instances_for_projects.set(key, *connection); + return *connection; + } + +protected: + virtual void handle(const Messages::LanguageClient::AutoCompleteSuggestions&) override; + + LanguageClient* m_language_client { nullptr }; + LexicalPath m_project_path; +}; + +class LanguageClient { +public: + explicit LanguageClient(NonnullRefPtr&& connection) + : m_connection(*connection) + , m_server_connection(move(connection)) + { + m_connection.attach(*this); + } + + virtual ~LanguageClient() + { + m_connection.detach(); + } + + virtual void open_file(const String& path); + virtual void set_file_content(const String& path, const String& content); + virtual void insert_text(const String& path, const String& text, size_t line, size_t column); + virtual void remove_text(const String& path, size_t from_line, size_t from_column, size_t to_line, size_t to_column); + virtual void request_autocomplete(const String& path, size_t cursor_line, size_t cursor_column); + + void provide_autocomplete_suggestions(const Vector&); + + Function)> on_autocomplete_suggestions; + +private: + ServerConnection& m_connection; + NonnullRefPtr m_server_connection; +}; + +template +static inline NonnullOwnPtr get_language_client(const String& project_path) +{ + return make(ServerConnection::get_or_create(project_path)); +} + +} diff --git a/DevTools/HackStudio/LanguageClients/CMakeLists.txt b/DevTools/HackStudio/LanguageClients/CMakeLists.txt index cdeb442a1d..8ffd97ebb7 100644 --- a/DevTools/HackStudio/LanguageClients/CMakeLists.txt +++ b/DevTools/HackStudio/LanguageClients/CMakeLists.txt @@ -1 +1,4 @@ -add_subdirectory(Cpp) + set(GENERATED_SOURCES + ../../LanguageServers/LanguageServerEndpoint.h + ../../LanguageServers/LanguageClientEndpoint.h + ) diff --git a/DevTools/HackStudio/LanguageClients/Cpp/CMakeLists.txt b/DevTools/HackStudio/LanguageClients/Cpp/CMakeLists.txt deleted file mode 100644 index f669bba3ed..0000000000 --- a/DevTools/HackStudio/LanguageClients/Cpp/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ - set(GENERATED_SOURCES - ../../LanguageServers/Cpp/CppLanguageServerEndpoint.h - ../../LanguageServers/Cpp/CppLanguageClientEndpoint.h - ) diff --git a/DevTools/HackStudio/LanguageClients/Cpp/ServerConnection.h b/DevTools/HackStudio/LanguageClients/ServerConnections.h similarity index 55% rename from DevTools/HackStudio/LanguageClients/Cpp/ServerConnection.h rename to DevTools/HackStudio/LanguageClients/ServerConnections.h index 9b916f42e4..cab9404f66 100644 --- a/DevTools/HackStudio/LanguageClients/Cpp/ServerConnection.h +++ b/DevTools/HackStudio/LanguageClients/ServerConnections.h @@ -26,35 +26,28 @@ #pragma once +#include "../LanguageClient.h" #include -#include -#include +#include +#include #include +#define LANGUAGE_CLIENT(namespace_, socket_name) \ + namespace namespace_ { \ + class ServerConnection : public HackStudio::ServerConnection { \ + C_OBJECT(ServerConnection) \ + private: \ + ServerConnection(const String& project_path) \ + : HackStudio::ServerConnection("/tmp/portal/language/" #socket_name, project_path) \ + { \ + } \ + }; \ + } + namespace LanguageClients { -namespace Cpp { -class ServerConnection : public IPC::ServerConnection - , public CppLanguageClientEndpoint { - C_OBJECT(ServerConnection) -public: - virtual void handshake() override - { - auto response = send_sync(m_project_path.string()); - set_my_client_id(response->client_id()); - } - -private: - ServerConnection(const String& project_path) - : IPC::ServerConnection(*this, "/tmp/portal/language/cpp") - , m_project_path(project_path) - { - } - - virtual void handle(const Messages::CppLanguageClient::Dummy&) override { } - - LexicalPath m_project_path; -}; +LANGUAGE_CLIENT(Cpp, cpp) } -} + +#undef LANGUAGE_CLIENT diff --git a/DevTools/HackStudio/LanguageServers/CMakeLists.txt b/DevTools/HackStudio/LanguageServers/CMakeLists.txt index cdeb442a1d..156dbe15c1 100644 --- a/DevTools/HackStudio/LanguageServers/CMakeLists.txt +++ b/DevTools/HackStudio/LanguageServers/CMakeLists.txt @@ -1 +1,4 @@ +compile_ipc(LanguageServer.ipc LanguageServerEndpoint.h) +compile_ipc(LanguageClient.ipc LanguageClientEndpoint.h) + add_subdirectory(Cpp) diff --git a/DevTools/HackStudio/LanguageServers/Cpp/CMakeLists.txt b/DevTools/HackStudio/LanguageServers/Cpp/CMakeLists.txt index 65d146295b..de9569d8ca 100644 --- a/DevTools/HackStudio/LanguageServers/Cpp/CMakeLists.txt +++ b/DevTools/HackStudio/LanguageServers/Cpp/CMakeLists.txt @@ -1,16 +1,15 @@ -compile_ipc(CppLanguageServer.ipc CppLanguageServerEndpoint.h) -compile_ipc(CppLanguageClient.ipc CppLanguageClientEndpoint.h) - set(SOURCES ClientConnection.cpp main.cpp - CppLanguageServerEndpoint.h - CppLanguageClientEndpoint.h AutoComplete.cpp ) +set(GENERATED_SOURCES + ../LanguageServerEndpoint.h + ../LanguageClientEndpoint.h) + serenity_bin(CppLanguageServer) -# We link with LibGUI because we use GUI::TextDocument to update +# We link with LibGUI because we use GUI::TextDocument to update # the content of files according to the edit actions we receive over IPC. target_link_libraries(CppLanguageServer LibIPC LibCpp LibGUI) diff --git a/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.cpp b/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.cpp index 21b820a814..5ffc750b8b 100644 --- a/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.cpp +++ b/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.cpp @@ -38,7 +38,7 @@ namespace LanguageServers::Cpp { static HashMap> s_connections; ClientConnection::ClientConnection(NonnullRefPtr socket, int client_id) - : IPC::ClientConnection(*this, move(socket), client_id) + : IPC::ClientConnection(*this, move(socket), client_id) { s_connections.set(client_id, *this); } @@ -53,13 +53,13 @@ void ClientConnection::die() exit(0); } -OwnPtr ClientConnection::handle(const Messages::CppLanguageServer::Greet& message) +OwnPtr ClientConnection::handle(const Messages::LanguageServer::Greet& message) { m_project_root = LexicalPath(message.project_root()); #ifdef DEBUG_CPP_LANGUAGE_SERVER dbg() << "project_root: " << m_project_root.string(); #endif - return make(client_id()); + return make(client_id()); } class DefaultDocumentClient final : public GUI::TextDocument::Client { @@ -74,12 +74,12 @@ public: virtual void document_did_set_cursor(const GUI::TextPosition&) override {}; virtual bool is_automatic_indentation_enabled() const override { return true; } - virtual int soft_tab_width() const { return 4; } + virtual int soft_tab_width() const override { return 4; } }; static DefaultDocumentClient s_default_document_client; -void ClientConnection::handle(const Messages::CppLanguageServer::FileOpened& message) +void ClientConnection::handle(const Messages::LanguageServer::FileOpened& message) { LexicalPath file_path(String::format("%s/%s", m_project_root.string().characters(), message.file_name().characters())); #ifdef DEBUG_CPP_LANGUAGE_SERVER @@ -103,7 +103,7 @@ void ClientConnection::handle(const Messages::CppLanguageServer::FileOpened& mes #endif } -void ClientConnection::handle(const Messages::CppLanguageServer::FileEditInsertText& message) +void ClientConnection::handle(const Messages::LanguageServer::FileEditInsertText& message) { #ifdef DEBUG_CPP_LANGUAGE_SERVER dbg() << "InsertText for file: " << message.file_name(); @@ -122,7 +122,7 @@ void ClientConnection::handle(const Messages::CppLanguageServer::FileEditInsertT #endif } -void ClientConnection::handle(const Messages::CppLanguageServer::FileEditRemoveText& message) +void ClientConnection::handle(const Messages::LanguageServer::FileEditRemoveText& message) { #ifdef DEBUG_CPP_LANGUAGE_SERVER dbg() << "RemoveText for file: " << message.file_name(); @@ -147,9 +147,7 @@ void ClientConnection::handle(const Messages::CppLanguageServer::FileEditRemoveT #endif } -// FIXME: The work we do here could be taxing and block the client for a significant time. -// Would should turn this to an async IPC endpoint and report the reuslts back in a separate Server->Client message. -OwnPtr ClientConnection::handle(const Messages::CppLanguageServer::AutoCompleteSuggestions& message) +void ClientConnection::handle(const Messages::LanguageServer::AutoCompleteSuggestions& message) { #ifdef DEBUG_CPP_LANGUAGE_SERVER dbg() << "AutoCompleteSuggestions for: " << message.file_name() << " " << message.cursor_line() << ":" << message.cursor_column(); @@ -158,11 +156,11 @@ OwnPtr ClientConne auto document = document_for(message.file_name()); if (!document) { dbg() << "file " << message.file_name() << " has not been opened"; - return nullptr; + return; } Vector suggestions = AutoComplete::get_suggestions(document->text(), { (size_t)message.cursor_line(), (size_t)message.cursor_column() }); - return make(suggestions); + post_message(Messages::LanguageClient::AutoCompleteSuggestions(move(suggestions))); } RefPtr ClientConnection::document_for(const String& file_name) @@ -174,7 +172,7 @@ RefPtr ClientConnection::document_for(const String& file_name return document_optional.value(); } -void ClientConnection::handle(const Messages::CppLanguageServer::SetFileContent& message) +void ClientConnection::handle(const Messages::LanguageServer::SetFileContent& message) { auto document = document_for(message.file_name()); if (!document) { diff --git a/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.h b/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.h index 428cfe7893..006688a524 100644 --- a/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.h +++ b/DevTools/HackStudio/LanguageServers/Cpp/ClientConnection.h @@ -28,16 +28,16 @@ #include #include -#include -#include +#include +#include #include #include namespace LanguageServers::Cpp { class ClientConnection final - : public IPC::ClientConnection - , public CppLanguageServerEndpoint { + : public IPC::ClientConnection + , public LanguageServerEndpoint { C_OBJECT(ClientConnection); public: @@ -47,12 +47,12 @@ public: virtual void die() override; private: - virtual OwnPtr 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 handle(const Messages::CppLanguageServer::AutoCompleteSuggestions&) override; + virtual OwnPtr 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 document_for(const String& file_name); diff --git a/DevTools/HackStudio/LanguageServers/Cpp/CppLanguageClient.ipc b/DevTools/HackStudio/LanguageServers/Cpp/CppLanguageClient.ipc deleted file mode 100644 index 47ae7f6fb6..0000000000 --- a/DevTools/HackStudio/LanguageServers/Cpp/CppLanguageClient.ipc +++ /dev/null @@ -1,4 +0,0 @@ -endpoint CppLanguageClient = 8002 -{ - Dummy() =| -} diff --git a/DevTools/HackStudio/LanguageServers/LanguageClient.ipc b/DevTools/HackStudio/LanguageServers/LanguageClient.ipc new file mode 100644 index 0000000000..dbd0d33d46 --- /dev/null +++ b/DevTools/HackStudio/LanguageServers/LanguageClient.ipc @@ -0,0 +1,4 @@ +endpoint LanguageClient = 8002 +{ + AutoCompleteSuggestions(Vector suggestions) =| +} diff --git a/DevTools/HackStudio/LanguageServers/Cpp/CppLanguageServer.ipc b/DevTools/HackStudio/LanguageServers/LanguageServer.ipc similarity index 83% rename from DevTools/HackStudio/LanguageServers/Cpp/CppLanguageServer.ipc rename to DevTools/HackStudio/LanguageServers/LanguageServer.ipc index 7265cc6f2e..5301c91942 100644 --- a/DevTools/HackStudio/LanguageServers/Cpp/CppLanguageServer.ipc +++ b/DevTools/HackStudio/LanguageServers/LanguageServer.ipc @@ -1,4 +1,4 @@ -endpoint CppLanguageServer = 8001 +endpoint LanguageServer = 8001 { Greet(String project_root) => (i32 client_id) @@ -7,5 +7,5 @@ endpoint CppLanguageServer = 8001 FileEditRemoveText(String file_name, i32 start_line, i32 start_column, i32 end_line, i32 end_column) =| SetFileContent(String file_name, String content) =| - AutoCompleteSuggestions(String file_name, i32 cursor_line, i32 cursor_column) => (Vector suggestions) + AutoCompleteSuggestions(String file_name, i32 cursor_line, i32 cursor_column) =| } diff --git a/DevTools/HackStudio/main.cpp b/DevTools/HackStudio/main.cpp index 8cbf81ea26..7dfab49f7c 100644 --- a/DevTools/HackStudio/main.cpp +++ b/DevTools/HackStudio/main.cpp @@ -26,7 +26,6 @@ #include "HackStudio.h" #include "HackStudioWidget.h" -#include "LanguageClients/Cpp/ServerConnection.h" #include "Project.h" #include #include @@ -52,13 +51,11 @@ using namespace HackStudio; static RefPtr s_window; static RefPtr s_hack_studio_widget; -static RefPtr s_cpp_Language_server_connection; static bool make_is_available(); static void update_path_environment_variable(); static String path_to_project(const String& path_argument_absolute_path); static void open_default_project_file(const String& project_path); -static void initialize_connections_to_language_servers(const String& project_path); int main(int argc, char** argv) { @@ -95,8 +92,6 @@ int main(int argc, char** argv) auto project_path = path_to_project(argument_absolute_path); s_hack_studio_widget = s_window->set_main_widget(project_path); - initialize_connections_to_language_servers(project_path); - s_hack_studio_widget->initialize_menubar(menubar); app->set_menubar(menubar); @@ -152,13 +147,6 @@ static void open_default_project_file(const String& project_path) open_file(s_hack_studio_widget->project().default_file()); } -static void initialize_connections_to_language_servers(const String& project_path) -{ - LexicalPath project_root_dir(LexicalPath(project_path).dirname()); - s_cpp_Language_server_connection = LanguageClients::Cpp::ServerConnection::construct(project_root_dir.string()); - s_cpp_Language_server_connection->handshake(); -} - namespace HackStudio { GUI::TextEditor& current_editor() @@ -195,10 +183,4 @@ void set_current_editor_wrapper(RefPtr wrapper) s_hack_studio_widget->set_current_editor_wrapper(wrapper); } -LanguageClients::Cpp::ServerConnection& cpp_Language_server_connection() -{ - ASSERT(s_cpp_Language_server_connection); - return *s_cpp_Language_server_connection; -} - }