aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2019-07-10 14:03:38 +0200
committerMarco Bubke <marco.bubke@qt.io>2019-07-11 08:59:16 +0000
commit2eb4050acb20fa3ab23394bb4734a176d6f247f6 (patch)
tree82ebe34d010bc172e27651adcd807273323dfddd /src/tools
parent4526a02e31d5dee46f41bce3c7f650b26582ac8d (diff)
ClangRefactoring: Make the indexer more robust
We check now if the database is busy. This should not be happen but better be careful. Change-Id: I8b667ff183368977991974ea1fe7fcde837e968a Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/clangrefactoringbackend/source/symbolindexer.cpp58
1 files changed, 35 insertions, 23 deletions
diff --git a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp
index 4d042b3fd3..c6909a0732 100644
--- a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp
+++ b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp
@@ -91,12 +91,31 @@ void SymbolIndexer::updateProjectParts(ProjectPartContainers &&projectParts)
updateProjectPart(std::move(projectPart));
}
+namespace {
+void store(SymbolStorageInterface &symbolStorage,
+ BuildDependenciesStorageInterface &buildDependencyStorage,
+ Sqlite::TransactionInterface &transactionInterface,
+ SymbolsCollectorInterface &symbolsCollector)
+{
+ try {
+ Sqlite::ImmediateTransaction transaction{transactionInterface};
+ buildDependencyStorage.insertOrUpdateIndexingTimeStamps(symbolsCollector.fileStatuses());
+ symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(),
+ symbolsCollector.sourceLocations());
+ transaction.commit();
+ } catch (const Sqlite::StatementIsBusy &) {
+ store(symbolStorage, buildDependencyStorage, transactionInterface, symbolsCollector);
+ }
+}
+} // namespace
+
void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart)
{
ProjectPartId projectPartId = projectPart.projectPartId;
std::vector<SymbolIndexerTask> symbolIndexerTask;
symbolIndexerTask.reserve(projectPart.sourcePathIds.size());
+
for (FilePathId sourcePathId : projectPart.sourcePathIds) {
SourceTimeStamps dependentTimeStamps = m_buildDependencyStorage.fetchIncludedIndexingTimeStamps(
sourcePathId);
@@ -117,27 +136,28 @@ void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart)
preIncludeSearchPath};
symbolsCollector.setFile(sourcePathId, commandLineBuilder.commandLine);
- return symbolsCollector.collectSymbols();
- };
- auto store = [&] {
- Sqlite::ImmediateTransaction transaction{m_transactionInterface};
- m_buildDependencyStorage.insertOrUpdateIndexingTimeStamps(
- symbolsCollector.fileStatuses());
- m_symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(),
- symbolsCollector.sourceLocations());
- transaction.commit();
+ return symbolsCollector.collectSymbols();
};
const PchPaths pchPaths = m_precompiledHeaderStorage.fetchPrecompiledHeaders(
projectPart.projectPartId);
if (pchPaths.projectPchPath.size() && collect(pchPaths.projectPchPath)) {
- store();
+ store(m_symbolStorage,
+ m_buildDependencyStorage,
+ m_transactionInterface,
+ symbolsCollector);
} else if (pchPaths.systemPchPath.size() && collect(pchPaths.systemPchPath)) {
- store();
+ store(m_symbolStorage,
+ m_buildDependencyStorage,
+ m_transactionInterface,
+ symbolsCollector);
} else if (collect({})) {
- store();
+ store(m_symbolStorage,
+ m_buildDependencyStorage,
+ m_transactionInterface,
+ symbolsCollector);
}
};
@@ -196,23 +216,15 @@ void SymbolIndexer::updateChangedPath(FilePathId filePathId,
return symbolsCollector.collectSymbols();
};
- auto store = [&] {
- Sqlite::ImmediateTransaction transaction{m_transactionInterface};
- m_buildDependencyStorage.insertOrUpdateIndexingTimeStamps(symbolsCollector.fileStatuses());
- m_symbolStorage.addSymbolsAndSourceLocations(symbolsCollector.symbols(),
- symbolsCollector.sourceLocations());
- transaction.commit();
- };
-
const PchPaths pchPaths = m_precompiledHeaderStorage.fetchPrecompiledHeaders(
optionalArtefact->projectPartId);
if (pchPaths.projectPchPath.size() && collect(pchPaths.projectPchPath)) {
- store();
+ store(m_symbolStorage, m_buildDependencyStorage, m_transactionInterface, symbolsCollector);
} else if (pchPaths.systemPchPath.size() && collect(pchPaths.systemPchPath)) {
- store();
+ store(m_symbolStorage, m_buildDependencyStorage, m_transactionInterface, symbolsCollector);
} else if (collect({})) {
- store();
+ store(m_symbolStorage, m_buildDependencyStorage, m_transactionInterface, symbolsCollector);
}
};