diff options
author | Marco Bubke <marco.bubke@qt.io> | 2018-02-08 17:49:02 +0100 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2018-02-22 10:24:59 +0000 |
commit | 73963cc9c73fda713b43578dac6c6bc7cd285712 (patch) | |
tree | 2d12cfaa521cae9f90af4c0d1e9f733756bbc534 /src/tools/clangrefactoringbackend/source/symbolindexer.cpp | |
parent | a6f47e872f4675429a78def3608eef11519c23f6 (diff) | |
download | qt-creator-73963cc9c73fda713b43578dac6c6bc7cd285712.tar.gz |
Clang: Add time stamp based filtering for project parts
The source ids are now filtered by the modified time. If the modified time
in the database is older than the modified time of the file it will be
parsed. If it is not newer it will be not parsed.
Change-Id: I4ade3443dd66573ac88053a2cafa600e54cfe973
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 | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp index ee68016940..e38009ed87 100644 --- a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp +++ b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp @@ -31,11 +31,13 @@ SymbolIndexer::SymbolIndexer(SymbolsCollectorInterface &symbolsCollector, SymbolStorageInterface &symbolStorage, ClangPathWatcherInterface &pathWatcher, FilePathCachingInterface &filePathCache, + FileStatusCache &fileStatusCache, Sqlite::TransactionInterface &transactionInterface) : m_symbolsCollector(symbolsCollector), m_symbolStorage(symbolStorage), m_pathWatcher(pathWatcher), m_filePathCache(filePathCache), + m_fileStatusCache(fileStatusCache), m_transactionInterface(transactionInterface) { pathWatcher.setNotifier(this); @@ -52,7 +54,9 @@ void SymbolIndexer::updateProjectPart(V2::ProjectPartContainer &&projectPart, { m_symbolsCollector.clear(); - if (compilerMacrosOrIncludeSearchPathsAreDifferent(projectPart)) { + FilePathIds sourcePathIds = updatableFilePathIds(projectPart); + + if (!sourcePathIds.empty()) { m_symbolsCollector.addFiles(projectPart.sourcePathIds(), projectPart.arguments()); m_symbolsCollector.addUnsavedFiles(generatedFiles); @@ -94,6 +98,7 @@ void SymbolIndexer::pathsChanged(const FilePathIds &filePathIds) void SymbolIndexer::updateChangedPath(FilePathId filePathId) { m_symbolsCollector.clear(); + m_fileStatusCache.update(filePathId); const Utils::optional<ProjectPartArtefact> optionalArtefact = m_symbolStorage.fetchProjectPartArtefact(filePathId); @@ -136,4 +141,27 @@ bool SymbolIndexer::compilerMacrosOrIncludeSearchPathsAreDifferent(const V2::Pro return true; } +FilePathIds SymbolIndexer::filterChangedFiles(const V2::ProjectPartContainer &projectPart) const +{ + FilePathIds ids; + ids.reserve(projectPart.sourcePathIds().size()); + + for (const FilePathId &sourceId : projectPart.sourcePathIds()) { + long long oldLastModified = m_symbolStorage.fetchLowestLastModifiedTime(sourceId); + long long currentLastModified = m_fileStatusCache.lastModifiedTime(sourceId); + if (oldLastModified < currentLastModified) + ids.push_back(sourceId); + } + + return ids; +} + +FilePathIds SymbolIndexer::updatableFilePathIds(const V2::ProjectPartContainer &projectPart) const +{ + if (compilerMacrosOrIncludeSearchPathsAreDifferent(projectPart)) + return projectPart.sourcePathIds(); + + return filterChangedFiles(projectPart); +} + } // namespace ClangBackEnd |