Clang: Add progress bars for creating PCHs and indexing

Task-number: QTCREATORBUG-21112
Change-Id: Ie0c00a58f479a2fe7cbc7322490808509733ff0f
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2018-09-27 17:52:44 +02:00
parent ffc070a3f2
commit 391cfab5d7
60 changed files with 865 additions and 49 deletions

View File

@@ -12,7 +12,9 @@ HEADERS += \
$$PWD/pchmanagerconnectionclient.h \
$$PWD/clangpchmanager_global.h \
$$PWD/projectupdater.h \
$$PWD/pchmanagerprojectupdater.h
$$PWD/pchmanagerprojectupdater.h \
$$PWD/progressmanager.h \
$$PWD/progressmanagerinterface.h
SOURCES += \
$$PWD/pchmanagerclient.cpp \

View File

@@ -13,6 +13,7 @@ win32 {
HEADERS += \
$$PWD/clangpchmanagerplugin.h \
qtcreatorprojectupdater.h
SOURCES += \
$$PWD/clangpchmanagerplugin.cpp \
qtcreatorprojectupdater.cpp

View File

@@ -27,6 +27,7 @@
#include "pchmanagerconnectionclient.h"
#include "pchmanagerclient.h"
#include "progressmanager.h"
#include "qtcreatorprojectupdater.h"
#include <filepathcaching.h>
@@ -34,10 +35,13 @@
#include <sqlitedatabase.h>
#include <coreplugin/icore.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/hostosinfo.h>
#include <QFutureInterface>
#include <chrono>
using namespace std::chrono_literals;
@@ -61,7 +65,12 @@ public:
Sqlite::Database database{Utils::PathString{Core::ICore::userResourcePath() + "/symbol-experimental-v1.db"}, 1000ms};
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
ClangBackEnd::FilePathCaching filePathCache{database};
PchManagerClient pchManagerClient;
ClangPchManager::ProgressManager progressManager{
[] (QFutureInterface<void> &promise) {
auto title = QCoreApplication::translate("ClangPchProgressManager", "Creating PCHs", "PCH stands for precompiled header");
Core::ProgressManager::addTask(promise.future(), title, "pch creation", nullptr);
}};
PchManagerClient pchManagerClient{progressManager};
PchManagerConnectionClient connectionClient{&pchManagerClient};
QtCreatorProjectUpdater<PchManagerProjectUpdater> projectUpdate{connectionClient.serverProxy(),
pchManagerClient,

View File

@@ -26,8 +26,9 @@
#include "pchmanagerclient.h"
#include <precompiledheadersupdatedmessage.h>
#include <progressmanagerinterface.h>
#include <progressmessage.h>
#include <pchmanagerconnectionclient.h>
#include <pchmanagernotifierinterface.h>
#include <algorithm>
@@ -50,6 +51,11 @@ void PchManagerClient::precompiledHeadersUpdated(ClangBackEnd::PrecompiledHeader
}
}
void PchManagerClient::progress(ClangBackEnd::ProgressMessage &&message)
{
m_progressManager.setProgress(message.progress, message.total);
}
void PchManagerClient::precompiledHeaderRemoved(const QString &projectPartId)
{
for (auto notifier : m_notifiers) {

View File

@@ -34,7 +34,7 @@
namespace ClangPchManager {
class PchManagerConnectionClient;
class ProgressManagerInterface;
class PchManagerNotifierInterface;
class CLANGPCHMANAGER_EXPORT PchManagerClient final : public ClangBackEnd::PchManagerClientInterface,
@@ -42,9 +42,13 @@ class CLANGPCHMANAGER_EXPORT PchManagerClient final : public ClangBackEnd::PchMa
{
friend class PchManagerNotifierInterface;
public:
PchManagerClient() = default;
PchManagerClient(ProgressManagerInterface &progressManager)
: m_progressManager(progressManager)
{}
void alive() override;
void precompiledHeadersUpdated(ClangBackEnd::PrecompiledHeadersUpdatedMessage &&message) override;
void progress(ClangBackEnd::ProgressMessage &&message) override;
void precompiledHeaderRemoved(const QString &projectPartId);
@@ -74,6 +78,7 @@ private:
ClangBackEnd::ProjectPartPchs m_projectPartPchs;
std::vector<PchManagerNotifierInterface*> m_notifiers;
PchManagerConnectionClient *m_connectionClient=nullptr;
ProgressManagerInterface &m_progressManager;
};
} // namespace ClangPchManager

View File

@@ -0,0 +1,84 @@
/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "progressmanagerinterface.h"
#include <QFutureInterface>
#include <QCoreApplication>
#include <QString>
#include <functional>
#include <memory>
namespace ClangPchManager {
class ProgressManager : public ProgressManagerInterface
{
public:
using Promise = QFutureInterface<void>;
using Callback = std::function<void(Promise &)>;
ProgressManager(Callback &&callback)
: m_callback(std::move(callback))
{}
void setProgress(int currentProgress, int maximumProgress)
{
if (!m_promise)
initialize();
m_promise->setExpectedResultCount(maximumProgress);
m_promise->setProgressValue(currentProgress);
if (currentProgress >= maximumProgress)
finish();
}
Promise *promise()
{
return m_promise.get();
}
private:
void initialize()
{
m_promise = std::make_unique<Promise>();
m_callback(*m_promise);
}
void finish()
{
m_promise->reportFinished();
m_promise.reset();
}
private:
Callback m_callback;
std::unique_ptr<Promise> m_promise;
};
} // namespace ClangPchManager

View File

@@ -0,0 +1,39 @@
/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
namespace ClangPchManager {
class ProgressManagerInterface
{
public:
virtual void setProgress(int currentProgress, int maximumProgress) = 0;
protected:
~ProgressManagerInterface() = default;
};
} // namespace ClangPchManager