forked from qt-creator/qt-creator
LSP: separate communication interface and client logic
Change-Id: I7d35fa634287b5f858c4a87aa10f99bf18d1ad07 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "baseclient.h"
|
||||
#include "languageclientmanager.h"
|
||||
#include "languageclient_global.h"
|
||||
#include "languageclientinterface.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <utils/algorithm.h>
|
||||
@@ -399,6 +400,13 @@ bool BaseSettings::isValid() const
|
||||
|
||||
BaseClient *BaseSettings::createClient() const
|
||||
{
|
||||
BaseClientInterface *interface = createInterface();
|
||||
if (QTC_GUARD(interface)) {
|
||||
auto *client = new BaseClient(interface);
|
||||
client->setName(m_name);
|
||||
client->setSupportedLanguage(m_languageFilter);
|
||||
return client;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -467,8 +475,8 @@ bool StdIOSettings::needsRestart() const
|
||||
{
|
||||
if (BaseSettings::needsRestart())
|
||||
return true;
|
||||
if (auto stdIOClient = qobject_cast<StdIOClient *>(m_client))
|
||||
return stdIOClient->needsRestart(this);
|
||||
if (auto stdIOInterface = qobject_cast<StdIOClientInterface *>(m_client))
|
||||
return stdIOInterface->needsRestart(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -477,14 +485,6 @@ bool StdIOSettings::isValid() const
|
||||
return BaseSettings::isValid() && !m_executable.isEmpty();
|
||||
}
|
||||
|
||||
BaseClient *StdIOSettings::createClient() const
|
||||
{
|
||||
auto client = new StdIOClient(m_executable, m_arguments);
|
||||
client->setName(m_name);
|
||||
client->setSupportedLanguage(m_languageFilter);
|
||||
return client;
|
||||
}
|
||||
|
||||
QVariantMap StdIOSettings::toMap() const
|
||||
{
|
||||
QVariantMap map = BaseSettings::toMap();
|
||||
@@ -500,6 +500,11 @@ void StdIOSettings::fromMap(const QVariantMap &map)
|
||||
m_arguments = map[argumentsKey].toString();
|
||||
}
|
||||
|
||||
BaseClientInterface *StdIOSettings::createInterface() const
|
||||
{
|
||||
return new StdIOClientInterface(m_executable, m_arguments);
|
||||
}
|
||||
|
||||
BaseSettingsWidget::BaseSettingsWidget(const BaseSettings *settings, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_name(new QLineEdit(settings->m_name, this))
|
||||
|
||||
Reference in New Issue
Block a user