From 5dd24110f5e497949fdeb2bc0979aeb08d0d0653 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Tue, 30 Jan 2018 14:02:48 +0100 Subject: [PATCH] Clang: SymbolIndexer is saving the file information to the symbol storage Change-Id: Id34ce9901c1a938e7ea14da444a9ef1b052286e5 Reviewed-by: Ivan Donchevskii --- .../clangrefactoringbackend/source/symbolindexer.cpp | 2 ++ tests/unit/unittest/symbolindexer-test.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp index acc2d4fe00b..41c824d5b88 100644 --- a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp +++ b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp @@ -71,6 +71,8 @@ void SymbolIndexer::updateProjectPart(V2::ProjectPartContainer &&projectPart, m_symbolStorage.insertOrUpdateUsedMacros(m_symbolsCollector.usedMacros()); + m_symbolStorage.insertFileInformations(m_symbolsCollector.fileInformations()); + transaction.commit(); } diff --git a/tests/unit/unittest/symbolindexer-test.cpp b/tests/unit/unittest/symbolindexer-test.cpp index 9e224d3497e..143e9a17231 100644 --- a/tests/unit/unittest/symbolindexer-test.cpp +++ b/tests/unit/unittest/symbolindexer-test.cpp @@ -37,6 +37,7 @@ namespace { using Utils::PathString; +using ClangBackEnd::FileInformations; using ClangBackEnd::FilePathIds; using ClangBackEnd::FilePathView; using ClangBackEnd::V2::ProjectPartContainer; @@ -65,6 +66,7 @@ protected: ON_CALL(mockCollector, sourceLocations()).WillByDefault(ReturnRef(sourceLocations)); ON_CALL(mockCollector, sourceFiles()).WillByDefault(ReturnRef(sourceFileIds)); ON_CALL(mockCollector, usedMacros()).WillByDefault(ReturnRef(usedMacros)); + ON_CALL(mockCollector, fileInformations()).WillByDefault(ReturnRef(fileInformation)); } protected: @@ -91,6 +93,7 @@ protected: SourceLocationEntries sourceLocations{{1, {1, 1}, {42, 23}, SymbolType::Declaration}}; FilePathIds sourceFileIds{{1, 1}, {42, 23}}; UsedMacros usedMacros{{"Foo", {1, 1}}}; + FileInformations fileInformation{{{1, 2}, 3, 4}}; NiceMock mockSqliteTransactionBackend; NiceMock mockCollector; NiceMock mockStorage; @@ -193,6 +196,14 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInsertOrUpdateUsedMacros) indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved)); } +TEST_F(SymbolIndexer, UpdateProjectPartsCallsInsertFileInformations) +{ + EXPECT_CALL(mockStorage, insertFileInformations(Eq(fileInformation))) + .Times(2); + + indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved)); +} + TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrder) { InSequence s; @@ -206,6 +217,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrder) EXPECT_CALL(mockStorage, insertOrUpdateProjectPart(_, _, _)); EXPECT_CALL(mockStorage, updateProjectPartSources(_, _)); EXPECT_CALL(mockStorage, insertOrUpdateUsedMacros(Eq(usedMacros))); + EXPECT_CALL(mockStorage, insertFileInformations(Eq(fileInformation))); EXPECT_CALL(mockSqliteTransactionBackend, commit()); indexer.updateProjectParts({projectPart1}, Utils::clone(unsaved));