Clang: Cleanup interface hierarchy

The server and client interfaces was tightly coupled.So it prevented
the introduction of immediate interfaces.

Change-Id: Ie4197ffddb862e076d080b3d2a5ee869fad9e4d0
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Marco Bubke
2017-08-24 15:22:37 +02:00
parent 6c5146ac67
commit b725018e9e
10 changed files with 74 additions and 29 deletions

View File

@@ -170,6 +170,7 @@ HEADERS += \
$$PWD/updatepchprojectpartsmessage.h \
$$PWD/updatetranslationunitsforeditormessage.h \
$$PWD/updatevisibletranslationunitsmessage.h \
$$PWD/writemessageblock.h
$$PWD/writemessageblock.h \
$$PWD/ipcclientprovider.h
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols

View File

@@ -33,7 +33,7 @@ namespace ClangBackEnd {
class ClangCodeModelClientInterface;
class CMBIPC_EXPORT ClangCodeModelServerInterface : public IpcServerInterface<ClangCodeModelClientInterface>
class CMBIPC_EXPORT ClangCodeModelServerInterface : public IpcServerInterface
{
public:
void dispatch(const MessageEnvelop &messageEnvelop) override;

View File

@@ -0,0 +1,53 @@
/****************************************************************************
**
** Copyright (C) 2017 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
namespace ClangBackEnd {
template <typename ClientType>
class IpcClientProvider
{
public:
void setClient(ClientType *client)
{
client_ = client;
}
void resetClient()
{
client_ = nullptr;
}
ClientType *client()
{
return client_;
}
private:
ClientType *client_;
};
} // namespace ClangBackEnd

View File

@@ -29,27 +29,8 @@
namespace ClangBackEnd {
template <typename ClientInterface>
class IpcServerInterface : public IpcInterface
{
public:
void setClient(ClientInterface *client)
{
client_ = client;
}
void resetClient()
{
client_ = nullptr;
}
ClientInterface *client()
{
return client_;
}
private:
ClientInterface *client_;
};
} // namespace ClangBackEnd

View File

@@ -36,7 +36,7 @@ class RemovePchProjectPartsMessage;
class UpdatePchProjectPartsMessage;
class CMBIPC_EXPORT PchManagerServerInterface : public IpcServerInterface<PchManagerClientInterface>
class CMBIPC_EXPORT PchManagerServerInterface : public IpcServerInterface
{
public:
void dispatch(const MessageEnvelop &messageEnvelop) override;

View File

@@ -37,7 +37,8 @@ class RequestSourceRangesAndDiagnosticsForQueryMessage;
class RequestSourceRangesForQueryMessage;
class CancelMessage;
class CMBIPC_EXPORT RefactoringServerInterface : public IpcServerInterface<RefactoringClientInterface>
class CMBIPC_EXPORT RefactoringServerInterface : public IpcServerInterface
{
public:
void dispatch(const MessageEnvelop &messageEnvelop) override;

View File

@@ -25,8 +25,6 @@
#pragma once
#include "clangcodemodelserverinterface.h"
#include "projectpart.h"
#include "projects.h"
#include "clangdocument.h"
@@ -35,6 +33,8 @@
#include "clangjobrequest.h"
#include "unsavedfiles.h"
#include <clangcodemodelserverinterface.h>
#include <ipcclientprovider.h>
#include <utf8string.h>
#include <QScopedPointer>
@@ -42,7 +42,8 @@
namespace ClangBackEnd {
class ClangCodeModelServer : public ClangCodeModelServerInterface
class ClangCodeModelServer : public ClangCodeModelServerInterface,
public IpcClientProvider<ClangCodeModelClientInterface>
{
public:
ClangCodeModelServer();

View File

@@ -33,13 +33,17 @@
#include "projectpartsinterface.h"
#include "stringcache.h"
#include <ipcclientprovider.h>
namespace ClangBackEnd {
class SourceRangesAndDiagnosticsForQueryMessage;
class PchManagerServer : public PchManagerServerInterface,
public ClangPathWatcherNotifier,
public PchGeneratorNotifierInterface
public PchGeneratorNotifierInterface,
public IpcClientProvider<PchManagerClientInterface>
{
public:
PchManagerServer(StringCache<Utils::PathString> &filePathCache,

View File

@@ -30,6 +30,7 @@
#include <refactoringserverinterface.h>
#include <QTimer>
#include <ipcclientprovider.h>
#include <stringcache.h>
#include <utils/smallstring.h>
@@ -46,7 +47,8 @@ namespace V2 {
class FileContainer;
}
class RefactoringServer : public RefactoringServerInterface
class RefactoringServer : public RefactoringServerInterface,
public IpcClientProvider<RefactoringClientInterface>
{
using Future = std::future<SourceRangesForQueryMessage>;
public:

View File

@@ -26,10 +26,12 @@
#pragma once
#include <clangbackendipc/clangcodemodelserverinterface.h>
#include <ipcclientprovider.h>
namespace ClangBackEnd {
class EchoClangCodeModelServer : public ClangCodeModelServerInterface
class EchoClangCodeModelServer : public ClangCodeModelServerInterface,
public IpcClientProvider<ClangCodeModelClientInterface>
{
public:
void dispatch(const MessageEnvelop &message) override;