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,
|
fileArguments,
|
||||||
documents))
|
documents))
|
||||||
{
|
{
|
||||||
if (fileExistsCheck == CheckIfFileExists)
|
if (fileExistsCheck == FileExistsCheck::Check)
|
||||||
checkIfFileExists();
|
checkIfFileExists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,9 +54,9 @@ class Documents;
|
|||||||
class Document
|
class Document
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum FileExistsCheck {
|
enum class FileExistsCheck {
|
||||||
CheckIfFileExists,
|
Check,
|
||||||
DoNotCheckIfFileExists
|
DoNotCheck
|
||||||
};
|
};
|
||||||
|
|
||||||
Document() = default;
|
Document() = default;
|
||||||
@@ -64,7 +64,7 @@ public:
|
|||||||
const ProjectPart &projectPart,
|
const ProjectPart &projectPart,
|
||||||
const Utf8StringVector &fileArguments,
|
const Utf8StringVector &fileArguments,
|
||||||
Documents &documents,
|
Documents &documents,
|
||||||
FileExistsCheck fileExistsCheck = CheckIfFileExists);
|
FileExistsCheck fileExistsCheck = FileExistsCheck::Check);
|
||||||
~Document();
|
~Document();
|
||||||
|
|
||||||
Document(const Document &cxTranslationUnit);
|
Document(const Document &cxTranslationUnit);
|
||||||
|
|||||||
@@ -218,7 +218,9 @@ const ClangFileSystemWatcher *Documents::clangFileSystemWatcher() const
|
|||||||
|
|
||||||
Document Documents::createDocument(const FileContainer &fileContainer)
|
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(),
|
documents_.emplace_back(fileContainer.filePath(),
|
||||||
projectParts.project(fileContainer.projectPartId()),
|
projectParts.project(fileContainer.projectPartId()),
|
||||||
|
|||||||
@@ -108,13 +108,15 @@ TEST_F(Document, DefaultDocumentIsNotIntact)
|
|||||||
|
|
||||||
TEST_F(Document, ThrowExceptionForNonExistingFilePath)
|
TEST_F(Document, ThrowExceptionForNonExistingFilePath)
|
||||||
{
|
{
|
||||||
ASSERT_THROW(::Document(Utf8StringLiteral("file.cpp"), projectPart, Utf8StringVector(), documents),
|
ASSERT_THROW(::Document(Utf8StringLiteral("file.cpp"), projectPart, Utf8StringVector(),
|
||||||
|
documents),
|
||||||
ClangBackEnd::DocumentFileDoesNotExistException);
|
ClangBackEnd::DocumentFileDoesNotExistException);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Document, ThrowNoExceptionForNonExistingFilePathIfDoNotCheckIfFileExistsIsSet)
|
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)
|
TEST_F(Document, DocumentIsValid)
|
||||||
|
|||||||
Reference in New Issue
Block a user