forked from qt-creator/qt-creator
Clang: Add UpdateTranslationUnitsForEditorMessage
If an editor is changing all translation units independent of their project part they must be updated too. So we introduce a new message to update all translation units with the same file path. Change-Id: I70d0ea2bbca9fa880111ff7219573e54f3277026 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
@@ -45,7 +45,8 @@ SOURCES += $$PWD/ipcserverinterface.cpp \
|
||||
$$PWD/fixitcontainer.cpp \
|
||||
$$PWD/requestdiagnosticsmessage.cpp \
|
||||
$$PWD/registerunsavedfilesforeditormessage.cpp \
|
||||
$$PWD/unregisterunsavedfilesforeditormessage.cpp
|
||||
$$PWD/unregisterunsavedfilesforeditormessage.cpp \
|
||||
$$PWD/updatetranslationunitsforeditormessage.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/ipcserverinterface.h \
|
||||
@@ -85,6 +86,7 @@ HEADERS += \
|
||||
$$PWD/fixitcontainer.h \
|
||||
$$PWD/requestdiagnosticsmessage.h \
|
||||
$$PWD/registerunsavedfilesforeditormessage.h \
|
||||
$$PWD/unregisterunsavedfilesforeditormessage.h
|
||||
$$PWD/unregisterunsavedfilesforeditormessage.h \
|
||||
$$PWD/updatetranslationunitsforeditormessage.h
|
||||
|
||||
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
#endif
|
||||
|
||||
namespace ClangBackEnd {
|
||||
CMBIPC_EXPORT void registerTypes();
|
||||
|
||||
enum class DiagnosticSeverity // one to one mapping of the clang enum numbers
|
||||
{
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "sourcerangecontainer.h"
|
||||
#include "translationunitdoesnotexistmessage.h"
|
||||
#include "unregisterunsavedfilesforeditormessage.h"
|
||||
#include "updatetranslationunitsforeditormessage.h"
|
||||
|
||||
#include <QDataStream>
|
||||
|
||||
@@ -137,6 +138,10 @@ void Messages::registerMessages()
|
||||
qRegisterMetaType<UnregisterUnsavedFilesForEditorMessage>();
|
||||
qRegisterMetaTypeStreamOperators<UnregisterUnsavedFilesForEditorMessage>();
|
||||
QMetaType::registerComparators<UnregisterUnsavedFilesForEditorMessage>();
|
||||
|
||||
qRegisterMetaType<UpdateTranslationUnitsForEditorMessage>();
|
||||
qRegisterMetaTypeStreamOperators<UpdateTranslationUnitsForEditorMessage>();
|
||||
QMetaType::registerComparators<UpdateTranslationUnitsForEditorMessage>();
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace ClangBackEnd {
|
||||
|
||||
class IpcServerInterface;
|
||||
class RegisterTranslationUnitForEditorMessage;
|
||||
class UpdateTranslationUnitsForEditorMessage;
|
||||
class RegisterProjectPartsForEditorMessage;
|
||||
class UnregisterTranslationUnitsForEditorMessage;
|
||||
class UnregisterProjectPartsForEditorMessage;
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "registerunsavedfilesforeditormessage.h"
|
||||
#include "requestdiagnosticsmessage.h"
|
||||
#include "unregisterunsavedfilesforeditormessage.h"
|
||||
#include "updatetranslationunitsforeditormessage.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QVariant>
|
||||
@@ -48,6 +49,7 @@ void IpcServerInterface::dispatch(const QVariant &message)
|
||||
{
|
||||
static const int endMessageType = QMetaType::type("ClangBackEnd::EndMessage");
|
||||
static const int registerTranslationUnitsForEditorMessageType = QMetaType::type("ClangBackEnd::RegisterTranslationUnitForEditorMessage");
|
||||
static const int updateTranslationUnitsForEditorMessageType = QMetaType::type("ClangBackEnd::UpdateTranslationUnitsForEditorMessage");
|
||||
static const int unregisterTranslationUnitsForEditorMessageType = QMetaType::type("ClangBackEnd::UnregisterTranslationUnitsForEditorMessage");
|
||||
static const int registerProjectPartsForEditorMessageType = QMetaType::type("ClangBackEnd::RegisterProjectPartsForEditorMessage");
|
||||
static const int unregisterProjectPartsForEditorMessageType = QMetaType::type("ClangBackEnd::UnregisterProjectPartsForEditorMessage");
|
||||
@@ -62,6 +64,8 @@ void IpcServerInterface::dispatch(const QVariant &message)
|
||||
end();
|
||||
else if (type == registerTranslationUnitsForEditorMessageType)
|
||||
registerTranslationUnitsForEditor(message.value<RegisterTranslationUnitForEditorMessage>());
|
||||
else if (type == updateTranslationUnitsForEditorMessageType)
|
||||
updateTranslationUnitsForEditor(message.value<UpdateTranslationUnitsForEditorMessage>());
|
||||
else if (type == unregisterTranslationUnitsForEditorMessageType)
|
||||
unregisterTranslationUnitsForEditor(message.value<UnregisterTranslationUnitsForEditorMessage>());
|
||||
else if (type == registerProjectPartsForEditorMessageType)
|
||||
|
||||
@@ -46,6 +46,7 @@ public:
|
||||
|
||||
virtual void end() = 0;
|
||||
virtual void registerTranslationUnitsForEditor(const RegisterTranslationUnitForEditorMessage &message) = 0;
|
||||
virtual void updateTranslationUnitsForEditor(const UpdateTranslationUnitsForEditorMessage &message) = 0;
|
||||
virtual void unregisterTranslationUnitsForEditor(const UnregisterTranslationUnitsForEditorMessage &message) = 0;
|
||||
virtual void registerProjectPartsForEditor(const RegisterProjectPartsForEditorMessage &message) = 0;
|
||||
virtual void unregisterProjectPartsForEditor(const UnregisterProjectPartsForEditorMessage &message) = 0;
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <registerunsavedfilesforeditormessage.h>
|
||||
#include <requestdiagnosticsmessage.h>
|
||||
#include <unregisterunsavedfilesforeditormessage.h>
|
||||
#include <updatetranslationunitsforeditormessage.h>
|
||||
|
||||
#include <QLocalServer>
|
||||
#include <QLocalSocket>
|
||||
@@ -78,6 +79,11 @@ void IpcServerProxy::registerTranslationUnitsForEditor(const RegisterTranslation
|
||||
writeMessageBlock.write(QVariant::fromValue(message));
|
||||
}
|
||||
|
||||
void IpcServerProxy::updateTranslationUnitsForEditor(const ClangBackEnd::UpdateTranslationUnitsForEditorMessage &message)
|
||||
{
|
||||
writeMessageBlock.write(QVariant::fromValue(message));
|
||||
}
|
||||
|
||||
void IpcServerProxy::unregisterTranslationUnitsForEditor(const UnregisterTranslationUnitsForEditorMessage &message)
|
||||
{
|
||||
writeMessageBlock.write(QVariant::fromValue(message));
|
||||
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
|
||||
void end() override;
|
||||
void registerTranslationUnitsForEditor(const RegisterTranslationUnitForEditorMessage &message) override;
|
||||
void updateTranslationUnitsForEditor(const UpdateTranslationUnitsForEditorMessage &message) override;
|
||||
void unregisterTranslationUnitsForEditor(const UnregisterTranslationUnitsForEditorMessage &message) override;
|
||||
void registerProjectPartsForEditor(const RegisterProjectPartsForEditorMessage &message) override;
|
||||
void unregisterProjectPartsForEditor(const UnregisterProjectPartsForEditorMessage &message) override;
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://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 Digia. For licensing terms and
|
||||
** conditions see http://www.qt.io/licensing. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "updatetranslationunitsforeditormessage.h"
|
||||
|
||||
#include "container_common.h"
|
||||
|
||||
#include <QDataStream>
|
||||
#include <QDebug>
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
UpdateTranslationUnitsForEditorMessage::UpdateTranslationUnitsForEditorMessage(const QVector<FileContainer> &fileContainers)
|
||||
: fileContainers_(fileContainers)
|
||||
{
|
||||
}
|
||||
|
||||
const QVector<FileContainer> &UpdateTranslationUnitsForEditorMessage::fileContainers() const
|
||||
{
|
||||
return fileContainers_;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const UpdateTranslationUnitsForEditorMessage &message)
|
||||
{
|
||||
out << message.fileContainers_;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, UpdateTranslationUnitsForEditorMessage &message)
|
||||
{
|
||||
in >> message.fileContainers_;
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
bool operator==(const UpdateTranslationUnitsForEditorMessage &first, const UpdateTranslationUnitsForEditorMessage &second)
|
||||
{
|
||||
return first.fileContainers_ == second.fileContainers_;
|
||||
}
|
||||
|
||||
bool operator<(const UpdateTranslationUnitsForEditorMessage &first, const UpdateTranslationUnitsForEditorMessage &second)
|
||||
{
|
||||
return compareContainer(first.fileContainers_, second.fileContainers_);
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const UpdateTranslationUnitsForEditorMessage &message)
|
||||
{
|
||||
debug.nospace() << "UpdateTranslationUnitsForEditorMessage(";
|
||||
|
||||
for (const FileContainer &fileContainer : message.fileContainers())
|
||||
debug.nospace() << fileContainer<< ", ";
|
||||
|
||||
debug.nospace() << ")";
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
void PrintTo(const UpdateTranslationUnitsForEditorMessage &message, ::std::ostream* os)
|
||||
{
|
||||
*os << "UpdateTranslationUnitsForEditorMessage(";
|
||||
|
||||
for (const FileContainer &fileContainer : message.fileContainers())
|
||||
PrintTo(fileContainer, os);
|
||||
|
||||
*os << ")";
|
||||
}
|
||||
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://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 Digia. For licensing terms and
|
||||
** conditions see http://www.qt.io/licensing. For further information
|
||||
** use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CLANGBACKEND_UPDATEFILEFOREDITOR_H
|
||||
#define CLANGBACKEND_UPDATEFILEFOREDITOR_H
|
||||
|
||||
#include "filecontainer.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVector>
|
||||
|
||||
namespace ClangBackEnd {
|
||||
|
||||
class CMBIPC_EXPORT UpdateTranslationUnitsForEditorMessage
|
||||
{
|
||||
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UpdateTranslationUnitsForEditorMessage &message);
|
||||
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UpdateTranslationUnitsForEditorMessage &message);
|
||||
friend CMBIPC_EXPORT bool operator==(const UpdateTranslationUnitsForEditorMessage &first, const UpdateTranslationUnitsForEditorMessage &second);
|
||||
friend CMBIPC_EXPORT bool operator<(const UpdateTranslationUnitsForEditorMessage &first, const UpdateTranslationUnitsForEditorMessage &second);
|
||||
friend void PrintTo(const UpdateTranslationUnitsForEditorMessage &message, ::std::ostream* os);
|
||||
public:
|
||||
UpdateTranslationUnitsForEditorMessage() = default;
|
||||
UpdateTranslationUnitsForEditorMessage(const QVector<FileContainer> &fileContainers);
|
||||
|
||||
const QVector<FileContainer> &fileContainers() const;
|
||||
|
||||
private:
|
||||
QVector<FileContainer> fileContainers_;
|
||||
};
|
||||
|
||||
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UpdateTranslationUnitsForEditorMessage &message);
|
||||
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UpdateTranslationUnitsForEditorMessage &message);
|
||||
CMBIPC_EXPORT bool operator==(const UpdateTranslationUnitsForEditorMessage &first, const UpdateTranslationUnitsForEditorMessage &second);
|
||||
CMBIPC_EXPORT bool operator<(const UpdateTranslationUnitsForEditorMessage &first, const UpdateTranslationUnitsForEditorMessage &second);
|
||||
|
||||
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const UpdateTranslationUnitsForEditorMessage &message);
|
||||
void PrintTo(const UpdateTranslationUnitsForEditorMessage &message, ::std::ostream* os);
|
||||
} // namespace ClangBackEnd
|
||||
|
||||
Q_DECLARE_METATYPE(ClangBackEnd::UpdateTranslationUnitsForEditorMessage)
|
||||
|
||||
#endif // CLANGBACKEND_UPDATEFILEFOREDITOR_H
|
||||
Reference in New Issue
Block a user