From 4bfe59df76ff2b4faac5cf376f0d5242d08cd3f9 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Mon, 24 Apr 2017 01:46:42 +0200 Subject: [PATCH] data: Fixed file complete flag not set when retrieving single source locations in SourceLocationCollection --- src/lib/data/PersistentStorage.cpp | 38 +++++++++++++++++++++++++++--- src/lib/data/PersistentStorage.h | 4 ++++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/lib/data/PersistentStorage.cpp b/src/lib/data/PersistentStorage.cpp index bb419661..c83cab3f 100644 --- a/src/lib/data/PersistentStorage.cpp +++ b/src/lib/data/PersistentStorage.cpp @@ -486,6 +486,7 @@ void PersistentStorage::clearCaches() m_fileIndex.clear(); m_fileNodeIds.clear(); m_fileNodePaths.clear(); + m_fileNodeComplete.clear(); m_hierarchyCache.clear(); m_fullTextSearchIndex.clear(); } @@ -729,6 +730,8 @@ std::shared_ptr PersistentStorage::getFullTextSearchLo } } + addCompleteFlagsToSourceLocationCollection(collection.get()); + MessageStatus( std::to_string(collection->getSourceLocationCount()) + " results in " + std::to_string(collection->getSourceLocationFileCount()) + " files for fulltext search (case-" + @@ -1320,6 +1323,8 @@ std::shared_ptr PersistentStorage::getSourceLocationsF } } + addCompleteFlagsToSourceLocationCollection(collection.get()); + return collection; } @@ -1351,6 +1356,8 @@ std::shared_ptr PersistentStorage::getSourceLocationsF ); } + addCompleteFlagsToSourceLocationCollection(collection.get()); + return collection; } @@ -1470,7 +1477,7 @@ std::shared_ptr PersistentStorage::getErrorSourceLocat { TRACE(); - std::shared_ptr errorCollection = std::make_shared(); + std::shared_ptr collection = std::make_shared(); for (const ErrorInfo& error : m_sqliteIndexStorage.getAll()) { if (m_errorFilter.filter(error)) @@ -1480,7 +1487,7 @@ std::shared_ptr PersistentStorage::getErrorSourceLocat // Set first bit to 1 to avoid collisions Id locationId = ~(~size_t(0) >> 1) + error.id; - errorCollection->addSourceLocation( + collection->addSourceLocation( LOCATION_ERROR, locationId, std::vector(1, error.id), @@ -1493,7 +1500,9 @@ std::shared_ptr PersistentStorage::getErrorSourceLocat } } - return errorCollection; + addCompleteFlagsToSourceLocationCollection(collection.get()); + + return collection; } Id PersistentStorage::getFileNodeId(const FilePath& filePath) const @@ -1552,6 +1561,18 @@ FilePath PersistentStorage::getFileNodePath(Id fileId) const return FilePath(); } +bool PersistentStorage::getFileNodeComplete(const FilePath& filePath) const +{ + std::map::const_iterator it = m_fileNodeComplete.find(filePath); + + if (it != m_fileNodeComplete.end()) + { + return it->second; + } + + return false; +} + std::unordered_map> PersistentStorage::getFileIdToIncludingFileIdMap() const { std::unordered_map> fileIdToIncludingFileIdMap; @@ -2003,6 +2024,16 @@ void PersistentStorage::addComponentAccessToGraph(Graph* graph) const } } +void PersistentStorage::addCompleteFlagsToSourceLocationCollection(SourceLocationCollection* collection) const +{ + collection->forEachSourceLocationFile( + [this](std::shared_ptr file) + { + file->setIsComplete(getFileNodeComplete(file->getFilePath())); + } + ); +} + void PersistentStorage::buildSearchIndex() { TRACE(); @@ -2061,6 +2092,7 @@ void PersistentStorage::buildFilePathMaps() { m_fileNodeIds.emplace(file.filePath, file.id); m_fileNodePaths.emplace(file.id, file.filePath); + m_fileNodeComplete.emplace(file.filePath, file.complete); } } diff --git a/src/lib/data/PersistentStorage.h b/src/lib/data/PersistentStorage.h index 0eecb1d5..65ea7620 100644 --- a/src/lib/data/PersistentStorage.h +++ b/src/lib/data/PersistentStorage.h @@ -149,6 +149,7 @@ private: std::vector getFileNodeIds(const std::vector& filePaths) const; std::set getFileNodeIds(const std::set& filePaths) const; FilePath getFileNodePath(Id fileId) const; + bool getFileNodeComplete(const FilePath& filePath) const; std::unordered_map> getFileIdToIncludingFileIdMap() const; std::unordered_map> getFileIdToImportingFileIdMap() const; @@ -172,6 +173,8 @@ private: void addAggregationEdgesToGraph(const Id nodeId, const std::vector& edgesToAggregate, Graph* graph) const; void addComponentAccessToGraph(Graph* graph) const; + void addCompleteFlagsToSourceLocationCollection(SourceLocationCollection* collection) const; + void buildSearchIndex(); void buildFilePathMaps(); void buildFullTextSearchIndex() const; @@ -190,6 +193,7 @@ private: std::map m_fileNodeIds; std::map m_fileNodePaths; + std::map m_fileNodeComplete; HierarchyCache m_hierarchyCache; };