Clang: Handle source dependencies in symbol indexer

Get the source dependencies from the collector and save them in the
symbol storage.

Change-Id: Ibc141970a100625398c1526f5bc644cc14d25c0c
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2018-01-31 14:14:34 +01:00
parent 048224bef1
commit 497900eb3f
2 changed files with 14 additions and 0 deletions

View File

@@ -73,6 +73,8 @@ void SymbolIndexer::updateProjectPart(V2::ProjectPartContainer &&projectPart,
m_symbolStorage.insertFileInformations(m_symbolsCollector.fileInformations()); m_symbolStorage.insertFileInformations(m_symbolsCollector.fileInformations());
m_symbolStorage.insertOrUpdateSourceDependencies(m_symbolsCollector.sourceDependencies());
transaction.commit(); transaction.commit();
} }

View File

@@ -45,6 +45,7 @@ using ClangBackEnd::V2::ProjectPartContainers;
using ClangBackEnd::V2::FileContainers; using ClangBackEnd::V2::FileContainers;
using ClangBackEnd::SymbolEntries; using ClangBackEnd::SymbolEntries;
using ClangBackEnd::SymbolEntry; using ClangBackEnd::SymbolEntry;
using ClangBackEnd::SourceDependencies;
using ClangBackEnd::SourceLocationEntries; using ClangBackEnd::SourceLocationEntries;
using ClangBackEnd::SourceLocationEntry; using ClangBackEnd::SourceLocationEntry;
using ClangBackEnd::SymbolType; using ClangBackEnd::SymbolType;
@@ -67,6 +68,7 @@ protected:
ON_CALL(mockCollector, sourceFiles()).WillByDefault(ReturnRef(sourceFileIds)); ON_CALL(mockCollector, sourceFiles()).WillByDefault(ReturnRef(sourceFileIds));
ON_CALL(mockCollector, usedMacros()).WillByDefault(ReturnRef(usedMacros)); ON_CALL(mockCollector, usedMacros()).WillByDefault(ReturnRef(usedMacros));
ON_CALL(mockCollector, fileInformations()).WillByDefault(ReturnRef(fileInformation)); ON_CALL(mockCollector, fileInformations()).WillByDefault(ReturnRef(fileInformation));
ON_CALL(mockCollector, sourceDependencies()).WillByDefault(ReturnRef(sourceDependencies));
} }
protected: protected:
@@ -94,6 +96,7 @@ protected:
FilePathIds sourceFileIds{{1, 1}, {42, 23}}; FilePathIds sourceFileIds{{1, 1}, {42, 23}};
UsedMacros usedMacros{{"Foo", {1, 1}}}; UsedMacros usedMacros{{"Foo", {1, 1}}};
FileInformations fileInformation{{{1, 2}, 3, 4}}; FileInformations fileInformation{{{1, 2}, 3, 4}};
SourceDependencies sourceDependencies{{{1, 1}, {1, 2}}, {{1, 1}, {1, 3}}};
NiceMock<MockSqliteTransactionBackend> mockSqliteTransactionBackend; NiceMock<MockSqliteTransactionBackend> mockSqliteTransactionBackend;
NiceMock<MockSymbolsCollector> mockCollector; NiceMock<MockSymbolsCollector> mockCollector;
NiceMock<MockSymbolStorage> mockStorage; NiceMock<MockSymbolStorage> mockStorage;
@@ -204,6 +207,14 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInsertFileInformations)
indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved)); indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
} }
TEST_F(SymbolIndexer, UpdateProjectPartsCallsInsertOrUpdateSourceDependencies)
{
EXPECT_CALL(mockStorage, insertOrUpdateSourceDependencies(Eq(sourceDependencies)))
.Times(2);
indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrder) TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrder)
{ {
InSequence s; InSequence s;
@@ -218,6 +229,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrder)
EXPECT_CALL(mockStorage, updateProjectPartSources(_, _)); EXPECT_CALL(mockStorage, updateProjectPartSources(_, _));
EXPECT_CALL(mockStorage, insertOrUpdateUsedMacros(Eq(usedMacros))); EXPECT_CALL(mockStorage, insertOrUpdateUsedMacros(Eq(usedMacros)));
EXPECT_CALL(mockStorage, insertFileInformations(Eq(fileInformation))); EXPECT_CALL(mockStorage, insertFileInformations(Eq(fileInformation)));
EXPECT_CALL(mockStorage, insertOrUpdateSourceDependencies(Eq(sourceDependencies)));
EXPECT_CALL(mockSqliteTransactionBackend, commit()); EXPECT_CALL(mockSqliteTransactionBackend, commit());
indexer.updateProjectParts({projectPart1}, Utils::clone(unsaved)); indexer.updateProjectParts({projectPart1}, Utils::clone(unsaved));