mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 13:57:35 +00:00
LanguageServers: Remove ClientConnection dependency
We now no longer need to provide a ClientConnection object to construct AutoCompleteEngine.
This commit is contained in:
parent
687efe6dd6
commit
c49cf23a86
12 changed files with 24 additions and 29 deletions
|
@ -8,9 +8,8 @@
|
||||||
|
|
||||||
namespace LanguageServers {
|
namespace LanguageServers {
|
||||||
|
|
||||||
AutoCompleteEngine::AutoCompleteEngine(ClientConnection& connection, const FileDB& filedb, bool should_store_all_declarations)
|
AutoCompleteEngine::AutoCompleteEngine(const FileDB& filedb, bool should_store_all_declarations)
|
||||||
: m_connection(connection)
|
: m_filedb(filedb)
|
||||||
, m_filedb(filedb)
|
|
||||||
, m_store_all_declarations(should_store_all_declarations)
|
, m_store_all_declarations(should_store_all_declarations)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -29,6 +28,6 @@ void AutoCompleteEngine::set_declarations_of_document(const String& filename, Ve
|
||||||
}
|
}
|
||||||
if (m_store_all_declarations)
|
if (m_store_all_declarations)
|
||||||
m_all_declarations.set(filename, declarations);
|
m_all_declarations.set(filename, declarations);
|
||||||
set_declarations_of_document_callback(m_connection, filename, move(declarations));
|
set_declarations_of_document_callback(filename, move(declarations));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ class ClientConnection;
|
||||||
|
|
||||||
class AutoCompleteEngine {
|
class AutoCompleteEngine {
|
||||||
public:
|
public:
|
||||||
AutoCompleteEngine(ClientConnection&, const FileDB& filedb, bool store_all_declarations = false);
|
AutoCompleteEngine(const FileDB& filedb, bool store_all_declarations = false);
|
||||||
virtual ~AutoCompleteEngine();
|
virtual ~AutoCompleteEngine();
|
||||||
|
|
||||||
virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& autocomplete_position) = 0;
|
virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& autocomplete_position) = 0;
|
||||||
|
@ -29,7 +29,7 @@ public:
|
||||||
virtual Optional<GUI::AutocompleteProvider::ProjectLocation> find_declaration_of(const String&, const GUI::TextPosition&) { return {}; };
|
virtual Optional<GUI::AutocompleteProvider::ProjectLocation> find_declaration_of(const String&, const GUI::TextPosition&) { return {}; };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Function<void(ClientConnection&, String, Vector<GUI::AutocompleteProvider::Declaration>)> set_declarations_of_document_callback;
|
Function<void(const String&, Vector<GUI::AutocompleteProvider::Declaration>&&)> set_declarations_of_document_callback;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const FileDB& filedb() const { return m_filedb; }
|
const FileDB& filedb() const { return m_filedb; }
|
||||||
|
@ -37,7 +37,6 @@ protected:
|
||||||
const HashMap<String, Vector<GUI::AutocompleteProvider::Declaration>>& all_declarations() const { return m_all_declarations; }
|
const HashMap<String, Vector<GUI::AutocompleteProvider::Declaration>>& all_declarations() const { return m_all_declarations; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ClientConnection& m_connection;
|
|
||||||
HashMap<String, Vector<GUI::AutocompleteProvider::Declaration>> m_all_declarations;
|
HashMap<String, Vector<GUI::AutocompleteProvider::Declaration>> m_all_declarations;
|
||||||
const FileDB& m_filedb;
|
const FileDB& m_filedb;
|
||||||
bool m_store_all_declarations { false };
|
bool m_store_all_declarations { false };
|
||||||
|
|
|
@ -118,9 +118,4 @@ void ClientConnection::find_declaration(GUI::AutocompleteProvider::ProjectLocati
|
||||||
async_declaration_location(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.async_declarations_in_document(filename, move(declarations));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,6 @@ protected:
|
||||||
virtual void find_declaration(GUI::AutocompleteProvider::ProjectLocation const&) override;
|
virtual void find_declaration(GUI::AutocompleteProvider::ProjectLocation const&) override;
|
||||||
virtual void set_auto_complete_mode(String const&) override = 0;
|
virtual void set_auto_complete_mode(String const&) override = 0;
|
||||||
|
|
||||||
static void set_declarations_of_document_callback(ClientConnection&, const String&, Vector<GUI::AutocompleteProvider::Declaration>&&);
|
|
||||||
|
|
||||||
FileDB m_filedb;
|
FileDB m_filedb;
|
||||||
OwnPtr<AutoCompleteEngine> m_autocomplete_engine;
|
OwnPtr<AutoCompleteEngine> m_autocomplete_engine;
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,8 +19,10 @@ public:
|
||||||
ClientConnection(NonnullRefPtr<Core::LocalSocket> socket, int client_id)
|
ClientConnection(NonnullRefPtr<Core::LocalSocket> socket, int client_id)
|
||||||
: LanguageServers::ClientConnection(move(socket), client_id)
|
: LanguageServers::ClientConnection(move(socket), client_id)
|
||||||
{
|
{
|
||||||
m_autocomplete_engine = make<ParserAutoComplete>(*this, m_filedb);
|
m_autocomplete_engine = make<ParserAutoComplete>(m_filedb);
|
||||||
m_autocomplete_engine->set_declarations_of_document_callback = &ClientConnection::set_declarations_of_document_callback;
|
m_autocomplete_engine->set_declarations_of_document_callback = [this](const String& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) {
|
||||||
|
async_declarations_in_document(filename, move(declarations));
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~ClientConnection() override = default;
|
virtual ~ClientConnection() override = default;
|
||||||
|
@ -30,9 +32,9 @@ private:
|
||||||
{
|
{
|
||||||
dbgln_if(CPP_LANGUAGE_SERVER_DEBUG, "SetAutoCompleteMode: {}", mode);
|
dbgln_if(CPP_LANGUAGE_SERVER_DEBUG, "SetAutoCompleteMode: {}", mode);
|
||||||
if (mode == "Parser")
|
if (mode == "Parser")
|
||||||
m_autocomplete_engine = make<ParserAutoComplete>(*this, m_filedb);
|
m_autocomplete_engine = make<ParserAutoComplete>(m_filedb);
|
||||||
else
|
else
|
||||||
m_autocomplete_engine = make<LexerAutoComplete>(*this, m_filedb);
|
m_autocomplete_engine = make<LexerAutoComplete>(m_filedb);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
namespace LanguageServers::Cpp {
|
namespace LanguageServers::Cpp {
|
||||||
|
|
||||||
LexerAutoComplete::LexerAutoComplete(ClientConnection& connection, const FileDB& filedb)
|
LexerAutoComplete::LexerAutoComplete(const FileDB& filedb)
|
||||||
: AutoCompleteEngine(connection, filedb)
|
: AutoCompleteEngine(filedb)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ using namespace ::Cpp;
|
||||||
|
|
||||||
class LexerAutoComplete : public AutoCompleteEngine {
|
class LexerAutoComplete : public AutoCompleteEngine {
|
||||||
public:
|
public:
|
||||||
LexerAutoComplete(ClientConnection&, const FileDB& filedb);
|
LexerAutoComplete(const FileDB& filedb);
|
||||||
|
|
||||||
virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& autocomplete_position) override;
|
virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& autocomplete_position) override;
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
namespace LanguageServers::Cpp {
|
namespace LanguageServers::Cpp {
|
||||||
|
|
||||||
ParserAutoComplete::ParserAutoComplete(ClientConnection& connection, const FileDB& filedb)
|
ParserAutoComplete::ParserAutoComplete(const FileDB& filedb)
|
||||||
: AutoCompleteEngine(connection, filedb, true)
|
: AutoCompleteEngine(filedb, true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ using namespace ::Cpp;
|
||||||
|
|
||||||
class ParserAutoComplete : public AutoCompleteEngine {
|
class ParserAutoComplete : public AutoCompleteEngine {
|
||||||
public:
|
public:
|
||||||
ParserAutoComplete(ClientConnection&, const FileDB& filedb);
|
ParserAutoComplete(const FileDB& filedb);
|
||||||
|
|
||||||
virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& autocomplete_position) override;
|
virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& autocomplete_position) override;
|
||||||
virtual void on_edit(const String& file) override;
|
virtual void on_edit(const String& file) override;
|
||||||
|
|
|
@ -14,8 +14,8 @@ namespace LanguageServers::Shell {
|
||||||
|
|
||||||
RefPtr<::Shell::Shell> AutoComplete::s_shell {};
|
RefPtr<::Shell::Shell> AutoComplete::s_shell {};
|
||||||
|
|
||||||
AutoComplete::AutoComplete(ClientConnection& connection, const FileDB& filedb)
|
AutoComplete::AutoComplete(const FileDB& filedb)
|
||||||
: AutoCompleteEngine(connection, filedb, true)
|
: AutoCompleteEngine(filedb, true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace LanguageServers::Shell {
|
||||||
|
|
||||||
class AutoComplete : public AutoCompleteEngine {
|
class AutoComplete : public AutoCompleteEngine {
|
||||||
public:
|
public:
|
||||||
AutoComplete(ClientConnection&, const FileDB& filedb);
|
AutoComplete(const FileDB& filedb);
|
||||||
virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& position) override;
|
virtual Vector<GUI::AutocompleteProvider::Entry> get_suggestions(const String& file, const GUI::TextPosition& position) override;
|
||||||
virtual void on_edit(const String& file) override;
|
virtual void on_edit(const String& file) override;
|
||||||
virtual void file_opened([[maybe_unused]] const String& file) override;
|
virtual void file_opened([[maybe_unused]] const String& file) override;
|
||||||
|
|
|
@ -17,8 +17,10 @@ class ClientConnection final : public LanguageServers::ClientConnection {
|
||||||
ClientConnection(NonnullRefPtr<Core::LocalSocket> socket, int client_id)
|
ClientConnection(NonnullRefPtr<Core::LocalSocket> socket, int client_id)
|
||||||
: LanguageServers::ClientConnection(move(socket), client_id)
|
: LanguageServers::ClientConnection(move(socket), client_id)
|
||||||
{
|
{
|
||||||
m_autocomplete_engine = make<AutoComplete>(*this, m_filedb);
|
m_autocomplete_engine = make<AutoComplete>(m_filedb);
|
||||||
m_autocomplete_engine->set_declarations_of_document_callback = &ClientConnection::set_declarations_of_document_callback;
|
m_autocomplete_engine->set_declarations_of_document_callback = [this](const String& filename, Vector<GUI::AutocompleteProvider::Declaration>&& declarations) {
|
||||||
|
async_declarations_in_document(filename, move(declarations));
|
||||||
|
};
|
||||||
}
|
}
|
||||||
virtual ~ClientConnection() override = default;
|
virtual ~ClientConnection() override = default;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue