forked from qt-creator/qt-creator
AutoTest: Free TestTreeItem from CppTools dependency
Makes TestTreeItem programming language agnostic. By moving the "query" methods to CppTools, the cohesion within these methods is improved, i.e. information crosses the AutoTest <-> CppTools border fewer times. Furthermore, it allows the CppTools plugin to see how its data is being used, allowing it to optimize its queries behind the scenes. Change-Id: I0a60140abaca1193d500605dfa2812b4d937d94c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -30,9 +30,6 @@
|
||||
#include "itestparser.h"
|
||||
#include "testconfiguration.h"
|
||||
|
||||
#include <cplusplus/Icons.h>
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
#include <cpptools/cpptoolsreuse.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
@@ -320,22 +317,6 @@ bool TestTreeItem::isGroupable() const
|
||||
return true;
|
||||
}
|
||||
|
||||
QSet<QString> TestTreeItem::internalTargets() const
|
||||
{
|
||||
auto cppMM = CppTools::CppModelManager::instance();
|
||||
const QList<CppTools::ProjectPart::Ptr> projectParts = cppMM->projectPart(filePath());
|
||||
// if we have no project parts it's most likely a header with declarations only and CMake based
|
||||
if (projectParts.isEmpty())
|
||||
return TestTreeItem::dependingInternalTargets(cppMM, filePath());
|
||||
QSet<QString> targets;
|
||||
for (const CppTools::ProjectPart::Ptr &part : projectParts) {
|
||||
targets.insert(part->buildSystemTarget);
|
||||
if (part->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
|
||||
targets.unite(TestTreeItem::dependingInternalTargets(cppMM, filePath()));
|
||||
}
|
||||
return targets;
|
||||
}
|
||||
|
||||
void TestTreeItem::forAllChildItems(const std::function<void(TestTreeItem *)> &pred) const
|
||||
{
|
||||
for (int row = 0, end = childCount(); row < end; ++row) {
|
||||
@@ -401,27 +382,4 @@ ITestFramework *TestTreeItem::framework() const
|
||||
return static_cast<ITestFramework *>(testBase());
|
||||
}
|
||||
|
||||
/*
|
||||
* try to find build system target that depends on the given file - if the file is no header
|
||||
* try to find the corresponding header and use this instead to find the respective target
|
||||
*/
|
||||
QSet<QString> TestTreeItem::dependingInternalTargets(CppTools::CppModelManager *cppMM,
|
||||
const QString &file)
|
||||
{
|
||||
QSet<QString> result;
|
||||
QTC_ASSERT(cppMM, return result);
|
||||
const CPlusPlus::Snapshot snapshot = cppMM->snapshot();
|
||||
QTC_ASSERT(snapshot.contains(file), return result);
|
||||
bool wasHeader;
|
||||
const QString correspondingFile
|
||||
= CppTools::correspondingHeaderOrSource(file, &wasHeader, CppTools::CacheUsage::ReadOnly);
|
||||
const Utils::FilePaths dependingFiles = snapshot.filesDependingOn(
|
||||
wasHeader ? file : correspondingFile);
|
||||
for (const Utils::FilePath &fn : dependingFiles) {
|
||||
for (const CppTools::ProjectPart::Ptr &part : cppMM->projectPart(fn))
|
||||
result.insert(part->buildSystemTarget);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace Autotest
|
||||
|
||||
Reference in New Issue
Block a user