forked from qt-creator/qt-creator
Clang: Merge highlighting/diagnostics messages
The messages
RequestDiagnosticsMessage
RequestHighlightingMessage
and
DiagnosticsChangedMessage
HighlightingChangedMessage
are always send/received together, so merge them into
RequestDocumentAnnotationsMessage
DocumentAnnotationsChangedMessage
Change-Id: I6a0b6281ed1e6efe6cb18386afe99b1d1fb58abf
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@theqtcompany.com>
This commit is contained in:
@@ -44,8 +44,6 @@
|
||||
#include <texteditor/codeassist/iassistprocessor.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
|
||||
#include <clangbackendipc/diagnosticschangedmessage.h>
|
||||
#include <clangbackendipc/highlightingchangedmessage.h>
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -58,9 +56,9 @@
|
||||
#include <clangbackendipc/cmbregisterprojectsforeditormessage.h>
|
||||
#include <clangbackendipc/cmbunregistertranslationunitsforeditormessage.h>
|
||||
#include <clangbackendipc/cmbunregisterprojectsforeditormessage.h>
|
||||
#include <clangbackendipc/documentannotationschangedmessage.h>
|
||||
#include <clangbackendipc/registerunsavedfilesforeditormessage.h>
|
||||
#include <clangbackendipc/requestdiagnosticsmessage.h>
|
||||
#include <clangbackendipc/requesthighlightingmessage.h>
|
||||
#include <clangbackendipc/requestdocumentannotations.h>
|
||||
#include <clangbackendipc/filecontainer.h>
|
||||
#include <clangbackendipc/projectpartsdonotexistmessage.h>
|
||||
#include <clangbackendipc/translationunitdoesnotexistmessage.h>
|
||||
@@ -167,36 +165,25 @@ void IpcReceiver::codeCompleted(const CodeCompletedMessage &message)
|
||||
}
|
||||
}
|
||||
|
||||
void IpcReceiver::diagnosticsChanged(const DiagnosticsChangedMessage &message)
|
||||
void IpcReceiver::documentAnnotationsChanged(const DocumentAnnotationsChangedMessage &message)
|
||||
{
|
||||
qCDebug(log) << "<<< DiagnosticsChangedMessage with" << message.diagnostics().size() << "items";
|
||||
qCDebug(log) << "<<< DocumentAnnotationsChangedMessage with"
|
||||
<< message.diagnostics().size() << "diagnostics"
|
||||
<< message.highlightingMarks().size() << "highlighting marks"
|
||||
<< message.skippedPreprocessorRanges().size() << "skipped preprocessor ranges";
|
||||
|
||||
auto processor = ClangEditorDocumentProcessor::get(message.file().filePath());
|
||||
auto processor = ClangEditorDocumentProcessor::get(message.fileContainer().filePath());
|
||||
|
||||
if (processor) {
|
||||
const QString diagnosticsProjectPartId = message.file().projectPartId();
|
||||
const QString filePath = message.file().filePath();
|
||||
const QString projectPartId = message.fileContainer().projectPartId();
|
||||
const QString filePath = message.fileContainer().filePath();
|
||||
const QString documentProjectPartId = CppTools::CppToolsBridge::projectPartIdForFile(filePath);
|
||||
if (diagnosticsProjectPartId == documentProjectPartId)
|
||||
processor->updateCodeWarnings(message.diagnostics(), message.file().documentRevision());
|
||||
}
|
||||
}
|
||||
|
||||
void IpcReceiver::highlightingChanged(const HighlightingChangedMessage &message)
|
||||
{
|
||||
qCDebug(log) << "<<< HighlightingChangedMessage with"
|
||||
<< message.highlightingMarks().size() << "items";
|
||||
|
||||
auto processor = ClangEditorDocumentProcessor::get(message.file().filePath());
|
||||
|
||||
if (processor) {
|
||||
const QString highlightingProjectPartId = message.file().projectPartId();
|
||||
const QString filePath = message.file().filePath();
|
||||
const QString documentProjectPartId = CppTools::CppToolsBridge::projectPartIdForFile(filePath);
|
||||
if (highlightingProjectPartId == documentProjectPartId) {
|
||||
if (projectPartId == documentProjectPartId) {
|
||||
const quint32 documentRevision = message.fileContainer().documentRevision();
|
||||
processor->updateCodeWarnings(message.diagnostics(), documentRevision);
|
||||
processor->updateHighlighting(message.highlightingMarks(),
|
||||
message.skippedPreprocessorRanges(),
|
||||
message.file().documentRevision());
|
||||
documentRevision);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -229,8 +216,7 @@ public:
|
||||
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;
|
||||
void requestHighlighting(const ClangBackEnd::RequestHighlightingMessage &message) override;
|
||||
void requestDocumentAnnotations(const ClangBackEnd::RequestDocumentAnnotationsMessage &message) override;
|
||||
void updateVisibleTranslationUnits(const UpdateVisibleTranslationUnitsMessage &message) override;
|
||||
|
||||
private:
|
||||
@@ -300,18 +286,11 @@ void IpcSender::completeCode(const CompleteCodeMessage &message)
|
||||
m_connection.serverProxy().completeCode(message);
|
||||
}
|
||||
|
||||
void IpcSender::requestDiagnostics(const RequestDiagnosticsMessage &message)
|
||||
void IpcSender::requestDocumentAnnotations(const RequestDocumentAnnotationsMessage &message)
|
||||
{
|
||||
QTC_CHECK(m_connection.isConnected());
|
||||
qCDebug(log) << ">>>" << message;
|
||||
m_connection.serverProxy().requestDiagnostics(message);
|
||||
}
|
||||
|
||||
void IpcSender::requestHighlighting(const RequestHighlightingMessage &message)
|
||||
{
|
||||
QTC_CHECK(m_connection.isConnected());
|
||||
qCDebug(log) << ">>>" << message;
|
||||
m_connection.serverProxy().requestHighlighting(message);
|
||||
m_connection.serverProxy().requestDocumentAnnotations(message);
|
||||
}
|
||||
|
||||
void IpcSender::updateVisibleTranslationUnits(const UpdateVisibleTranslationUnitsMessage &message)
|
||||
@@ -333,8 +312,7 @@ public:
|
||||
void registerUnsavedFilesForEditor(const ClangBackEnd::RegisterUnsavedFilesForEditorMessage &) override {}
|
||||
void unregisterUnsavedFilesForEditor(const ClangBackEnd::UnregisterUnsavedFilesForEditorMessage &) override {}
|
||||
void completeCode(const ClangBackEnd::CompleteCodeMessage &) override {}
|
||||
void requestDiagnostics(const ClangBackEnd::RequestDiagnosticsMessage &) override {}
|
||||
void requestHighlighting(const ClangBackEnd::RequestHighlightingMessage &) override {}
|
||||
void requestDocumentAnnotations(const ClangBackEnd::RequestDocumentAnnotationsMessage &) override {}
|
||||
void updateVisibleTranslationUnits(const UpdateVisibleTranslationUnitsMessage &) override {}
|
||||
};
|
||||
|
||||
@@ -602,16 +580,10 @@ void IpcCommunicator::updateTranslationUnitWithRevisionCheck(const FileContainer
|
||||
}
|
||||
}
|
||||
|
||||
void IpcCommunicator::requestDiagnostics(const FileContainer &fileContainer)
|
||||
void IpcCommunicator::requestDocumentAnnotations(const FileContainer &fileContainer)
|
||||
{
|
||||
const RequestDiagnosticsMessage message(fileContainer);
|
||||
m_ipcSender->requestDiagnostics(message);
|
||||
}
|
||||
|
||||
void IpcCommunicator::requestHighlighting(const FileContainer &fileContainer)
|
||||
{
|
||||
const RequestHighlightingMessage message(fileContainer);
|
||||
m_ipcSender->requestHighlighting(message);
|
||||
const RequestDocumentAnnotationsMessage message(fileContainer);
|
||||
m_ipcSender->requestDocumentAnnotations(message);
|
||||
}
|
||||
|
||||
void IpcCommunicator::updateTranslationUnitWithRevisionCheck(Core::IDocument *document)
|
||||
|
||||
@@ -42,7 +42,7 @@ class IDocument;
|
||||
}
|
||||
|
||||
namespace ClangBackEnd {
|
||||
class DiagnosticsChangedMessage;
|
||||
class DocumentAnnotationsChangedMessage;
|
||||
}
|
||||
|
||||
namespace TextEditor {
|
||||
@@ -76,8 +76,8 @@ private:
|
||||
void alive() override;
|
||||
void echo(const ClangBackEnd::EchoMessage &message) override;
|
||||
void codeCompleted(const ClangBackEnd::CodeCompletedMessage &message) override;
|
||||
void diagnosticsChanged(const ClangBackEnd::DiagnosticsChangedMessage &message) override;
|
||||
void highlightingChanged(const ClangBackEnd::HighlightingChangedMessage &message) override;
|
||||
|
||||
void documentAnnotationsChanged(const ClangBackEnd::DocumentAnnotationsChangedMessage &message) override;
|
||||
|
||||
void translationUnitDoesNotExist(const ClangBackEnd::TranslationUnitDoesNotExistMessage &message) override;
|
||||
void projectPartsDoNotExist(const ClangBackEnd::ProjectPartsDoNotExistMessage &message) override;
|
||||
@@ -101,8 +101,7 @@ public:
|
||||
virtual void registerUnsavedFilesForEditor(const ClangBackEnd::RegisterUnsavedFilesForEditorMessage &message) = 0;
|
||||
virtual void unregisterUnsavedFilesForEditor(const ClangBackEnd::UnregisterUnsavedFilesForEditorMessage &message) = 0;
|
||||
virtual void completeCode(const ClangBackEnd::CompleteCodeMessage &message) = 0;
|
||||
virtual void requestDiagnostics(const ClangBackEnd::RequestDiagnosticsMessage &message) = 0;
|
||||
virtual void requestHighlighting(const ClangBackEnd::RequestHighlightingMessage &message) = 0;
|
||||
virtual void requestDocumentAnnotations(const ClangBackEnd::RequestDocumentAnnotationsMessage &message) = 0;
|
||||
virtual void updateVisibleTranslationUnits(const ClangBackEnd::UpdateVisibleTranslationUnitsMessage &message) = 0;
|
||||
};
|
||||
|
||||
@@ -125,8 +124,7 @@ public:
|
||||
void unregisterProjectPartsForEditor(const QStringList &projectPartIds);
|
||||
void registerUnsavedFilesForEditor(const FileContainers &fileContainers);
|
||||
void unregisterUnsavedFilesForEditor(const FileContainers &fileContainers);
|
||||
void requestDiagnostics(const ClangBackEnd::FileContainer &fileContainer);
|
||||
void requestHighlighting(const ClangBackEnd::FileContainer &fileContainer);
|
||||
void requestDocumentAnnotations(const ClangBackEnd::FileContainer &fileContainer);
|
||||
void completeCode(ClangCompletionAssistProcessor *assistProcessor, const QString &filePath,
|
||||
quint32 line,
|
||||
quint32 column,
|
||||
|
||||
@@ -323,8 +323,7 @@ void ClangEditorDocumentProcessor::requestDocumentAnnotations(const QString &pro
|
||||
{
|
||||
const auto fileContainer = fileContainerWithDocumentContent(projectpartId);
|
||||
|
||||
m_ipcCommunicator.requestDiagnostics(fileContainer);
|
||||
m_ipcCommunicator.requestHighlighting(fileContainer);
|
||||
m_ipcCommunicator.requestDocumentAnnotations(fileContainer);
|
||||
}
|
||||
|
||||
static CppTools::ProjectPart projectPartForLanguageOption(CppTools::ProjectPart *projectPart)
|
||||
|
||||
@@ -370,15 +370,11 @@ QString toString(const CompleteCodeMessage &)
|
||||
return QLatin1String("CompleteCodeMessage\n");
|
||||
}
|
||||
|
||||
QString toString(const RequestDiagnosticsMessage &)
|
||||
QString toString(const RequestDocumentAnnotationsMessage &)
|
||||
{
|
||||
return QStringLiteral("RequestDiagnosticsMessage\n");
|
||||
return QStringLiteral("RequestDocumentAnnotationsMessage\n");
|
||||
}
|
||||
|
||||
QString toString(const RequestHighlightingMessage &)
|
||||
{
|
||||
return QStringLiteral("RequestHighlightingMessage\n");
|
||||
}
|
||||
|
||||
QString toString(const UpdateVisibleTranslationUnitsMessage &)
|
||||
{
|
||||
@@ -415,10 +411,7 @@ public:
|
||||
void completeCode(const CompleteCodeMessage &message) override
|
||||
{ senderLog.append(toString(message)); }
|
||||
|
||||
void requestDiagnostics(const RequestDiagnosticsMessage &message) override
|
||||
{ senderLog.append(toString(message)); }
|
||||
|
||||
void requestHighlighting(const RequestHighlightingMessage &message) override
|
||||
void requestDocumentAnnotations(const RequestDocumentAnnotationsMessage &message) override
|
||||
{ senderLog.append(toString(message)); }
|
||||
|
||||
void updateVisibleTranslationUnits(const UpdateVisibleTranslationUnitsMessage &message) override
|
||||
|
||||
Reference in New Issue
Block a user