Clang: Update ModifiedTimeChecker in SymbolIndexer

If a watched file changed we should update the ModifiedTimeChecker too.

Change-Id: Ie43f5cf5b6dd4ddb1383168a1326add21f6e3e9d
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2019-06-17 18:17:49 +02:00
parent bbd58ca30b
commit cbfd9dc16b
6 changed files with 19 additions and 4 deletions

View File

@@ -25,6 +25,7 @@
#pragma once #pragma once
#include "clangpathwatcher.h"
#include "filepathcachinginterface.h" #include "filepathcachinginterface.h"
#include "modifiedtimecheckerinterface.h" #include "modifiedtimecheckerinterface.h"
@@ -54,7 +55,7 @@ public:
return compareEntries(sourceEntries); return compareEntries(sourceEntries);
} }
void pathsChanged(const FilePathIds &filePathIds) void pathsChanged(const FilePathIds &filePathIds) override
{ {
using SourceTimeStampReferences = std::vector<std::reference_wrapper<SourceTimeStamp>>; using SourceTimeStampReferences = std::vector<std::reference_wrapper<SourceTimeStamp>>;

View File

@@ -38,6 +38,7 @@ public:
ModifiedTimeCheckerInterface &operator=(const ModifiedTimeCheckerInterface &) = delete; ModifiedTimeCheckerInterface &operator=(const ModifiedTimeCheckerInterface &) = delete;
virtual bool isUpToDate(const SourceEntries &sourceEntries) const = 0; virtual bool isUpToDate(const SourceEntries &sourceEntries) const = 0;
virtual void pathsChanged(const FilePathIds &filePathIds) = 0;
protected: protected:
~ModifiedTimeCheckerInterface() = default; ~ModifiedTimeCheckerInterface() = default;

View File

@@ -87,8 +87,8 @@ SymbolIndexer::SymbolIndexer(SymbolIndexerTaskQueueInterface &symbolIndexerTaskQ
void SymbolIndexer::updateProjectParts(ProjectPartContainers &&projectParts) void SymbolIndexer::updateProjectParts(ProjectPartContainers &&projectParts)
{ {
for (ProjectPartContainer &projectPart : projectParts) for (ProjectPartContainer &projectPart : projectParts)
updateProjectPart(std::move(projectPart)); updateProjectPart(std::move(projectPart));
} }
void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart) void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart)
@@ -154,6 +154,8 @@ void SymbolIndexer::pathsWithIdsChanged(const ProjectPartIds &) {}
void SymbolIndexer::pathsChanged(const FilePathIds &filePathIds) void SymbolIndexer::pathsChanged(const FilePathIds &filePathIds)
{ {
m_modifiedTimeChecker.pathsChanged(filePathIds);
FilePathIds dependentSourcePathIds = m_symbolStorage.fetchDependentSourceIds(filePathIds); FilePathIds dependentSourcePathIds = m_symbolStorage.fetchDependentSourceIds(filePathIds);
std::vector<SymbolIndexerTask> symbolIndexerTask; std::vector<SymbolIndexerTask> symbolIndexerTask;

View File

@@ -29,8 +29,8 @@
#include "symbolindexertaskqueueinterface.h" #include "symbolindexertaskqueueinterface.h"
#include "symbolstorageinterface.h" #include "symbolstorageinterface.h"
#include "builddependenciesstorageinterface.h" #include "builddependenciesstorageinterface.h"
#include "clangpathwatcher.h"
#include <clangpathwatcher.h>
#include <filecontainerv2.h> #include <filecontainerv2.h>
#include <modifiedtimecheckerinterface.h> #include <modifiedtimecheckerinterface.h>
#include <precompiledheaderstorageinterface.h> #include <precompiledheaderstorageinterface.h>

View File

@@ -35,6 +35,7 @@ class MockSourceEntriesModifiedTimeChecker
public: public:
MOCK_CONST_METHOD1(isUpToDate, MOCK_CONST_METHOD1(isUpToDate,
bool (const ClangBackEnd::SourceEntries &sourceEntries)); bool (const ClangBackEnd::SourceEntries &sourceEntries));
MOCK_METHOD1(pathsChanged, void(const ClangBackEnd::FilePathIds &filePathIds));
}; };
class MockSourceTimeStampsModifiedTimeChecker class MockSourceTimeStampsModifiedTimeChecker
@@ -42,4 +43,5 @@ class MockSourceTimeStampsModifiedTimeChecker
{ {
public: public:
MOCK_CONST_METHOD1(isUpToDate, bool(const ClangBackEnd::SourceTimeStamps &sourceTimeStamps)); MOCK_CONST_METHOD1(isUpToDate, bool(const ClangBackEnd::SourceTimeStamps &sourceTimeStamps));
MOCK_METHOD1(pathsChanged, void(const ClangBackEnd::FilePathIds &filePathIds));
}; };

View File

@@ -1667,6 +1667,15 @@ TEST_F(SymbolIndexer, PathsChangedUpdatesFileStatusCache)
ASSERT_THAT(fileStatusCache.lastModifiedTime(sourceId), 65); ASSERT_THAT(fileStatusCache.lastModifiedTime(sourceId), 65);
} }
TEST_F(SymbolIndexer, PathsChangedCallsModifiedTimeChecker)
{
auto sourceId = filePathId(TESTDATA_DIR "/symbolindexer_pathChanged.cpp");
EXPECT_CALL(mockModifiedTimeChecker, pathsChanged(ElementsAre(sourceId)));
indexer.pathsChanged({sourceId});
}
TEST_F(SymbolIndexer, GetUpdatableFilePathIdsIfCompilerMacrosAreDifferent) TEST_F(SymbolIndexer, GetUpdatableFilePathIdsIfCompilerMacrosAreDifferent)
{ {
ON_CALL(mockProjectPartsStorage, fetchProjectPartArtefact(A<ProjectPartId>())) ON_CALL(mockProjectPartsStorage, fetchProjectPartArtefact(A<ProjectPartId>()))