forked from qt-creator/qt-creator
Clang: Remove ClangCodeModelClientDispatcher
We always use one client and the dispatching is removing to possibility of moving commands. Moving the client to IpcServerInterface improves the code sharing. Change-Id: I5f102ab7907239572534b7d4c2848abbaade69b6 Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
@@ -20,7 +20,6 @@ SOURCES += $$PWD/clangcodemodelserverinterface.cpp \
|
||||
$$PWD/connectionserver.cpp \
|
||||
$$PWD/connectionclient.cpp \
|
||||
$$PWD/cmbechomessage.cpp \
|
||||
$$PWD/clangcodemodelclientdispatcher.cpp \
|
||||
$$PWD/cmbregistertranslationunitsforeditormessage.cpp \
|
||||
$$PWD/filecontainer.cpp \
|
||||
$$PWD/cmbunregistertranslationunitsforeditormessage.cpp \
|
||||
@@ -66,7 +65,6 @@ HEADERS += \
|
||||
$$PWD/connectionserver.h \
|
||||
$$PWD/connectionclient.h \
|
||||
$$PWD/cmbechomessage.h \
|
||||
$$PWD/clangcodemodelclientdispatcher.h \
|
||||
$$PWD/cmbregistertranslationunitsforeditormessage.h \
|
||||
$$PWD/filecontainer.h \
|
||||
$$PWD/cmbunregistertranslationunitsforeditormessage.h \
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "clangcodemodelclientdispatcher.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
void ClangCodeModelClientDispatcher::addClient(ClangCodeModelClientInterface *client)
|
||||
{
|
||||
clients.append(client);
|
||||
}
|
||||
|
||||
void ClangCodeModelClientDispatcher::removeClient(ClangCodeModelClientInterface *client)
|
||||
{
|
||||
clients.removeOne(client);
|
||||
}
|
||||
|
||||
void ClangCodeModelClientDispatcher::alive()
|
||||
{
|
||||
for (auto *client : clients)
|
||||
client->alive();
|
||||
}
|
||||
|
||||
void ClangCodeModelClientDispatcher::echo(const EchoMessage &message)
|
||||
{
|
||||
for (auto *client : clients)
|
||||
client->echo(message);
|
||||
}
|
||||
|
||||
void ClangCodeModelClientDispatcher::codeCompleted(const CodeCompletedMessage &message)
|
||||
{
|
||||
for (auto *client : clients)
|
||||
client->codeCompleted(message);
|
||||
}
|
||||
|
||||
void ClangCodeModelClientDispatcher::translationUnitDoesNotExist(const TranslationUnitDoesNotExistMessage &message)
|
||||
{
|
||||
for (auto *client : clients)
|
||||
client->translationUnitDoesNotExist(message);
|
||||
}
|
||||
|
||||
void ClangCodeModelClientDispatcher::projectPartsDoNotExist(const ProjectPartsDoNotExistMessage &message)
|
||||
{
|
||||
for (auto *client : clients)
|
||||
client->projectPartsDoNotExist(message);
|
||||
}
|
||||
|
||||
void ClangCodeModelClientDispatcher::diagnosticsChanged(const DiagnosticsChangedMessage &message)
|
||||
{
|
||||
for (auto *client : clients)
|
||||
client->diagnosticsChanged(message);
|
||||
}
|
||||
|
||||
void ClangCodeModelClientDispatcher::highlightingChanged(const HighlightingChangedMessage &message)
|
||||
{
|
||||
for (auto *client : clients)
|
||||
client->highlightingChanged(message);
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "clangcodemodelclientinterface.h"
|
||||
|
||||
#include <QVector>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class CMBIPC_EXPORT ClangCodeModelClientDispatcher : public ClangBackEnd::ClangCodeModelClientInterface
|
||||
{
|
||||
public:
|
||||
void addClient(ClangCodeModelClientInterface *client);
|
||||
void removeClient(ClangCodeModelClientInterface *client);
|
||||
|
||||
void alive() override;
|
||||
void echo(const EchoMessage &message) override;
|
||||
void codeCompleted(const CodeCompletedMessage &message) override;
|
||||
void translationUnitDoesNotExist(const TranslationUnitDoesNotExistMessage &message) override;
|
||||
void projectPartsDoNotExist(const ProjectPartsDoNotExistMessage &message) override;
|
||||
void diagnosticsChanged(const DiagnosticsChangedMessage &message) override;
|
||||
void highlightingChanged(const HighlightingChangedMessage &message) override;
|
||||
|
||||
private:
|
||||
QVector<ClangCodeModelClientInterface*> clients;
|
||||
};
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
@@ -87,20 +87,5 @@ void ClangCodeModelServerInterface::dispatch(const MessageEnvelop &messageEnvelo
|
||||
}
|
||||
}
|
||||
|
||||
void ClangCodeModelServerInterface::addClient(ClangCodeModelClientInterface *client)
|
||||
{
|
||||
clientDispatcher.addClient(client);
|
||||
}
|
||||
|
||||
void ClangCodeModelServerInterface::removeClient(ClangCodeModelClientInterface *client)
|
||||
{
|
||||
clientDispatcher.removeClient(client);
|
||||
}
|
||||
|
||||
ClangCodeModelClientInterface *ClangCodeModelServerInterface::client()
|
||||
{
|
||||
return &clientDispatcher;
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
|
||||
@@ -27,13 +27,13 @@
|
||||
|
||||
#include "ipcserverinterface.h"
|
||||
|
||||
#include "clangcodemodelclientdispatcher.h"
|
||||
#include "clangcodemodelclientinterface.h"
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class ClangCodeModelClientInterface;
|
||||
|
||||
class CMBIPC_EXPORT ClangCodeModelServerInterface : public IpcServerInterface
|
||||
class CMBIPC_EXPORT ClangCodeModelServerInterface : public IpcServerInterface<ClangCodeModelClientInterface>
|
||||
{
|
||||
public:
|
||||
void dispatch(const MessageEnvelop &messageEnvelop) override;
|
||||
@@ -50,14 +50,6 @@ public:
|
||||
virtual void requestDiagnostics(const RequestDiagnosticsMessage &message) = 0;
|
||||
virtual void requestHighlighting(const RequestHighlightingMessage &message) = 0;
|
||||
virtual void updateVisibleTranslationUnits(const UpdateVisibleTranslationUnitsMessage &message) = 0;
|
||||
|
||||
void addClient(ClangCodeModelClientInterface *client);
|
||||
void removeClient(ClangCodeModelClientInterface *client);
|
||||
|
||||
ClangCodeModelClientInterface *client();
|
||||
|
||||
private:
|
||||
ClangCodeModelClientDispatcher clientDispatcher;
|
||||
};
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
@@ -42,6 +42,8 @@ ConnectionServer::ConnectionServer(const QString &connectionName)
|
||||
{
|
||||
this->connectionName = connectionName;
|
||||
|
||||
localServer.setMaxPendingConnections(1);
|
||||
|
||||
connect(&localServer, &QLocalServer::newConnection, this, &ConnectionServer::handleNewConnection);
|
||||
std::atexit(&ConnectionServer::removeServer);
|
||||
#if defined(_GLIBCXX_HAVE_AT_QUICK_EXIT)
|
||||
@@ -85,7 +87,7 @@ void ConnectionServer::handleNewConnection()
|
||||
|
||||
ipcServerProxies.emplace_back(ipcServer, localSocket);
|
||||
|
||||
ipcServer->addClient(&ipcServerProxies.back());
|
||||
ipcServer->setClient(&ipcServerProxies.back());
|
||||
|
||||
localSockets.push_back(localSocket);
|
||||
|
||||
|
||||
@@ -29,10 +29,27 @@
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
template <typename ClientInterface>
|
||||
class CMBIPC_EXPORT IpcServerInterface : public IpcInterface
|
||||
{
|
||||
public:
|
||||
void setClient(ClientInterface *client)
|
||||
{
|
||||
client_ = client;
|
||||
}
|
||||
|
||||
void resetClient()
|
||||
{
|
||||
client_ = nullptr;
|
||||
}
|
||||
|
||||
ClientInterface *client()
|
||||
{
|
||||
return client_;
|
||||
}
|
||||
|
||||
private:
|
||||
ClientInterface *client_;
|
||||
};
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
@@ -431,7 +431,7 @@ TEST_F(ClangClangCodeModelServer, IsNotCurrentCurrentAndVisibleEditorAnymore)
|
||||
|
||||
void ClangClangCodeModelServer::SetUp()
|
||||
{
|
||||
clangServer.addClient(&mockClangCodeModelClient);
|
||||
clangServer.setClient(&mockClangCodeModelClient);
|
||||
registerProjectPart();
|
||||
registerFiles();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user