Clang: Rename "Editor Updates" to "Document Annotations"

"Editor Updates" are not to the point since what we generate is for the
document.

Change-Id: I94ceeca5c85c7cf01cc659ca55320d07010c8617
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
This commit is contained in:
Nikolai Kosjar
2015-11-27 15:15:28 +01:00
parent 1410bf3faf
commit ed4bfff644
7 changed files with 119 additions and 119 deletions

View File

@@ -66,40 +66,40 @@
namespace ClangBackEnd {
namespace {
const int delayedEditorUpdatesTimerInterval = 300;
const int delayedDocumentAnnotationsTimerInterval = 300;
}
ClangIpcServer::ClangIpcServer()
: translationUnits(projects, unsavedFiles)
{
const auto sendEditorUpdates
const auto sendDocumentAnnotations
= [this] (const DiagnosticsChangedMessage &diagnosticsMessage,
const HighlightingChangedMessage &highlightingsMessage) {
client()->diagnosticsChanged(diagnosticsMessage);
client()->highlightingChanged(highlightingsMessage);
};
const auto sendDelayedEditorUpdates = [this] () {
const auto sendDelayedDocumentAnnotations = [this] () {
try {
auto editorUpdatesSendState = translationUnits.sendDelayedEditorUpdates();
if (editorUpdatesSendState == EditorUpdatesSendState::MaybeThereAreMoreEditorUpdates)
sendDelayedEditorUpdatesTimer.setInterval(0);
auto sendState = translationUnits.sendDocumentAnnotations();
if (sendState == DocumentAnnotationsSendState::MaybeThereAreDocumentAnnotations)
sendDocumentAnnotationsTimer.setInterval(0);
else
sendDelayedEditorUpdatesTimer.stop();
sendDocumentAnnotationsTimer.stop();
} catch (const std::exception &exception) {
qWarning() << "Error in ClangIpcServer::sendDelayedEditorUpdatesTimer:" << exception.what();
qWarning() << "Error in ClangIpcServer::sendDelayedDocumentAnnotationsTimer:" << exception.what();
}
};
const auto onFileChanged = [this] (const Utf8String &filePath) {
startSendDelayedEditorUpdatesTimerIfFileIsNotATranslationUnit(filePath);
startDocumentAnnotationsTimerIfFileIsNotATranslationUnit(filePath);
};
translationUnits.setSendDelayedEditorUpdatesCallback(sendEditorUpdates);
translationUnits.setSendDocumentAnnotationsCallback(sendDocumentAnnotations);
QObject::connect(&sendDelayedEditorUpdatesTimer,
QObject::connect(&sendDocumentAnnotationsTimer,
&QTimer::timeout,
sendDelayedEditorUpdates);
sendDelayedDocumentAnnotations);
QObject::connect(translationUnits.clangFileSystemWatcher(),
&ClangFileSystemWatcher::fileChanged,
@@ -118,7 +118,7 @@ void ClangIpcServer::registerTranslationUnitsForEditor(const ClangBackEnd::Regis
try {
translationUnits.create(message.fileContainers());
unsavedFiles.createOrUpdate(message.fileContainers());
sendDelayedEditorUpdatesTimer.start(0);
sendDocumentAnnotationsTimer.start(0);
} catch (const ProjectPartDoNotExistException &exception) {
client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds()));
} catch (const std::exception &exception) {
@@ -135,7 +135,7 @@ void ClangIpcServer::updateTranslationUnitsForEditor(const UpdateTranslationUnit
if (newerFileContainers.size() > 0) {
translationUnits.update(newerFileContainers);
unsavedFiles.createOrUpdate(newerFileContainers);
sendDelayedEditorUpdatesTimer.start(delayedEditorUpdatesTimerInterval);
sendDocumentAnnotationsTimer.start(delayedDocumentAnnotationsTimerInterval);
}
} catch (const ProjectPartDoNotExistException &exception) {
client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds()));
@@ -193,7 +193,7 @@ void ClangIpcServer::registerUnsavedFilesForEditor(const RegisterUnsavedFilesFor
try {
unsavedFiles.createOrUpdate(message.fileContainers());
translationUnits.updateTranslationUnitsWithChangedDependencies(message.fileContainers());
sendDelayedEditorUpdatesTimer.start(delayedEditorUpdatesTimerInterval);
sendDocumentAnnotationsTimer.start(delayedDocumentAnnotationsTimerInterval);
} catch (const ProjectPartDoNotExistException &exception) {
client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds()));
} catch (const std::exception &exception) {
@@ -292,10 +292,10 @@ const TranslationUnits &ClangIpcServer::translationUnitsForTestOnly() const
return translationUnits;
}
void ClangIpcServer::startSendDelayedEditorUpdatesTimerIfFileIsNotATranslationUnit(const Utf8String &filePath)
void ClangIpcServer::startDocumentAnnotationsTimerIfFileIsNotATranslationUnit(const Utf8String &filePath)
{
if (!translationUnits.hasTranslationUnit(filePath))
sendDelayedEditorUpdatesTimer.start(0);
sendDocumentAnnotationsTimer.start(0);
}
}

View File

@@ -67,13 +67,13 @@ public:
const TranslationUnits &translationUnitsForTestOnly() const;
private:
void startSendDelayedEditorUpdatesTimerIfFileIsNotATranslationUnit(const Utf8String &filePath);
void startDocumentAnnotationsTimerIfFileIsNotATranslationUnit(const Utf8String &filePath);
private:
ProjectParts projects;
UnsavedFiles unsavedFiles;
TranslationUnits translationUnits;
QTimer sendDelayedEditorUpdatesTimer;
QTimer sendDocumentAnnotationsTimer;
};
} // namespace ClangBackEnd

View File

@@ -166,73 +166,73 @@ void TranslationUnits::updateTranslationUnitsWithChangedDependencies(const QVect
updateTranslationUnitsWithChangedDependency(fileContainer.filePath());
}
EditorUpdatesSendState TranslationUnits::sendDelayedEditorUpdates()
DocumentAnnotationsSendState TranslationUnits::sendDocumentAnnotations()
{
auto editorUpdatesSendState = sendDelayedEditorUpdatesForCurrentEditor();
if (editorUpdatesSendState == EditorUpdatesSendState::NoEditorUpdatesSend)
editorUpdatesSendState = sendDelayedEditorUpdatesForVisibleEditors();
if (editorUpdatesSendState == EditorUpdatesSendState::NoEditorUpdatesSend)
editorUpdatesSendState = sendDelayedEditorUpdatesForAll();
auto documentAnnotationsSendState = sendDocumentAnnotationsForCurrentEditor();
if (documentAnnotationsSendState == DocumentAnnotationsSendState::NoDocumentAnnotationsSent)
documentAnnotationsSendState = sendDocumentAnnotationsForVisibleEditors();
if (documentAnnotationsSendState == DocumentAnnotationsSendState::NoDocumentAnnotationsSent)
documentAnnotationsSendState = sendDocumentAnnotationsForAll();
return editorUpdatesSendState;
return documentAnnotationsSendState;
}
template<class Predicate>
EditorUpdatesSendState TranslationUnits::sendDelayedEditorUpdates(Predicate predicate)
DocumentAnnotationsSendState TranslationUnits::sendDocumentAnnotations(Predicate predicate)
{
auto foundTranslationUnit = std::find_if(translationUnits_.begin(),
translationUnits_.end(),
predicate);
if (foundTranslationUnit != translationUnits().end()) {
sendDelayedEditorUpdates(*foundTranslationUnit);
return EditorUpdatesSendState::MaybeThereAreMoreEditorUpdates;
sendDocumentAnnotations(*foundTranslationUnit);
return DocumentAnnotationsSendState::MaybeThereAreDocumentAnnotations;
}
return EditorUpdatesSendState::NoEditorUpdatesSend;
return DocumentAnnotationsSendState::NoDocumentAnnotationsSent;
}
namespace {
bool translationUnitHasEditorDocumentUpdates(const TranslationUnit &translationUnit)
bool translationUnitHasNewDocumentAnnotations(const TranslationUnit &translationUnit)
{
return translationUnit.hasNewDiagnostics() || translationUnit.hasNewHighlightingInformations();
}
}
EditorUpdatesSendState TranslationUnits::sendDelayedEditorUpdatesForCurrentEditor()
DocumentAnnotationsSendState TranslationUnits::sendDocumentAnnotationsForCurrentEditor()
{
auto hasEditorUpdatesForCurrentEditor = [] (const TranslationUnit &translationUnit) {
auto hasDocumentAnnotationsForCurrentEditor = [] (const TranslationUnit &translationUnit) {
return translationUnit.isUsedByCurrentEditor()
&& translationUnitHasEditorDocumentUpdates(translationUnit);
&& translationUnitHasNewDocumentAnnotations(translationUnit);
};
return sendDelayedEditorUpdates(hasEditorUpdatesForCurrentEditor);
return sendDocumentAnnotations(hasDocumentAnnotationsForCurrentEditor);
}
EditorUpdatesSendState TranslationUnits::sendDelayedEditorUpdatesForVisibleEditors()
DocumentAnnotationsSendState TranslationUnits::sendDocumentAnnotationsForVisibleEditors()
{
auto hasEditorUpdatesForVisibleEditor = [] (const TranslationUnit &translationUnit) {
auto hasDocumentAnnotationsForVisibleEditor = [] (const TranslationUnit &translationUnit) {
return translationUnit.isVisibleInEditor()
&& translationUnitHasEditorDocumentUpdates(translationUnit);
&& translationUnitHasNewDocumentAnnotations(translationUnit);
};
return sendDelayedEditorUpdates(hasEditorUpdatesForVisibleEditor);
return sendDocumentAnnotations(hasDocumentAnnotationsForVisibleEditor);
}
EditorUpdatesSendState TranslationUnits::sendDelayedEditorUpdatesForAll()
DocumentAnnotationsSendState TranslationUnits::sendDocumentAnnotationsForAll()
{
auto hasEditorUpdates = [] (const TranslationUnit &translationUnit) {
return translationUnitHasEditorDocumentUpdates(translationUnit);
auto hasDocumentAnnotations = [] (const TranslationUnit &translationUnit) {
return translationUnitHasNewDocumentAnnotations(translationUnit);
};
return sendDelayedEditorUpdates(hasEditorUpdates);
return sendDocumentAnnotations(hasDocumentAnnotations);
}
void TranslationUnits::setSendDelayedEditorUpdatesCallback(DelayedEditorUpdatesCallback &&callback)
void TranslationUnits::setSendDocumentAnnotationsCallback(SendDocumentAnnotationsCallback &&callback)
{
sendDelayedEditorUpdatesCallback = std::move(callback);
sendDocumentAnnotationsCallback = std::move(callback);
}
QVector<FileContainer> TranslationUnits::newerFileContainers(const QVector<FileContainer> &fileContainers) const
@@ -354,9 +354,9 @@ void TranslationUnits::checkIfTranslationUnitsForFilePathsDoesExists(const QVect
}
}
void TranslationUnits::sendDelayedEditorUpdates(const TranslationUnit &translationUnit)
void TranslationUnits::sendDocumentAnnotations(const TranslationUnit &translationUnit)
{
if (sendDelayedEditorUpdatesCallback) {
if (sendDocumentAnnotationsCallback) {
const auto fileContainer = translationUnit.fileContainer();
DiagnosticsChangedMessage diagnosticsMessage(fileContainer,
translationUnit.mainFileDiagnostics());
@@ -364,7 +364,7 @@ void TranslationUnits::sendDelayedEditorUpdates(const TranslationUnit &translati
translationUnit.highlightingInformations().toHighlightingMarksContainers(),
translationUnit.skippedSourceRanges().toSourceRangeContainers());
sendDelayedEditorUpdatesCallback(std::move(diagnosticsMessage),
sendDocumentAnnotationsCallback(std::move(diagnosticsMessage),
std::move(highlightingsMessage));
}
}

View File

@@ -48,16 +48,17 @@ class UnsavedFiles;
class DiagnosticsChangedMessage;
class HighlightingChangedMessage;
enum class EditorUpdatesSendState
enum class DocumentAnnotationsSendState
{
NoEditorUpdatesSend,
MaybeThereAreMoreEditorUpdates,
NoDocumentAnnotationsSent,
MaybeThereAreDocumentAnnotations,
};
class TranslationUnits
{
public:
using DelayedEditorUpdatesCallback = std::function<void (const DiagnosticsChangedMessage &,
using SendDocumentAnnotationsCallback
= std::function<void (const DiagnosticsChangedMessage &,
const HighlightingChangedMessage &)>;
public:
@@ -83,13 +84,12 @@ public:
void updateTranslationUnitsWithChangedDependency(const Utf8String &filePath);
void updateTranslationUnitsWithChangedDependencies(const QVector<FileContainer> &fileContainers);
EditorUpdatesSendState sendDelayedEditorUpdatesForCurrentEditor();
EditorUpdatesSendState sendDelayedEditorUpdatesForVisibleEditors();
EditorUpdatesSendState sendDelayedEditorUpdatesForAll();
DocumentAnnotationsSendState sendDocumentAnnotationsForCurrentEditor();
DocumentAnnotationsSendState sendDocumentAnnotationsForVisibleEditors();
DocumentAnnotationsSendState sendDocumentAnnotationsForAll();
DocumentAnnotationsSendState sendDocumentAnnotations();
EditorUpdatesSendState sendDelayedEditorUpdates();
void setSendDelayedEditorUpdatesCallback(DelayedEditorUpdatesCallback &&callback);
void setSendDocumentAnnotationsCallback(SendDocumentAnnotationsCallback &&callback);
QVector<FileContainer> newerFileContainers(const QVector<FileContainer> &fileContainers) const;
@@ -108,15 +108,15 @@ private:
void checkIfTranslationUnitsDoesNotExists(const QVector<FileContainer> &fileContainers) const;
void checkIfTranslationUnitsForFilePathsDoesExists(const QVector<FileContainer> &fileContainers) const;
void sendDelayedEditorUpdates(const TranslationUnit &translationUnit);
void removeTranslationUnits(const QVector<FileContainer> &fileContainers);
template<class Predicate>
EditorUpdatesSendState sendDelayedEditorUpdates(Predicate predicate);
DocumentAnnotationsSendState sendDocumentAnnotations(Predicate predicate);
void sendDocumentAnnotations(const TranslationUnit &translationUnit);
private:
ClangFileSystemWatcher fileSystemWatcher;
DelayedEditorUpdatesCallback sendDelayedEditorUpdatesCallback;
SendDocumentAnnotationsCallback sendDocumentAnnotationsCallback;
std::vector<TranslationUnit> translationUnits_;
ProjectParts &projectParts;
UnsavedFiles &unsavedFiles_;

View File

@@ -27,27 +27,27 @@
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef MOCKSENDEDITORUPDATESCALLBACK_H
#define MOCKSENDEDITORUPDATESCALLBACK_H
#ifndef MOCKSENDDOCUMENTANNOTATIONSCALLBACK_H
#define MOCKSENDDOCUMENTANNOTATIONSCALLBACK_H
#include <gmock/gmock.h>
#include <gmock/gmock-matchers.h>
#include <gtest/gtest.h>
#include "gtest-qt-printing.h"
class SendEditorUpdatesCallback
class SendDocumentAnnotationsCallback
{
public:
virtual ~SendEditorUpdatesCallback() = default;
virtual ~SendDocumentAnnotationsCallback() = default;
virtual void sendEditorUpdates() = 0;
virtual void sendDocumentAnnotations() = 0;
};
class MockSendEditorUpdatesCallback : public SendEditorUpdatesCallback
class MockSendDocumentAnnotationsCallback : public SendDocumentAnnotationsCallback
{
public:
MOCK_METHOD0(sendEditorUpdates,
MOCK_METHOD0(sendDocumentAnnotations,
void());
};
#endif // MOCKSENDEDITORUPDATESCALLBACK_H
#endif // MOCKSENDDOCUMENTANNOTATIONSCALLBACK_H

View File

@@ -47,7 +47,7 @@
#include <clang-c/Index.h>
#include "mocksendeditorupdatescallback.h"
#include "mocksenddocumentannotationscallback.h"
#include <gmock/gmock.h>
#include <gmock/gmock-matchers.h>
@@ -59,7 +59,7 @@ using ClangBackEnd::UnsavedFiles;
using ClangBackEnd::ProjectPart;
using ClangBackEnd::DiagnosticsChangedMessage;
using ClangBackEnd::HighlightingChangedMessage;
using ClangBackEnd::EditorUpdatesSendState;
using ClangBackEnd::DocumentAnnotationsSendState;
using testing::IsNull;
using testing::NotNull;
@@ -87,15 +87,15 @@ class TranslationUnits : public ::testing::Test
{
protected:
void SetUp() override;
void sendAllEditorUpdates();
void sendAllEditorUpdatesForCurrentEditor();
void sendAllEditorUpdatesForVisibleEditors();
void sendAllDocumentAnnotations();
void sendAllDocumentAnnotationsForCurrentEditor();
void sendAllDocumentAnnotationsForVisibleEditors();
protected:
ClangBackEnd::ProjectParts projects;
ClangBackEnd::UnsavedFiles unsavedFiles;
ClangBackEnd::TranslationUnits translationUnits{projects, unsavedFiles};
MockSendEditorUpdatesCallback mockSendEditorUpdatesCallback;
MockSendDocumentAnnotationsCallback mockSendDocumentAnnotationsCallback;
const Utf8String filePath = Utf8StringLiteral(TESTDATA_DIR"/translationunits.cpp");
const Utf8String headerPath = Utf8StringLiteral(TESTDATA_DIR"/translationunits.h");
const Utf8String nonExistingFilePath = Utf8StringLiteral("foo.cpp");
@@ -374,55 +374,55 @@ TEST_F(TranslationUnits, IsNotVisibleEditorAfterBeingVisible)
ASSERT_FALSE(translationUnit.isVisibleInEditor());
}
TEST_F(TranslationUnits, DoNotSendEditorUpdatesIfThereIsNothingToSend)
TEST_F(TranslationUnits, DoNotSendDocumentAnnotationsIfThereIsNothingToSend)
{
EXPECT_CALL(mockSendEditorUpdatesCallback, sendEditorUpdates()).Times(0);
EXPECT_CALL(mockSendDocumentAnnotationsCallback, sendDocumentAnnotations()).Times(0);
sendAllEditorUpdates();
sendAllDocumentAnnotations();
}
TEST_F(TranslationUnits, SendEditorUpdatessAfterTranslationUnitCreation)
TEST_F(TranslationUnits, SendDocumentAnnotationsAfterTranslationUnitCreation)
{
translationUnits.create({fileContainer, headerContainer});
EXPECT_CALL(mockSendEditorUpdatesCallback, sendEditorUpdates()).Times(2);
EXPECT_CALL(mockSendDocumentAnnotationsCallback, sendDocumentAnnotations()).Times(2);
sendAllEditorUpdates();
sendAllDocumentAnnotations();
}
TEST_F(TranslationUnits, DoNotSendEditorUpdatesAfterGettingEditorUpdates)
TEST_F(TranslationUnits, DoNotSendDocumentAnnotationsAfterGettingDocumentAnnotations)
{
translationUnits.create({fileContainer, headerContainer});
auto translationUnit = translationUnits.translationUnit(fileContainer);
translationUnit.diagnostics(); // Reset
translationUnit.highlightingInformations(); // Reset
EXPECT_CALL(mockSendEditorUpdatesCallback, sendEditorUpdates()).Times(1);
EXPECT_CALL(mockSendDocumentAnnotationsCallback, sendDocumentAnnotations()).Times(1);
sendAllEditorUpdates();
sendAllDocumentAnnotations();
}
TEST_F(TranslationUnits, SendEditorUpdatesForCurrentEditor)
TEST_F(TranslationUnits, SendDocumentAnnotationsForCurrentEditor)
{
translationUnits.create({fileContainer, headerContainer});
auto translationUnit = translationUnits.translationUnit(fileContainer);
translationUnit.setIsUsedByCurrentEditor(true);
EXPECT_CALL(mockSendEditorUpdatesCallback, sendEditorUpdates()).Times(1);
EXPECT_CALL(mockSendDocumentAnnotationsCallback, sendDocumentAnnotations()).Times(1);
sendAllEditorUpdatesForCurrentEditor();
sendAllDocumentAnnotationsForCurrentEditor();
}
TEST_F(TranslationUnits, DoNotSendEditorUpdatesForCurrentEditorIfThereIsNoCurrentEditor)
TEST_F(TranslationUnits, DoNotSendDocumentAnnotationsForCurrentEditorIfThereIsNoCurrentEditor)
{
translationUnits.create({fileContainer, headerContainer});
EXPECT_CALL(mockSendEditorUpdatesCallback, sendEditorUpdates()).Times(0);
EXPECT_CALL(mockSendDocumentAnnotationsCallback, sendDocumentAnnotations()).Times(0);
sendAllEditorUpdatesForCurrentEditor();
sendAllDocumentAnnotationsForCurrentEditor();
}
TEST_F(TranslationUnits, DoNotSendEditorUpdatesForCurrentEditorAfterGettingEditorUpdates)
TEST_F(TranslationUnits, DoNotSendDocumentAnnotationsForCurrentEditorAfterGettingDocumentAnnotations)
{
translationUnits.create({fileContainer, headerContainer});
auto translationUnit = translationUnits.translationUnit(fileContainer);
@@ -430,21 +430,21 @@ TEST_F(TranslationUnits, DoNotSendEditorUpdatesForCurrentEditorAfterGettingEdito
translationUnit.diagnostics(); // Reset
translationUnit.highlightingInformations(); // Reset
EXPECT_CALL(mockSendEditorUpdatesCallback, sendEditorUpdates()).Times(0);
EXPECT_CALL(mockSendDocumentAnnotationsCallback, sendDocumentAnnotations()).Times(0);
sendAllEditorUpdatesForCurrentEditor();
sendAllDocumentAnnotationsForCurrentEditor();
}
TEST_F(TranslationUnits, DoNotSendEditorUpdatesForVisibleEditorIfThereAreNoVisibleEditors)
TEST_F(TranslationUnits, DoNotSendDocumentAnnotationsForVisibleEditorIfThereAreNoVisibleEditors)
{
translationUnits.create({fileContainer, headerContainer});
EXPECT_CALL(mockSendEditorUpdatesCallback, sendEditorUpdates()).Times(0);
EXPECT_CALL(mockSendDocumentAnnotationsCallback, sendDocumentAnnotations()).Times(0);
translationUnits.sendDelayedEditorUpdatesForVisibleEditors();
translationUnits.sendDocumentAnnotationsForVisibleEditors();
}
TEST_F(TranslationUnits, SendEditorUpdatesForVisibleEditors)
TEST_F(TranslationUnits, SendDocumentAnnotationsForVisibleEditors)
{
translationUnits.create({fileContainer, headerContainer});
auto fileTranslationUnit = translationUnits.translationUnit(fileContainer);
@@ -452,12 +452,12 @@ TEST_F(TranslationUnits, SendEditorUpdatesForVisibleEditors)
auto headerTranslationUnit = translationUnits.translationUnit(headerContainer);
headerTranslationUnit.setIsVisibleInEditor(true);
EXPECT_CALL(mockSendEditorUpdatesCallback, sendEditorUpdates()).Times(2);
EXPECT_CALL(mockSendDocumentAnnotationsCallback, sendDocumentAnnotations()).Times(2);
sendAllEditorUpdatesForVisibleEditors();
sendAllDocumentAnnotationsForVisibleEditors();
}
TEST_F(TranslationUnits, SendOnlyOneEditorUpdateForVisibleEditor)
TEST_F(TranslationUnits, SendDocumentAnnotationsOnlyOnceForVisibleEditor)
{
translationUnits.create({fileContainer, headerContainer});
auto fileTranslationUnit = translationUnits.translationUnit(fileContainer);
@@ -467,9 +467,9 @@ TEST_F(TranslationUnits, SendOnlyOneEditorUpdateForVisibleEditor)
headerTranslationUnit.diagnostics(); // Reset
headerTranslationUnit.highlightingInformations(); // Reset
EXPECT_CALL(mockSendEditorUpdatesCallback, sendEditorUpdates()).Times(1);
EXPECT_CALL(mockSendDocumentAnnotationsCallback, sendDocumentAnnotations()).Times(1);
sendAllEditorUpdatesForVisibleEditors();
sendAllDocumentAnnotationsForVisibleEditors();
}
void TranslationUnits::SetUp()
@@ -477,33 +477,33 @@ void TranslationUnits::SetUp()
projects.createOrUpdate({ClangBackEnd::ProjectPartContainer(projectPartId)});
auto callback = [&] (const DiagnosticsChangedMessage &, const HighlightingChangedMessage &) {
mockSendEditorUpdatesCallback.sendEditorUpdates();
mockSendDocumentAnnotationsCallback.sendDocumentAnnotations();
};
translationUnits.setSendDelayedEditorUpdatesCallback(callback);
translationUnits.setSendDocumentAnnotationsCallback(callback);
}
void TranslationUnits::sendAllEditorUpdates()
void TranslationUnits::sendAllDocumentAnnotations()
{
auto editorUpdatesSendState = EditorUpdatesSendState::MaybeThereAreMoreEditorUpdates;
auto sendState = DocumentAnnotationsSendState::MaybeThereAreDocumentAnnotations;
while (editorUpdatesSendState == EditorUpdatesSendState::MaybeThereAreMoreEditorUpdates)
editorUpdatesSendState = translationUnits.sendDelayedEditorUpdates();
while (sendState == DocumentAnnotationsSendState::MaybeThereAreDocumentAnnotations)
sendState = translationUnits.sendDocumentAnnotations();
}
void TranslationUnits::sendAllEditorUpdatesForCurrentEditor()
void TranslationUnits::sendAllDocumentAnnotationsForCurrentEditor()
{
auto editorUpdatesSendState = EditorUpdatesSendState::MaybeThereAreMoreEditorUpdates;
auto sendState = DocumentAnnotationsSendState::MaybeThereAreDocumentAnnotations;
while (editorUpdatesSendState == EditorUpdatesSendState::MaybeThereAreMoreEditorUpdates)
editorUpdatesSendState = translationUnits.sendDelayedEditorUpdatesForCurrentEditor();
while (sendState == DocumentAnnotationsSendState::MaybeThereAreDocumentAnnotations)
sendState = translationUnits.sendDocumentAnnotationsForCurrentEditor();
}
void TranslationUnits::sendAllEditorUpdatesForVisibleEditors()
void TranslationUnits::sendAllDocumentAnnotationsForVisibleEditors()
{
auto editorUpdatesSendState = EditorUpdatesSendState::MaybeThereAreMoreEditorUpdates;
auto sendState = DocumentAnnotationsSendState::MaybeThereAreDocumentAnnotations;
while (editorUpdatesSendState == EditorUpdatesSendState::MaybeThereAreMoreEditorUpdates)
editorUpdatesSendState = translationUnits.sendDelayedEditorUpdatesForVisibleEditors();
while (sendState == DocumentAnnotationsSendState::MaybeThereAreDocumentAnnotations)
sendState = translationUnits.sendDocumentAnnotationsForVisibleEditors();
}
}

View File

@@ -68,6 +68,6 @@ HEADERS += \
spydummy.h \
matcher-diagnosticcontainer.h \
chunksreportedmonitor.h \
mocksendeditorupdatescallback.h
mocksenddocumentannotationscallback.h
OTHER_FILES += $$files(data/*)