mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 14:07:42 +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 {
|
||||
|
||||
AutoCompleteEngine::AutoCompleteEngine(ClientConnection& connection, const FileDB& filedb, bool should_store_all_declarations)
|
||||
: m_connection(connection)
|
||||
, m_filedb(filedb)
|
||||
AutoCompleteEngine::AutoCompleteEngine(const FileDB& filedb, bool should_store_all_declarations)
|
||||
: m_filedb(filedb)
|
||||
, 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)
|
||||
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 {
|
||||
public:
|
||||
AutoCompleteEngine(ClientConnection&, const FileDB& filedb, bool store_all_declarations = false);
|
||||
AutoCompleteEngine(const FileDB& filedb, bool store_all_declarations = false);
|
||||
virtual ~AutoCompleteEngine();
|
||||
|
||||
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 {}; };
|
||||
|
||||
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:
|
||||
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; }
|
||||
|
||||
private:
|
||||
ClientConnection& m_connection;
|
||||
HashMap<String, Vector<GUI::AutocompleteProvider::Declaration>> m_all_declarations;
|
||||
const FileDB& m_filedb;
|
||||
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 });
|
||||
}
|
||||
|
||||
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 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;
|
||||
OwnPtr<AutoCompleteEngine> m_autocomplete_engine;
|
||||
};
|
||||
|
|
|
@ -19,8 +19,10 @@ public:
|
|||
ClientConnection(NonnullRefPtr<Core::LocalSocket> socket, int client_id)
|
||||
: LanguageServers::ClientConnection(move(socket), client_id)
|
||||
{
|
||||
m_autocomplete_engine = make<ParserAutoComplete>(*this, m_filedb);
|
||||
m_autocomplete_engine->set_declarations_of_document_callback = &ClientConnection::set_declarations_of_document_callback;
|
||||
m_autocomplete_engine = make<ParserAutoComplete>(m_filedb);
|
||||
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;
|
||||
|
@ -30,9 +32,9 @@ private:
|
|||
{
|
||||
dbgln_if(CPP_LANGUAGE_SERVER_DEBUG, "SetAutoCompleteMode: {}", mode);
|
||||
if (mode == "Parser")
|
||||
m_autocomplete_engine = make<ParserAutoComplete>(*this, m_filedb);
|
||||
m_autocomplete_engine = make<ParserAutoComplete>(m_filedb);
|
||||
else
|
||||
m_autocomplete_engine = make<LexerAutoComplete>(*this, m_filedb);
|
||||
m_autocomplete_engine = make<LexerAutoComplete>(m_filedb);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace LanguageServers::Cpp {
|
||||
|
||||
LexerAutoComplete::LexerAutoComplete(ClientConnection& connection, const FileDB& filedb)
|
||||
: AutoCompleteEngine(connection, filedb)
|
||||
LexerAutoComplete::LexerAutoComplete(const FileDB& filedb)
|
||||
: AutoCompleteEngine(filedb)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ using namespace ::Cpp;
|
|||
|
||||
class LexerAutoComplete : public AutoCompleteEngine {
|
||||
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;
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
namespace LanguageServers::Cpp {
|
||||
|
||||
ParserAutoComplete::ParserAutoComplete(ClientConnection& connection, const FileDB& filedb)
|
||||
: AutoCompleteEngine(connection, filedb, true)
|
||||
ParserAutoComplete::ParserAutoComplete(const FileDB& filedb)
|
||||
: AutoCompleteEngine(filedb, true)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ using namespace ::Cpp;
|
|||
|
||||
class ParserAutoComplete : public AutoCompleteEngine {
|
||||
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 void on_edit(const String& file) override;
|
||||
|
|
|
@ -14,8 +14,8 @@ namespace LanguageServers::Shell {
|
|||
|
||||
RefPtr<::Shell::Shell> AutoComplete::s_shell {};
|
||||
|
||||
AutoComplete::AutoComplete(ClientConnection& connection, const FileDB& filedb)
|
||||
: AutoCompleteEngine(connection, filedb, true)
|
||||
AutoComplete::AutoComplete(const FileDB& filedb)
|
||||
: AutoCompleteEngine(filedb, true)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace LanguageServers::Shell {
|
|||
|
||||
class AutoComplete : public AutoCompleteEngine {
|
||||
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 void on_edit(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)
|
||||
: LanguageServers::ClientConnection(move(socket), client_id)
|
||||
{
|
||||
m_autocomplete_engine = make<AutoComplete>(*this, m_filedb);
|
||||
m_autocomplete_engine->set_declarations_of_document_callback = &ClientConnection::set_declarations_of_document_callback;
|
||||
m_autocomplete_engine = make<AutoComplete>(m_filedb);
|
||||
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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue