static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CppTools::CppModelManager *cppMM) { static QString expectedHeaderPrefix = Utils::HostOsInfo::isMacHost() ? QLatin1String("QtTest.framework/Headers") : QLatin1String("QtTest"); const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes(); foreach (const CPlusPlus::Document::Include &inc, includes) { // TODO this short cut works only for #include <QtTest> // bad, as there could be much more different approaches if (inc.unresolvedFileName() == QLatin1String("QtTest") && inc.resolvedFileName().endsWith( QString::fromLatin1("%1/QtTest").arg(expectedHeaderPrefix))) { return true; } } if (cppMM) { CPlusPlus::Snapshot snapshot = cppMM->snapshot(); const QSet<QString> allIncludes = snapshot.allIncludesForDocument(doc->fileName()); foreach (const QString &include, allIncludes) { if (include.endsWith(QString::fromLatin1("%1/qtest.h").arg(expectedHeaderPrefix))) { return true; } } } return false; }
static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc, const CppTools::CppModelManager *cppMM) { static QString expectedHeaderPrefix = Utils::HostOsInfo::isMacHost() ? QLatin1String("QtQuickTest.framework/Headers") : QLatin1String("QtQuickTest"); const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes(); foreach (const CPlusPlus::Document::Include &inc, includes) { if (inc.unresolvedFileName() == QLatin1String("QtQuickTest/quicktest.h") && inc.resolvedFileName().endsWith( QString::fromLatin1("%1/quicktest.h").arg(expectedHeaderPrefix))) { return true; } } if (cppMM) { foreach (const QString &include, cppMM->snapshot().allIncludesForDocument(doc->fileName())) { if (include.endsWith(QString::fromLatin1("%1/quicktest.h").arg(expectedHeaderPrefix))) return true; } } return false; }
bool CppElementEvaluator::matchIncludeFile(const CPlusPlus::Document::Ptr &document, unsigned line) { foreach (const Document::Include &includeFile, document->resolvedIncludes()) { if (includeFile.line() == line) { m_element = QSharedPointer<CppElement>(new CppInclude(includeFile)); return true; } } return false; }
static bool includesGTest(const CPlusPlus::Document::Ptr &doc, const CppTools::CppModelManager *cppMM) { const QString gtestH = QLatin1String("gtest/gtest.h"); foreach (const CPlusPlus::Document::Include &inc, doc->resolvedIncludes()) { if (inc.resolvedFileName().endsWith(gtestH)) return true; } if (cppMM) { const CPlusPlus::Snapshot snapshot = cppMM->snapshot(); foreach (const QString &include, snapshot.allIncludesForDocument(doc->fileName())) { if (include.endsWith(gtestH)) return true; } } return false; }