diff options
author | Marco Bubke <marco.bubke@qt.io> | 2018-02-06 11:16:29 +0100 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2018-02-14 15:06:58 +0000 |
commit | 29a4419c075b199621269c2e17f02106d1657b45 (patch) | |
tree | d7ed454eaab30d7223246560352e0c34afaa19c4 /src/tools/clangrefactoringbackend/source/symbolindexer.cpp | |
parent | dfb9e4355f14afd9b543b9967aa3095eb6b431eb (diff) | |
download | qt-creator-29a4419c075b199621269c2e17f02106d1657b45.tar.gz |
Clang: Update symbol database if file has changed
The code in the symbol indexer is quite similar, but still different
enough to prevent easy reuse of the function.
Change-Id: I47907d90066da922eafe8ff3cce124ea47ea4a0a
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/tools/clangrefactoringbackend/source/symbolindexer.cpp')
-rw-r--r-- | src/tools/clangrefactoringbackend/source/symbolindexer.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp index 13239155cd..9c8c871cfa 100644 --- a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp +++ b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp @@ -85,7 +85,39 @@ void SymbolIndexer::pathsWithIdsChanged(const Utils::SmallStringVector &) void SymbolIndexer::pathsChanged(const FilePathIds &filePathIds) { + for (FilePathId filePathId : filePathIds) + updateChangedPath(filePathId); +} + +void SymbolIndexer::updateChangedPath(FilePathId filePathId) +{ + m_symbolsCollector.clear(); + + const Utils::optional<ProjectPartArtefact> optionalArtefact = m_symbolStorage.fetchProjectPartArtefact(filePathId); + + if (optionalArtefact) { + const ProjectPartArtefact &artefact = optionalArtefact.value(); + + m_symbolsCollector.addFiles({filePathId}, artefact.compilerArguments); + + m_symbolsCollector.collectSymbols(); + + Sqlite::ImmediateTransaction transaction{m_transactionInterface}; + + m_symbolStorage.addSymbolsAndSourceLocations(m_symbolsCollector.symbols(), + m_symbolsCollector.sourceLocations()); + + m_symbolStorage.updateProjectPartSources(artefact.projectPartId, + m_symbolsCollector.sourceFiles()); + + m_symbolStorage.insertOrUpdateUsedMacros(m_symbolsCollector.usedMacros()); + + m_symbolStorage.insertFileStatuses(m_symbolsCollector.fileStatuses()); + + m_symbolStorage.insertOrUpdateSourceDependencies(m_symbolsCollector.sourceDependencies()); + transaction.commit(); + } } } // namespace ClangBackEnd |