Clang: Add RefactoringDatabaseInitializer

We moved the creation of the tables and indices to an extra class which can
be called from other places. So you can be sure that a database is
initialized.

Change-Id: Ief5b30ced7b9011ca94367aa2578098423dcecd9
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2017-09-19 17:56:54 +02:00
committed by Tim Jenssen
parent 623135592c
commit 2df9a99cac
7 changed files with 198 additions and 107 deletions

View File

@@ -32,6 +32,7 @@
#include "symbolscollector.h"
#include "symbolstorage.h"
#include <refactoringdatabaseinitializer.h>
#include <stringcache.h>
#include <sqlitedatabase.h>
@@ -47,12 +48,13 @@ public:
Sqlite::ReadStatement,
Sqlite::WriteStatement>;
using Storage = ClangBackEnd::SymbolStorage<StatementFactory>;
using DatabaseInitializer = RefactoringDatabaseInitializer<Sqlite::Database>;
SymbolIndexing(FilePathCache<std::mutex> &filePathCache,
Utils::PathString &&databaseFilePath)
: m_filePathCache(filePathCache),
m_database(std::move(databaseFilePath))
m_database(std::move(databaseFilePath)),
m_databaseInitializer(m_database)
{
}
@@ -75,6 +77,7 @@ public:
private:
FilePathCache<std::mutex> &m_filePathCache;
Sqlite::Database m_database;
DatabaseInitializer m_databaseInitializer;
SymbolsCollector m_collector{m_filePathCache};
StatementFactory m_statementFactory{m_database};
Storage m_symbolStorage{m_statementFactory, m_filePathCache};