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:
Bernhard Beschow
2021-01-01 19:19:43 +01:00
parent 3f0f289b28
commit ac61bfdc90
11 changed files with 96 additions and 76 deletions

View File

@@ -1389,6 +1389,38 @@ void CppModelManager::onAboutToLoadSession()
GC();
}
QSet<QString> CppModelManager::dependingInternalTargets(const QString &file) const
{
QSet<QString> result;
const Snapshot snapshot = this->snapshot();
QTC_ASSERT(snapshot.contains(file), return result);
bool wasHeader;
const QString correspondingFile
= correspondingHeaderOrSource(file, &wasHeader, CacheUsage::ReadOnly);
const Utils::FilePaths dependingFiles = snapshot.filesDependingOn(
wasHeader ? file : correspondingFile);
for (const Utils::FilePath &fn : qAsConst(dependingFiles)) {
for (const ProjectPart::Ptr &part : projectPart(fn))
result.insert(part->buildSystemTarget);
}
return result;
}
QSet<QString> CppModelManager::internalTargets(const QString &filePath) const
{
const QList<ProjectPart::Ptr> projectParts = projectPart(filePath);
// if we have no project parts it's most likely a header with declarations only and CMake based
if (projectParts.isEmpty())
return dependingInternalTargets(filePath);
QSet<QString> targets;
for (const ProjectPart::Ptr &part : projectParts) {
targets.insert(part->buildSystemTarget);
if (part->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
targets.unite(dependingInternalTargets(filePath));
}
return targets;
}
void CppModelManager::renameIncludes(const QString &oldFileName, const QString &newFileName)
{
if (oldFileName.isEmpty() || newFileName.isEmpty())