Commit 4ab44b07 authored by Tobias Hunger's avatar Tobias Hunger Committed by Tim Jenssen

qmake: Add method to find QmakePriFiles and QmakeProFiles

Change-Id: I04a75b94603b5483d5f9eaa827d08415c0a92985
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent bc64e91c
......@@ -38,7 +38,6 @@
#include <coreplugin/iversioncontrol.h>
#include <coreplugin/vcsmanager.h>
#include <cpptools/cpptoolsconstants.h>
#include <projectexplorer/nodesvisitor.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
......@@ -286,6 +285,18 @@ QVector<QmakePriFile *> QmakePriFile::children() const
return m_children;
}
QmakePriFile *QmakePriFile::findPriFile(const FileName &fileName)
{
if (fileName == filePath())
return this;
for (QmakePriFile *n : children()) {
if (QmakePriFile *result = n->findPriFile(fileName))
return result;
}
return nullptr;
}
void QmakePriFile::makeEmpty()
{
qDeleteAll(m_children);
......@@ -1113,40 +1124,9 @@ static ProjectType proFileTemplateTypeToProjectType(ProFileEvaluator::TemplateTy
}
}
namespace {
// feed all files accepted by any of the factories to the callback.
class FindGeneratorSourcesVisitor : public NodesVisitor
{
public:
FindGeneratorSourcesVisitor(
const QList<ProjectExplorer::ExtraCompilerFactory *> &factories,
std::function<void(FileNode *, ProjectExplorer::ExtraCompilerFactory *)> callback) :
factories(factories), callback(callback) {}
void visitFolderNode(FolderNode *folderNode) final
{
foreach (FileNode *fileNode, folderNode->fileNodes()) {
foreach (ProjectExplorer::ExtraCompilerFactory *factory, factories) {
if (factory->sourceType() == fileNode->fileType())
callback(fileNode, factory);
}
}
}
const QList<ProjectExplorer::ExtraCompilerFactory *> factories;
std::function<void(FileNode *, ProjectExplorer::ExtraCompilerFactory *)> callback;
};
}
QmakeProFile *QmakeProFile::findProFileFor(const FileName &fileName) const
QmakeProFile *QmakeProFile::findProFile(const FileName &fileName)
{
if (fileName == filePath())
return const_cast<QmakeProFile *>(this);
foreach (const QmakePriFile *n, children())
if (auto qmakeProFileNode = dynamic_cast<const QmakeProFile *>(n))
if (QmakeProFile *result = qmakeProFileNode->findProFileFor(fileName))
return result;
return nullptr;
return dynamic_cast<QmakeProFile *>(findPriFile(fileName));
}
QString QmakeProFile::makefile() const
......
......@@ -119,6 +119,9 @@ public:
QmakePriFile *parent() const;
QmakeProject *project() const;
QVector<QmakePriFile *> children() const;
QmakePriFile *findPriFile(const Utils::FileName &fileName);
void makeEmpty();
QSet<Utils::FileName> files(const ProjectExplorer::FileType &type) const;
......@@ -216,7 +219,7 @@ private:
// Memory is cheap...
QMap<ProjectExplorer::FileType, QSet<Utils::FileName>> m_files;
QSet<Utils::FileName> m_recursiveEnumerateFiles;
QSet<Utils::FileName> m_recursiveEnumerateFiles; // FIXME: Remove this?!
QSet<QString> m_watchedFolders;
bool m_includedInExactParse = true;
......@@ -277,6 +280,7 @@ public:
QString displayName() const final;
QList<QmakeProFile *> allProFiles();
QmakeProFile *findProFile(const Utils::FileName &fileName);
ProjectType projectType() const;
......@@ -294,7 +298,6 @@ public:
const Utils::FileName &sourceFile) const;
QList<ProjectExplorer::ExtraCompiler *> extraCompilers() const;
QmakeProFile *findProFileFor(const Utils::FileName &string) const;
TargetParserInformation targetInformation() const;
InstallsParserList installsList() const;
......@@ -333,8 +336,6 @@ private:
void asyncEvaluate(QFutureInterface<Internal::QmakeEvalResult *> &fi, Internal::QmakeEvalInput input);
void cleanupProFileReaders();
using VariablesHash = QHash<Variable, QStringList>;
void updateGeneratedFiles(const Utils::FileName &buildDir);
static QString uiDirPath(QtSupport::ProFileReader *reader, const Utils::FileName &buildDir);
......@@ -352,7 +353,10 @@ private:
QString m_displayName;
ProjectType m_projectType = ProjectType::Invalid;
using VariablesHash = QHash<Variable, QStringList>;
VariablesHash m_varValues;
QList<ProjectExplorer::ExtraCompiler *> m_extraCompilers;
TargetParserInformation m_qmakeTargetInformation;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment