forked from qt-creator/qt-creator
Clang: Add UpdateTranslationUnitsForEditorMessage
If an editor is changing all translation units independent of their project part they must be updated too. So we introduce a new message to update all translation units with the same file path. Change-Id: I70d0ea2bbca9fa880111ff7219573e54f3277026 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
@@ -53,6 +53,7 @@
|
||||
#include <projectpartsdonotexistmessage.h>
|
||||
#include <translationunitdoesnotexistmessage.h>
|
||||
#include <unregisterunsavedfilesforeditormessage.h>
|
||||
#include <updatetranslationunitsforeditormessage.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
@@ -103,12 +104,9 @@ void ClangIpcServer::registerTranslationUnitsForEditor(const ClangBackEnd::Regis
|
||||
TIME_SCOPE_DURATION("ClangIpcServer::registerTranslationUnitsForEditor");
|
||||
|
||||
try {
|
||||
const auto newerFileContainers = translationUnits.newerFileContainers(message.fileContainers());
|
||||
if (newerFileContainers.size() > 0) {
|
||||
unsavedFiles.createOrUpdate(newerFileContainers);
|
||||
translationUnits.createOrUpdate(newerFileContainers);
|
||||
sendDiagnosticsTimer.start(sendDiagnosticsTimerInterval);
|
||||
}
|
||||
translationUnits.create(message.fileContainers());
|
||||
unsavedFiles.createOrUpdate(message.fileContainers());
|
||||
sendDiagnosticsTimer.start(sendDiagnosticsTimerInterval);
|
||||
} catch (const ProjectPartDoNotExistException &exception) {
|
||||
client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds()));
|
||||
} catch (const std::exception &exception) {
|
||||
@@ -116,13 +114,33 @@ void ClangIpcServer::registerTranslationUnitsForEditor(const ClangBackEnd::Regis
|
||||
}
|
||||
}
|
||||
|
||||
void ClangIpcServer::updateTranslationUnitsForEditor(const UpdateTranslationUnitsForEditorMessage &message)
|
||||
{
|
||||
TIME_SCOPE_DURATION("ClangIpcServer::updateTranslationUnitsForEditor");
|
||||
|
||||
try {
|
||||
const auto newerFileContainers = translationUnits.newerFileContainers(message.fileContainers());
|
||||
if (newerFileContainers.size() > 0) {
|
||||
translationUnits.update(newerFileContainers);
|
||||
unsavedFiles.createOrUpdate(newerFileContainers);
|
||||
sendDiagnosticsTimer.start(sendDiagnosticsTimerInterval);
|
||||
}
|
||||
} catch (const ProjectPartDoNotExistException &exception) {
|
||||
client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds()));
|
||||
} catch (const TranslationUnitDoesNotExistException &exception) {
|
||||
client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistMessage(exception.fileContainer()));
|
||||
} catch (const std::exception &exception) {
|
||||
qWarning() << "Error in ClangIpcServer::updateTranslationUnitsForEditor:" << exception.what();
|
||||
}
|
||||
}
|
||||
|
||||
void ClangIpcServer::unregisterTranslationUnitsForEditor(const ClangBackEnd::UnregisterTranslationUnitsForEditorMessage &message)
|
||||
{
|
||||
TIME_SCOPE_DURATION("ClangIpcServer::unregisterTranslationUnitsForEditor");
|
||||
|
||||
try {
|
||||
unsavedFiles.remove(message.fileContainers());
|
||||
translationUnits.remove(message.fileContainers());
|
||||
unsavedFiles.remove(message.fileContainers());
|
||||
} catch (const TranslationUnitDoesNotExistException &exception) {
|
||||
client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistMessage(exception.fileContainer()));
|
||||
} catch (const ProjectPartDoNotExistException &exception) {
|
||||
@@ -225,6 +243,11 @@ void ClangIpcServer::requestDiagnostics(const RequestDiagnosticsMessage &message
|
||||
}
|
||||
}
|
||||
|
||||
const TranslationUnits &ClangIpcServer::translationUnitsForTestOnly() const
|
||||
{
|
||||
return translationUnits;
|
||||
}
|
||||
|
||||
void ClangIpcServer::startSendDiagnosticTimerIfFileIsNotATranslationUnit(const Utf8String &filePath)
|
||||
{
|
||||
if (!translationUnits.hasTranslationUnit(filePath))
|
||||
|
||||
Reference in New Issue
Block a user