diff --git a/src/plugins/autotest/gtest/gtestparser.cpp b/src/plugins/autotest/gtest/gtestparser.cpp index b21f161f06c..6f1525ed103 100644 --- a/src/plugins/autotest/gtest/gtestparser.cpp +++ b/src/plugins/autotest/gtest/gtestparser.cpp @@ -139,12 +139,10 @@ static bool handleGTest(QFutureInterface futureInterface, bool GTestParser::processDocument(QFutureInterface futureInterface, const QString &fileName) { - if (!m_cppSnapshot.contains(fileName) || !selectedForBuilding(fileName)) + CPlusPlus::Document::Ptr doc = document(fileName); + if (doc.isNull() || !includesGTest(doc, m_cppSnapshot) || !hasGTestNames(doc)) return false; - CPlusPlus::Document::Ptr document = m_cppSnapshot.find(fileName).value(); - if (!includesGTest(document, m_cppSnapshot) || !hasGTestNames(document)) - return false; - return handleGTest(futureInterface, document, m_cppSnapshot, id()); + return handleGTest(futureInterface, doc, m_cppSnapshot, id()); } } // namespace Internal diff --git a/src/plugins/autotest/itestparser.cpp b/src/plugins/autotest/itestparser.cpp index 9d06320322c..b7e1f152457 100644 --- a/src/plugins/autotest/itestparser.cpp +++ b/src/plugins/autotest/itestparser.cpp @@ -78,5 +78,10 @@ void CppParser::release() m_workingCopy = CppTools::WorkingCopy(); } +CPlusPlus::Document::Ptr CppParser::document(const QString &fileName) +{ + return selectedForBuilding(fileName) ? m_cppSnapshot.document(fileName) : nullptr; +} + } // namespace Internal } // namespace Autotest diff --git a/src/plugins/autotest/itestparser.h b/src/plugins/autotest/itestparser.h index b79b3c131b9..b69b23b2532 100644 --- a/src/plugins/autotest/itestparser.h +++ b/src/plugins/autotest/itestparser.h @@ -81,6 +81,8 @@ public: static QByteArray getFileContent(const QString &filePath); void release() override; + CPlusPlus::Document::Ptr document(const QString &fileName); + protected: CPlusPlus::Snapshot m_cppSnapshot; CppTools::WorkingCopy m_workingCopy; diff --git a/src/plugins/autotest/qtest/qttestparser.cpp b/src/plugins/autotest/qtest/qttestparser.cpp index 234aeca79f9..ddedf4dc52b 100644 --- a/src/plugins/autotest/qtest/qttestparser.cpp +++ b/src/plugins/autotest/qtest/qttestparser.cpp @@ -389,9 +389,9 @@ void QtTestParser::release() bool QtTestParser::processDocument(QFutureInterface futureInterface, const QString &fileName) { - if (!m_cppSnapshot.contains(fileName) || !selectedForBuilding(fileName)) + CPlusPlus::Document::Ptr doc = document(fileName); + if (doc.isNull()) return false; - CPlusPlus::Document::Ptr doc = m_cppSnapshot.find(fileName).value(); const QString &oldName = m_testCaseNames.value(fileName); const QStringList &alternativeFiles = m_alternativeFiles.values(fileName); if ((!includesQtTest(doc, m_cppSnapshot) || !qtTestLibDefined(fileName)) && oldName.isEmpty())