diff options
-rw-r--r-- | plugins/autotest/testcodeparser.cpp | 42 | ||||
-rw-r--r-- | plugins/autotest/testcodeparser.h | 2 |
2 files changed, 18 insertions, 26 deletions
diff --git a/plugins/autotest/testcodeparser.cpp b/plugins/autotest/testcodeparser.cpp index 004f733fbd..edf5102419 100644 --- a/plugins/autotest/testcodeparser.cpp +++ b/plugins/autotest/testcodeparser.cpp @@ -55,7 +55,7 @@ namespace Internal { TestCodeParser::TestCodeParser(TestTreeModel *parent) : QObject(parent), m_model(parent), - m_parserEnabled(true), + m_codeModelParsing(false), m_fullUpdatePostponed(false), m_partialUpdatePostponed(false), m_dirty(true), @@ -76,18 +76,10 @@ TestCodeParser::~TestCodeParser() clearCache(); } -ProjectExplorer::Project *currentProject() -{ - const ProjectExplorer::SessionManager *session = ProjectExplorer::SessionManager::instance(); - if (!session || !session->hasProjects()) - return 0; - return session->startupProject(); -} - void TestCodeParser::setState(State state) { // avoid triggering parse before code model parsing has finished - if (!m_parserEnabled) + if (m_codeModelParsing) return; if ((state == Disabled || state == Idle) @@ -98,7 +90,8 @@ void TestCodeParser::setState(State state) if (m_parserState == Disabled) { m_fullUpdatePostponed = m_partialUpdatePostponed = false; m_postponedFiles.clear(); - } else if (m_parserState == Idle && m_dirty && currentProject()) { + } else if (m_parserState == Idle && m_dirty + && ProjectExplorer::SessionManager::startupProject()) { scanForTests(m_postponedFiles.toList()); } } @@ -110,12 +103,12 @@ void TestCodeParser::emitUpdateTestTree() void TestCodeParser::updateTestTree() { - if (!m_parserEnabled) { + if (m_codeModelParsing) { m_fullUpdatePostponed = true; return; } - if (ProjectExplorer::Project *project = currentProject()) { + if (ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject()) { if (auto qmakeProject = qobject_cast<QmakeProjectManager::QmakeProject *>(project)) { if (qmakeProject->asyncUpdateState() != QmakeProjectManager::QmakeProject::Base) { m_fullUpdatePostponed = true; @@ -482,7 +475,7 @@ void TestCodeParser::handleQtQuickTest(CPlusPlus::Document::Ptr document) void TestCodeParser::onCppDocumentUpdated(const CPlusPlus::Document::Ptr &document) { - if (!m_parserEnabled) { + if (m_codeModelParsing) { if (!m_fullUpdatePostponed) { m_partialUpdatePostponed = true; m_postponedFiles.insert(document->fileName()); @@ -490,7 +483,7 @@ void TestCodeParser::onCppDocumentUpdated(const CPlusPlus::Document::Ptr &docume return; } - ProjectExplorer::Project *project = currentProject(); + ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); if (!project) return; const QString fileName = document->fileName(); @@ -507,7 +500,7 @@ void TestCodeParser::onCppDocumentUpdated(const CPlusPlus::Document::Ptr &docume void TestCodeParser::onQmlDocumentUpdated(const QmlJS::Document::Ptr &document) { - if (!m_parserEnabled) { + if (m_codeModelParsing) { if (!m_fullUpdatePostponed) { m_partialUpdatePostponed = true; m_postponedFiles.insert(document->fileName()); @@ -515,7 +508,7 @@ void TestCodeParser::onQmlDocumentUpdated(const QmlJS::Document::Ptr &document) return; } - ProjectExplorer::Project *project = currentProject(); + ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); if (!project) return; const QString fileName = document->fileName(); @@ -545,9 +538,9 @@ void TestCodeParser::onQmlDocumentUpdated(const QmlJS::Document::Ptr &document) void TestCodeParser::onProjectPartsUpdated(ProjectExplorer::Project *project) { - if (project != currentProject()) + if (project != ProjectExplorer::SessionManager::startupProject()) return; - if (!m_parserEnabled || m_parserState == Disabled) + if (m_codeModelParsing || m_parserState == Disabled) m_fullUpdatePostponed = true; else emitUpdateTestTree(); @@ -628,7 +621,7 @@ void TestCodeParser::scanForTests(const QStringList &fileList) bool isSmallChange = !isFullParse && fileList.size() < 6; QStringList list; if (isFullParse) { - list = currentProject()->files(ProjectExplorer::Project::AllFiles); + list = ProjectExplorer::SessionManager::startupProject()->files(ProjectExplorer::Project::AllFiles); if (list.isEmpty()) return; m_parserState = FullParse; @@ -734,9 +727,8 @@ void TestCodeParser::removeTestsIfNecessaryByProFile(const QString &proFile) void TestCodeParser::onTaskStarted(Core::Id type) { - if (type != CppTools::Constants::TASK_INDEX) - return; - m_parserEnabled = false; + if (type == CppTools::Constants::TASK_INDEX) + m_codeModelParsing = true; } void TestCodeParser::onAllTasksFinished(Core::Id type) @@ -744,7 +736,7 @@ void TestCodeParser::onAllTasksFinished(Core::Id type) // only CPP parsing is relevant as we trigger Qml parsing internally anyway if (type != CppTools::Constants::TASK_INDEX) return; - m_parserEnabled = true; + m_codeModelParsing = false; // avoid illegal parser state if respective widgets became hidden while parsing setState(Idle); @@ -896,7 +888,7 @@ void TestCodeParser::removeUnnamedQuickTestsByName(const QString &fileName) void TestCodeParser::onProFileEvaluated() { - ProjectExplorer::Project *project = currentProject(); + ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); if (!project) return; diff --git a/plugins/autotest/testcodeparser.h b/plugins/autotest/testcodeparser.h index 1b8215fe50..5a1ad98be4 100644 --- a/plugins/autotest/testcodeparser.h +++ b/plugins/autotest/testcodeparser.h @@ -111,7 +111,7 @@ private: QMap<QString, TestInfo> m_cppDocMap; QMap<QString, TestInfo> m_quickDocMap; QList<UnnamedQuickTestInfo> m_unnamedQuickDocList; - bool m_parserEnabled; + bool m_codeModelParsing; bool m_fullUpdatePostponed; bool m_partialUpdatePostponed; bool m_dirty; |