forked from qt-creator/qt-creator
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:
@@ -170,6 +170,7 @@ HEADERS += \
|
|||||||
$$PWD/updatepchprojectpartsmessage.h \
|
$$PWD/updatepchprojectpartsmessage.h \
|
||||||
$$PWD/updatetranslationunitsforeditormessage.h \
|
$$PWD/updatetranslationunitsforeditormessage.h \
|
||||||
$$PWD/updatevisibletranslationunitsmessage.h \
|
$$PWD/updatevisibletranslationunitsmessage.h \
|
||||||
$$PWD/writemessageblock.h
|
$$PWD/writemessageblock.h \
|
||||||
|
$$PWD/ipcclientprovider.h
|
||||||
|
|
||||||
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
|
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace ClangBackEnd {
|
|||||||
|
|
||||||
class ClangCodeModelClientInterface;
|
class ClangCodeModelClientInterface;
|
||||||
|
|
||||||
class CMBIPC_EXPORT ClangCodeModelServerInterface : public IpcServerInterface<ClangCodeModelClientInterface>
|
class CMBIPC_EXPORT ClangCodeModelServerInterface : public IpcServerInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void dispatch(const MessageEnvelop &messageEnvelop) override;
|
void dispatch(const MessageEnvelop &messageEnvelop) override;
|
||||||
|
|||||||
53
src/libs/clangbackendipc/ipcclientprovider.h
Normal file
53
src/libs/clangbackendipc/ipcclientprovider.h
Normal 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
|
||||||
@@ -29,27 +29,8 @@
|
|||||||
|
|
||||||
namespace ClangBackEnd {
|
namespace ClangBackEnd {
|
||||||
|
|
||||||
template <typename ClientInterface>
|
|
||||||
class IpcServerInterface : public IpcInterface
|
class IpcServerInterface : public IpcInterface
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
void setClient(ClientInterface *client)
|
|
||||||
{
|
|
||||||
client_ = client;
|
|
||||||
}
|
|
||||||
|
|
||||||
void resetClient()
|
|
||||||
{
|
|
||||||
client_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
ClientInterface *client()
|
|
||||||
{
|
|
||||||
return client_;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
ClientInterface *client_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ClangBackEnd
|
} // namespace ClangBackEnd
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class RemovePchProjectPartsMessage;
|
|||||||
class UpdatePchProjectPartsMessage;
|
class UpdatePchProjectPartsMessage;
|
||||||
|
|
||||||
|
|
||||||
class CMBIPC_EXPORT PchManagerServerInterface : public IpcServerInterface<PchManagerClientInterface>
|
class CMBIPC_EXPORT PchManagerServerInterface : public IpcServerInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void dispatch(const MessageEnvelop &messageEnvelop) override;
|
void dispatch(const MessageEnvelop &messageEnvelop) override;
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ class RequestSourceRangesAndDiagnosticsForQueryMessage;
|
|||||||
class RequestSourceRangesForQueryMessage;
|
class RequestSourceRangesForQueryMessage;
|
||||||
class CancelMessage;
|
class CancelMessage;
|
||||||
|
|
||||||
class CMBIPC_EXPORT RefactoringServerInterface : public IpcServerInterface<RefactoringClientInterface>
|
class CMBIPC_EXPORT RefactoringServerInterface : public IpcServerInterface
|
||||||
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void dispatch(const MessageEnvelop &messageEnvelop) override;
|
void dispatch(const MessageEnvelop &messageEnvelop) override;
|
||||||
|
|||||||
@@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "clangcodemodelserverinterface.h"
|
|
||||||
|
|
||||||
#include "projectpart.h"
|
#include "projectpart.h"
|
||||||
#include "projects.h"
|
#include "projects.h"
|
||||||
#include "clangdocument.h"
|
#include "clangdocument.h"
|
||||||
@@ -35,6 +33,8 @@
|
|||||||
#include "clangjobrequest.h"
|
#include "clangjobrequest.h"
|
||||||
#include "unsavedfiles.h"
|
#include "unsavedfiles.h"
|
||||||
|
|
||||||
|
#include <clangcodemodelserverinterface.h>
|
||||||
|
#include <ipcclientprovider.h>
|
||||||
#include <utf8string.h>
|
#include <utf8string.h>
|
||||||
|
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
@@ -42,7 +42,8 @@
|
|||||||
|
|
||||||
namespace ClangBackEnd {
|
namespace ClangBackEnd {
|
||||||
|
|
||||||
class ClangCodeModelServer : public ClangCodeModelServerInterface
|
class ClangCodeModelServer : public ClangCodeModelServerInterface,
|
||||||
|
public IpcClientProvider<ClangCodeModelClientInterface>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ClangCodeModelServer();
|
ClangCodeModelServer();
|
||||||
|
|||||||
@@ -33,13 +33,17 @@
|
|||||||
#include "projectpartsinterface.h"
|
#include "projectpartsinterface.h"
|
||||||
#include "stringcache.h"
|
#include "stringcache.h"
|
||||||
|
|
||||||
|
#include <ipcclientprovider.h>
|
||||||
|
|
||||||
namespace ClangBackEnd {
|
namespace ClangBackEnd {
|
||||||
|
|
||||||
class SourceRangesAndDiagnosticsForQueryMessage;
|
class SourceRangesAndDiagnosticsForQueryMessage;
|
||||||
|
|
||||||
class PchManagerServer : public PchManagerServerInterface,
|
class PchManagerServer : public PchManagerServerInterface,
|
||||||
public ClangPathWatcherNotifier,
|
public ClangPathWatcherNotifier,
|
||||||
public PchGeneratorNotifierInterface
|
public PchGeneratorNotifierInterface,
|
||||||
|
public IpcClientProvider<PchManagerClientInterface>
|
||||||
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PchManagerServer(StringCache<Utils::PathString> &filePathCache,
|
PchManagerServer(StringCache<Utils::PathString> &filePathCache,
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include <refactoringserverinterface.h>
|
#include <refactoringserverinterface.h>
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <ipcclientprovider.h>
|
||||||
#include <stringcache.h>
|
#include <stringcache.h>
|
||||||
|
|
||||||
#include <utils/smallstring.h>
|
#include <utils/smallstring.h>
|
||||||
@@ -46,7 +47,8 @@ namespace V2 {
|
|||||||
class FileContainer;
|
class FileContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
class RefactoringServer : public RefactoringServerInterface
|
class RefactoringServer : public RefactoringServerInterface,
|
||||||
|
public IpcClientProvider<RefactoringClientInterface>
|
||||||
{
|
{
|
||||||
using Future = std::future<SourceRangesForQueryMessage>;
|
using Future = std::future<SourceRangesForQueryMessage>;
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -26,10 +26,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <clangbackendipc/clangcodemodelserverinterface.h>
|
#include <clangbackendipc/clangcodemodelserverinterface.h>
|
||||||
|
#include <ipcclientprovider.h>
|
||||||
|
|
||||||
namespace ClangBackEnd {
|
namespace ClangBackEnd {
|
||||||
|
|
||||||
class EchoClangCodeModelServer : public ClangCodeModelServerInterface
|
class EchoClangCodeModelServer : public ClangCodeModelServerInterface,
|
||||||
|
public IpcClientProvider<ClangCodeModelClientInterface>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void dispatch(const MessageEnvelop &message) override;
|
void dispatch(const MessageEnvelop &message) override;
|
||||||
|
|||||||
Reference in New Issue
Block a user