forked from qt-creator/qt-creator
Replace two bool flags with one enum
Since it's not allowed to have both m_fullUpdatePostponed and m_partialUpdatePostponed set to true, replace these two flags with one UpdateType enum. Change-Id: Ia4193dafd234f817d34204709d14f345c0a3b962 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -97,10 +97,10 @@ void TestCodeParser::setState(State state)
|
|||||||
m_parserState = state;
|
m_parserState = state;
|
||||||
|
|
||||||
if (m_parserState == Idle && SessionManager::startupProject()) {
|
if (m_parserState == Idle && SessionManager::startupProject()) {
|
||||||
if (m_fullUpdatePostponed || m_dirty) {
|
if (m_postponedUpdateType == UpdateType::FullUpdate || m_dirty) {
|
||||||
emitUpdateTestTree();
|
emitUpdateTestTree();
|
||||||
} else if (m_partialUpdatePostponed) {
|
} else if (m_postponedUpdateType == UpdateType::PartialUpdate) {
|
||||||
m_partialUpdatePostponed = false;
|
m_postponedUpdateType = UpdateType::NoUpdate;
|
||||||
qCDebug(LOG) << "calling scanForTests with postponed files (setState)";
|
qCDebug(LOG) << "calling scanForTests with postponed files (setState)";
|
||||||
if (!m_reparseTimer.isActive())
|
if (!m_reparseTimer.isActive())
|
||||||
scanForTests(Utils::toList(m_postponedFiles));
|
scanForTests(Utils::toList(m_postponedFiles));
|
||||||
@@ -112,7 +112,7 @@ void TestCodeParser::syncTestFrameworks(const QList<ITestParser *> &parsers)
|
|||||||
{
|
{
|
||||||
if (m_parserState != Idle) {
|
if (m_parserState != Idle) {
|
||||||
// there's a running parse
|
// there's a running parse
|
||||||
m_fullUpdatePostponed = m_partialUpdatePostponed = false;
|
m_postponedUpdateType = UpdateType::NoUpdate;
|
||||||
m_postponedFiles.clear();
|
m_postponedFiles.clear();
|
||||||
Core::ProgressManager::cancelTasks(Constants::TASK_PARSE);
|
Core::ProgressManager::cancelTasks(Constants::TASK_PARSE);
|
||||||
}
|
}
|
||||||
@@ -142,8 +142,7 @@ void TestCodeParser::updateTestTree(const QSet<ITestParser *> &parsers)
|
|||||||
{
|
{
|
||||||
m_singleShotScheduled = false;
|
m_singleShotScheduled = false;
|
||||||
if (m_codeModelParsing) {
|
if (m_codeModelParsing) {
|
||||||
m_fullUpdatePostponed = true;
|
m_postponedUpdateType = UpdateType::FullUpdate;
|
||||||
m_partialUpdatePostponed = false;
|
|
||||||
m_postponedFiles.clear();
|
m_postponedFiles.clear();
|
||||||
if (parsers.isEmpty()) {
|
if (parsers.isEmpty()) {
|
||||||
m_updateParsers.clear();
|
m_updateParsers.clear();
|
||||||
@@ -157,7 +156,7 @@ void TestCodeParser::updateTestTree(const QSet<ITestParser *> &parsers)
|
|||||||
if (!SessionManager::startupProject())
|
if (!SessionManager::startupProject())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_fullUpdatePostponed = false;
|
m_postponedUpdateType = UpdateType::NoUpdate;
|
||||||
qCDebug(LOG) << "calling scanForTests (updateTestTree)";
|
qCDebug(LOG) << "calling scanForTests (updateTestTree)";
|
||||||
QList<ITestParser *> sortedParsers = Utils::toList(parsers);
|
QList<ITestParser *> sortedParsers = Utils::toList(parsers);
|
||||||
Utils::sort(sortedParsers, [](const ITestParser *lhs, const ITestParser *rhs) {
|
Utils::sort(sortedParsers, [](const ITestParser *lhs, const ITestParser *rhs) {
|
||||||
@@ -170,7 +169,7 @@ void TestCodeParser::updateTestTree(const QSet<ITestParser *> &parsers)
|
|||||||
|
|
||||||
void TestCodeParser::onDocumentUpdated(const Utils::FilePath &fileName, bool isQmlFile)
|
void TestCodeParser::onDocumentUpdated(const Utils::FilePath &fileName, bool isQmlFile)
|
||||||
{
|
{
|
||||||
if (m_codeModelParsing || m_fullUpdatePostponed)
|
if (m_codeModelParsing || m_postponedUpdateType == UpdateType::FullUpdate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Project *project = SessionManager::startupProject();
|
Project *project = SessionManager::startupProject();
|
||||||
@@ -211,7 +210,7 @@ void TestCodeParser::onProjectPartsUpdated(Project *project)
|
|||||||
if (project != SessionManager::startupProject())
|
if (project != SessionManager::startupProject())
|
||||||
return;
|
return;
|
||||||
if (m_codeModelParsing)
|
if (m_codeModelParsing)
|
||||||
m_fullUpdatePostponed = true;
|
m_postponedUpdateType = UpdateType::FullUpdate;
|
||||||
else
|
else
|
||||||
emitUpdateTestTree();
|
emitUpdateTestTree();
|
||||||
}
|
}
|
||||||
@@ -260,19 +259,18 @@ bool TestCodeParser::postponed(const Utils::FilePaths &fileList)
|
|||||||
case FullParse:
|
case FullParse:
|
||||||
// parse is running, postponing a full parse
|
// parse is running, postponing a full parse
|
||||||
if (fileList.isEmpty()) {
|
if (fileList.isEmpty()) {
|
||||||
m_partialUpdatePostponed = false;
|
|
||||||
m_postponedFiles.clear();
|
m_postponedFiles.clear();
|
||||||
m_fullUpdatePostponed = true;
|
m_postponedUpdateType = UpdateType::FullUpdate;
|
||||||
qCDebug(LOG) << "Canceling scanForTest (full parse triggered while running a scan)";
|
qCDebug(LOG) << "Canceling scanForTest (full parse triggered while running a scan)";
|
||||||
Core::ProgressManager::cancelTasks(Constants::TASK_PARSE);
|
Core::ProgressManager::cancelTasks(Constants::TASK_PARSE);
|
||||||
} else {
|
} else {
|
||||||
// partial parse triggered, but full parse is postponed already, ignoring this
|
// partial parse triggered, but full parse is postponed already, ignoring this
|
||||||
if (m_fullUpdatePostponed)
|
if (m_postponedUpdateType == UpdateType::FullUpdate)
|
||||||
return true;
|
return true;
|
||||||
// partial parse triggered, postpone or add current files to already postponed partial
|
// partial parse triggered, postpone or add current files to already postponed partial
|
||||||
for (const Utils::FilePath &file : fileList)
|
for (const Utils::FilePath &file : fileList)
|
||||||
m_postponedFiles.insert(file);
|
m_postponedFiles.insert(file);
|
||||||
m_partialUpdatePostponed = true;
|
m_postponedUpdateType = UpdateType::PartialUpdate;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case Shutdown:
|
case Shutdown:
|
||||||
@@ -378,8 +376,8 @@ void TestCodeParser::onTaskStarted(Utils::Id type)
|
|||||||
if (type == CppTools::Constants::TASK_INDEX) {
|
if (type == CppTools::Constants::TASK_INDEX) {
|
||||||
m_codeModelParsing = true;
|
m_codeModelParsing = true;
|
||||||
if (m_parserState == FullParse || m_parserState == PartialParse) {
|
if (m_parserState == FullParse || m_parserState == PartialParse) {
|
||||||
m_fullUpdatePostponed = m_parserState == FullParse;
|
m_postponedUpdateType = m_parserState == FullParse
|
||||||
m_partialUpdatePostponed = !m_fullUpdatePostponed;
|
? UpdateType::FullUpdate : UpdateType::PartialUpdate;
|
||||||
qCDebug(LOG) << "Canceling scan for test (CppModelParsing started)";
|
qCDebug(LOG) << "Canceling scan for test (CppModelParsing started)";
|
||||||
m_parsingHasFailed = true;
|
m_parsingHasFailed = true;
|
||||||
Core::ProgressManager::cancelTasks(Constants::TASK_PARSE);
|
Core::ProgressManager::cancelTasks(Constants::TASK_PARSE);
|
||||||
@@ -417,7 +415,7 @@ void TestCodeParser::onFinished()
|
|||||||
qCDebug(LOG) << "setting state to Idle (onFinished, FullParse)";
|
qCDebug(LOG) << "setting state to Idle (onFinished, FullParse)";
|
||||||
m_parserState = Idle;
|
m_parserState = Idle;
|
||||||
m_dirty = m_parsingHasFailed;
|
m_dirty = m_parsingHasFailed;
|
||||||
if (m_partialUpdatePostponed || m_fullUpdatePostponed || m_parsingHasFailed) {
|
if (m_postponedUpdateType != UpdateType::NoUpdate || m_parsingHasFailed) {
|
||||||
onPartialParsingFinished();
|
onPartialParsingFinished();
|
||||||
} else {
|
} else {
|
||||||
qCDebug(LOG) << "emitting parsingFinished"
|
qCDebug(LOG) << "emitting parsingFinished"
|
||||||
@@ -439,19 +437,19 @@ void TestCodeParser::onFinished()
|
|||||||
|
|
||||||
void TestCodeParser::onPartialParsingFinished()
|
void TestCodeParser::onPartialParsingFinished()
|
||||||
{
|
{
|
||||||
// fail only when both are true
|
const UpdateType oldType = m_postponedUpdateType;
|
||||||
QTC_ASSERT(!m_fullUpdatePostponed || !m_partialUpdatePostponed,
|
m_postponedUpdateType = UpdateType::NoUpdate;
|
||||||
m_partialUpdatePostponed = false; m_postponedFiles.clear());
|
switch (oldType) {
|
||||||
if (m_fullUpdatePostponed) {
|
case UpdateType::FullUpdate:
|
||||||
m_fullUpdatePostponed = false;
|
|
||||||
qCDebug(LOG) << "calling updateTestTree (onPartialParsingFinished)";
|
qCDebug(LOG) << "calling updateTestTree (onPartialParsingFinished)";
|
||||||
updateTestTree(m_updateParsers);
|
updateTestTree(m_updateParsers);
|
||||||
} else if (m_partialUpdatePostponed) {
|
break;
|
||||||
m_partialUpdatePostponed = false;
|
case UpdateType::PartialUpdate:
|
||||||
qCDebug(LOG) << "calling scanForTests with postponed files (onPartialParsingFinished)";
|
qCDebug(LOG) << "calling scanForTests with postponed files (onPartialParsingFinished)";
|
||||||
if (!m_reparseTimer.isActive())
|
if (!m_reparseTimer.isActive())
|
||||||
scanForTests(Utils::toList(m_postponedFiles));
|
scanForTests(Utils::toList(m_postponedFiles));
|
||||||
} else {
|
break;
|
||||||
|
case UpdateType::NoUpdate:
|
||||||
m_dirty |= m_codeModelParsing;
|
m_dirty |= m_codeModelParsing;
|
||||||
if (m_dirty) {
|
if (m_dirty) {
|
||||||
emit parsingFailed();
|
emit parsingFailed();
|
||||||
@@ -466,6 +464,7 @@ void TestCodeParser::onPartialParsingFinished()
|
|||||||
qCDebug(LOG) << "not emitting parsingFinished"
|
qCDebug(LOG) << "not emitting parsingFinished"
|
||||||
<< "(on PartialParsingFinished, singleshot scheduled)";
|
<< "(on PartialParsingFinished, singleshot scheduled)";
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -65,7 +65,7 @@ public:
|
|||||||
void syncTestFrameworks(const QList<ITestParser *> &parsers);
|
void syncTestFrameworks(const QList<ITestParser *> &parsers);
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
bool furtherParsingExpected() const
|
bool furtherParsingExpected() const
|
||||||
{ return m_singleShotScheduled || m_fullUpdatePostponed || m_partialUpdatePostponed; }
|
{ return m_singleShotScheduled || m_postponedUpdateType != UpdateType::NoUpdate; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@@ -105,8 +105,11 @@ private:
|
|||||||
bool m_parsingHasFailed = false;
|
bool m_parsingHasFailed = false;
|
||||||
|
|
||||||
bool m_codeModelParsing = false;
|
bool m_codeModelParsing = false;
|
||||||
bool m_fullUpdatePostponed = false;
|
enum class UpdateType {
|
||||||
bool m_partialUpdatePostponed = false;
|
NoUpdate,
|
||||||
|
PartialUpdate,
|
||||||
|
FullUpdate
|
||||||
|
} m_postponedUpdateType = UpdateType::NoUpdate;
|
||||||
bool m_dirty = false;
|
bool m_dirty = false;
|
||||||
bool m_singleShotScheduled = false;
|
bool m_singleShotScheduled = false;
|
||||||
bool m_reparseTimerTimedOut = false;
|
bool m_reparseTimerTimedOut = false;
|
||||||
|
Reference in New Issue
Block a user