2015-05-08 15:48:17 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2015-06-16 11:56:00 +02:00
|
|
|
#include "clangbackendipcintegration.h"
|
2015-05-08 15:48:17 +02:00
|
|
|
|
2015-07-06 12:05:02 +02:00
|
|
|
#include "clangcompletionassistprocessor.h"
|
2015-08-31 16:28:26 +02:00
|
|
|
#include "clangeditordocumentprocessor.h"
|
2015-05-08 15:48:17 +02:00
|
|
|
#include "clangmodelmanagersupport.h"
|
|
|
|
|
#include "clangutils.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
|
|
|
|
|
#include <cpptools/abstracteditorsupport.h>
|
|
|
|
|
#include <cpptools/baseeditordocumentprocessor.h>
|
|
|
|
|
#include <cpptools/editordocumenthandle.h>
|
|
|
|
|
|
|
|
|
|
#include <texteditor/codeassist/functionhintproposal.h>
|
|
|
|
|
#include <texteditor/codeassist/iassistprocessor.h>
|
|
|
|
|
#include <texteditor/texteditor.h>
|
|
|
|
|
|
2015-08-31 16:28:26 +02:00
|
|
|
#include <clangbackendipc/diagnosticschangedmessage.h>
|
2015-11-18 17:07:44 +01:00
|
|
|
#include <clangbackendipc/highlightingchangedmessage.h>
|
2015-08-31 16:28:26 +02:00
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
#include <clangbackendipc/cmbcodecompletedmessage.h>
|
|
|
|
|
#include <clangbackendipc/cmbcompletecodemessage.h>
|
|
|
|
|
#include <clangbackendipc/cmbechomessage.h>
|
2015-08-31 14:36:58 +02:00
|
|
|
#include <clangbackendipc/cmbregistertranslationunitsforeditormessage.h>
|
|
|
|
|
#include <clangbackendipc/cmbregisterprojectsforeditormessage.h>
|
|
|
|
|
#include <clangbackendipc/cmbunregistertranslationunitsforeditormessage.h>
|
|
|
|
|
#include <clangbackendipc/cmbunregisterprojectsforeditormessage.h>
|
2015-08-19 12:36:43 +02:00
|
|
|
#include <clangbackendipc/cmbmessages.h>
|
2015-08-31 16:10:36 +02:00
|
|
|
#include <clangbackendipc/registerunsavedfilesforeditormessage.h>
|
2015-08-31 16:28:26 +02:00
|
|
|
#include <clangbackendipc/requestdiagnosticsmessage.h>
|
2015-11-18 17:07:44 +01:00
|
|
|
#include <clangbackendipc/requesthighlightingmessage.h>
|
2015-08-31 16:28:26 +02:00
|
|
|
#include <clangbackendipc/filecontainer.h>
|
2015-08-19 12:36:43 +02:00
|
|
|
#include <clangbackendipc/projectpartsdonotexistmessage.h>
|
|
|
|
|
#include <clangbackendipc/translationunitdoesnotexistmessage.h>
|
2015-08-31 16:10:36 +02:00
|
|
|
#include <clangbackendipc/unregisterunsavedfilesforeditormessage.h>
|
2015-10-13 15:56:41 +02:00
|
|
|
#include <clangbackendipc/updatetranslationunitsforeditormessage.h>
|
2015-12-01 11:57:08 +01:00
|
|
|
#include <clangbackendipc/updatevisibletranslationunitsmessage.h>
|
2015-05-08 15:48:17 +02:00
|
|
|
|
|
|
|
|
#include <cplusplus/Icons.h>
|
|
|
|
|
|
|
|
|
|
#include <QElapsedTimer>
|
|
|
|
|
#include <QLoggingCategory>
|
|
|
|
|
#include <QProcess>
|
|
|
|
|
|
|
|
|
|
static Q_LOGGING_CATEGORY(log, "qtc.clangcodemodel.ipc")
|
|
|
|
|
|
|
|
|
|
using namespace CPlusPlus;
|
|
|
|
|
using namespace ClangCodeModel;
|
|
|
|
|
using namespace ClangCodeModel::Internal;
|
2015-06-16 11:56:00 +02:00
|
|
|
using namespace ClangBackEnd;
|
2015-05-08 15:48:17 +02:00
|
|
|
using namespace TextEditor;
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
QString backendProcessPath()
|
|
|
|
|
{
|
2015-06-10 16:06:27 +02:00
|
|
|
return Core::ICore::libexecPath()
|
2015-06-16 11:56:00 +02:00
|
|
|
+ QStringLiteral("/clangbackend")
|
2015-05-08 15:48:17 +02:00
|
|
|
+ QStringLiteral(QTC_HOST_EXE_SUFFIX);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
|
|
IpcReceiver::IpcReceiver()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IpcReceiver::~IpcReceiver()
|
|
|
|
|
{
|
|
|
|
|
deleteAndClearWaitingAssistProcessors();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IpcReceiver::setAliveHandler(const IpcReceiver::AliveHandler &handler)
|
|
|
|
|
{
|
|
|
|
|
m_aliveHandler = handler;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
void IpcReceiver::addExpectedCodeCompletedMessage(
|
2015-05-08 15:48:17 +02:00
|
|
|
quint64 ticket,
|
|
|
|
|
ClangCompletionAssistProcessor *processor)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(processor, return);
|
|
|
|
|
QTC_CHECK(!m_assistProcessorsTable.contains(ticket));
|
|
|
|
|
m_assistProcessorsTable.insert(ticket, processor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IpcReceiver::deleteAndClearWaitingAssistProcessors()
|
|
|
|
|
{
|
|
|
|
|
qDeleteAll(m_assistProcessorsTable.begin(), m_assistProcessorsTable.end());
|
|
|
|
|
m_assistProcessorsTable.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IpcReceiver::deleteProcessorsOfEditorWidget(TextEditor::TextEditorWidget *textEditorWidget)
|
|
|
|
|
{
|
|
|
|
|
QMutableHashIterator<quint64, ClangCompletionAssistProcessor *> it(m_assistProcessorsTable);
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
it.next();
|
|
|
|
|
ClangCompletionAssistProcessor *assistProcessor = it.value();
|
|
|
|
|
if (assistProcessor->textEditorWidget() == textEditorWidget) {
|
|
|
|
|
delete assistProcessor;
|
|
|
|
|
it.remove();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-01 13:21:02 +01:00
|
|
|
bool IpcReceiver::isExpectingCodeCompletedMessage() const
|
|
|
|
|
{
|
|
|
|
|
return !m_assistProcessorsTable.isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
void IpcReceiver::alive()
|
|
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
qCDebug(log) << "<<< AliveMessage";
|
2015-05-08 15:48:17 +02:00
|
|
|
QTC_ASSERT(m_aliveHandler, return);
|
|
|
|
|
m_aliveHandler();
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
void IpcReceiver::echo(const EchoMessage &message)
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
qCDebug(log) << "<<<" << message;
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
void IpcReceiver::codeCompleted(const CodeCompletedMessage &message)
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
qCDebug(log) << "<<< CodeCompletedMessage with" << message.codeCompletions().size() << "items";
|
2015-05-08 15:48:17 +02:00
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
const quint64 ticket = message.ticketNumber();
|
2015-05-08 15:48:17 +02:00
|
|
|
QScopedPointer<ClangCompletionAssistProcessor> processor(m_assistProcessorsTable.take(ticket));
|
2015-07-22 13:09:44 +02:00
|
|
|
if (processor) {
|
2015-08-19 12:36:43 +02:00
|
|
|
const bool finished = processor->handleAvailableAsyncCompletions(message.codeCompletions());
|
2015-07-22 13:09:44 +02:00
|
|
|
if (!finished)
|
|
|
|
|
processor.take();
|
|
|
|
|
}
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-31 16:28:26 +02:00
|
|
|
void IpcReceiver::diagnosticsChanged(const DiagnosticsChangedMessage &message)
|
|
|
|
|
{
|
|
|
|
|
qCDebug(log) << "<<< DiagnosticsChangedMessage with" << message.diagnostics().size() << "items";
|
|
|
|
|
|
|
|
|
|
auto processor = ClangEditorDocumentProcessor::get(message.file().filePath());
|
|
|
|
|
|
|
|
|
|
if (processor && processor->projectPart()) {
|
|
|
|
|
const QString diagnosticsProjectPartId = message.file().projectPartId();
|
|
|
|
|
const QString documentProjectPartId = processor->projectPart()->id();
|
|
|
|
|
if (diagnosticsProjectPartId == documentProjectPartId)
|
2015-08-31 12:40:14 +02:00
|
|
|
processor->updateCodeWarnings(message.diagnostics(), message.file().documentRevision());
|
2015-08-31 16:28:26 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-18 17:07:44 +01:00
|
|
|
void IpcReceiver::highlightingChanged(const HighlightingChangedMessage &message)
|
|
|
|
|
{
|
|
|
|
|
qCDebug(log) << "<<< HighlightingChangedMessage with"
|
|
|
|
|
<< message.highlightingMarks().size() << "items";
|
|
|
|
|
|
|
|
|
|
auto processor = ClangEditorDocumentProcessor::get(message.file().filePath());
|
|
|
|
|
|
|
|
|
|
if (processor && processor->projectPart()) {
|
|
|
|
|
const QString highlightingProjectPartId = message.file().projectPartId();
|
|
|
|
|
const QString documentProjectPartId = processor->projectPart()->id();
|
|
|
|
|
if (highlightingProjectPartId == documentProjectPartId) {
|
|
|
|
|
processor->updateHighlighting(message.highlightingMarks(),
|
|
|
|
|
message.skippedPreprocessorRanges(),
|
|
|
|
|
message.file().documentRevision());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
void IpcReceiver::translationUnitDoesNotExist(const TranslationUnitDoesNotExistMessage &message)
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
QTC_CHECK(!"Got TranslationUnitDoesNotExistMessage");
|
|
|
|
|
qCDebug(log) << "<<< ERROR:" << message;
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
void IpcReceiver::projectPartsDoNotExist(const ProjectPartsDoNotExistMessage &message)
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
QTC_CHECK(!"Got ProjectPartsDoNotExistMessage");
|
|
|
|
|
qCDebug(log) << "<<< ERROR:" << message;
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class IpcSender : public IpcSenderInterface
|
|
|
|
|
{
|
|
|
|
|
public:
|
2015-06-16 11:56:00 +02:00
|
|
|
IpcSender(ClangBackEnd::ConnectionClient &connectionClient)
|
2015-05-08 15:48:17 +02:00
|
|
|
: m_connection(connectionClient)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
void end() override;
|
2015-08-31 14:36:58 +02:00
|
|
|
void registerTranslationUnitsForEditor(const ClangBackEnd::RegisterTranslationUnitForEditorMessage &message) override;
|
2015-10-13 15:56:41 +02:00
|
|
|
void updateTranslationUnitsForEditor(const ClangBackEnd::UpdateTranslationUnitsForEditorMessage &message) override;
|
2015-08-31 14:36:58 +02:00
|
|
|
void unregisterTranslationUnitsForEditor(const ClangBackEnd::UnregisterTranslationUnitsForEditorMessage &message) override;
|
|
|
|
|
void registerProjectPartsForEditor(const ClangBackEnd::RegisterProjectPartsForEditorMessage &message) override;
|
|
|
|
|
void unregisterProjectPartsForEditor(const ClangBackEnd::UnregisterProjectPartsForEditorMessage &message) override;
|
2015-08-31 16:10:36 +02:00
|
|
|
void registerUnsavedFilesForEditor(const ClangBackEnd::RegisterUnsavedFilesForEditorMessage &message) override;
|
|
|
|
|
void unregisterUnsavedFilesForEditor(const ClangBackEnd::UnregisterUnsavedFilesForEditorMessage &message) override;
|
2015-08-19 12:36:43 +02:00
|
|
|
void completeCode(const ClangBackEnd::CompleteCodeMessage &message) override;
|
2015-08-31 16:28:26 +02:00
|
|
|
void requestDiagnostics(const ClangBackEnd::RequestDiagnosticsMessage &message) override;
|
2015-11-18 17:07:44 +01:00
|
|
|
void requestHighlighting(const ClangBackEnd::RequestHighlightingMessage &message) override;
|
2015-12-01 11:57:08 +01:00
|
|
|
void updateVisibleTranslationUnits(const UpdateVisibleTranslationUnitsMessage &message) override;
|
2015-05-08 15:48:17 +02:00
|
|
|
|
|
|
|
|
private:
|
2015-06-16 11:56:00 +02:00
|
|
|
ClangBackEnd::ConnectionClient &m_connection;
|
2015-05-08 15:48:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void IpcSender::end()
|
|
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_connection.isConnected());
|
2015-08-19 12:36:43 +02:00
|
|
|
m_connection.sendEndMessage();
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-31 14:36:58 +02:00
|
|
|
void IpcSender::registerTranslationUnitsForEditor(const RegisterTranslationUnitForEditorMessage &message)
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_connection.isConnected());
|
2015-08-31 14:36:58 +02:00
|
|
|
m_connection.serverProxy().registerTranslationUnitsForEditor(message);
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-10-13 15:56:41 +02:00
|
|
|
void IpcSender::updateTranslationUnitsForEditor(const UpdateTranslationUnitsForEditorMessage &message)
|
|
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_connection.isConnected());
|
|
|
|
|
m_connection.serverProxy().updateTranslationUnitsForEditor(message);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-31 14:36:58 +02:00
|
|
|
void IpcSender::unregisterTranslationUnitsForEditor(const UnregisterTranslationUnitsForEditorMessage &message)
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_connection.isConnected());
|
2015-08-31 14:36:58 +02:00
|
|
|
m_connection.serverProxy().unregisterTranslationUnitsForEditor(message);
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-31 14:36:58 +02:00
|
|
|
void IpcSender::registerProjectPartsForEditor(const RegisterProjectPartsForEditorMessage &message)
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_connection.isConnected());
|
2015-08-31 14:36:58 +02:00
|
|
|
m_connection.serverProxy().registerProjectPartsForEditor(message);
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-31 14:36:58 +02:00
|
|
|
void IpcSender::unregisterProjectPartsForEditor(const UnregisterProjectPartsForEditorMessage &message)
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_connection.isConnected());
|
2015-08-31 14:36:58 +02:00
|
|
|
m_connection.serverProxy().unregisterProjectPartsForEditor(message);
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-31 16:10:36 +02:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
void IpcSender::completeCode(const CompleteCodeMessage &message)
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_connection.isConnected());
|
2015-08-19 12:36:43 +02:00
|
|
|
m_connection.serverProxy().completeCode(message);
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-31 16:28:26 +02:00
|
|
|
void IpcSender::requestDiagnostics(const RequestDiagnosticsMessage &message)
|
|
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_connection.isConnected());
|
|
|
|
|
m_connection.serverProxy().requestDiagnostics(message);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-18 17:07:44 +01:00
|
|
|
void IpcSender::requestHighlighting(const RequestHighlightingMessage &message)
|
|
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_connection.isConnected());
|
|
|
|
|
m_connection.serverProxy().requestHighlighting(message);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-01 11:57:08 +01:00
|
|
|
void IpcSender::updateVisibleTranslationUnits(const UpdateVisibleTranslationUnitsMessage &message)
|
|
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_connection.isConnected());
|
|
|
|
|
m_connection.serverProxy().updateVisibleTranslationUnits(message);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
IpcCommunicator::IpcCommunicator()
|
|
|
|
|
: m_connection(&m_ipcReceiver)
|
|
|
|
|
, m_ipcSender(new IpcSender(m_connection))
|
|
|
|
|
{
|
|
|
|
|
m_ipcReceiver.setAliveHandler([this]() { m_connection.resetProcessAliveTimer(); });
|
|
|
|
|
|
|
|
|
|
connect(Core::EditorManager::instance(), &Core::EditorManager::editorAboutToClose,
|
|
|
|
|
this, &IpcCommunicator::onEditorAboutToClose);
|
2015-07-14 10:15:52 +02:00
|
|
|
connect(Core::ICore::instance(), &Core::ICore::coreAboutToClose,
|
|
|
|
|
this, &IpcCommunicator::onCoreAboutToClose);
|
2015-05-08 15:48:17 +02:00
|
|
|
|
|
|
|
|
initializeBackend();
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
static bool areMessagesRegistered = false;
|
2015-05-08 15:48:17 +02:00
|
|
|
|
|
|
|
|
void IpcCommunicator::initializeBackend()
|
|
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
if (!areMessagesRegistered) {
|
|
|
|
|
areMessagesRegistered = true;
|
|
|
|
|
Messages::registerMessages();
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-06-16 11:56:00 +02:00
|
|
|
const QString clangBackEndProcessPath = backendProcessPath();
|
|
|
|
|
qCDebug(log) << "Starting" << clangBackEndProcessPath;
|
|
|
|
|
QTC_ASSERT(QFileInfo(clangBackEndProcessPath).exists(), return);
|
2015-05-08 15:48:17 +02:00
|
|
|
|
2015-08-06 12:25:25 +02:00
|
|
|
m_connection.setProcessAliveTimerInterval(30 * 1000);
|
2015-06-16 11:56:00 +02:00
|
|
|
m_connection.setProcessPath(clangBackEndProcessPath);
|
2015-05-08 15:48:17 +02:00
|
|
|
|
|
|
|
|
connect(&m_connection, &ConnectionClient::processRestarted,
|
|
|
|
|
this, &IpcCommunicator::onBackendRestarted);
|
|
|
|
|
|
2015-07-28 16:04:49 +02:00
|
|
|
// TODO: Add a asynchron API to ConnectionClient, otherwise we might hang here
|
|
|
|
|
if (m_connection.connectToServer())
|
2015-05-08 15:48:17 +02:00
|
|
|
initializeBackendWithCurrentData();
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-05 16:59:28 +01:00
|
|
|
static QStringList projectPartOptions(const CppTools::ProjectPart::Ptr &projectPart)
|
|
|
|
|
{
|
2015-11-27 18:21:46 +01:00
|
|
|
const QStringList options = ClangCodeModel::Utils::createClangOptions(projectPart,
|
2015-11-05 16:59:28 +01:00
|
|
|
CppTools::ProjectFile::Unclassified); // No language option
|
|
|
|
|
|
|
|
|
|
return options;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ClangBackEnd::ProjectPartContainer toProjectPartContainer(
|
|
|
|
|
const CppTools::ProjectPart::Ptr &projectPart)
|
|
|
|
|
{
|
|
|
|
|
const QStringList options = projectPartOptions(projectPart);
|
|
|
|
|
|
|
|
|
|
return ClangBackEnd::ProjectPartContainer(projectPart->id(), Utf8StringVector(options));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QVector<ClangBackEnd::ProjectPartContainer> toProjectPartContainers(
|
|
|
|
|
const QList<CppTools::ProjectPart::Ptr> projectParts)
|
|
|
|
|
{
|
|
|
|
|
QVector<ClangBackEnd::ProjectPartContainer> projectPartContainers;
|
|
|
|
|
projectPartContainers.reserve(projectParts.size());
|
|
|
|
|
|
|
|
|
|
foreach (const CppTools::ProjectPart::Ptr &projectPart, projectParts)
|
|
|
|
|
projectPartContainers << toProjectPartContainer(projectPart);
|
|
|
|
|
|
|
|
|
|
return projectPartContainers;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-06 16:58:24 +01:00
|
|
|
void IpcCommunicator::registerFallbackProjectPart()
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
|
|
|
|
QTC_CHECK(m_connection.isConnected());
|
2015-11-05 16:59:28 +01:00
|
|
|
|
|
|
|
|
const auto projectPart = CppTools::CppModelManager::instance()->fallbackProjectPart();
|
|
|
|
|
const auto projectPartContainer = toProjectPartContainer(projectPart);
|
|
|
|
|
|
|
|
|
|
registerProjectPartsForEditor({projectPartContainer});
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-12-01 11:57:08 +01:00
|
|
|
namespace {
|
|
|
|
|
Utf8String currentCppEditorDocumentFilePath()
|
|
|
|
|
{
|
|
|
|
|
Utf8String currentCppEditorDocumentFilePath;
|
|
|
|
|
|
|
|
|
|
const auto currentEditor = Core::EditorManager::currentEditor();
|
|
|
|
|
if (currentEditor && CppTools::CppModelManager::isCppEditor(currentEditor)) {
|
|
|
|
|
const auto currentDocument = currentEditor->document();
|
|
|
|
|
if (currentDocument)
|
|
|
|
|
currentCppEditorDocumentFilePath = currentDocument->filePath().toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return currentCppEditorDocumentFilePath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void removeDuplicates(Utf8StringVector &visibleEditorDocumentsFilePaths)
|
|
|
|
|
{
|
|
|
|
|
std::sort(visibleEditorDocumentsFilePaths.begin(),
|
|
|
|
|
visibleEditorDocumentsFilePaths.end());
|
|
|
|
|
const auto end = std::unique(visibleEditorDocumentsFilePaths.begin(),
|
|
|
|
|
visibleEditorDocumentsFilePaths.end());
|
|
|
|
|
visibleEditorDocumentsFilePaths.erase(end,
|
|
|
|
|
visibleEditorDocumentsFilePaths.end());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void removeNonCppEditors(QList<Core::IEditor*> &visibleEditors)
|
|
|
|
|
{
|
|
|
|
|
const auto isNotCppEditor = [] (Core::IEditor *editor) {
|
|
|
|
|
return !CppTools::CppModelManager::isCppEditor(editor);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const auto end = std::remove_if(visibleEditors.begin(),
|
|
|
|
|
visibleEditors.end(),
|
|
|
|
|
isNotCppEditor);
|
|
|
|
|
|
|
|
|
|
visibleEditors.erase(end, visibleEditors.end());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utf8StringVector visibleCppEditorDocumentsFilePaths()
|
|
|
|
|
{
|
|
|
|
|
auto visibleEditors = Core::EditorManager::visibleEditors();
|
|
|
|
|
|
|
|
|
|
removeNonCppEditors(visibleEditors);
|
|
|
|
|
|
|
|
|
|
Utf8StringVector visibleCppEditorDocumentsFilePaths;
|
|
|
|
|
visibleCppEditorDocumentsFilePaths.reserve(visibleEditors.size());
|
|
|
|
|
|
|
|
|
|
const auto editorFilePaths = [] (Core::IEditor *editor) {
|
|
|
|
|
return Utf8String(editor->document()->filePath().toString());
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
std::transform(visibleEditors.begin(),
|
|
|
|
|
visibleEditors.end(),
|
|
|
|
|
std::back_inserter(visibleCppEditorDocumentsFilePaths),
|
|
|
|
|
editorFilePaths);
|
|
|
|
|
|
|
|
|
|
removeDuplicates(visibleCppEditorDocumentsFilePaths);
|
|
|
|
|
|
|
|
|
|
return visibleCppEditorDocumentsFilePaths;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IpcCommunicator::updateTranslationUnitVisiblity()
|
|
|
|
|
{
|
|
|
|
|
updateTranslationUnitVisiblity(currentCppEditorDocumentFilePath(), visibleCppEditorDocumentsFilePaths());
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-01 13:21:02 +01:00
|
|
|
bool IpcCommunicator::isNotWaitingForCompletion() const
|
|
|
|
|
{
|
|
|
|
|
return !m_ipcReceiver.isExpectingCodeCompletedMessage();
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-01 11:57:08 +01:00
|
|
|
void IpcCommunicator::updateTranslationUnitVisiblity(const Utf8String ¤tEditorFilePath,
|
|
|
|
|
const Utf8StringVector &visibleEditorsFilePaths)
|
|
|
|
|
{
|
|
|
|
|
if (m_sendMode == IgnoreSendRequests)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const UpdateVisibleTranslationUnitsMessage message(currentEditorFilePath, visibleEditorsFilePaths);
|
|
|
|
|
qCDebug(log) << ">>>" << message;
|
|
|
|
|
m_ipcSender->updateVisibleTranslationUnits(message);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
void IpcCommunicator::registerCurrentProjectParts()
|
|
|
|
|
{
|
|
|
|
|
using namespace CppTools;
|
|
|
|
|
|
|
|
|
|
const QList<ProjectInfo> projectInfos = CppModelManager::instance()->projectInfos();
|
|
|
|
|
foreach (const ProjectInfo &projectInfo, projectInfos)
|
|
|
|
|
registerProjectsParts(projectInfo.projectParts());
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-21 12:23:21 +02:00
|
|
|
void IpcCommunicator::registerCurrentCppEditorDocuments()
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
|
|
|
|
using namespace CppTools;
|
|
|
|
|
|
|
|
|
|
const auto cppEditorDocuments = CppModelManager::instance()->cppEditorDocuments();
|
|
|
|
|
foreach (const CppEditorDocumentHandle *cppEditorDocument, cppEditorDocuments) {
|
|
|
|
|
if (cppEditorDocument->processor()->baseTextDocument()->isModified())
|
2015-08-31 16:10:36 +02:00
|
|
|
updateTranslationUnitFromCppEditorDocument(cppEditorDocument->filePath());
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-18 15:46:13 +02:00
|
|
|
void IpcCommunicator::registerCurrentCodeModelUiHeaders()
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
|
|
|
|
using namespace CppTools;
|
|
|
|
|
|
|
|
|
|
const auto editorSupports = CppModelManager::instance()->abstractEditorSupports();
|
|
|
|
|
foreach (const AbstractEditorSupport *es, editorSupports)
|
2015-08-31 12:40:14 +02:00
|
|
|
updateUnsavedFile(es->fileName(), es->contents(), es->revision());
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IpcCommunicator::registerProjectsParts(const QList<CppTools::ProjectPart::Ptr> projectParts)
|
|
|
|
|
{
|
|
|
|
|
const auto projectPartContainers = toProjectPartContainers(projectParts);
|
2015-08-31 14:36:58 +02:00
|
|
|
registerProjectPartsForEditor(projectPartContainers);
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-31 16:10:36 +02:00
|
|
|
void IpcCommunicator::updateTranslationUnitFromCppEditorDocument(const QString &filePath)
|
|
|
|
|
{
|
|
|
|
|
const auto document = CppTools::CppModelManager::instance()->cppEditorDocument(filePath);
|
|
|
|
|
|
|
|
|
|
updateTranslationUnit(filePath, document->contents(), document->revision());
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
void IpcCommunicator::updateUnsavedFileFromCppEditorDocument(const QString &filePath)
|
|
|
|
|
{
|
2015-08-31 12:40:14 +02:00
|
|
|
const auto document = CppTools::CppModelManager::instance()->cppEditorDocument(filePath);
|
|
|
|
|
|
|
|
|
|
updateUnsavedFile(filePath, document->contents(), document->revision());
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-09-28 17:42:43 +02:00
|
|
|
namespace {
|
|
|
|
|
CppTools::CppEditorDocumentHandle *cppDocument(const QString &filePath)
|
|
|
|
|
{
|
|
|
|
|
return CppTools::CppModelManager::instance()->cppEditorDocument(filePath);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-01 14:02:39 +01:00
|
|
|
bool documentHasChanged(const QString &filePath,
|
|
|
|
|
uint revision)
|
2015-09-28 17:42:43 +02:00
|
|
|
{
|
|
|
|
|
auto *document = cppDocument(filePath);
|
|
|
|
|
|
|
|
|
|
if (document)
|
2015-12-01 14:02:39 +01:00
|
|
|
return document->sendTracker().shouldSendRevision(revision);
|
2015-09-28 17:42:43 +02:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setLastSentDocumentRevision(const QString &filePath,
|
|
|
|
|
uint revision)
|
|
|
|
|
{
|
|
|
|
|
auto *document = cppDocument(filePath);
|
|
|
|
|
|
|
|
|
|
if (document)
|
2015-10-13 15:56:41 +02:00
|
|
|
document->sendTracker().setLastSentRevision(int(revision));
|
2015-09-28 17:42:43 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-13 15:56:41 +02:00
|
|
|
void IpcCommunicator::updateTranslationUnit(const QString &filePath,
|
|
|
|
|
const QByteArray &contents,
|
|
|
|
|
uint documentRevision)
|
|
|
|
|
{
|
|
|
|
|
const bool hasUnsavedContent = true;
|
|
|
|
|
|
|
|
|
|
updateTranslationUnitsForEditor({{filePath,
|
|
|
|
|
Utf8String(),
|
|
|
|
|
Utf8String::fromByteArray(contents),
|
|
|
|
|
hasUnsavedContent,
|
|
|
|
|
documentRevision}});
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-31 16:10:36 +02:00
|
|
|
void IpcCommunicator::updateUnsavedFile(const QString &filePath, const QByteArray &contents, uint documentRevision)
|
|
|
|
|
{
|
|
|
|
|
const bool hasUnsavedContent = true;
|
|
|
|
|
|
|
|
|
|
// TODO: Send new only if changed
|
|
|
|
|
registerUnsavedFilesForEditor({{filePath,
|
2015-10-13 15:56:41 +02:00
|
|
|
Utf8String(),
|
2015-08-31 16:10:36 +02:00
|
|
|
Utf8String::fromByteArray(contents),
|
|
|
|
|
hasUnsavedContent,
|
|
|
|
|
documentRevision}});
|
2015-08-31 16:28:26 +02:00
|
|
|
}
|
|
|
|
|
|
2015-11-30 10:55:25 +01:00
|
|
|
void IpcCommunicator::updateTranslationUnitWithRevisionCheck(const FileContainer &fileContainer)
|
2015-08-31 16:28:26 +02:00
|
|
|
{
|
2015-09-30 14:23:26 +02:00
|
|
|
if (m_sendMode == IgnoreSendRequests)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-12-01 14:02:39 +01:00
|
|
|
if (documentHasChanged(fileContainer.filePath(), fileContainer.documentRevision())) {
|
2015-11-30 10:55:25 +01:00
|
|
|
updateTranslationUnitsForEditor({fileContainer});
|
|
|
|
|
setLastSentDocumentRevision(fileContainer.filePath(),
|
|
|
|
|
fileContainer.documentRevision());
|
2015-11-18 17:07:44 +01:00
|
|
|
}
|
|
|
|
|
}
|
2015-09-30 14:23:26 +02:00
|
|
|
|
2015-11-18 17:07:44 +01:00
|
|
|
void IpcCommunicator::requestDiagnostics(const FileContainer &fileContainer)
|
|
|
|
|
{
|
|
|
|
|
const RequestDiagnosticsMessage message(fileContainer);
|
|
|
|
|
qCDebug(log) << ">>>" << message;
|
|
|
|
|
m_ipcSender->requestDiagnostics(message);
|
|
|
|
|
}
|
2015-09-30 14:23:26 +02:00
|
|
|
|
2015-11-18 17:07:44 +01:00
|
|
|
void IpcCommunicator::requestHighlighting(const FileContainer &fileContainer)
|
|
|
|
|
{
|
|
|
|
|
const RequestHighlightingMessage message(fileContainer);
|
|
|
|
|
qCDebug(log) << ">>>" << message;
|
|
|
|
|
m_ipcSender->requestHighlighting(message);
|
2015-09-28 17:42:43 +02:00
|
|
|
}
|
|
|
|
|
|
2015-11-30 10:55:25 +01:00
|
|
|
void IpcCommunicator::updateTranslationUnitWithRevisionCheck(Core::IDocument *document)
|
2015-10-12 12:08:32 +02:00
|
|
|
{
|
|
|
|
|
const auto textDocument = qobject_cast<TextDocument*>(document);
|
|
|
|
|
const auto filePath = textDocument->filePath().toString();
|
|
|
|
|
const QString projectPartId = Utils::projectPartIdForFile(filePath);
|
|
|
|
|
|
2015-11-30 10:55:25 +01:00
|
|
|
updateTranslationUnitWithRevisionCheck(FileContainer(filePath,
|
|
|
|
|
projectPartId,
|
|
|
|
|
Utf8StringVector(),
|
|
|
|
|
textDocument->document()->revision()));
|
2015-10-12 12:08:32 +02:00
|
|
|
}
|
|
|
|
|
|
2015-09-28 17:42:43 +02:00
|
|
|
void IpcCommunicator::updateChangeContentStartPosition(const QString &filePath, int position)
|
|
|
|
|
{
|
|
|
|
|
auto *document = cppDocument(filePath);
|
|
|
|
|
|
2015-10-13 15:56:41 +02:00
|
|
|
if (document)
|
|
|
|
|
document->sendTracker().applyContentChange(position);
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-31 16:10:36 +02:00
|
|
|
void IpcCommunicator::updateTranslationUnitIfNotCurrentDocument(Core::IDocument *document)
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
|
|
|
|
QTC_ASSERT(document, return);
|
|
|
|
|
if (Core::EditorManager::currentDocument() != document)
|
2015-09-30 14:08:03 +02:00
|
|
|
updateTranslationUnit(document);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IpcCommunicator::updateTranslationUnit(Core::IDocument *document)
|
|
|
|
|
{
|
|
|
|
|
updateTranslationUnitFromCppEditorDocument(document->filePath().toString());
|
2015-08-31 16:10:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IpcCommunicator::updateUnsavedFile(Core::IDocument *document)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(document, return);
|
|
|
|
|
|
|
|
|
|
updateUnsavedFileFromCppEditorDocument(document->filePath().toString());
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IpcCommunicator::onBackendRestarted()
|
|
|
|
|
{
|
2015-06-16 11:56:00 +02:00
|
|
|
qWarning("Clang back end finished unexpectedly, restarted.");
|
2015-05-08 15:48:17 +02:00
|
|
|
qCDebug(log) << "Backend restarted, re-initializing with project data and unsaved files.";
|
|
|
|
|
|
|
|
|
|
m_ipcReceiver.deleteAndClearWaitingAssistProcessors();
|
|
|
|
|
initializeBackendWithCurrentData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IpcCommunicator::onEditorAboutToClose(Core::IEditor *editor)
|
|
|
|
|
{
|
|
|
|
|
if (auto *textEditor = qobject_cast<TextEditor::BaseTextEditor *>(editor))
|
|
|
|
|
m_ipcReceiver.deleteProcessorsOfEditorWidget(textEditor->editorWidget());
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-14 10:15:52 +02:00
|
|
|
void IpcCommunicator::onCoreAboutToClose()
|
|
|
|
|
{
|
|
|
|
|
m_sendMode = IgnoreSendRequests;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
void IpcCommunicator::initializeBackendWithCurrentData()
|
|
|
|
|
{
|
2015-11-06 16:58:24 +01:00
|
|
|
registerFallbackProjectPart();
|
2015-05-08 15:48:17 +02:00
|
|
|
registerCurrentProjectParts();
|
2015-09-21 12:23:21 +02:00
|
|
|
registerCurrentCppEditorDocuments();
|
2015-09-18 15:46:13 +02:00
|
|
|
registerCurrentCodeModelUiHeaders();
|
2015-12-01 11:57:08 +01:00
|
|
|
updateTranslationUnitVisiblity();
|
2015-05-08 15:48:17 +02:00
|
|
|
|
|
|
|
|
emit backendReinitialized();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IpcSenderInterface *IpcCommunicator::setIpcSender(IpcSenderInterface *ipcSender)
|
|
|
|
|
{
|
2015-08-19 12:36:43 +02:00
|
|
|
IpcSenderInterface *previousMessageSender = m_ipcSender.take();
|
2015-05-08 15:48:17 +02:00
|
|
|
m_ipcSender.reset(ipcSender);
|
2015-08-19 12:36:43 +02:00
|
|
|
return previousMessageSender;
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IpcCommunicator::killBackendProcess()
|
|
|
|
|
{
|
|
|
|
|
m_connection.processForTestOnly()->kill();
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-31 16:10:36 +02:00
|
|
|
void IpcCommunicator::registerTranslationUnitsForEditor(const FileContainers &fileContainers)
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
|
|
|
|
if (m_sendMode == IgnoreSendRequests)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-12-02 13:31:07 +01:00
|
|
|
const RegisterTranslationUnitForEditorMessage message(fileContainers,
|
|
|
|
|
currentCppEditorDocumentFilePath(),
|
|
|
|
|
visibleCppEditorDocumentsFilePaths());
|
2015-08-19 12:36:43 +02:00
|
|
|
qCDebug(log) << ">>>" << message;
|
2015-08-31 14:36:58 +02:00
|
|
|
m_ipcSender->registerTranslationUnitsForEditor(message);
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-10-13 15:56:41 +02:00
|
|
|
void IpcCommunicator::updateTranslationUnitsForEditor(const IpcCommunicator::FileContainers &fileContainers)
|
|
|
|
|
{
|
|
|
|
|
if (m_sendMode == IgnoreSendRequests)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const UpdateTranslationUnitsForEditorMessage message(fileContainers);
|
|
|
|
|
qCDebug(log) << ">>>" << message;
|
|
|
|
|
m_ipcSender->updateTranslationUnitsForEditor(message);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-31 16:10:36 +02:00
|
|
|
void IpcCommunicator::unregisterTranslationUnitsForEditor(const FileContainers &fileContainers)
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
|
|
|
|
if (m_sendMode == IgnoreSendRequests)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-08-31 14:36:58 +02:00
|
|
|
const UnregisterTranslationUnitsForEditorMessage message(fileContainers);
|
2015-08-19 12:36:43 +02:00
|
|
|
qCDebug(log) << ">>>" << message;
|
2015-08-31 14:36:58 +02:00
|
|
|
m_ipcSender->unregisterTranslationUnitsForEditor(message);
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-31 14:36:58 +02:00
|
|
|
void IpcCommunicator::registerProjectPartsForEditor(
|
2015-05-08 15:48:17 +02:00
|
|
|
const ProjectPartContainers &projectPartContainers)
|
|
|
|
|
{
|
|
|
|
|
if (m_sendMode == IgnoreSendRequests)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-08-31 14:36:58 +02:00
|
|
|
const RegisterProjectPartsForEditorMessage message(projectPartContainers);
|
2015-08-19 12:36:43 +02:00
|
|
|
qCDebug(log) << ">>>" << message;
|
2015-08-31 14:36:58 +02:00
|
|
|
m_ipcSender->registerProjectPartsForEditor(message);
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-31 14:36:58 +02:00
|
|
|
void IpcCommunicator::unregisterProjectPartsForEditor(const QStringList &projectPartIds)
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
|
|
|
|
if (m_sendMode == IgnoreSendRequests)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-08-31 14:36:58 +02:00
|
|
|
const UnregisterProjectPartsForEditorMessage message((Utf8StringVector(projectPartIds)));
|
2015-08-19 12:36:43 +02:00
|
|
|
qCDebug(log) << ">>>" << message;
|
2015-08-31 14:36:58 +02:00
|
|
|
m_ipcSender->unregisterProjectPartsForEditor(message);
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-31 16:10:36 +02:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
void IpcCommunicator::completeCode(ClangCompletionAssistProcessor *assistProcessor,
|
2015-08-31 14:36:58 +02:00
|
|
|
const QString &filePath,
|
|
|
|
|
quint32 line,
|
|
|
|
|
quint32 column,
|
|
|
|
|
const QString &projectFilePath)
|
2015-05-08 15:48:17 +02:00
|
|
|
{
|
|
|
|
|
if (m_sendMode == IgnoreSendRequests)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-08-19 12:36:43 +02:00
|
|
|
const CompleteCodeMessage message(filePath, line, column, projectFilePath);
|
|
|
|
|
qCDebug(log) << ">>>" << message;
|
|
|
|
|
m_ipcSender->completeCode(message);
|
|
|
|
|
m_ipcReceiver.addExpectedCodeCompletedMessage(message.ticketNumber(), assistProcessor);
|
2015-05-08 15:48:17 +02:00
|
|
|
}
|