forked from qt-creator/qt-creator
LSP: let the settings generate the client
In preperation for settings other than the stdio client. Change-Id: I11635119db9165163947d822e911ee26ce8548f1 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -165,17 +165,6 @@ void LanguageClientManager::removeMarks(const Core::Id &id)
|
||||
removeMarks(fileName, id);
|
||||
}
|
||||
|
||||
void LanguageClientManager::startClient(LanguageClientSettings setting)
|
||||
{
|
||||
if (managerInstance->m_shuttingDown)
|
||||
return;
|
||||
auto client = new StdIOClient(setting.m_executable, setting.m_arguments);
|
||||
client->setName(setting.m_name);
|
||||
if (setting.m_mimeType != noLanguageFilter)
|
||||
client->setSupportedMimeType({setting.m_mimeType});
|
||||
startClient(client);
|
||||
}
|
||||
|
||||
void LanguageClientManager::startClient(BaseClient *client)
|
||||
{
|
||||
if (managerInstance->m_shuttingDown) {
|
||||
|
||||
@@ -61,7 +61,6 @@ public:
|
||||
static void removeMarks(const Utils::FileName &fileName, const Core::Id &id);
|
||||
static void removeMarks(const Core::Id &id);
|
||||
|
||||
static void startClient(LanguageClientSettings setting);
|
||||
static void startClient(BaseClient *client);
|
||||
static QVector<BaseClient *> clients();
|
||||
|
||||
|
||||
@@ -371,7 +371,7 @@ void LanguageClientSettingsModel::applyChanges()
|
||||
}
|
||||
for (auto setting : toStart) {
|
||||
if (setting.isValid() && setting.m_enabled)
|
||||
LanguageClientManager::startClient(setting);
|
||||
LanguageClientManager::startClient(setting.createClient());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,6 +389,15 @@ bool LanguageClientSettings::operator==(const LanguageClientSettings &other) con
|
||||
&& m_arguments == other.m_arguments;
|
||||
}
|
||||
|
||||
BaseClient *LanguageClientSettings::createClient()
|
||||
{
|
||||
auto client = new StdIOClient(m_executable, m_arguments);
|
||||
client->setName(m_name);
|
||||
if (m_mimeType != noLanguageFilter)
|
||||
client->setSupportedMimeType({m_mimeType});
|
||||
return client;
|
||||
}
|
||||
|
||||
QVariantMap LanguageClientSettings::toMap() const
|
||||
{
|
||||
QVariantMap map;
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace LanguageClient {
|
||||
|
||||
constexpr char noLanguageFilter[] = "No Filter";
|
||||
|
||||
class BaseClient;
|
||||
|
||||
class LanguageClientSettings
|
||||
{
|
||||
public:
|
||||
@@ -57,6 +59,8 @@ public:
|
||||
|
||||
bool operator==(const LanguageClientSettings &other) const;
|
||||
|
||||
BaseClient *createClient();
|
||||
|
||||
QVariantMap toMap() const;
|
||||
static LanguageClientSettings fromMap(const QVariantMap &map);
|
||||
static void init();
|
||||
|
||||
Reference in New Issue
Block a user