forked from qt-creator/qt-creator
Clang: Use class enum in Document
Change-Id: I754eaf185d10b61db5bd5f622d1912c53f71e79b Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -107,7 +107,7 @@ Document::Document(const Utf8String &filePath,
|
||||
fileArguments,
|
||||
documents))
|
||||
{
|
||||
if (fileExistsCheck == CheckIfFileExists)
|
||||
if (fileExistsCheck == FileExistsCheck::Check)
|
||||
checkIfFileExists();
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()),
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user