Commit 7eee8061 authored by Marco Bubke's avatar Marco Bubke

Clang: Add unsaved files messages

We have auto generated buffers from ui files which are not open but have no
file representation. So we need to provide them as unsaved files only.

Change-Id: I48a426c18e06eeda2fa707864f32f293e17ac651
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 3114780e
......@@ -43,7 +43,9 @@ SOURCES += $$PWD/ipcserverinterface.cpp \
$$PWD/sourcerangecontainer.cpp \
$$PWD/sourcelocationcontainer.cpp \
$$PWD/fixitcontainer.cpp \
$$PWD/requestdiagnosticsmessage.cpp
$$PWD/requestdiagnosticsmessage.cpp \
$$PWD/registerunsavedfilesforeditormessage.cpp \
$$PWD/unregisterunsavedfilesforeditormessage.cpp
HEADERS += \
$$PWD/ipcserverinterface.h \
......@@ -81,6 +83,8 @@ HEADERS += \
$$PWD/sourcerangecontainer.h \
$$PWD/sourcelocationcontainer.h \
$$PWD/fixitcontainer.h \
$$PWD/requestdiagnosticsmessage.h
$$PWD/requestdiagnosticsmessage.h \
$$PWD/registerunsavedfilesforeditormessage.h \
$$PWD/unregisterunsavedfilesforeditormessage.h
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
......@@ -41,11 +41,13 @@
#include "cmbcodecompletedmessage.h"
#include "diagnosticcontainer.h"
#include "diagnosticschangedmessage.h"
#include "registerunsavedfilesforeditormessage.h"
#include "requestdiagnosticsmessage.h"
#include "projectpartsdonotexistmessage.h"
#include "sourcelocationcontainer.h"
#include "sourcerangecontainer.h"
#include "translationunitdoesnotexistmessage.h"
#include "unregisterunsavedfilesforeditormessage.h"
#include <QDataStream>
......@@ -127,6 +129,14 @@ void Messages::registerMessages()
qRegisterMetaType<RequestDiagnosticsMessage>();
qRegisterMetaTypeStreamOperators<RequestDiagnosticsMessage>();
QMetaType::registerComparators<RequestDiagnosticsMessage>();
qRegisterMetaType<RegisterUnsavedFilesForEditorMessage>();
qRegisterMetaTypeStreamOperators<RegisterUnsavedFilesForEditorMessage>();
QMetaType::registerComparators<RegisterUnsavedFilesForEditorMessage>();
qRegisterMetaType<UnregisterUnsavedFilesForEditorMessage>();
qRegisterMetaTypeStreamOperators<UnregisterUnsavedFilesForEditorMessage>();
QMetaType::registerComparators<UnregisterUnsavedFilesForEditorMessage>();
}
} // namespace ClangBackEnd
......
......@@ -47,6 +47,8 @@ class TranslationUnitDoesNotExistMessage;
class ProjectPartsDoNotExistMessage;
class DiagnosticsChangedMessage;
class RequestDiagnosticsMessage;
class RegisterUnsavedFilesForEditorMessage;
class UnregisterUnsavedFilesForEditorMessage;
class CMBIPC_EXPORT IpcClientInterface : public IpcInterface
{
......
......@@ -35,7 +35,9 @@
#include "cmbregistertranslationunitsforeditormessage.h"
#include "cmbunregisterprojectsforeditormessage.h"
#include "cmbunregistertranslationunitsforeditormessage.h"
#include "registerunsavedfilesforeditormessage.h"
#include "requestdiagnosticsmessage.h"
#include "unregisterunsavedfilesforeditormessage.h"
#include <QDebug>
#include <QVariant>
......@@ -49,6 +51,8 @@ void IpcServerInterface::dispatch(const QVariant &message)
static const int unregisterTranslationUnitsForEditorMessageType = QMetaType::type("ClangBackEnd::UnregisterTranslationUnitsForEditorMessage");
static const int registerProjectPartsForEditorMessageType = QMetaType::type("ClangBackEnd::RegisterProjectPartsForEditorMessage");
static const int unregisterProjectPartsForEditorMessageType = QMetaType::type("ClangBackEnd::UnregisterProjectPartsForEditorMessage");
static const int registerUnsavedFilesForEditorMessageType = QMetaType::type("ClangBackEnd::RegisterUnsavedFilesForEditorMessage");
static const int unregisterUnsavedFilesForEditorMessageType = QMetaType::type("ClangBackEnd::UnregisterUnsavedFilesForEditorMessage");
static const int completeCodeMessageType = QMetaType::type("ClangBackEnd::CompleteCodeMessage");
static const int requestDiagnosticsMessageType = QMetaType::type("ClangBackEnd::RequestDiagnosticsMessage");
......@@ -64,6 +68,10 @@ void IpcServerInterface::dispatch(const QVariant &message)
registerProjectPartsForEditor(message.value<RegisterProjectPartsForEditorMessage>());
else if (type == unregisterProjectPartsForEditorMessageType)
unregisterProjectPartsForEditor(message.value<UnregisterProjectPartsForEditorMessage>());
else if (type == registerUnsavedFilesForEditorMessageType)
registerUnsavedFilesForEditor(message.value<RegisterUnsavedFilesForEditorMessage>());
else if (type == unregisterUnsavedFilesForEditorMessageType)
unregisterUnsavedFilesForEditor(message.value<UnregisterUnsavedFilesForEditorMessage>());
else if (type == completeCodeMessageType)
completeCode(message.value<CompleteCodeMessage>());
else if (type == requestDiagnosticsMessageType)
......
......@@ -49,6 +49,8 @@ public:
virtual void unregisterTranslationUnitsForEditor(const UnregisterTranslationUnitsForEditorMessage &message) = 0;
virtual void registerProjectPartsForEditor(const RegisterProjectPartsForEditorMessage &message) = 0;
virtual void unregisterProjectPartsForEditor(const UnregisterProjectPartsForEditorMessage &message) = 0;
virtual void registerUnsavedFilesForEditor(const RegisterUnsavedFilesForEditorMessage &message) = 0;
virtual void unregisterUnsavedFilesForEditor(const UnregisterUnsavedFilesForEditorMessage &message) = 0;
virtual void completeCode(const CompleteCodeMessage &message) = 0;
virtual void requestDiagnostics(const RequestDiagnosticsMessage &message) = 0;
......
......@@ -37,8 +37,10 @@
#include <cmbregistertranslationunitsforeditormessage.h>
#include <cmbunregisterprojectsforeditormessage.h>
#include <cmbunregistertranslationunitsforeditormessage.h>
#include <requestdiagnosticsmessage.h>
#include <ipcclientinterface.h>
#include <registerunsavedfilesforeditormessage.h>
#include <requestdiagnosticsmessage.h>
#include <unregisterunsavedfilesforeditormessage.h>
#include <QLocalServer>
#include <QLocalSocket>
......@@ -91,6 +93,16 @@ void IpcServerProxy::unregisterProjectPartsForEditor(const UnregisterProjectPart
writeMessageBlock.write(QVariant::fromValue(message));
}
void ClangBackEnd::IpcServerProxy::registerUnsavedFilesForEditor(const ClangBackEnd::RegisterUnsavedFilesForEditorMessage &message)
{
writeMessageBlock.write(QVariant::fromValue(message));
}
void ClangBackEnd::IpcServerProxy::unregisterUnsavedFilesForEditor(const ClangBackEnd::UnregisterUnsavedFilesForEditorMessage &message)
{
writeMessageBlock.write(QVariant::fromValue(message));
}
void IpcServerProxy::completeCode(const CompleteCodeMessage &message)
{
writeMessageBlock.write(QVariant::fromValue(message));
......
......@@ -60,6 +60,8 @@ public:
void unregisterTranslationUnitsForEditor(const UnregisterTranslationUnitsForEditorMessage &message) override;
void registerProjectPartsForEditor(const RegisterProjectPartsForEditorMessage &message) override;
void unregisterProjectPartsForEditor(const UnregisterProjectPartsForEditorMessage &message) override;
void registerUnsavedFilesForEditor(const RegisterUnsavedFilesForEditorMessage &message) override;
void unregisterUnsavedFilesForEditor(const UnregisterUnsavedFilesForEditorMessage &message) override;
void completeCode(const CompleteCodeMessage &message) override;
void requestDiagnostics(const RequestDiagnosticsMessage &message) override;
......
/****************************************************************************
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. 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, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "registerunsavedfilesforeditormessage.h"
#include "container_common.h"
#include <QDataStream>
#include <QDebug>
#include <ostream>
namespace ClangBackEnd {
RegisterUnsavedFilesForEditorMessage::RegisterUnsavedFilesForEditorMessage(const QVector<FileContainer> &fileContainers)
: fileContainers_(fileContainers)
{
}
const QVector<FileContainer> &RegisterUnsavedFilesForEditorMessage::fileContainers() const
{
return fileContainers_;
}
QDataStream &operator<<(QDataStream &out, const RegisterUnsavedFilesForEditorMessage &message)
{
out << message.fileContainers_;
return out;
}
QDataStream &operator>>(QDataStream &in, RegisterUnsavedFilesForEditorMessage &message)
{
in >> message.fileContainers_;
return in;
}
bool operator==(const RegisterUnsavedFilesForEditorMessage &first, const RegisterUnsavedFilesForEditorMessage &second)
{
return first.fileContainers_ == second.fileContainers_;
}
bool operator<(const RegisterUnsavedFilesForEditorMessage &first, const RegisterUnsavedFilesForEditorMessage &second)
{
return compareContainer(first.fileContainers_, second.fileContainers_);
}
QDebug operator<<(QDebug debug, const RegisterUnsavedFilesForEditorMessage &message)
{
debug.nospace() << "RegisterUnsavedFilesForEditorMessage(";
for (const FileContainer &fileContainer : message.fileContainers())
debug.nospace() << fileContainer<< ", ";
debug.nospace() << ")";
return debug;
}
void PrintTo(const RegisterUnsavedFilesForEditorMessage &message, ::std::ostream* os)
{
*os << "RegisterUnsavedFilesForEditorMessage(";
for (const FileContainer &fileContainer : message.fileContainers())
PrintTo(fileContainer, os);
*os << ")";
}
} // namespace ClangBackEnd
/****************************************************************************
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. 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, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CLANGBACKEND_REGISTERUNSAVEDFILESFOREDITORMESSAGE_H
#define CLANGBACKEND_REGISTERUNSAVEDFILESFOREDITORMESSAGE_H
#include "filecontainer.h"
#include <QMetaType>
#include <QVector>
namespace ClangBackEnd {
class CMBIPC_EXPORT RegisterUnsavedFilesForEditorMessage
{
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterUnsavedFilesForEditorMessage &message);
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterUnsavedFilesForEditorMessage &message);
friend CMBIPC_EXPORT bool operator==(const RegisterUnsavedFilesForEditorMessage &first, const RegisterUnsavedFilesForEditorMessage &second);
friend CMBIPC_EXPORT bool operator<(const RegisterUnsavedFilesForEditorMessage &first, const RegisterUnsavedFilesForEditorMessage &second);
friend void PrintTo(const RegisterUnsavedFilesForEditorMessage &message, ::std::ostream* os);
public:
RegisterUnsavedFilesForEditorMessage() = default;
RegisterUnsavedFilesForEditorMessage(const QVector<FileContainer> &fileContainers);
const QVector<FileContainer> &fileContainers() const;
private:
QVector<FileContainer> fileContainers_;
};
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterUnsavedFilesForEditorMessage &message);
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterUnsavedFilesForEditorMessage &message);
CMBIPC_EXPORT bool operator==(const RegisterUnsavedFilesForEditorMessage &first, const RegisterUnsavedFilesForEditorMessage &second);
CMBIPC_EXPORT bool operator<(const RegisterUnsavedFilesForEditorMessage &first, const RegisterUnsavedFilesForEditorMessage &second);
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const RegisterUnsavedFilesForEditorMessage &message);
void PrintTo(const RegisterUnsavedFilesForEditorMessage &message, ::std::ostream* os);
} // namespace ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::RegisterUnsavedFilesForEditorMessage)
#endif // CLANGBACKEND_REGISTERUNSAVEDFILESFOREDITORMESSAGE_H
/****************************************************************************
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. 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, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "unregisterunsavedfilesforeditormessage.h"
#include "container_common.h"
#include <QDataStream>
#include <QDebug>
#include <ostream>
namespace ClangBackEnd {
UnregisterUnsavedFilesForEditorMessage::UnregisterUnsavedFilesForEditorMessage(const QVector<FileContainer> &fileContainers)
: fileContainers_(fileContainers)
{
}
const QVector<FileContainer> &UnregisterUnsavedFilesForEditorMessage::fileContainers() const
{
return fileContainers_;
}
QDataStream &operator<<(QDataStream &out, const UnregisterUnsavedFilesForEditorMessage &message)
{
out << message.fileContainers_;
return out;
}
QDataStream &operator>>(QDataStream &in, UnregisterUnsavedFilesForEditorMessage &message)
{
in >> message.fileContainers_;
return in;
}
bool operator==(const UnregisterUnsavedFilesForEditorMessage &first, const UnregisterUnsavedFilesForEditorMessage &second)
{
return first.fileContainers_ == second.fileContainers_;
}
bool operator<(const UnregisterUnsavedFilesForEditorMessage &first, const UnregisterUnsavedFilesForEditorMessage &second)
{
return compareContainer(first.fileContainers_, second.fileContainers_);
}
QDebug operator<<(QDebug debug, const UnregisterUnsavedFilesForEditorMessage &message)
{
debug.nospace() << "UnregisterUnsavedFilesForEditorMessage(";
for (const FileContainer &fileContainer : message.fileContainers())
debug.nospace() << fileContainer<< ", ";
debug.nospace() << ")";
return debug;
}
void PrintTo(const UnregisterUnsavedFilesForEditorMessage &message, ::std::ostream* os)
{
*os << "UnregisterUnsavedFilesForEditorMessage(";
for (const FileContainer &fileContainer : message.fileContainers())
PrintTo(fileContainer, os);
*os << ")";
}
} // namespace ClangBackEnd
/****************************************************************************
**
** 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 The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. 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, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CLANGBACKEND_UNREGISTERTRANSLATIONUNITSFOREDITORMESSAGE_H
#define CLANGBACKEND_UNREGISTERTRANSLATIONUNITSFOREDITORMESSAGE_H
#include "filecontainer.h"
#include <QMetaType>
#include <QVector>
namespace ClangBackEnd {
class CMBIPC_EXPORT UnregisterUnsavedFilesForEditorMessage
{
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterUnsavedFilesForEditorMessage &message);
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterUnsavedFilesForEditorMessage &message);
friend CMBIPC_EXPORT bool operator==(const UnregisterUnsavedFilesForEditorMessage &first, const UnregisterUnsavedFilesForEditorMessage &second);
friend CMBIPC_EXPORT bool operator<(const UnregisterUnsavedFilesForEditorMessage &first, const UnregisterUnsavedFilesForEditorMessage &second);
friend void PrintTo(const UnregisterUnsavedFilesForEditorMessage &message, ::std::ostream* os);
public:
UnregisterUnsavedFilesForEditorMessage() = default;
UnregisterUnsavedFilesForEditorMessage(const QVector<FileContainer> &fileContainers);
const QVector<FileContainer> &fileContainers() const;
private:
QVector<FileContainer> fileContainers_;
};
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterUnsavedFilesForEditorMessage &message);
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterUnsavedFilesForEditorMessage &message);
CMBIPC_EXPORT bool operator==(const UnregisterUnsavedFilesForEditorMessage &first, const UnregisterUnsavedFilesForEditorMessage &second);
CMBIPC_EXPORT bool operator<(const UnregisterUnsavedFilesForEditorMessage &first, const UnregisterUnsavedFilesForEditorMessage &second);
CMBIPC_EXPORT QDebug operator<<(QDebug debug, const UnregisterUnsavedFilesForEditorMessage &message);
void PrintTo(const UnregisterUnsavedFilesForEditorMessage &message, ::std::ostream* os);
} // namespace ClangBackEnd
Q_DECLARE_METATYPE(ClangBackEnd::UnregisterUnsavedFilesForEditorMessage)
#endif // CLANGBACKEND_UNREGISTERTRANSLATIONUNITSFOREDITORMESSAGE_H
......@@ -60,10 +60,12 @@
#include <clangbackendipc/cmbunregistertranslationunitsforeditormessage.h>
#include <clangbackendipc/cmbunregisterprojectsforeditormessage.h>
#include <clangbackendipc/cmbmessages.h>
#include <clangbackendipc/registerunsavedfilesforeditormessage.h>
#include <clangbackendipc/requestdiagnosticsmessage.h>
#include <clangbackendipc/filecontainer.h>
#include <clangbackendipc/projectpartsdonotexistmessage.h>
#include <clangbackendipc/translationunitdoesnotexistmessage.h>
#include <clangbackendipc/unregisterunsavedfilesforeditormessage.h>
#include <cplusplus/Icons.h>
......@@ -195,6 +197,8 @@ public:
void unregisterTranslationUnitsForEditor(const ClangBackEnd::UnregisterTranslationUnitsForEditorMessage &message) override;
void registerProjectPartsForEditor(const ClangBackEnd::RegisterProjectPartsForEditorMessage &message) override;
void unregisterProjectPartsForEditor(const ClangBackEnd::UnregisterProjectPartsForEditorMessage &message) override;
void registerUnsavedFilesForEditor(const ClangBackEnd::RegisterUnsavedFilesForEditorMessage &message) override;
void unregisterUnsavedFilesForEditor(const ClangBackEnd::UnregisterUnsavedFilesForEditorMessage &message) override;
void completeCode(const ClangBackEnd::CompleteCodeMessage &message) override;
void requestDiagnostics(const ClangBackEnd::RequestDiagnosticsMessage &message) override;
......@@ -232,6 +236,18 @@ void IpcSender::unregisterProjectPartsForEditor(const UnregisterProjectPartsForE
m_connection.serverProxy().unregisterProjectPartsForEditor(message);
}
void IpcSender::registerUnsavedFilesForEditor(const RegisterUnsavedFilesForEditorMessage &message)
{
QTC_CHECK(m_connection.isConnected());
m_connection.serverProxy().registerUnsavedFilesForEditor(message);
}
void IpcSender::unregisterUnsavedFilesForEditor(const UnregisterUnsavedFilesForEditorMessage &message)
{
QTC_CHECK(m_connection.isConnected());
m_connection.serverProxy().unregisterUnsavedFilesForEditor(message);
}
void IpcSender::completeCode(const CompleteCodeMessage &message)
{
QTC_CHECK(m_connection.isConnected());
......@@ -306,7 +322,7 @@ void IpcCommunicator::registerCurrentUnsavedFiles()
const auto cppEditorDocuments = CppModelManager::instance()->cppEditorDocuments();
foreach (const CppEditorDocumentHandle *cppEditorDocument, cppEditorDocuments) {
if (cppEditorDocument->processor()->baseTextDocument()->isModified())
updateUnsavedFileFromCppEditorDocument(cppEditorDocument->filePath());
updateTranslationUnitFromCppEditorDocument(cppEditorDocument->filePath());
}
}
......@@ -353,6 +369,13 @@ void IpcCommunicator::registerProjectsParts(const QList<CppTools::ProjectPart::P
registerProjectPartsForEditor(projectPartContainers);
}
void IpcCommunicator::updateTranslationUnitFromCppEditorDocument(const QString &filePath)
{
const auto document = CppTools::CppModelManager::instance()->cppEditorDocument(filePath);
updateTranslationUnit(filePath, document->contents(), document->revision());
}
void IpcCommunicator::updateUnsavedFileFromCppEditorDocument(const QString &filePath)
{
const auto document = CppTools::CppModelManager::instance()->cppEditorDocument(filePath);
......@@ -360,7 +383,7 @@ void IpcCommunicator::updateUnsavedFileFromCppEditorDocument(const QString &file
updateUnsavedFile(filePath, document->contents(), document->revision());
}
void IpcCommunicator::updateUnsavedFile(const QString &filePath,
void IpcCommunicator::updateTranslationUnit(const QString &filePath,
const QByteArray &contents,
uint documentRevision)
{
......@@ -368,25 +391,44 @@ void IpcCommunicator::updateUnsavedFile(const QString &filePath,
const bool hasUnsavedContent = true;
// TODO: Send new only if changed
registerFilesForEditor({{filePath,
projectPartId,
Utf8String::fromByteArray(contents),
hasUnsavedContent,
documentRevision}});
registerTranslationUnitsForEditor({{filePath,
projectPartId,
Utf8String::fromByteArray(contents),
hasUnsavedContent,
documentRevision}});
}
void IpcCommunicator::updateUnsavedFile(const QString &filePath, const QByteArray &contents, uint documentRevision)
{
const QString projectPartId = Utils::projectPartIdForFile(filePath);
const bool hasUnsavedContent = true;
// TODO: Send new only if changed
registerUnsavedFilesForEditor({{filePath,
projectPartId,
Utf8String::fromByteArray(contents),
hasUnsavedContent,
documentRevision}});
}
void IpcCommunicator::requestDiagnostics(const FileContainer &fileContainer)
{
registerFilesForEditor({fileContainer});
registerTranslationUnitsForEditor({fileContainer});
m_ipcSender->requestDiagnostics({fileContainer});
}
void IpcCommunicator::updateUnsavedFileIfNotCurrentDocument(Core::IDocument *document)
void IpcCommunicator::updateTranslationUnitIfNotCurrentDocument(Core::IDocument *document)
{
QTC_ASSERT(document, return);
if (Core::EditorManager::currentDocument() != document)
updateUnsavedFileFromCppEditorDocument(document->filePath().toString());
updateTranslationUnitFromCppEditorDocument(document->filePath().toString());
}
void IpcCommunicator::updateUnsavedFile(Core::IDocument *document)
{
QTC_ASSERT(document, return);
updateUnsavedFileFromCppEditorDocument(document->filePath().toString());
}
void IpcCommunicator::onBackendRestarted()
......@@ -431,7 +473,7 @@ void IpcCommunicator::killBackendProcess()
m_connection.processForTestOnly()->kill();
}
void IpcCommunicator::registerFilesForEditor(const FileContainers &fileContainers)
void IpcCommunicator::registerTranslationUnitsForEditor(const FileContainers &fileContainers)
{
if (m_sendMode == IgnoreSendRequests)
return;
......@@ -441,7 +483,7 @@ void IpcCommunicator::registerFilesForEditor(const FileContainers &fileContainer
m_ipcSender->registerTranslationUnitsForEditor(message);
}
void IpcCommunicator::unregisterFilesForEditor(const FileContainers &fileContainers)
void IpcCommunicator::unregisterTranslationUnitsForEditor(const FileContainers &fileContainers)
{
if (m_sendMode == IgnoreSendRequests)
return;
......@@ -472,6 +514,26 @@ void IpcCommunicator::unregisterProjectPartsForEditor(const QStringList &project
m_ipcSender->unregisterProjectPartsForEditor(message);
}
void IpcCommunicator::registerUnsavedFilesForEditor(const IpcCommunicator::FileContainers &fileContainers)
{
if (m_sendMode == IgnoreSendRequests)
return;
const RegisterUnsavedFilesForEditorMessage message(fileContainers);
qCDebug(log) << ">>>" << message;
m_ipcSender->registerUnsavedFilesForEditor(message);
}
void IpcCommunicator::unregisterUnsavedFilesForEditor(const IpcCommunicator::FileContainers &fileContainers)
{
if (m_sendMode == IgnoreSendRequests)
return;
const UnregisterUnsavedFilesForEditorMessage message(fileContainers);
qCDebug(log) << ">>>" << message;
m_ipcSender->unregisterUnsavedFilesForEditor(message);
}
void IpcCommunicator::completeCode(ClangCompletionAssistProcessor *assistProcessor,
const QString &filePath,
quint32 line,
......
......@@ -99,6 +99,8 @@ public:
virtual void unregisterTranslationUnitsForEditor(const ClangBackEnd::UnregisterTranslationUnitsForEditorMessage &message) = 0;