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

@@ -83,6 +83,20 @@ public:
}
};
struct Data // because we have a cycle dependency
{
Data(const QString &databasePath)
: database{Utils::PathString{databasePath}, 100000ms}
{}
Sqlite::Database database;
RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
FilePathCaching filePathCache{database};
GeneratedFiles generatedFiles;
SymbolIndexing symbolIndexing{database, filePathCache, generatedFiles, [&] (int progress, int total) { clangCodeModelServer.setProgress(progress, total); }};
RefactoringServer clangCodeModelServer{symbolIndexing, filePathCache, generatedFiles};
};
int main(int argc, char *argv[])
{
try {
@@ -99,14 +113,10 @@ int main(int argc, char *argv[])
const QString connectionName = arguments[0];
const QString databasePath = arguments[1];
Sqlite::Database database{Utils::PathString{databasePath}, 100000ms};
RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
FilePathCaching filePathCache{database};
GeneratedFiles generatedFiles;
SymbolIndexing symbolIndexing{database, filePathCache, generatedFiles};
RefactoringServer clangCodeModelServer{symbolIndexing, filePathCache, generatedFiles};
Data data{databasePath};
ConnectionServer<RefactoringServer, RefactoringClientProxy> connectionServer;
connectionServer.setServer(&clangCodeModelServer);
connectionServer.setServer(&data.clangCodeModelServer);
connectionServer.start(connectionName);
return application.exec();

View File

@@ -158,6 +158,11 @@ void RefactoringServer::setGathererProcessingSlotCount(uint count)
m_gatherer.setProcessingSlotCount(count);
}
void RefactoringServer::setProgress(int progress, int total)
{
client()->progress({ProgressType::Indexing, progress, total});
}
void RefactoringServer::gatherSourceRangesForQueryMessages(
std::vector<V2::FileContainer> &&sources,
std::vector<V2::FileContainer> &&unsaved,

View File

@@ -79,6 +79,8 @@ public:
void setGathererProcessingSlotCount(uint count);
void setProgress(int progress, int total);
private:
void gatherSourceRangesForQueryMessages(std::vector<V2::FileContainer> &&sources,
std::vector<V2::FileContainer> &&unsaved,

View File

@@ -29,6 +29,7 @@
#include "symbolindexertask.h"
#include <filepathid.h>
#include <progresscounter.h>
#include <taskschedulerinterface.h>
#include <utils/algorithm.h>
@@ -51,8 +52,10 @@ class SymbolIndexerTaskQueue final : public SymbolIndexerTaskQueueInterface
public:
using Task = SymbolIndexerTask::Callable;
SymbolIndexerTaskQueue(TaskSchedulerInterface<Task> &symbolIndexerTaskScheduler)
: m_symbolIndexerScheduler(symbolIndexerTaskScheduler)
SymbolIndexerTaskQueue(TaskSchedulerInterface<Task> &symbolIndexerTaskScheduler,
ProgressCounter &progressCounter)
: m_symbolIndexerScheduler(symbolIndexerTaskScheduler),
m_progressCounter(progressCounter)
{}
void addOrUpdateTasks(std::vector<SymbolIndexerTask> &&tasks)
@@ -63,7 +66,11 @@ public:
return std::move(first);
};
const std::size_t oldSize = m_tasks.size();
m_tasks = Utils::setUnionMerge<std::vector<SymbolIndexerTask>>(tasks, m_tasks, merge);
m_progressCounter.addTotal(int(m_tasks.size() - oldSize));
}
void removeTasks(const std::vector<int> &projectPartIds)
{
@@ -71,9 +78,13 @@ public:
return std::binary_search(projectPartIds.begin(), projectPartIds.end(), task.projectPartId);
};
const std::size_t oldSize = m_tasks.size();
auto newEnd = std::remove_if(m_tasks.begin(), m_tasks.end(), shouldBeRemoved);
m_tasks.erase(newEnd, m_tasks.end());
m_progressCounter.removeTotal(int(oldSize -m_tasks.size()));
}
const std::vector<SymbolIndexerTask> &tasks() const
@@ -96,6 +107,7 @@ private:
std::vector<Utils::SmallString> m_projectPartIds;
std::vector<SymbolIndexerTask> m_tasks;
TaskSchedulerInterface<Task> &m_symbolIndexerScheduler;
ProgressCounter &m_progressCounter;
};
} // namespace ClangBackEnd

View File

@@ -49,6 +49,7 @@
namespace ClangBackEnd {
class SymbolsCollectorManager;
class RefactoringServer;
class SymbolsCollectorManager final : public ClangBackEnd::ProcessorManager<SymbolsCollector>
{
@@ -77,11 +78,13 @@ public:
using Storage = ClangBackEnd::SymbolStorage<StatementFactory>;
SymbolIndexing(Sqlite::Database &database,
FilePathCachingInterface &filePathCache,
const GeneratedFiles &generatedFiles)
const GeneratedFiles &generatedFiles,
ProgressCounter::SetProgressCallback &&setProgressCallback)
: m_filePathCache(filePathCache),
m_statementFactory(database),
m_collectorManger(generatedFiles, database),
m_indexerScheduler(m_collectorManger, m_indexerQueue, std::thread::hardware_concurrency())
m_progressCounter(std::move(setProgressCallback)),
m_indexerScheduler(m_collectorManger, m_indexerQueue, m_progressCounter, std::thread::hardware_concurrency())
{
}
@@ -114,8 +117,9 @@ private:
ClangPathWatcher<QFileSystemWatcher, QTimer> m_sourceWatcher{m_filePathCache};
FileStatusCache m_fileStatusCache{m_filePathCache};
SymbolsCollectorManager m_collectorManger;
ProgressCounter m_progressCounter;
SymbolIndexerTaskScheduler m_indexerScheduler;
SymbolIndexerTaskQueue m_indexerQueue{m_indexerScheduler};
SymbolIndexerTaskQueue m_indexerQueue{m_indexerScheduler, m_progressCounter};
SymbolIndexer m_indexer{m_indexerQueue,
m_symbolStorage,
m_sourceWatcher,