Clang: Use class enum in Document

Change-Id: I754eaf185d10b61db5bd5f622d1912c53f71e79b
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Nikolai Kosjar
2017-05-03 09:36:37 +02:00
parent 30f3fbdd17
commit e811ac4bfe
4 changed files with 12 additions and 8 deletions

View File

@@ -107,7 +107,7 @@ Document::Document(const Utf8String &filePath,
fileArguments,
documents))
{
if (fileExistsCheck == CheckIfFileExists)
if (fileExistsCheck == FileExistsCheck::Check)
checkIfFileExists();
}

View File

@@ -54,9 +54,9 @@ class Documents;
class Document
{
public:
enum FileExistsCheck {
CheckIfFileExists,
DoNotCheckIfFileExists
enum class FileExistsCheck {
Check,
DoNotCheck
};
Document() = default;
@@ -64,7 +64,7 @@ public:
const ProjectPart &projectPart,
const Utf8StringVector &fileArguments,
Documents &documents,
FileExistsCheck fileExistsCheck = CheckIfFileExists);
FileExistsCheck fileExistsCheck = FileExistsCheck::Check);
~Document();
Document(const Document &cxTranslationUnit);

View File

@@ -218,7 +218,9 @@ const ClangFileSystemWatcher *Documents::clangFileSystemWatcher() const
Document Documents::createDocument(const FileContainer &fileContainer)
{
Document::FileExistsCheck checkIfFileExists = fileContainer.hasUnsavedFileContent() ? Document::DoNotCheckIfFileExists : Document::CheckIfFileExists;
const Document::FileExistsCheck checkIfFileExists = fileContainer.hasUnsavedFileContent()
? Document::FileExistsCheck::DoNotCheck
: Document::FileExistsCheck::Check;
documents_.emplace_back(fileContainer.filePath(),
projectParts.project(fileContainer.projectPartId()),

View File

@@ -108,13 +108,15 @@ TEST_F(Document, DefaultDocumentIsNotIntact)
TEST_F(Document, ThrowExceptionForNonExistingFilePath)
{
ASSERT_THROW(::Document(Utf8StringLiteral("file.cpp"), projectPart, Utf8StringVector(), documents),
ASSERT_THROW(::Document(Utf8StringLiteral("file.cpp"), projectPart, Utf8StringVector(),
documents),
ClangBackEnd::DocumentFileDoesNotExistException);
}
TEST_F(Document, ThrowNoExceptionForNonExistingFilePathIfDoNotCheckIfFileExistsIsSet)
{
ASSERT_NO_THROW(::Document(Utf8StringLiteral("file.cpp"), projectPart, Utf8StringVector(), documents, ::Document::DoNotCheckIfFileExists));
ASSERT_NO_THROW(::Document(Utf8StringLiteral("file.cpp"), projectPart, Utf8StringVector(),
documents, ::Document::FileExistsCheck::DoNotCheck));
}
TEST_F(Document, DocumentIsValid)