mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 17:45:09 +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:
parent
44f9637e20
commit
ac5e08a541
17 changed files with 291 additions and 118 deletions
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include "HackStudio.h"
|
||||
#include "HackStudioWidget.h"
|
||||
#include "LanguageClients/Cpp/ServerConnection.h"
|
||||
#include "Project.h"
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
|
@ -52,13 +51,11 @@ using namespace HackStudio;
|
|||
|
||||
static RefPtr<GUI::Window> s_window;
|
||||
static RefPtr<HackStudioWidget> s_hack_studio_widget;
|
||||
static RefPtr<LanguageClients::Cpp::ServerConnection> 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<HackStudioWidget>(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<EditorWrapper> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue