Observe the cration of extra compiler

We link into the extra compiler factory and notify the PchManager for every
extra compiler creation. It enables to monitor if all extra compiler finished.

Change-Id: If8da386c88909abd2e0e651e4336865c9dc5bf34
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2019-02-12 19:49:38 +01:00
parent 2887f5e5a9
commit fbadbd3b0d
6 changed files with 62 additions and 8 deletions

View File

@@ -30,9 +30,9 @@ namespace V2 {
QDebug operator<<(QDebug debug, const FileContainer &container)
{
debug.nospace() << "FileContainer("
<< container.filePath << ", "
debug.nospace() << "FileContainer(" << container.filePath << ", "
<< container.commandLineArguments << ", "
<< container.unsavedFileContent.hasContent() << ", "
<< container.documentRevision;
debug.nospace() << ")";

View File

@@ -28,6 +28,7 @@
#include "pchmanagerprojectupdater.h"
#include <cpptools/cppmodelmanager.h>
#include <projectexplorer/extracompiler.h>
#include <filecontainerv2.h>
@@ -49,8 +50,9 @@ CLANGPCHMANAGER_EXPORT std::vector<ClangBackEnd::V2::FileContainer> createGenera
CLANGPCHMANAGER_EXPORT std::vector<CppTools::ProjectPart*> createProjectParts(ProjectExplorer::Project *project);
}
template <typename ProjectUpdaterType>
class QtCreatorProjectUpdater : public ProjectUpdaterType
template<typename ProjectUpdaterType>
class QtCreatorProjectUpdater : public ProjectUpdaterType,
public ProjectExplorer::ExtraCompilerFactoryObserver
{
public:
template <typename ClientType>
@@ -90,6 +92,15 @@ public:
ProjectUpdaterType::removeGeneratedFiles({ClangBackEnd::FilePath{filePath}});
}
protected:
void newExtraCompiler(const ProjectExplorer::Project *,
const Utils::FileName &,
const Utils::FileNameList &targets) override
{
for (const Utils::FileName &target : targets)
abstractEditorUpdated(target.toString(), {});
}
private:
void connectToCppModelManager()
{

View File

@@ -52,7 +52,7 @@ namespace ProjectExplorer {
Q_GLOBAL_STATIC(QThreadPool, s_extraCompilerThreadPool);
Q_GLOBAL_STATIC(QList<ExtraCompilerFactory *>, factories);
Q_GLOBAL_STATIC(QVector<ExtraCompilerFactoryObserver *>, observers);
class ExtraCompilerPrivate
{
public:
@@ -310,7 +310,8 @@ void ExtraCompiler::setContent(const Utils::FileName &file, const QByteArray &co
}
}
ExtraCompilerFactory::ExtraCompilerFactory(QObject *parent) : QObject(parent)
ExtraCompilerFactory::ExtraCompilerFactory(QObject *parent)
: QObject(parent)
{
factories->append(this);
}
@@ -320,6 +321,14 @@ ExtraCompilerFactory::~ExtraCompilerFactory()
factories->removeAll(this);
}
void ExtraCompilerFactory::annouceCreation(const Project *project,
const Utils::FileName &source,
const Utils::FileNameList &targets)
{
for (ExtraCompilerFactoryObserver *observer : *observers)
observer->newExtraCompiler(project, source, targets);
}
QList<ExtraCompilerFactory *> ExtraCompilerFactory::extraCompilerFactories()
{
return *factories();
@@ -455,4 +464,14 @@ void ProcessExtraCompiler::cleanUp()
setCompileTime(QDateTime::currentDateTime());
}
ExtraCompilerFactoryObserver::ExtraCompilerFactoryObserver()
{
observers->push_back(this);
}
ExtraCompilerFactoryObserver::~ExtraCompilerFactoryObserver()
{
observers->removeOne(this);
}
} // namespace ProjectExplorer

View File

@@ -137,6 +137,20 @@ private:
QFutureWatcher<FileNameToContentsHash> *m_watcher = nullptr;
};
class PROJECTEXPLORER_EXPORT ExtraCompilerFactoryObserver
{
friend class ExtraCompilerFactory;
protected:
ExtraCompilerFactoryObserver();
~ExtraCompilerFactoryObserver();
virtual void newExtraCompiler(const Project *project,
const Utils::FileName &source,
const Utils::FileNameList &targets)
= 0;
};
class PROJECTEXPLORER_EXPORT ExtraCompilerFactory : public QObject
{
Q_OBJECT
@@ -147,8 +161,14 @@ public:
virtual FileType sourceType() const = 0;
virtual QString sourceTag() const = 0;
virtual ExtraCompiler *create(const Project *project, const Utils::FileName &source,
const Utils::FileNameList &targets) = 0;
virtual ExtraCompiler *create(const Project *project,
const Utils::FileName &source,
const Utils::FileNameList &targets)
= 0;
void annouceCreation(const Project *project,
const Utils::FileName &source,
const Utils::FileNameList &targets);
static QList<ExtraCompilerFactory *> extraCompilerFactories();
};

View File

@@ -149,6 +149,8 @@ ExtraCompiler *QScxmlcGeneratorFactory::create(
const Project *project, const Utils::FileName &source,
const Utils::FileNameList &targets)
{
annouceCreation(project, source, targets);
return new QScxmlcGenerator(project, source, targets, this);
}

View File

@@ -100,6 +100,8 @@ ExtraCompiler *UicGeneratorFactory::create(const Project *project,
const Utils::FileName &source,
const Utils::FileNameList &targets)
{
annouceCreation(project, source, targets);
return new UicGenerator(project, source, targets, this);
}