Commit ae92b681 authored by Nikolai Kosjar's avatar Nikolai Kosjar

Clang: Remove some needless bools

Change-Id: Ia845c803fce85ad0e29e2cf6b64820b86599bac6
Reviewed-by: David Schulz's avatarDavid Schulz <david.schulz@qt.io>
parent 9ff15c1a
......@@ -301,15 +301,15 @@ void Document::incorporateUpdaterResult(const TranslationUnitUpdateResult &resul
return;
}
if (result.parseTimePointIsSet)
if (result.hasParsed())
d->lastProjectPartChangeTimePoint = result.parseTimePoint;
if (result.parseTimePointIsSet || result.reparsed)
if (result.hasParsed() || result.hasReparsed())
d->dependedFilePaths = result.dependedOnFilePaths;
d->documents.addWatchedFiles(d->dependedFilePaths);
if (result.reparsed
if (result.hasReparsed()
&& result.needsToBeReparsedChangeTimePoint == d->needsToBeReparsedChangeTimePoint) {
d->needsToBeReparsed = false;
}
......
......@@ -122,7 +122,7 @@ void TranslationUnitUpdater::createTranslationUnitIfNeeded()
if (parseWasSuccessful()) {
updateIncludeFilePaths();
updateLastProjectPartChangeTimePoint();
m_out.parseTimePoint = std::chrono::steady_clock::now();
} else {
qWarning() << "Parsing" << m_in.filePath << "failed:"
<< errorCodeToText(m_parseErrorCode);
......@@ -151,7 +151,7 @@ void TranslationUnitUpdater::reparse()
if (reparseWasSuccessful()) {
updateIncludeFilePaths();
m_out.reparsed = true;
m_out.reparseTimePoint = std::chrono::steady_clock::now();
m_out.needsToBeReparsedChangeTimePoint = m_in.needsToBeReparsedChangeTimePoint;
} else {
qWarning() << "Reparsing" << m_in.filePath << "failed:" << m_reparseErrorCode;
......@@ -185,12 +185,6 @@ void TranslationUnitUpdater::createIndexIfNeeded()
}
}
void TranslationUnitUpdater::updateLastProjectPartChangeTimePoint()
{
m_out.parseTimePointIsSet = true;
m_out.parseTimePoint = std::chrono::steady_clock::now();
}
void TranslationUnitUpdater::includeCallback(CXFile included_file,
CXSourceLocation *,
unsigned, CXClientData clientData)
......
......@@ -55,14 +55,19 @@ public:
};
class TranslationUnitUpdateResult {
public:
bool hasParsed() const
{ return parseTimePoint != time_point(); }
bool hasReparsed() const
{ return reparseTimePoint != time_point(); }
public:
bool hasParseOrReparseFailed = false;
bool parseTimePointIsSet = false;
time_point parseTimePoint;
time_point reparseTimePoint;
time_point needsToBeReparsedChangeTimePoint;
bool reparsed = false;
QSet<Utf8String> dependedOnFilePaths;
};
......@@ -93,8 +98,6 @@ private:
void recreateAndParseIfNeeded();
void reparse();
void updateLastProjectPartChangeTimePoint();
void updateIncludeFilePaths();
static void includeCallback(CXFile included_file,
CXSourceLocation *,
......
......@@ -330,7 +330,7 @@ TEST_F(Document, IncorporateUpdaterResultResetsDirtyness)
{
document.setDirtyIfDependencyIsMet(document.filePath());
TranslationUnitUpdateResult result;
result.reparsed = true;
result.reparseTimePoint = std::chrono::steady_clock::now();
result.needsToBeReparsedChangeTimePoint = document.isNeededReparseChangeTimePoint();
document.incorporateUpdaterResult(result);
......@@ -341,7 +341,7 @@ TEST_F(Document, IncorporateUpdaterResultResetsDirtyness)
TEST_F(Document, IncorporateUpdaterResultDoesNotResetDirtynessIfItWasChanged)
{
TranslationUnitUpdateResult result;
result.reparsed = true;
result.reparseTimePoint = std::chrono::steady_clock::now();
result.needsToBeReparsedChangeTimePoint = std::chrono::steady_clock::now();
document.setDirtyIfDependencyIsMet(document.filePath());
......
......@@ -61,7 +61,7 @@ TEST_F(TranslationUnitUpdater, ParsesIfNeeded)
TranslationUnitUpdateResult result = updater.update(::TranslationUnitUpdater::UpdateMode::AsNeeded);
ASSERT_TRUE(cxTranslationUnit);
ASSERT_FALSE(result.reparsed);
ASSERT_FALSE(result.hasReparsed());
}
TEST_F(TranslationUnitUpdater, ReparsesIfNeeded)
......@@ -70,7 +70,7 @@ TEST_F(TranslationUnitUpdater, ReparsesIfNeeded)
TranslationUnitUpdateResult result = updater.update(::TranslationUnitUpdater::UpdateMode::AsNeeded);
ASSERT_TRUE(result.reparsed);
ASSERT_TRUE(result.hasReparsed());
}
TEST_F(TranslationUnitUpdater, UpdatesParseTimePoint)
......@@ -80,7 +80,7 @@ TEST_F(TranslationUnitUpdater, UpdatesParseTimePoint)
TranslationUnitUpdateResult result = updater.update(::TranslationUnitUpdater::UpdateMode::AsNeeded);
ASSERT_TRUE(result.parseTimePointIsSet);
ASSERT_TRUE(result.hasParsed());
ASSERT_THAT(result.parseTimePoint, Gt(now));
}
......@@ -92,8 +92,8 @@ TEST_F(TranslationUnitUpdater, NotUpdatingParseTimePointForReparseOnly)
::TranslationUnitUpdater reparseUpdater = createUpdater(createInput(SetReparseNeeded));
result = reparseUpdater.update(::TranslationUnitUpdater::UpdateMode::AsNeeded);
ASSERT_TRUE(result.reparsed);
ASSERT_FALSE(result.parseTimePointIsSet);
ASSERT_TRUE(result.hasReparsed());
ASSERT_FALSE(result.hasParsed());
}
TEST_F(TranslationUnitUpdater, UpdatesDependendOnFilesOnParse)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment