Skip to content

Commit 3839d68

Browse files
authored
refactor: Pass LLMClientInterface to QodeAssistClient (#122)
Contructing LLMClientInterface in constructor of QodeAssistClient when initializing base class severely limits what can be done. In particular, no members can be referred to, because nothing of the class instance itself has been initialized at that point of time.
1 parent 6b86637 commit 3839d68

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

QodeAssistClient.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,8 @@ using namespace Core;
4444

4545
namespace QodeAssist {
4646

47-
QodeAssistClient::QodeAssistClient(
48-
LLMCore::IProviderRegistry &providerRegistry, LLMCore::IPromptProvider *promptProvider)
49-
: LanguageClient::Client(new LLMClientInterface(
50-
Settings::generalSettings(),
51-
Settings::codeCompletionSettings(),
52-
providerRegistry,
53-
promptProvider))
47+
QodeAssistClient::QodeAssistClient(LLMClientInterface *clientInterface)
48+
: LanguageClient::Client(clientInterface)
5449
, m_recentCharCount(0)
5550
{
5651
setName("Qode Assist");

QodeAssistClient.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#pragma once
2626

27+
#include "LLMClientInterface.hpp"
2728
#include "LSPCompletion.hpp"
2829
#include <languageclient/client.h>
2930
#include <llmcore/IPromptProvider.hpp>
@@ -34,8 +35,7 @@ namespace QodeAssist {
3435
class QodeAssistClient : public LanguageClient::Client
3536
{
3637
public:
37-
explicit QodeAssistClient(
38-
LLMCore::IProviderRegistry &providerRegistry, LLMCore::IPromptProvider *promptProvider);
38+
explicit QodeAssistClient(LLMClientInterface *clientInterface);
3939
~QodeAssistClient() override;
4040

4141
void openDocument(TextEditor::TextDocument *document) override;

qodeassist.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,11 @@ class QodeAssistPlugin final : public ExtensionSystem::IPlugin
138138
void restartClient()
139139
{
140140
LanguageClient::LanguageClientManager::shutdownClient(m_qodeAssistClient);
141-
m_qodeAssistClient
142-
= new QodeAssistClient(LLMCore::ProvidersManager::instance(), &m_promptProvider);
141+
m_qodeAssistClient = new QodeAssistClient(new LLMClientInterface(
142+
Settings::generalSettings(),
143+
Settings::codeCompletionSettings(),
144+
LLMCore::ProvidersManager::instance(),
145+
&m_promptProvider));
143146
}
144147

145148
bool delayedInitialize() final

0 commit comments

Comments
 (0)