ClangRefactoring: Activate updating for indexing

Change-Id: I6fb818edfab8ef7d9cfab0520276acedf0597fd3
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2019-06-04 15:53:27 +02:00
parent ee27ae2ef7
commit 300feced20
6 changed files with 38 additions and 1 deletions

View File

@@ -66,6 +66,12 @@ public:
}
}
FilePathIds fetchSources(ProjectPartId projectPartId) const override
{
return fetchProjectPartsFilesStatement.template values<FilePathId>(1024,
projectPartId.projectPathId);
}
void insertOrUpdateFileStatuses(const FileStatuses &fileStatuses) override
{
WriteStatement &statement = insertOrUpdateFileStatusesStatement;
@@ -246,6 +252,8 @@ public:
"CONFLICT(sourceId, projectPartId) DO UPDATE SET sourceType = ?003, "
"hasMissingIncludes = ?004",
database};
mutable ReadStatement fetchProjectPartsFilesStatement{
"SELECT sourceId FROM projectPartsFiles WHERE projectPartId = ? ORDER BY sourceId", database};
mutable ReadStatement fetchSourceDependenciesStatement{
"WITH RECURSIVE collectedDependencies(sourceId) AS (VALUES(?) UNION "
"SELECT dependencySourceId FROM sourceDependencies, "

View File

@@ -56,6 +56,7 @@ public:
virtual UsedMacros fetchUsedMacros(FilePathId sourceId) const = 0;
virtual ProjectPartId fetchProjectPartId(Utils::SmallStringView projectPartName) = 0;
virtual void updatePchCreationTimeStamp(long long pchCreationTimeStamp, ProjectPartId projectPartId) = 0;
virtual FilePathIds fetchSources(ProjectPartId projectPartId) const = 0;
protected:
~BuildDependenciesStorageInterface() = default;

View File

@@ -144,6 +144,8 @@ void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart)
}
}
m_pathWatcher.updateIdPaths(
{{projectPartId, m_buildDependencyStorage.fetchSources(projectPartId)}});
m_symbolIndexerTaskQueue.addOrUpdateTasks(std::move(symbolIndexerTask));
m_symbolIndexerTaskQueue.processEntries();
}

View File

@@ -70,6 +70,7 @@ protected:
MockSqliteWriteStatement &updatePchCreationTimeStampStatement = storage.updatePchCreationTimeStampStatement;
MockSqliteWriteStatement &deleteAllProjectPartsFilesWithProjectPartNameStatement
= storage.deleteAllProjectPartsFilesWithProjectPartNameStatement;
MockSqliteReadStatement &fetchProjectPartsFilesStatement = storage.fetchProjectPartsFilesStatement;
};
TEST_F(BuildDependenciesStorage, ConvertStringsToJson)
@@ -232,5 +233,13 @@ TEST_F(BuildDependenciesStorage, FetchUsedMacros)
ASSERT_THAT(usedMacros, result);
}
}
TEST_F(BuildDependenciesStorage, FetchSources)
{
ClangBackEnd::FilePathIds result{3, 5, 7};
EXPECT_CALL(fetchProjectPartsFilesStatement, valuesReturnFilePathIds(_, 22)).WillOnce(Return(result));
auto sources = storage.fetchSources(22);
ASSERT_THAT(sources, result);
}
} // namespace

View File

@@ -51,5 +51,7 @@ public:
ClangBackEnd::ProjectPartId(Utils::SmallStringView projectPartName));
MOCK_METHOD2(updatePchCreationTimeStamp,
void(long long pchCreationTimeStamp, ClangBackEnd::ProjectPartId projectPartId));
MOCK_CONST_METHOD1(fetchSources,
ClangBackEnd::FilePathIds(ClangBackEnd::ProjectPartId projectPartId));
};

View File

@@ -922,6 +922,21 @@ TEST_F(SymbolIndexer, DependentSourceAreUpToDate)
indexer.updateProjectParts({projectPart1});
}
TEST_F(SymbolIndexer, SourcesAreWatched)
{
using ClangBackEnd::IdPaths;
InSequence s;
FilePathIds sourcePathIds{4, 6, 8};
EXPECT_CALL(mockBuildDependenciesStorage, fetchSources(projectPart1.projectPartId))
.WillOnce(Return(sourcePathIds));
EXPECT_CALL(mockPathWatcher,
updateIdPaths(ElementsAre(AllOf(Field(&IdPaths::id, projectPart1.projectPartId),
Field(&IdPaths::filePathIds, sourcePathIds)))));
indexer.updateProjectParts({projectPart1});
}
TEST_F(SymbolIndexer, CallSetNotifier)
{
EXPECT_CALL(mockPathWatcher, setNotifier(_));