diff --git a/src/tools/clangbackend/ipcsource/clangcodemodelserver.cpp b/src/tools/clangbackend/ipcsource/clangcodemodelserver.cpp index 2eb8ce6b113..c032435d795 100644 --- a/src/tools/clangbackend/ipcsource/clangcodemodelserver.cpp +++ b/src/tools/clangbackend/ipcsource/clangcodemodelserver.cpp @@ -95,7 +95,7 @@ ClangCodeModelServer::ClangCodeModelServer() QObject::connect(documents.clangFileSystemWatcher(), &ClangFileSystemWatcher::fileChanged, [this](const Utf8String &filePath) { - ClangCodeModelServer::startDocumentAnnotationsTimerIfFileIsNotATranslationUnit(filePath); + ClangCodeModelServer::startDocumentAnnotationsTimerIfFileIsNotOpenAsDocument(filePath); }); } @@ -136,7 +136,7 @@ void ClangCodeModelServer::updateTranslationUnitsForEditor(const UpdateTranslati } } catch (const ProjectPartDoNotExistException &exception) { client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds())); - } catch (const TranslationUnitDoesNotExistException &exception) { + } catch (const DocumentDoesNotExistException &exception) { client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistMessage(exception.fileContainer())); } catch (const std::exception &exception) { qWarning() << "Error in ClangCodeModelServer::updateTranslationUnitsForEditor:" << exception.what(); @@ -150,7 +150,7 @@ void ClangCodeModelServer::unregisterTranslationUnitsForEditor(const ClangBackEn try { documents.remove(message.fileContainers()); unsavedFiles.remove(message.fileContainers()); - } catch (const TranslationUnitDoesNotExistException &exception) { + } catch (const DocumentDoesNotExistException &exception) { client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistMessage(exception.fileContainer())); } catch (const ProjectPartDoNotExistException &exception) { client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds())); @@ -209,7 +209,7 @@ void ClangCodeModelServer::unregisterUnsavedFilesForEditor(const UnregisterUnsav try { unsavedFiles.remove(message.fileContainers()); documents.updateDocumentsWithChangedDependencies(message.fileContainers()); - } catch (const TranslationUnitDoesNotExistException &exception) { + } catch (const DocumentDoesNotExistException &exception) { client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistMessage(exception.fileContainer())); } catch (const ProjectPartDoNotExistException &exception) { client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds())); @@ -232,7 +232,7 @@ void ClangCodeModelServer::completeCode(const ClangBackEnd::CompleteCodeMessage jobs().add(jobRequest); jobs().process(); - } catch (const TranslationUnitDoesNotExistException &exception) { + } catch (const DocumentDoesNotExistException &exception) { client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistMessage(exception.fileContainer())); } catch (const ProjectPartDoNotExistException &exception) { client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds())); @@ -254,7 +254,7 @@ void ClangCodeModelServer::requestDocumentAnnotations(const RequestDocumentAnnot jobs().add(jobRequest); jobs().process(); - } catch (const TranslationUnitDoesNotExistException &exception) { + } catch (const DocumentDoesNotExistException &exception) { client()->translationUnitDoesNotExist(TranslationUnitDoesNotExistMessage(exception.fileContainer())); } catch (const ProjectPartDoNotExistException &exception) { client()->projectPartsDoNotExist(ProjectPartsDoNotExistMessage(exception.projectPartIds())); @@ -281,7 +281,7 @@ const Documents &ClangCodeModelServer::documentsForTestOnly() const return documents; } -void ClangCodeModelServer::startDocumentAnnotationsTimerIfFileIsNotATranslationUnit(const Utf8String &filePath) +void ClangCodeModelServer::startDocumentAnnotationsTimerIfFileIsNotOpenAsDocument(const Utf8String &filePath) { if (!documents.hasDocumentWithFilePath(filePath)) updateDocumentAnnotationsTimer.start(0); diff --git a/src/tools/clangbackend/ipcsource/clangcodemodelserver.h b/src/tools/clangbackend/ipcsource/clangcodemodelserver.h index 8fb481eebc1..ff0db141f9c 100644 --- a/src/tools/clangbackend/ipcsource/clangcodemodelserver.h +++ b/src/tools/clangbackend/ipcsource/clangcodemodelserver.h @@ -67,7 +67,7 @@ public /*for tests*/: private: Jobs &jobs(); - void startDocumentAnnotationsTimerIfFileIsNotATranslationUnit(const Utf8String &filePath); + void startDocumentAnnotationsTimerIfFileIsNotOpenAsDocument(const Utf8String &filePath); void addJobRequestsForDirtyAndVisibleDocuments(); void processJobsForDirtyAndVisibleDocuments(); void processInitialJobsForDocuments(const std::vector &documents); diff --git a/src/tools/clangbackend/ipcsource/clangdocument.cpp b/src/tools/clangbackend/ipcsource/clangdocument.cpp index e994c62f8aa..2d4d1eac7fa 100644 --- a/src/tools/clangbackend/ipcsource/clangdocument.cpp +++ b/src/tools/clangbackend/ipcsource/clangdocument.cpp @@ -359,13 +359,13 @@ void Document::setDirty() void Document::checkIfNull() const { if (isNull()) - throw TranslationUnitIsNullException(); + throw DocumentIsNullException(); } void Document::checkIfFileExists() const { if (!fileExists()) - throw TranslationUnitFileNotExitsException(d->filePath); + throw DocumentFileDoesNotExistException(d->filePath); } bool Document::fileExists() const diff --git a/src/tools/clangbackend/ipcsource/clangdocuments.cpp b/src/tools/clangbackend/ipcsource/clangdocuments.cpp index d571c7de37f..e0d04453214 100644 --- a/src/tools/clangbackend/ipcsource/clangdocuments.cpp +++ b/src/tools/clangbackend/ipcsource/clangdocuments.cpp @@ -116,7 +116,7 @@ const Document &Documents::document(const Utf8String &filePath, const Utf8String auto findIterator = findDocument(filePath, projectPartId); if (findIterator == documents_.end()) - throw TranslationUnitDoesNotExistException(FileContainer(filePath, projectPartId)); + throw DocumentDoesNotExistException(FileContainer(filePath, projectPartId)); return *findIterator; } @@ -169,10 +169,10 @@ QVector Documents::newerFileContainers(const QVector newerContainers; - auto translationUnitIsNewer = [this] (const FileContainer &fileContainer) { + auto documentIsNewer = [this] (const FileContainer &fileContainer) { try { return document(fileContainer).documentRevision() != fileContainer.documentRevision(); - } catch (const TranslationUnitDoesNotExistException &) { + } catch (const DocumentDoesNotExistException &) { return true; } }; @@ -180,7 +180,7 @@ QVector Documents::newerFileContainers(const QVector &fileCon { for (const FileContainer &fileContainer : fileContainers) { if (hasDocument(fileContainer)) - throw TranslationUnitAlreadyExistsException(fileContainer); + throw DocumentAlreadyExistsException(fileContainer); } } @@ -288,7 +288,7 @@ void Documents::checkIfDocumentsForFilePathsExist(const QVector & { for (const FileContainer &fileContainer : fileContainers) { if (!hasDocumentWithFilePath(fileContainer.filePath())) - throw TranslationUnitDoesNotExistException(fileContainer); + throw DocumentDoesNotExistException(fileContainer); } } @@ -303,7 +303,7 @@ void Documents::removeDocuments(const QVector &fileContainers) documents_.erase(removeBeginIterator, documents_.end()); if (!processedFileContainers.isEmpty()) - throw TranslationUnitDoesNotExistException(processedFileContainers.first()); + throw DocumentDoesNotExistException(processedFileContainers.first()); } } // namespace ClangBackEnd diff --git a/src/tools/clangbackend/ipcsource/clangexceptions.cpp b/src/tools/clangbackend/ipcsource/clangexceptions.cpp index 5c22ad4c2f5..2dc9cff8eb3 100644 --- a/src/tools/clangbackend/ipcsource/clangexceptions.cpp +++ b/src/tools/clangbackend/ipcsource/clangexceptions.cpp @@ -48,25 +48,25 @@ const char *ProjectPartDoNotExistException::what() const Q_DECL_NOEXCEPT return what_.constData(); } -TranslationUnitAlreadyExistsException::TranslationUnitAlreadyExistsException( +DocumentAlreadyExistsException::DocumentAlreadyExistsException( const FileContainer &fileContainer) : fileContainer_(fileContainer) { } -TranslationUnitAlreadyExistsException::TranslationUnitAlreadyExistsException( +DocumentAlreadyExistsException::DocumentAlreadyExistsException( const Utf8String &filePath, const Utf8String &projectPartId) : fileContainer_(filePath, projectPartId) { } -const FileContainer &TranslationUnitAlreadyExistsException::fileContainer() const +const FileContainer &DocumentAlreadyExistsException::fileContainer() const { return fileContainer_; } -const char *TranslationUnitAlreadyExistsException::what() const Q_DECL_NOEXCEPT +const char *DocumentAlreadyExistsException::what() const Q_DECL_NOEXCEPT { if (what_.isEmpty()) { what_ += Utf8StringLiteral("Translation unit '") @@ -79,25 +79,25 @@ const char *TranslationUnitAlreadyExistsException::what() const Q_DECL_NOEXCEPT return what_.constData(); } -TranslationUnitDoesNotExistException::TranslationUnitDoesNotExistException( +DocumentDoesNotExistException::DocumentDoesNotExistException( const FileContainer &fileContainer) : fileContainer_(fileContainer) { } -TranslationUnitDoesNotExistException::TranslationUnitDoesNotExistException( +DocumentDoesNotExistException::DocumentDoesNotExistException( const Utf8String &filePath, const Utf8String &projectPartId) : fileContainer_(filePath, projectPartId) { } -const FileContainer &TranslationUnitDoesNotExistException::fileContainer() const +const FileContainer &DocumentDoesNotExistException::fileContainer() const { return fileContainer_; } -const char *TranslationUnitDoesNotExistException::what() const Q_DECL_NOEXCEPT +const char *DocumentDoesNotExistException::what() const Q_DECL_NOEXCEPT { if (what_.isEmpty()) what_ += Utf8StringLiteral("Translation unit '") @@ -109,18 +109,18 @@ const char *TranslationUnitDoesNotExistException::what() const Q_DECL_NOEXCEPT return what_.constData(); } -TranslationUnitFileNotExitsException::TranslationUnitFileNotExitsException( +DocumentFileDoesNotExistException::DocumentFileDoesNotExistException( const Utf8String &filePath) : filePath_(filePath) { } -const Utf8String &TranslationUnitFileNotExitsException::filePath() const +const Utf8String &DocumentFileDoesNotExistException::filePath() const { return filePath_; } -const char *TranslationUnitFileNotExitsException::what() const Q_DECL_NOEXCEPT +const char *DocumentFileDoesNotExistException::what() const Q_DECL_NOEXCEPT { if (what_.isEmpty()) what_ += Utf8StringLiteral("File ") @@ -130,7 +130,7 @@ const char *TranslationUnitFileNotExitsException::what() const Q_DECL_NOEXCEPT return what_.constData(); } -const char *TranslationUnitIsNullException::what() const Q_DECL_NOEXCEPT +const char *DocumentIsNullException::what() const Q_DECL_NOEXCEPT { return "Tried to access a null TranslationUnit!"; } diff --git a/src/tools/clangbackend/ipcsource/clangexceptions.h b/src/tools/clangbackend/ipcsource/clangexceptions.h index 00ded5b20c3..8c5fa49925d 100644 --- a/src/tools/clangbackend/ipcsource/clangexceptions.h +++ b/src/tools/clangbackend/ipcsource/clangexceptions.h @@ -49,12 +49,12 @@ private: mutable Utf8String what_; }; -class TranslationUnitAlreadyExistsException : public std::exception +class DocumentAlreadyExistsException : public std::exception { public: - TranslationUnitAlreadyExistsException(const FileContainer &fileContainer); - TranslationUnitAlreadyExistsException(const Utf8String &filePath, - const Utf8String &projectPartId); + DocumentAlreadyExistsException(const FileContainer &fileContainer); + DocumentAlreadyExistsException(const Utf8String &filePath, + const Utf8String &projectPartId); const FileContainer &fileContainer() const; @@ -65,12 +65,12 @@ private: mutable Utf8String what_; }; -class TranslationUnitDoesNotExistException : public std::exception +class DocumentDoesNotExistException : public std::exception { public: - TranslationUnitDoesNotExistException(const FileContainer &fileContainer); - TranslationUnitDoesNotExistException(const Utf8String &filePath, - const Utf8String &projectPartId); + DocumentDoesNotExistException(const FileContainer &fileContainer); + DocumentDoesNotExistException(const Utf8String &filePath, + const Utf8String &projectPartId); const FileContainer &fileContainer() const; @@ -81,10 +81,10 @@ private: mutable Utf8String what_; }; -class TranslationUnitFileNotExitsException : public std::exception +class DocumentFileDoesNotExistException : public std::exception { public: - TranslationUnitFileNotExitsException(const Utf8String &filePath); + DocumentFileDoesNotExistException(const Utf8String &filePath); const Utf8String &filePath() const; @@ -95,7 +95,7 @@ private: mutable Utf8String what_; }; -class TranslationUnitIsNullException : public std::exception +class DocumentIsNullException : public std::exception { public: const char *what() const Q_DECL_NOEXCEPT override; diff --git a/src/tools/clangbackend/ipcsource/clangjobcontext.cpp b/src/tools/clangbackend/ipcsource/clangjobcontext.cpp index f09235ca329..e0eb444a94e 100644 --- a/src/tools/clangbackend/ipcsource/clangjobcontext.cpp +++ b/src/tools/clangbackend/ipcsource/clangjobcontext.cpp @@ -52,13 +52,11 @@ bool JobContext::isOutdated() const bool JobContext::isDocumentOpen() const { - const bool hasTranslationUnit - = documents->hasDocument(jobRequest.filePath, jobRequest.projectPartId); - - if (!hasTranslationUnit) + const bool hasDocument = documents->hasDocument(jobRequest.filePath, jobRequest.projectPartId); + if (!hasDocument) qCDebug(jobsLog) << "Document already closed for results of" << jobRequest; - return hasTranslationUnit; + return hasDocument; } bool JobContext::documentRevisionChanged() const diff --git a/tests/unit/unittest/clangdocumentstest.cpp b/tests/unit/unittest/clangdocumentstest.cpp index 017f2ffadc6..6889c7dea03 100644 --- a/tests/unit/unittest/clangdocumentstest.cpp +++ b/tests/unit/unittest/clangdocumentstest.cpp @@ -87,7 +87,7 @@ protected: TEST_F(Documents, ThrowForGettingWithWrongFilePath) { ASSERT_THROW(documents.document(nonExistingFilePath, projectPartId), - ClangBackEnd::TranslationUnitDoesNotExistException); + ClangBackEnd::DocumentDoesNotExistException); } @@ -103,7 +103,7 @@ TEST_F(Documents, ThrowForAddingNonExistingFile) ClangBackEnd::FileContainer fileContainer(nonExistingFilePath, projectPartId); ASSERT_THROW(documents.create({fileContainer}), - ClangBackEnd::TranslationUnitFileNotExitsException); + ClangBackEnd::DocumentFileDoesNotExistException); } TEST_F(Documents, DoNotThrowForAddingNonExistingFileWithUnsavedContent) @@ -139,14 +139,14 @@ TEST_F(Documents, ThrowForCreatingAnExistingDocument) documents.create({fileContainer}); ASSERT_THROW(documents.create({fileContainer}), - ClangBackEnd::TranslationUnitAlreadyExistsException); + ClangBackEnd::DocumentAlreadyExistsException); } TEST_F(Documents, ThrowForUpdatingANonExistingDocument) { ClangBackEnd::FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74u); ASSERT_THROW(documents.update({fileContainer}), - ClangBackEnd::TranslationUnitDoesNotExistException); + ClangBackEnd::DocumentDoesNotExistException); } TEST_F(Documents, UpdateSingle) @@ -230,7 +230,7 @@ TEST_F(Documents, ThrowForRemovingWithWrongFilePath) ClangBackEnd::FileContainer fileContainer(nonExistingFilePath, projectPartId); ASSERT_THROW(documents.remove({fileContainer}), - ClangBackEnd::TranslationUnitDoesNotExistException); + ClangBackEnd::DocumentDoesNotExistException); } TEST_F(Documents, ThrowForRemovingWithWrongProjectPartFilePath) @@ -249,7 +249,7 @@ TEST_F(Documents, Remove) documents.remove({fileContainer}); ASSERT_THROW(documents.document(filePath, projectPartId), - ClangBackEnd::TranslationUnitDoesNotExistException); + ClangBackEnd::DocumentDoesNotExistException); } TEST_F(Documents, RemoveAllValidIfExceptionIsThrown) @@ -258,7 +258,7 @@ TEST_F(Documents, RemoveAllValidIfExceptionIsThrown) documents.create({fileContainer}); ASSERT_THROW(documents.remove({ClangBackEnd::FileContainer(Utf8StringLiteral("dontextist.pro"), projectPartId), fileContainer}), - ClangBackEnd::TranslationUnitDoesNotExistException); + ClangBackEnd::DocumentDoesNotExistException); ASSERT_THAT(documents.documents(), Not(Contains(Document(filePath, diff --git a/tests/unit/unittest/clangdocumenttest.cpp b/tests/unit/unittest/clangdocumenttest.cpp index b3c4745b695..5817541a664 100644 --- a/tests/unit/unittest/clangdocumenttest.cpp +++ b/tests/unit/unittest/clangdocumenttest.cpp @@ -104,7 +104,7 @@ TEST_F(Document, DefaultDocumentIsNotIntact) TEST_F(Document, ThrowExceptionForNonExistingFilePath) { ASSERT_THROW(::Document(Utf8StringLiteral("file.cpp"), projectPart, Utf8StringVector(), documents), - ClangBackEnd::TranslationUnitFileNotExitsException); + ClangBackEnd::DocumentFileDoesNotExistException); } TEST_F(Document, ThrowNoExceptionForNonExistingFilePathIfDoNotCheckIfFileExistsIsSet) @@ -122,14 +122,14 @@ TEST_F(Document, ThrowExceptionForGettingIndexForInvalidUnit) { ::Document document; - ASSERT_THROW(document.translationUnit().cxIndex(), ClangBackEnd::TranslationUnitIsNullException); + ASSERT_THROW(document.translationUnit().cxIndex(), ClangBackEnd::DocumentIsNullException); } TEST_F(Document, ThrowExceptionForGettingCxTranslationUnitForInvalidUnit) { ::Document document; - ASSERT_THROW(document.translationUnit().cxIndex(), ClangBackEnd::TranslationUnitIsNullException); + ASSERT_THROW(document.translationUnit().cxIndex(), ClangBackEnd::DocumentIsNullException); } TEST_F(Document, CxTranslationUnitGetterIsNonNullForParsedUnit) @@ -143,7 +143,7 @@ TEST_F(Document, ThrowExceptionIfGettingFilePathForNullUnit) { ::Document document; - ASSERT_THROW(document.filePath(), ClangBackEnd::TranslationUnitIsNullException); + ASSERT_THROW(document.filePath(), ClangBackEnd::DocumentIsNullException); } TEST_F(Document, ResettedDocumentIsNull)