forked from qt-creator/qt-creator
Clang: Rename reparseNeeded to isDirty
...because the flag can be set for needed parses, too. Change-Id: I8b328afefb282cb6bd1cf88711af3d08a56808db Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -283,7 +283,7 @@ void ClangCodeModelServer::processJobsForDirtyAndVisibleDocuments()
|
||||
void ClangCodeModelServer::processJobsForDirtyCurrentDocument()
|
||||
{
|
||||
const auto currentDirtyDocuments = documents.filtered([](const Document &document) {
|
||||
return document.isNeedingReparse() && document.isUsedByCurrentEditor();
|
||||
return document.isDirty() && document.isUsedByCurrentEditor();
|
||||
});
|
||||
QTC_CHECK(currentDirtyDocuments.size() <= 1);
|
||||
|
||||
|
||||
@@ -70,9 +70,11 @@ public:
|
||||
QSet<Utf8String> dependedFilePaths;
|
||||
|
||||
uint documentRevision = 0;
|
||||
TimePoint needsToBeReparsedChangeTimePoint;
|
||||
|
||||
TimePoint isDirtyChangeTimePoint;
|
||||
bool isDirty = false;
|
||||
|
||||
bool hasParseOrReparseFailed = false;
|
||||
bool needsToBeReparsed = false;
|
||||
bool isUsedByCurrentEditor = false;
|
||||
bool isVisibleInEditor = false;
|
||||
};
|
||||
@@ -87,7 +89,7 @@ DocumentData::DocumentData(const Utf8String &filePath,
|
||||
projectPart(projectPart),
|
||||
lastProjectPartChangeTimePoint(Clock::now()),
|
||||
translationUnits(filePath),
|
||||
needsToBeReparsedChangeTimePoint(lastProjectPartChangeTimePoint)
|
||||
isDirtyChangeTimePoint(lastProjectPartChangeTimePoint)
|
||||
{
|
||||
dependedFilePaths.insert(filePath);
|
||||
translationUnits.createAndAppend();
|
||||
@@ -239,18 +241,18 @@ void Document::setIsVisibleInEditor(bool isVisibleInEditor)
|
||||
d->isVisibleInEditor = isVisibleInEditor;
|
||||
}
|
||||
|
||||
TimePoint Document::isNeededReparseChangeTimePoint() const
|
||||
bool Document::isDirty() const
|
||||
{
|
||||
checkIfNull();
|
||||
|
||||
return d->needsToBeReparsedChangeTimePoint;
|
||||
return d->isDirty;
|
||||
}
|
||||
|
||||
bool Document::isNeedingReparse() const
|
||||
TimePoint Document::isDirtyTimeChangePoint() const
|
||||
{
|
||||
checkIfNull();
|
||||
|
||||
return d->needsToBeReparsed;
|
||||
return d->isDirtyChangeTimePoint;
|
||||
}
|
||||
|
||||
void Document::setDirtyIfProjectPartIsOutdated()
|
||||
@@ -269,8 +271,8 @@ TranslationUnitUpdateInput Document::createUpdateInput() const
|
||||
{
|
||||
TranslationUnitUpdateInput updateInput;
|
||||
updateInput.parseNeeded = isProjectPartOutdated();
|
||||
updateInput.reparseNeeded = isNeedingReparse();
|
||||
updateInput.needsToBeReparsedChangeTimePoint = d->needsToBeReparsedChangeTimePoint;
|
||||
updateInput.reparseNeeded = d->isDirty;
|
||||
updateInput.needsToBeReparsedChangeTimePoint = d->isDirtyChangeTimePoint;
|
||||
updateInput.filePath = filePath();
|
||||
updateInput.fileArguments = fileArguments();
|
||||
updateInput.unsavedFiles = d->documents.unsavedFiles();
|
||||
@@ -302,7 +304,7 @@ void Document::incorporateUpdaterResult(const TranslationUnitUpdateResult &resul
|
||||
{
|
||||
d->hasParseOrReparseFailed = result.hasParseOrReparseFailed;
|
||||
if (d->hasParseOrReparseFailed) {
|
||||
d->needsToBeReparsed = false;
|
||||
d->isDirty = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -319,8 +321,8 @@ void Document::incorporateUpdaterResult(const TranslationUnitUpdateResult &resul
|
||||
d->documents.addWatchedFiles(d->dependedFilePaths);
|
||||
|
||||
if (result.hasReparsed()
|
||||
&& result.needsToBeReparsedChangeTimePoint == d->needsToBeReparsedChangeTimePoint) {
|
||||
d->needsToBeReparsed = false;
|
||||
&& result.needsToBeReparsedChangeTimePoint == d->isDirtyChangeTimePoint) {
|
||||
d->isDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,8 +373,8 @@ void Document::setDependedFilePaths(const QSet<Utf8String> &filePaths)
|
||||
|
||||
void Document::setDirty()
|
||||
{
|
||||
d->needsToBeReparsedChangeTimePoint = Clock::now();
|
||||
d->needsToBeReparsed = true;
|
||||
d->isDirtyChangeTimePoint = Clock::now();
|
||||
d->isDirty = true;
|
||||
}
|
||||
|
||||
void Document::checkIfNull() const
|
||||
|
||||
@@ -96,7 +96,8 @@ public:
|
||||
bool isVisibleInEditor() const;
|
||||
void setIsVisibleInEditor(bool isVisibleInEditor);
|
||||
|
||||
bool isNeedingReparse() const;
|
||||
bool isDirty() const;
|
||||
TimePoint isDirtyTimeChangePoint() const;
|
||||
void setDirtyIfProjectPartIsOutdated();
|
||||
void setDirtyIfDependencyIsMet(const Utf8String &filePath);
|
||||
|
||||
@@ -114,7 +115,6 @@ public: // for tests
|
||||
void setDependedFilePaths(const QSet<Utf8String> &filePaths);
|
||||
TranslationUnitUpdater createUpdater() const;
|
||||
void setHasParseOrReparseFailed(bool hasFailed);
|
||||
TimePoint isNeededReparseChangeTimePoint() const;
|
||||
|
||||
private:
|
||||
void setDirty();
|
||||
|
||||
@@ -157,7 +157,7 @@ const std::vector<Document> Documents::filtered(const IsMatchingDocument &isMatc
|
||||
std::vector<Document> Documents::dirtyAndVisibleButNotCurrentDocuments() const
|
||||
{
|
||||
return filtered([](const Document &document) {
|
||||
return document.isNeedingReparse()
|
||||
return document.isDirty()
|
||||
&& document.isVisibleInEditor()
|
||||
&& !document.isUsedByCurrentEditor();
|
||||
});
|
||||
|
||||
@@ -213,12 +213,12 @@ TEST_F(Document, DeletedFileShouldNotNeedReparsing)
|
||||
|
||||
document.setDirtyIfDependencyIsMet(document.filePath());
|
||||
|
||||
ASSERT_FALSE(document.isNeedingReparse());
|
||||
ASSERT_FALSE(document.isDirty());
|
||||
}
|
||||
|
||||
TEST_F(Document, NeedsNoReparseAfterCreation)
|
||||
{
|
||||
ASSERT_FALSE(document.isNeedingReparse());
|
||||
ASSERT_FALSE(document.isDirty());
|
||||
}
|
||||
|
||||
TEST_F(DocumentSlowTest, NeedsReparseAfterChangeOfMainFile)
|
||||
@@ -227,7 +227,7 @@ TEST_F(DocumentSlowTest, NeedsReparseAfterChangeOfMainFile)
|
||||
|
||||
document.setDirtyIfDependencyIsMet(documentFilePath);
|
||||
|
||||
ASSERT_TRUE(document.isNeedingReparse());
|
||||
ASSERT_TRUE(document.isDirty());
|
||||
}
|
||||
|
||||
TEST_F(DocumentSlowTest, NoNeedForReparsingForIndependendFile)
|
||||
@@ -236,7 +236,7 @@ TEST_F(DocumentSlowTest, NoNeedForReparsingForIndependendFile)
|
||||
|
||||
document.setDirtyIfDependencyIsMet(Utf8StringLiteral(TESTDATA_DIR"/otherfiles.h"));
|
||||
|
||||
ASSERT_FALSE(document.isNeedingReparse());
|
||||
ASSERT_FALSE(document.isDirty());
|
||||
}
|
||||
|
||||
TEST_F(DocumentSlowTest, NeedsReparsingForDependendFile)
|
||||
@@ -245,7 +245,7 @@ TEST_F(DocumentSlowTest, NeedsReparsingForDependendFile)
|
||||
|
||||
document.setDirtyIfDependencyIsMet(Utf8StringLiteral(TESTDATA_DIR"/translationunits.h"));
|
||||
|
||||
ASSERT_TRUE(document.isNeedingReparse());
|
||||
ASSERT_TRUE(document.isDirty());
|
||||
}
|
||||
|
||||
TEST_F(DocumentSlowTest, NeedsNoReparsingAfterReparsing)
|
||||
@@ -255,7 +255,7 @@ TEST_F(DocumentSlowTest, NeedsNoReparsingAfterReparsing)
|
||||
|
||||
document.reparse();
|
||||
|
||||
ASSERT_FALSE(document.isNeedingReparse());
|
||||
ASSERT_FALSE(document.isDirty());
|
||||
}
|
||||
|
||||
TEST_F(DocumentSlowTest, IsIntactAfterParsing)
|
||||
@@ -276,7 +276,7 @@ TEST_F(DocumentSlowTest, DoesNotNeedReparseAfterParse)
|
||||
{
|
||||
document.parse();
|
||||
|
||||
ASSERT_FALSE(document.isNeedingReparse());
|
||||
ASSERT_FALSE(document.isDirty());
|
||||
}
|
||||
|
||||
TEST_F(DocumentSlowTest, NeedsReparseAfterMainFileChanged)
|
||||
@@ -285,7 +285,7 @@ TEST_F(DocumentSlowTest, NeedsReparseAfterMainFileChanged)
|
||||
|
||||
document.setDirtyIfDependencyIsMet(documentFilePath);
|
||||
|
||||
ASSERT_TRUE(document.isNeedingReparse());
|
||||
ASSERT_TRUE(document.isDirty());
|
||||
}
|
||||
|
||||
TEST_F(DocumentSlowTest, NeedsReparseAfterIncludedFileChanged)
|
||||
@@ -294,7 +294,7 @@ TEST_F(DocumentSlowTest, NeedsReparseAfterIncludedFileChanged)
|
||||
|
||||
document.setDirtyIfDependencyIsMet(Utf8StringLiteral(TESTDATA_DIR"/translationunits.h"));
|
||||
|
||||
ASSERT_TRUE(document.isNeedingReparse());
|
||||
ASSERT_TRUE(document.isDirty());
|
||||
}
|
||||
|
||||
TEST_F(DocumentSlowTest, DoesNotNeedReparseAfterNotIncludedFileChanged)
|
||||
@@ -303,7 +303,7 @@ TEST_F(DocumentSlowTest, DoesNotNeedReparseAfterNotIncludedFileChanged)
|
||||
|
||||
document.setDirtyIfDependencyIsMet(Utf8StringLiteral(TESTDATA_DIR"/otherfiles.h"));
|
||||
|
||||
ASSERT_FALSE(document.isNeedingReparse());
|
||||
ASSERT_FALSE(document.isDirty());
|
||||
}
|
||||
|
||||
TEST_F(DocumentSlowTest, DoesNotNeedReparseAfterReparse)
|
||||
@@ -313,7 +313,7 @@ TEST_F(DocumentSlowTest, DoesNotNeedReparseAfterReparse)
|
||||
|
||||
document.reparse();
|
||||
|
||||
ASSERT_FALSE(document.isNeedingReparse());
|
||||
ASSERT_FALSE(document.isDirty());
|
||||
}
|
||||
|
||||
TEST_F(Document, SetDirtyIfProjectPartIsOutdated)
|
||||
@@ -324,7 +324,7 @@ TEST_F(Document, SetDirtyIfProjectPartIsOutdated)
|
||||
|
||||
document.setDirtyIfProjectPartIsOutdated();
|
||||
|
||||
ASSERT_TRUE(document.isNeedingReparse());
|
||||
ASSERT_TRUE(document.isDirty());
|
||||
}
|
||||
|
||||
TEST_F(DocumentSlowTest, SetNotDirtyIfProjectPartIsNotOutdated)
|
||||
@@ -333,7 +333,7 @@ TEST_F(DocumentSlowTest, SetNotDirtyIfProjectPartIsNotOutdated)
|
||||
|
||||
document.setDirtyIfProjectPartIsOutdated();
|
||||
|
||||
ASSERT_FALSE(document.isNeedingReparse());
|
||||
ASSERT_FALSE(document.isDirty());
|
||||
}
|
||||
|
||||
TEST_F(Document, IncorporateUpdaterResultResetsDirtyness)
|
||||
@@ -341,12 +341,12 @@ TEST_F(Document, IncorporateUpdaterResultResetsDirtyness)
|
||||
document.setDirtyIfDependencyIsMet(document.filePath());
|
||||
TranslationUnitUpdateResult result;
|
||||
result.reparseTimePoint = Clock::now();
|
||||
result.needsToBeReparsedChangeTimePoint = document.isNeededReparseChangeTimePoint();
|
||||
result.needsToBeReparsedChangeTimePoint = document.isDirtyTimeChangePoint();
|
||||
result.translationUnitId = document.translationUnit().id();
|
||||
|
||||
document.incorporateUpdaterResult(result);
|
||||
|
||||
ASSERT_FALSE(document.isNeedingReparse());
|
||||
ASSERT_FALSE(document.isDirty());
|
||||
}
|
||||
|
||||
TEST_F(Document, IncorporateUpdaterResultDoesNotResetDirtynessIfItWasChanged)
|
||||
@@ -359,7 +359,7 @@ TEST_F(Document, IncorporateUpdaterResultDoesNotResetDirtynessIfItWasChanged)
|
||||
|
||||
document.incorporateUpdaterResult(result);
|
||||
|
||||
ASSERT_TRUE(document.isNeedingReparse());
|
||||
ASSERT_TRUE(document.isDirty());
|
||||
}
|
||||
|
||||
TEST_F(Document, IncorporateUpdaterResultUpdatesTranslationUnitsReparseTimePoint)
|
||||
|
||||
@@ -133,7 +133,7 @@ TEST_F(Documents, CreateWithUnsavedContentSetsDependenciesDirty)
|
||||
|
||||
documents.create({fileContainerWithUnsavedContent});
|
||||
|
||||
ASSERT_TRUE(dependentDocument.isNeedingReparse());
|
||||
ASSERT_TRUE(dependentDocument.isDirty());
|
||||
}
|
||||
|
||||
TEST_F(Documents, AddAndTestCreatedTranslationUnit)
|
||||
@@ -212,7 +212,7 @@ TEST_F(DocumentsSlowTest, UpdateUnsavedFileAndCheckForReparse)
|
||||
|
||||
documents.update({headerContainerWithUnsavedContent});
|
||||
|
||||
ASSERT_TRUE(documents.document(filePath, projectPartId).isNeedingReparse());
|
||||
ASSERT_TRUE(documents.document(filePath, projectPartId).isDirty());
|
||||
}
|
||||
|
||||
TEST_F(DocumentsSlowTest, RemoveFileAndCheckForReparse)
|
||||
@@ -226,7 +226,7 @@ TEST_F(DocumentsSlowTest, RemoveFileAndCheckForReparse)
|
||||
|
||||
documents.remove({headerContainerWithUnsavedContent});
|
||||
|
||||
ASSERT_TRUE(documents.document(filePath, projectPartId).isNeedingReparse());
|
||||
ASSERT_TRUE(documents.document(filePath, projectPartId).isDirty());
|
||||
}
|
||||
|
||||
TEST_F(Documents, DontGetNewerFileContainerIfRevisionIsTheSame)
|
||||
|
||||
@@ -60,13 +60,13 @@ MATCHER_P5(HasDirtyDocument,
|
||||
filePath,
|
||||
projectPartId,
|
||||
documentRevision,
|
||||
isNeedingReparse,
|
||||
isDirty,
|
||||
hasNewDiagnostics,
|
||||
std::string(negation ? "isn't" : "is")
|
||||
+ " document with file path "+ PrintToString(filePath)
|
||||
+ " and project " + PrintToString(projectPartId)
|
||||
+ " and document revision " + PrintToString(documentRevision)
|
||||
+ " and isNeedingReparse = " + PrintToString(isNeedingReparse)
|
||||
+ " and isDirty = " + PrintToString(isDirty)
|
||||
+ " and hasNewDiagnostics = " + PrintToString(hasNewDiagnostics)
|
||||
)
|
||||
{
|
||||
@@ -75,10 +75,10 @@ MATCHER_P5(HasDirtyDocument,
|
||||
auto document = documents.document(filePath, projectPartId);
|
||||
|
||||
if (document.documentRevision() == documentRevision) {
|
||||
if (document.isNeedingReparse() && !isNeedingReparse) {
|
||||
if (document.isDirty() && !isDirty) {
|
||||
*result_listener << "isNeedingReparse is true";
|
||||
return false;
|
||||
} else if (!document.isNeedingReparse() && isNeedingReparse) {
|
||||
} else if (!document.isDirty() && isDirty) {
|
||||
*result_listener << "isNeedingReparse is false";
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user