forked from qt-creator/qt-creator
Clang: Add clang refactoring
Change-Id: I2e3f36f810276da3f8dc7dcc587b06f8edb586d3 GPush-Base: d02f51b48fc752fddcdef6dcb32b3f7f6c0195a3 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -44,11 +44,20 @@ SOURCES += $$PWD/clangcodemodelserverinterface.cpp \
|
||||
$$PWD/updatetranslationunitsforeditormessage.cpp \
|
||||
$$PWD/updatevisibletranslationunitsmessage.cpp \
|
||||
$$PWD/highlightingmarkcontainer.cpp \
|
||||
$$PWD/refactoringclientinterface.cpp \
|
||||
$$PWD/messageenvelop.cpp \
|
||||
$$PWD/refactoringserverinterface.cpp \
|
||||
$$PWD/refactoringserverproxy.cpp \
|
||||
$$PWD/ipcclientinterface.cpp \
|
||||
$$PWD/ipcserverinterface.cpp \
|
||||
$$PWD/clangcodemodelconnectionclient.cpp \
|
||||
$$PWD/documentannotationschangedmessage.cpp
|
||||
$$PWD/documentannotationschangedmessage.cpp \
|
||||
$$PWD/refactoringclientproxy.cpp \
|
||||
$$PWD/sourcelocationscontainer.cpp \
|
||||
$$PWD/sourcelocationcontainerv2.cpp \
|
||||
$$PWD/sourcelocationsforrenamingmessage.cpp \
|
||||
$$PWD/requestsourcelocationforrenamingmessage.cpp \
|
||||
$$PWD/filepath.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/clangcodemodelserverinterface.h \
|
||||
@@ -92,6 +101,15 @@ HEADERS += \
|
||||
$$PWD/ipcclientinterface.h \
|
||||
$$PWD/ipcserverinterface.h \
|
||||
$$PWD/clangcodemodelconnectionclient.h \
|
||||
$$PWD/documentannotationschangedmessage.h
|
||||
$$PWD/documentannotationschangedmessage.h \
|
||||
$$PWD/refactoringclientinterface.h \
|
||||
$$PWD/refactoringserverinterface.h \
|
||||
$$PWD/refactoringserverproxy.h \
|
||||
$$PWD/refactoringclientproxy.h \
|
||||
$$PWD/sourcelocationscontainer.h \
|
||||
$$PWD/sourcelocationcontainerv2.h \
|
||||
$$PWD/sourcelocationsforrenamingmessage.h \
|
||||
$$PWD/requestsourcelocationforrenamingmessage.h \
|
||||
$$PWD/filepath.h
|
||||
|
||||
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
|
||||
|
||||
@@ -106,7 +106,10 @@ enum class MessageType : quint8 {
|
||||
CodeCompletedMessage,
|
||||
|
||||
TranslationUnitDoesNotExistMessage,
|
||||
ProjectPartsDoNotExistMessage
|
||||
ProjectPartsDoNotExistMessage,
|
||||
|
||||
SourceLocationsForRenamingMessage,
|
||||
RequestSourceLocationsForRenamingMessage
|
||||
};
|
||||
|
||||
template<MessageType messageEnumeration>
|
||||
|
||||
@@ -25,14 +25,26 @@
|
||||
|
||||
#include "clangcodemodelconnectionclient.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
namespace {
|
||||
|
||||
QString currentProcessId()
|
||||
{
|
||||
return QString::number(QCoreApplication::applicationPid());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ClangCodeModelConnectionClient::ClangCodeModelConnectionClient(
|
||||
ClangCodeModelClientInterface *client)
|
||||
: serverProxy_(client, ioDevice())
|
||||
{
|
||||
|
||||
stdErrPrefixer().setPrefix("ClangCodeModelConnectionClient.error:");
|
||||
stdOutPrefixer().setPrefix("ClangCodeModelConnectionClient.out:");
|
||||
}
|
||||
|
||||
ClangCodeModelConnectionClient::~ClangCodeModelConnectionClient()
|
||||
@@ -55,4 +67,14 @@ void ClangCodeModelConnectionClient::resetCounter()
|
||||
serverProxy_.resetCounter();
|
||||
}
|
||||
|
||||
QString ClangCodeModelConnectionClient::connectionName() const
|
||||
{
|
||||
return temporaryDirectory().path() + QStringLiteral("/ClangBackEnd-") + currentProcessId();
|
||||
}
|
||||
|
||||
QString ClangCodeModelConnectionClient::outputName() const
|
||||
{
|
||||
return QStringLiteral("ClangCodeModelConnectionClient");
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
@@ -41,6 +41,8 @@ public:
|
||||
protected:
|
||||
void sendEndCommand() override;
|
||||
void resetCounter() override;
|
||||
QString connectionName() const override;
|
||||
QString outputName() const override;
|
||||
|
||||
private:
|
||||
ClangCodeModelServerProxy serverProxy_;
|
||||
|
||||
@@ -38,25 +38,6 @@
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
namespace {
|
||||
const QTemporaryDir &temporaryDirectory()
|
||||
{
|
||||
static QTemporaryDir temporaryDirectory(QDir::tempPath() + QStringLiteral("/qtc-clang-XXXXXX"));
|
||||
|
||||
return temporaryDirectory;
|
||||
}
|
||||
|
||||
QString currentProcessId()
|
||||
{
|
||||
return QString::number(QCoreApplication::applicationPid());
|
||||
}
|
||||
|
||||
QString connectionName()
|
||||
{
|
||||
return temporaryDirectory().path() + QStringLiteral("/ClangBackEnd-") + currentProcessId();
|
||||
}
|
||||
}
|
||||
|
||||
ConnectionClient::ConnectionClient()
|
||||
{
|
||||
processAliveTimer.setInterval(10000);
|
||||
@@ -72,7 +53,7 @@ ConnectionClient::ConnectionClient()
|
||||
|
||||
void ConnectionClient::startProcessAndConnectToServerAsynchronously()
|
||||
{
|
||||
process_ = startProcess();
|
||||
process_ = startProcess();
|
||||
}
|
||||
|
||||
bool ConnectionClient::disconnectFromServer()
|
||||
@@ -127,6 +108,23 @@ QProcessEnvironment ConnectionClient::processEnvironment() const
|
||||
return processEnvironment;
|
||||
}
|
||||
|
||||
const QTemporaryDir &ConnectionClient::temporaryDirectory() const
|
||||
{
|
||||
static QTemporaryDir temporaryDirectory(QDir::tempPath() + QStringLiteral("/qtc-clang-XXXXXX"));
|
||||
|
||||
return temporaryDirectory;
|
||||
}
|
||||
|
||||
LinePrefixer &ConnectionClient::stdErrPrefixer()
|
||||
{
|
||||
return stdErrPrefixer_;
|
||||
}
|
||||
|
||||
LinePrefixer &ConnectionClient::stdOutPrefixer()
|
||||
{
|
||||
return stdOutPrefixer_;
|
||||
}
|
||||
|
||||
std::unique_ptr<QProcess> ConnectionClient::startProcess()
|
||||
{
|
||||
processIsStarting = true;
|
||||
@@ -207,17 +205,17 @@ void ConnectionClient::resetProcessIsStarting()
|
||||
void ConnectionClient::printLocalSocketError(QLocalSocket::LocalSocketError socketError)
|
||||
{
|
||||
if (socketError != QLocalSocket::ServerNotFoundError)
|
||||
qWarning() << "ClangCodeModel ConnectionClient LocalSocket Error:" << localSocket.errorString();
|
||||
qWarning() << outputName() << "LocalSocket Error:" << localSocket.errorString();
|
||||
}
|
||||
|
||||
void ConnectionClient::printStandardOutput()
|
||||
{
|
||||
qDebug("%s", stdOutPrefixer.prefix(process_->readAllStandardOutput()).constData());
|
||||
qDebug("%s", stdOutPrefixer_.prefix(process_->readAllStandardOutput()).constData());
|
||||
}
|
||||
|
||||
void ConnectionClient::printStandardError()
|
||||
{
|
||||
qDebug("%s", stdErrPrefixer.prefix(process_->readAllStandardError()).constData());
|
||||
qDebug("%s", stdErrPrefixer_.prefix(process_->readAllStandardError()).constData());
|
||||
}
|
||||
|
||||
void ConnectionClient::connectLocalSocketConnected()
|
||||
@@ -240,8 +238,6 @@ void ConnectionClient::finishProcess()
|
||||
|
||||
void ConnectionClient::finishProcess(std::unique_ptr<QProcess> &&process)
|
||||
{
|
||||
TIME_SCOPE_DURATION("ConnectionClient::finishProcess");
|
||||
|
||||
if (process) {
|
||||
processAliveTimer.stop();
|
||||
|
||||
@@ -251,7 +247,7 @@ void ConnectionClient::finishProcess(std::unique_ptr<QProcess> &&process)
|
||||
terminateProcess(process.get());
|
||||
killProcess(process.get());
|
||||
|
||||
resetCounter();
|
||||
resetCounter();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +270,7 @@ bool ConnectionClient::waitForConnected()
|
||||
}
|
||||
}
|
||||
|
||||
qWarning() << "Cannot connect:" << localSocket.errorString();
|
||||
qWarning() << outputName() << "cannot connect:" << localSocket.errorString();
|
||||
|
||||
return isConnected;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QProcess;
|
||||
class QTemporaryDir;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class Utf8String;
|
||||
@@ -79,9 +80,14 @@ signals:
|
||||
|
||||
protected:
|
||||
QIODevice *ioDevice();
|
||||
const QTemporaryDir &temporaryDirectory() const;
|
||||
LinePrefixer &stdErrPrefixer();
|
||||
LinePrefixer &stdOutPrefixer();
|
||||
|
||||
virtual void sendEndCommand() = 0;
|
||||
virtual void resetCounter() = 0;
|
||||
virtual QString connectionName() const = 0;
|
||||
virtual QString outputName() const = 0;
|
||||
|
||||
private:
|
||||
std::unique_ptr<QProcess> startProcess();
|
||||
@@ -108,6 +114,9 @@ private:
|
||||
QProcessEnvironment processEnvironment() const;
|
||||
|
||||
private:
|
||||
LinePrefixer stdErrPrefixer_;
|
||||
LinePrefixer stdOutPrefixer_;
|
||||
|
||||
mutable std::unique_ptr<QProcess> process_;
|
||||
QLocalSocket localSocket;
|
||||
QTimer processAliveTimer;
|
||||
@@ -115,8 +124,6 @@ private:
|
||||
bool isAliveTimerResetted = false;
|
||||
bool processIsStarting = false;
|
||||
|
||||
LinePrefixer stdErrPrefixer = QByteArrayLiteral("clangbackend.stderr: ");
|
||||
LinePrefixer stdOutPrefixer = QByteArrayLiteral("clangbackend.stdout: ");
|
||||
};
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
localServer.listen(ConnectionName::connectionName);
|
||||
}
|
||||
|
||||
void setClangCodeModelServer(ServerInterface *ipcServer)
|
||||
void setServer(ServerInterface *ipcServer)
|
||||
{
|
||||
this->ipcServer = ipcServer;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <clangbackendipc_global.h>
|
||||
#include "clangbackendipc_global.h"
|
||||
|
||||
#include <utf8string.h>
|
||||
#include <utf8stringvector.h>
|
||||
|
||||
42
src/libs/clangbackendipc/filepath.cpp
Normal file
42
src/libs/clangbackendipc/filepath.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "filepath.h"
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
QDebug operator<<(QDebug debug, const FilePath &filePath)
|
||||
{
|
||||
debug.nospace() << filePath.directory() << "/" << filePath.name();
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
void PrintTo(const FilePath &filePath, ::std::ostream* os)
|
||||
{
|
||||
*os << filePath.directory() << "/" << filePath.name();
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
88
src/libs/clangbackendipc/filepath.h
Normal file
88
src/libs/clangbackendipc/filepath.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "clangbackendipc_global.h"
|
||||
|
||||
#include <utils/smallstring.h>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
struct FilePath
|
||||
{
|
||||
public:
|
||||
FilePath() = default;
|
||||
FilePath(Utils::SmallString &&directory, Utils::SmallString &&name)
|
||||
: directory_(std::move(directory)),
|
||||
name_(std::move(name))
|
||||
{}
|
||||
|
||||
const Utils::SmallString &directory() const
|
||||
{
|
||||
return directory_;
|
||||
}
|
||||
|
||||
const Utils::SmallString &name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out, const FilePath &filePath)
|
||||
{
|
||||
out << filePath.directory_;
|
||||
out << filePath.name_;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
friend QDataStream &operator>>(QDataStream &in, FilePath &filePath)
|
||||
{
|
||||
in >> filePath.directory_;
|
||||
in >> filePath.name_;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
friend bool operator==(const FilePath &first, const FilePath &second)
|
||||
{
|
||||
return first.directory_ == second.directory_
|
||||
&& first.name_ == second.name_;
|
||||
}
|
||||
|
||||
FilePath clone() const
|
||||
{
|
||||
return FilePath(directory_.clone(), name_.clone());
|
||||
}
|
||||
|
||||
private:
|
||||
Utils::SmallString directory_;
|
||||
Utils::SmallString name_;
|
||||
};
|
||||
|
||||
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const FilePath &filePath);
|
||||
void PrintTo(const FilePath &filePath, ::std::ostream* os);
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
@@ -28,10 +28,15 @@
|
||||
namespace ClangBackEnd {
|
||||
|
||||
LinePrefixer::LinePrefixer(const QByteArray &prefix)
|
||||
: m_prefix(prefix)
|
||||
, m_previousIsEndingWithNewLine(true)
|
||||
: m_prefix(prefix),
|
||||
m_previousIsEndingWithNewLine(true)
|
||||
{}
|
||||
|
||||
void LinePrefixer::setPrefix(const QByteArray &prefix)
|
||||
{
|
||||
m_prefix = prefix;
|
||||
}
|
||||
|
||||
QByteArray LinePrefixer::prefix(const QByteArray &text)
|
||||
{
|
||||
QByteArray output = text;
|
||||
|
||||
@@ -25,17 +25,20 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "clangbackendipc_global.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QTextStream>
|
||||
#include <utf8string.h>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class LinePrefixer
|
||||
class CMBIPC_EXPORT LinePrefixer
|
||||
{
|
||||
public:
|
||||
LinePrefixer() = delete;
|
||||
LinePrefixer(const QByteArray &m_prefix);
|
||||
LinePrefixer() = default;
|
||||
LinePrefixer(const QByteArray &prefix);
|
||||
void setPrefix(const QByteArray &prefix);
|
||||
QByteArray prefix(const QByteArray &text);
|
||||
|
||||
private:
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <clangbackendipc_global.h>
|
||||
#include "clangbackendipc_global.h"
|
||||
|
||||
#include <utf8stringvector.h>
|
||||
|
||||
|
||||
49
src/libs/clangbackendipc/refactoringclientinterface.cpp
Normal file
49
src/libs/clangbackendipc/refactoringclientinterface.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "refactoringclientinterface.h"
|
||||
|
||||
#include "messageenvelop.h"
|
||||
#include "sourcelocationsforrenamingmessage.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
void RefactoringClientInterface::dispatch(const MessageEnvelop &messageEnvelop)
|
||||
{
|
||||
switch (messageEnvelop.messageType()) {
|
||||
case MessageType::AliveMessage:
|
||||
alive();
|
||||
break;
|
||||
case MessageType::SourceLocationsForRenamingMessage:
|
||||
sourceLocationsForRenamingMessage(messageEnvelop.message<SourceLocationsForRenamingMessage>());
|
||||
break;
|
||||
default:
|
||||
qWarning() << "Unknown IpcClientMessage";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
52
src/libs/clangbackendipc/refactoringclientinterface.h
Normal file
52
src/libs/clangbackendipc/refactoringclientinterface.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "ipcclientinterface.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class SourceLocationsForRenamingMessage;
|
||||
class SourceLocationsContainer;
|
||||
|
||||
class CMBIPC_EXPORT RefactoringClientInterface : public IpcClientInterface
|
||||
{
|
||||
public:
|
||||
using RenameCallback = std::function<void(const QString &,
|
||||
const SourceLocationsContainer &,
|
||||
int)>;
|
||||
|
||||
void dispatch(const MessageEnvelop &messageEnvelop) override;
|
||||
|
||||
virtual void alive() = 0;
|
||||
virtual void sourceLocationsForRenamingMessage(SourceLocationsForRenamingMessage &&message) = 0;
|
||||
|
||||
virtual void setLocalRenamingCallback(RenameCallback &&localRenamingCallback) = 0;
|
||||
};
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
82
src/libs/clangbackendipc/refactoringclientproxy.cpp
Normal file
82
src/libs/clangbackendipc/refactoringclientproxy.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "refactoringclientproxy.h"
|
||||
|
||||
#include "cmbalivemessage.h"
|
||||
#include "messageenvelop.h"
|
||||
#include "refactoringserverinterface.h"
|
||||
#include "sourcelocationsforrenamingmessage.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QIODevice>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
RefactoringClientProxy::RefactoringClientProxy(RefactoringServerInterface *server, QIODevice *ioDevice)
|
||||
: writeMessageBlock(ioDevice),
|
||||
readMessageBlock(ioDevice),
|
||||
server(server),
|
||||
ioDevice(ioDevice)
|
||||
{
|
||||
QObject::connect(ioDevice, &QIODevice::readyRead, [this] () {RefactoringClientProxy::readMessages();});
|
||||
}
|
||||
|
||||
RefactoringClientProxy::RefactoringClientProxy(RefactoringClientProxy &&other)
|
||||
: writeMessageBlock(std::move(other.writeMessageBlock)),
|
||||
readMessageBlock(std::move(other.readMessageBlock)),
|
||||
server(std::move(other.server)),
|
||||
ioDevice(std::move(other.ioDevice))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RefactoringClientProxy &RefactoringClientProxy::operator=(RefactoringClientProxy &&other)
|
||||
{
|
||||
writeMessageBlock = std::move(other.writeMessageBlock);
|
||||
readMessageBlock = std::move(other.readMessageBlock);
|
||||
server = std::move(other.server);
|
||||
ioDevice = std::move(other.ioDevice);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void RefactoringClientProxy::readMessages()
|
||||
{
|
||||
for (const MessageEnvelop &message : readMessageBlock.readAll())
|
||||
server->dispatch(message);
|
||||
}
|
||||
|
||||
void RefactoringClientProxy::alive()
|
||||
{
|
||||
writeMessageBlock.write(AliveMessage());
|
||||
}
|
||||
|
||||
void RefactoringClientProxy::sourceLocationsForRenamingMessage(SourceLocationsForRenamingMessage &&message)
|
||||
{
|
||||
writeMessageBlock.write(message);
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
63
src/libs/clangbackendipc/refactoringclientproxy.h
Normal file
63
src/libs/clangbackendipc/refactoringclientproxy.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "clangbackendipc_global.h"
|
||||
#include "refactoringclientinterface.h"
|
||||
#include "readmessageblock.h"
|
||||
#include "writemessageblock.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class RefactoringServerInterface;
|
||||
|
||||
class CMBIPC_EXPORT RefactoringClientProxy : public RefactoringClientInterface
|
||||
{
|
||||
public:
|
||||
explicit RefactoringClientProxy(RefactoringServerInterface *server, QIODevice *ioDevice);
|
||||
RefactoringClientProxy(const RefactoringClientProxy&) = delete;
|
||||
const RefactoringClientProxy &operator=(const RefactoringClientProxy&) = delete;
|
||||
|
||||
RefactoringClientProxy(RefactoringClientProxy&&other);
|
||||
RefactoringClientProxy &operator=(RefactoringClientProxy&&other);
|
||||
|
||||
void readMessages();
|
||||
|
||||
void alive() override;
|
||||
void sourceLocationsForRenamingMessage(SourceLocationsForRenamingMessage &&message) override;
|
||||
|
||||
void setLocalRenamingCallback(RenameCallback &&) {}
|
||||
|
||||
private:
|
||||
ClangBackEnd::WriteMessageBlock writeMessageBlock;
|
||||
ClangBackEnd::ReadMessageBlock readMessageBlock;
|
||||
RefactoringServerInterface *server = nullptr;
|
||||
QIODevice *ioDevice = nullptr;
|
||||
};
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
49
src/libs/clangbackendipc/refactoringserverinterface.cpp
Normal file
49
src/libs/clangbackendipc/refactoringserverinterface.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "refactoringserverinterface.h"
|
||||
|
||||
#include "messageenvelop.h"
|
||||
#include "requestsourcelocationforrenamingmessage.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
void RefactoringServerInterface::dispatch(const MessageEnvelop &messageEnvelop)
|
||||
{
|
||||
switch (messageEnvelop.messageType()) {
|
||||
case MessageType::EndMessage:
|
||||
end();
|
||||
break;
|
||||
case MessageType::RequestSourceLocationsForRenamingMessage:
|
||||
requestSourceLocationsForRenamingMessage(messageEnvelop.message<RequestSourceLocationsForRenamingMessage>());
|
||||
break;
|
||||
default:
|
||||
qWarning() << "Unknown IpcClientMessage";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
46
src/libs/clangbackendipc/refactoringserverinterface.h
Normal file
46
src/libs/clangbackendipc/refactoringserverinterface.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "ipcserverinterface.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class RefactoringClientInterface;
|
||||
class RequestSourceLocationsForRenamingMessage;
|
||||
|
||||
class CMBIPC_EXPORT RefactoringServerInterface : public IpcServerInterface<RefactoringClientInterface>
|
||||
{
|
||||
public:
|
||||
void dispatch(const MessageEnvelop &messageEnvelop) override;
|
||||
|
||||
virtual void end() = 0;
|
||||
virtual void requestSourceLocationsForRenamingMessage(RequestSourceLocationsForRenamingMessage &&message) = 0;
|
||||
};
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
68
src/libs/clangbackendipc/refactoringserverproxy.cpp
Normal file
68
src/libs/clangbackendipc/refactoringserverproxy.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "refactoringserverproxy.h"
|
||||
|
||||
#include "cmbendmessage.h"
|
||||
#include "messageenvelop.h"
|
||||
#include "refactoringclientinterface.h"
|
||||
#include "requestsourcelocationforrenamingmessage.h"
|
||||
|
||||
#include <QIODevice>
|
||||
#include <QVector>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
RefactoringServerProxy::RefactoringServerProxy(RefactoringClientInterface *client, QIODevice *ioDevice)
|
||||
: writeMessageBlock(ioDevice),
|
||||
readMessageBlock(ioDevice),
|
||||
client(client)
|
||||
{
|
||||
QObject::connect(ioDevice, &QIODevice::readyRead, [this] () { readMessages(); });
|
||||
}
|
||||
|
||||
void RefactoringServerProxy::end()
|
||||
{
|
||||
writeMessageBlock.write(EndMessage());
|
||||
}
|
||||
|
||||
void RefactoringServerProxy::requestSourceLocationsForRenamingMessage(RequestSourceLocationsForRenamingMessage &&message)
|
||||
{
|
||||
writeMessageBlock.write(message);
|
||||
}
|
||||
|
||||
void RefactoringServerProxy::readMessages()
|
||||
{
|
||||
for (const auto &message : readMessageBlock.readAll())
|
||||
client->dispatch(message);
|
||||
}
|
||||
|
||||
void RefactoringServerProxy::resetCounter()
|
||||
{
|
||||
writeMessageBlock.resetCounter();
|
||||
readMessageBlock.resetCounter();
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
66
src/libs/clangbackendipc/refactoringserverproxy.h
Normal file
66
src/libs/clangbackendipc/refactoringserverproxy.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "clangbackendipc_global.h"
|
||||
#include "refactoringserverinterface.h"
|
||||
#include "readmessageblock.h"
|
||||
#include "writemessageblock.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#include <memory>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QIODevice;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class RefactoringClientInterface;
|
||||
|
||||
class CMBIPC_EXPORT RefactoringServerProxy : public RefactoringServerInterface
|
||||
{
|
||||
public:
|
||||
explicit RefactoringServerProxy(RefactoringClientInterface *client, QIODevice *ioDevice);
|
||||
RefactoringServerProxy(const RefactoringServerProxy&) = delete;
|
||||
const RefactoringServerProxy &operator=(const RefactoringServerProxy&) = delete;
|
||||
|
||||
void end() override;
|
||||
void requestSourceLocationsForRenamingMessage(ClangBackEnd::RequestSourceLocationsForRenamingMessage &&message) override;
|
||||
|
||||
void readMessages();
|
||||
|
||||
void resetCounter();
|
||||
|
||||
private:
|
||||
ClangBackEnd::WriteMessageBlock writeMessageBlock;
|
||||
ClangBackEnd::ReadMessageBlock readMessageBlock;
|
||||
RefactoringClientInterface *client = nullptr;
|
||||
QIODevice *ioDevice = nullptr;
|
||||
};
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
@@ -0,0 +1,54 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "requestsourcelocationforrenamingmessage.h"
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
QDebug operator<<(QDebug debug, const RequestSourceLocationsForRenamingMessage &message)
|
||||
{
|
||||
debug.nospace() << "RequestSourceLocationsForRenamingMessage("
|
||||
<< message.filePath() << ", "
|
||||
<< message.line() << ", "
|
||||
<< message.column() << ", "
|
||||
<< message.unsavedContent() << ")";
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
void PrintTo(const RequestSourceLocationsForRenamingMessage &message, ::std::ostream* os)
|
||||
{
|
||||
*os << "RequestSourceLocationsForRenamingMessage(";
|
||||
PrintTo(message.filePath(), os);
|
||||
*os << ", "
|
||||
<< message.line() << ", "
|
||||
<< message.column() << ", ";
|
||||
PrintTo(message.unsavedContent(), os);
|
||||
*os << ", ";
|
||||
PrintTo(message.commandLine(), os);
|
||||
*os << ")";
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
@@ -0,0 +1,139 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "clangbackendipc_global.h"
|
||||
#include "filepath.h"
|
||||
|
||||
#include <utils/smallstringvector.h>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class CMBIPC_EXPORT RequestSourceLocationsForRenamingMessage
|
||||
{
|
||||
public:
|
||||
RequestSourceLocationsForRenamingMessage() = default;
|
||||
RequestSourceLocationsForRenamingMessage(FilePath &&filePath,
|
||||
uint line,
|
||||
uint column,
|
||||
Utils::SmallString &&unsavedContent,
|
||||
Utils::SmallStringVector &&commandLine,
|
||||
int textDocumentRevision)
|
||||
: filePath_(std::move(filePath)),
|
||||
unsavedContent_(std::move(unsavedContent)),
|
||||
commandLine_(std::move(commandLine)),
|
||||
line_(line),
|
||||
column_(column),
|
||||
revision(textDocumentRevision)
|
||||
{}
|
||||
|
||||
const FilePath &filePath() const
|
||||
{
|
||||
return filePath_;
|
||||
}
|
||||
|
||||
uint line() const
|
||||
{
|
||||
return line_;
|
||||
}
|
||||
|
||||
uint column() const
|
||||
{
|
||||
return column_;
|
||||
}
|
||||
|
||||
const Utils::SmallString &unsavedContent() const
|
||||
{
|
||||
return unsavedContent_;
|
||||
}
|
||||
|
||||
const Utils::SmallStringVector &commandLine() const
|
||||
{
|
||||
return commandLine_;
|
||||
}
|
||||
|
||||
int textDocumentRevision() const
|
||||
{
|
||||
return revision;
|
||||
}
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out, const RequestSourceLocationsForRenamingMessage &message)
|
||||
{
|
||||
out << message.filePath_;
|
||||
out << message.unsavedContent_;
|
||||
out << message.commandLine_;
|
||||
out << message.line_;
|
||||
out << message.column_;
|
||||
out << message.revision;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
friend QDataStream &operator>>(QDataStream &in, RequestSourceLocationsForRenamingMessage &message)
|
||||
{
|
||||
in >> message.filePath_;
|
||||
in >> message.unsavedContent_;
|
||||
in >> message.commandLine_;
|
||||
in >> message.line_;
|
||||
in >> message.column_;
|
||||
in >> message.revision;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
friend bool operator==(const RequestSourceLocationsForRenamingMessage &first, const RequestSourceLocationsForRenamingMessage &second)
|
||||
{
|
||||
return first.filePath_ == second.filePath_
|
||||
&& first.line_ == second.line_
|
||||
&& first.column_ == second.column_
|
||||
&& first.revision == second.revision
|
||||
&& first.unsavedContent_ == second.unsavedContent_
|
||||
&& first.commandLine_ == second.commandLine_;
|
||||
}
|
||||
|
||||
RequestSourceLocationsForRenamingMessage clone() const
|
||||
{
|
||||
return RequestSourceLocationsForRenamingMessage(filePath_.clone(),
|
||||
line_, column_,
|
||||
unsavedContent_.clone(),
|
||||
commandLine_.clone(),
|
||||
revision);
|
||||
}
|
||||
|
||||
private:
|
||||
FilePath filePath_;
|
||||
Utils::SmallString unsavedContent_;
|
||||
Utils::SmallStringVector commandLine_;
|
||||
uint line_ = 1;
|
||||
uint column_ = 1;
|
||||
int revision = 1;
|
||||
};
|
||||
|
||||
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const RequestSourceLocationsForRenamingMessage &message);
|
||||
void PrintTo(const RequestSourceLocationsForRenamingMessage &message, ::std::ostream* os);
|
||||
|
||||
DECLARE_MESSAGE(RequestSourceLocationsForRenamingMessage)
|
||||
} // namespace ClangBackEnd
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <clangbackendipc_global.h>
|
||||
#include "clangbackendipc_global.h"
|
||||
|
||||
#include <utf8string.h>
|
||||
|
||||
|
||||
55
src/libs/clangbackendipc/sourcelocationcontainerv2.cpp
Normal file
55
src/libs/clangbackendipc/sourcelocationcontainerv2.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "sourcelocationcontainerv2.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
namespace V2 {
|
||||
|
||||
QDebug operator<<(QDebug debug, const SourceLocationContainer &container)
|
||||
{
|
||||
debug.nospace() << "SourceLocationContainer("
|
||||
<< container.fileHash() << ", "
|
||||
<< container.line() << ", "
|
||||
<< container.column()
|
||||
<< ")";
|
||||
return debug;
|
||||
}
|
||||
|
||||
void PrintTo(const SourceLocationContainer &container, ::std::ostream* os)
|
||||
{
|
||||
*os << "["
|
||||
<< container.fileHash() << ", "
|
||||
<< container.line() << ", "
|
||||
<< container.column()
|
||||
<< "]";
|
||||
}
|
||||
|
||||
} // namespace V2
|
||||
} // namespace ClangBackEnd
|
||||
110
src/libs/clangbackendipc/sourcelocationcontainerv2.h
Normal file
110
src/libs/clangbackendipc/sourcelocationcontainerv2.h
Normal file
@@ -0,0 +1,110 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "clangbackendipc_global.h"
|
||||
|
||||
#include <QDataStream>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
namespace V2 {
|
||||
|
||||
|
||||
class SourceLocationContainer
|
||||
{
|
||||
public:
|
||||
SourceLocationContainer() = default;
|
||||
SourceLocationContainer(uint fileHash,
|
||||
uint line,
|
||||
uint column)
|
||||
: fileHash_(fileHash),
|
||||
line_(line),
|
||||
column_(column)
|
||||
{
|
||||
}
|
||||
|
||||
uint fileHash() const
|
||||
{
|
||||
return fileHash_;
|
||||
}
|
||||
|
||||
uint line() const
|
||||
{
|
||||
return line_;
|
||||
}
|
||||
|
||||
uint column() const
|
||||
{
|
||||
return column_;
|
||||
}
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out, const SourceLocationContainer &container)
|
||||
{
|
||||
out << container.fileHash_;
|
||||
out << container.line_;
|
||||
out << container.column_;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
friend QDataStream &operator>>(QDataStream &in, SourceLocationContainer &container)
|
||||
{
|
||||
in >> container.fileHash_;
|
||||
in >> container.line_;
|
||||
in >> container.column_;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
friend bool operator==(const SourceLocationContainer &first, const SourceLocationContainer &second)
|
||||
{
|
||||
return !(first != second);
|
||||
}
|
||||
|
||||
friend bool operator!=(const SourceLocationContainer &first, const SourceLocationContainer &second)
|
||||
{
|
||||
return first.line_ != second.line_
|
||||
|| first.column_ != second.column_
|
||||
|| first.fileHash_ != second.fileHash_;
|
||||
}
|
||||
|
||||
SourceLocationContainer clone() const
|
||||
{
|
||||
return SourceLocationContainer(fileHash_, line_, column_);
|
||||
}
|
||||
|
||||
private:
|
||||
uint fileHash_ = 0;
|
||||
uint line_ = 1;
|
||||
uint column_ = 1;
|
||||
};
|
||||
|
||||
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const SourceLocationContainer &container);
|
||||
void PrintTo(const SourceLocationContainer &container, ::std::ostream* os);
|
||||
|
||||
} // namespace V2
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
57
src/libs/clangbackendipc/sourcelocationscontainer.cpp
Normal file
57
src/libs/clangbackendipc/sourcelocationscontainer.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "sourcelocationscontainer.h"
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
QDebug operator<<(QDebug debug, const SourceLocationsContainer &container)
|
||||
{
|
||||
debug.nospace() << "SourceLocationsContainer([";
|
||||
for (const auto &sourceLocation: container.sourceLocationContainers()) {
|
||||
debug.nospace() << "["
|
||||
<< container.filePathForSourceLocation(sourceLocation).name() << ","
|
||||
<< sourceLocation.line() << ","
|
||||
<< sourceLocation.column() << "], ";
|
||||
}
|
||||
|
||||
debug.nospace() << "])";
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
void PrintTo(const SourceLocationsContainer &container, ::std::ostream* os)
|
||||
{
|
||||
*os << "SourceLocationsContainer(";
|
||||
for (const auto &sourceLocation: container.sourceLocationContainers()) {
|
||||
*os << "["
|
||||
<< container.filePathForSourceLocation(sourceLocation).name() << ","
|
||||
<< sourceLocation.line() << ","
|
||||
<< sourceLocation.column() << "], ";
|
||||
}
|
||||
*os << ")";
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
118
src/libs/clangbackendipc/sourcelocationscontainer.h
Normal file
118
src/libs/clangbackendipc/sourcelocationscontainer.h
Normal file
@@ -0,0 +1,118 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "filepath.h"
|
||||
#include "sourcelocationcontainerv2.h"
|
||||
|
||||
#include <utils/smallstringvector.h>
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class SourceLocationsContainer
|
||||
{
|
||||
public:
|
||||
SourceLocationsContainer() = default;
|
||||
SourceLocationsContainer(std::unordered_map<uint, FilePath> &&filePathHash,
|
||||
std::vector<V2::SourceLocationContainer> &&sourceLocationContainers)
|
||||
: filePathHash(std::move(filePathHash)),
|
||||
sourceLocationContainers_(std::move(sourceLocationContainers))
|
||||
{}
|
||||
|
||||
const FilePath &filePathForSourceLocation(const V2::SourceLocationContainer &sourceLocation) const
|
||||
{
|
||||
auto found = filePathHash.find(sourceLocation.fileHash());
|
||||
|
||||
return found->second;
|
||||
}
|
||||
|
||||
const std::vector<V2::SourceLocationContainer> &sourceLocationContainers() const
|
||||
{
|
||||
return sourceLocationContainers_;
|
||||
}
|
||||
|
||||
bool hasContent() const
|
||||
{
|
||||
return !sourceLocationContainers_.empty();
|
||||
}
|
||||
|
||||
void insertFilePath(uint fileId, Utils::SmallString &&fileDirectory, Utils::SmallString &&fileName)
|
||||
{
|
||||
filePathHash.emplace(std::piecewise_construct,
|
||||
std::forward_as_tuple(fileId),
|
||||
std::forward_as_tuple(std::move(fileDirectory), std::move(fileName)));
|
||||
}
|
||||
|
||||
void insertSourceLocation(uint fileId, uint line, uint column)
|
||||
{
|
||||
sourceLocationContainers_.emplace_back(fileId, line, column);
|
||||
}
|
||||
|
||||
void reserve(std::size_t size)
|
||||
{
|
||||
filePathHash.reserve(size / 3);
|
||||
sourceLocationContainers_.reserve(size);
|
||||
}
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out, const SourceLocationsContainer &container)
|
||||
{
|
||||
out << container.filePathHash;
|
||||
out << container.sourceLocationContainers_;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
friend QDataStream &operator>>(QDataStream &in, SourceLocationsContainer &container)
|
||||
{
|
||||
in >> container.filePathHash;
|
||||
in >> container.sourceLocationContainers_;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
friend bool operator==(const SourceLocationsContainer &first, const SourceLocationsContainer &second)
|
||||
{
|
||||
return first.sourceLocationContainers_ == second.sourceLocationContainers_;
|
||||
}
|
||||
|
||||
SourceLocationsContainer clone() const
|
||||
{
|
||||
return SourceLocationsContainer(Utils::clone(filePathHash), Utils::clone(sourceLocationContainers_));
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<uint, FilePath> filePathHash;
|
||||
std::vector<V2::SourceLocationContainer> sourceLocationContainers_;
|
||||
};
|
||||
|
||||
|
||||
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const SourceLocationsContainer &container);
|
||||
void PrintTo(const SourceLocationsContainer &container, ::std::ostream* os);
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "sourcelocationsforrenamingmessage.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
QDebug operator<<(QDebug debug, const SourceLocationsForRenamingMessage &message)
|
||||
{
|
||||
debug.nospace() << "SourceLocationsForRenamingMessage("
|
||||
<< message.sourceLocations()
|
||||
<< ")";
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
void PrintTo(const SourceLocationsForRenamingMessage &message, ::std::ostream* os)
|
||||
{
|
||||
*os << "SourceLocationsForRenamingMessage(\""
|
||||
<< message.symbolName() << "\", "
|
||||
<< message.textDocumentRevision() << ", ";
|
||||
PrintTo(message.sourceLocations(), os);
|
||||
*os << ")";
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
103
src/libs/clangbackendipc/sourcelocationsforrenamingmessage.h
Normal file
103
src/libs/clangbackendipc/sourcelocationsforrenamingmessage.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 "sourcelocationscontainer.h"
|
||||
|
||||
#include <utils/smallstring.h>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class SourceLocationsForRenamingMessage
|
||||
{
|
||||
public:
|
||||
SourceLocationsForRenamingMessage() = default;
|
||||
SourceLocationsForRenamingMessage(Utils::SmallString &&symbolName,
|
||||
SourceLocationsContainer &&sourceLocationContainer,
|
||||
int textDocumentRevision)
|
||||
: symbolName_(std::move(symbolName)),
|
||||
sourceLocationContainer(std::move(sourceLocationContainer)),
|
||||
revision(textDocumentRevision)
|
||||
{}
|
||||
|
||||
const Utils::SmallString &symbolName() const
|
||||
{
|
||||
return symbolName_;
|
||||
}
|
||||
|
||||
int textDocumentRevision() const
|
||||
{
|
||||
return revision;
|
||||
}
|
||||
|
||||
const SourceLocationsContainer &sourceLocations() const
|
||||
{
|
||||
return sourceLocationContainer;
|
||||
}
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out, const SourceLocationsForRenamingMessage &message)
|
||||
{
|
||||
out << message.symbolName_;
|
||||
out << message.sourceLocationContainer;
|
||||
out << message.revision;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
friend QDataStream &operator>>(QDataStream &in, SourceLocationsForRenamingMessage &message)
|
||||
{
|
||||
in >> message.symbolName_;
|
||||
in >> message.sourceLocationContainer;
|
||||
in >> message.revision;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
friend bool operator==(const SourceLocationsForRenamingMessage &first, const SourceLocationsForRenamingMessage &second)
|
||||
{
|
||||
return first.revision == second.revision
|
||||
&& first.symbolName_ == second.symbolName_
|
||||
&& first.sourceLocationContainer == second.sourceLocationContainer;
|
||||
}
|
||||
|
||||
SourceLocationsForRenamingMessage clone() const
|
||||
{
|
||||
return SourceLocationsForRenamingMessage(symbolName_.clone(),
|
||||
sourceLocationContainer.clone(),
|
||||
revision);
|
||||
}
|
||||
|
||||
private:
|
||||
Utils::SmallString symbolName_;
|
||||
SourceLocationsContainer sourceLocationContainer;
|
||||
int revision;
|
||||
};
|
||||
|
||||
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const SourceLocationsForRenamingMessage &message);
|
||||
void PrintTo(const SourceLocationsForRenamingMessage &message, ::std::ostream* os);
|
||||
|
||||
DECLARE_MESSAGE(SourceLocationsForRenamingMessage)
|
||||
} // namespace ClangBackEnd
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <clangbackendipc_global.h>
|
||||
#include "clangbackendipc_global.h"
|
||||
|
||||
#include <utf8stringvector.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user