diff --git a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp index 0f5c57af0c3..02aa98dea0e 100644 --- a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp +++ b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp @@ -68,6 +68,8 @@ void SymbolIndexer::updateProjectPart(V2::ProjectPartContainer &&projectPart, m_symbolStorage.updateProjectPartSources(projectPart.projectPartId(), m_symbolsCollector.sourceFiles()); + m_symbolStorage.insertOrUpdateUsedDefines(m_symbolsCollector.usedDefines()); + transaction.commit(); } diff --git a/src/tools/clangrefactoringbackend/source/symbolstorage.h b/src/tools/clangrefactoringbackend/source/symbolstorage.h index bbdf11a9222..54183619dcf 100644 --- a/src/tools/clangrefactoringbackend/source/symbolstorage.h +++ b/src/tools/clangrefactoringbackend/source/symbolstorage.h @@ -81,6 +81,11 @@ public: } } + void insertOrUpdateUsedDefines(const UsedDefines &usedDefines) override + { + + } + void updateProjectPartSources(Utils::SmallStringView projectPartName, const FilePathIds &sourceFilePathIds) override { diff --git a/src/tools/clangrefactoringbackend/source/symbolstorageinterface.h b/src/tools/clangrefactoringbackend/source/symbolstorageinterface.h index 8f05c512f7c..7c58d2fbde7 100644 --- a/src/tools/clangrefactoringbackend/source/symbolstorageinterface.h +++ b/src/tools/clangrefactoringbackend/source/symbolstorageinterface.h @@ -28,6 +28,7 @@ #include "projectpartentry.h" #include "sourcelocationentry.h" #include "symbolentry.h" +#include "useddefines.h" #include @@ -47,6 +48,7 @@ public: const Utils::SmallStringVector &commandLineArguments) = 0; virtual void updateProjectPartSources(Utils::SmallStringView projectPartName, const FilePathIds &sourceFilePathIds) = 0; + virtual void insertOrUpdateUsedDefines(const UsedDefines &usedDefines) = 0; }; } // namespace ClangBackEnd diff --git a/tests/unit/unittest/mocksymbolstorage.h b/tests/unit/unittest/mocksymbolstorage.h index 36cdf49381d..2c147b9eac2 100644 --- a/tests/unit/unittest/mocksymbolstorage.h +++ b/tests/unit/unittest/mocksymbolstorage.h @@ -43,4 +43,6 @@ public: MOCK_METHOD2(updateProjectPartSources, void(Utils::SmallStringView projectPartName, const ClangBackEnd::FilePathIds &sourceFilePathIds)); + MOCK_METHOD1(insertOrUpdateUsedDefines, + void (const ClangBackEnd::UsedDefines &usedDefines)); }; diff --git a/tests/unit/unittest/symbolindexer-test.cpp b/tests/unit/unittest/symbolindexer-test.cpp index 1e0d239094e..a58bf0f4704 100644 --- a/tests/unit/unittest/symbolindexer-test.cpp +++ b/tests/unit/unittest/symbolindexer-test.cpp @@ -47,6 +47,7 @@ using ClangBackEnd::SymbolEntry; using ClangBackEnd::SourceLocationEntries; using ClangBackEnd::SourceLocationEntry; using ClangBackEnd::SymbolType; +using ClangBackEnd::UsedDefines; MATCHER_P2(IsFileId, directoryId, fileNameId, std::string(negation ? "isn't " : "is ") @@ -63,6 +64,7 @@ protected: ON_CALL(mockCollector, symbols()).WillByDefault(ReturnRef(symbolEntries)); ON_CALL(mockCollector, sourceLocations()).WillByDefault(ReturnRef(sourceLocations)); ON_CALL(mockCollector, sourceFiles()).WillByDefault(ReturnRef(sourceFileIds)); + ON_CALL(mockCollector, usedDefines()).WillByDefault(ReturnRef(usedDefines)); } protected: @@ -86,6 +88,7 @@ protected: SymbolEntries symbolEntries{{1, {"function", "function"}}}; SourceLocationEntries sourceLocations{{1, {1, 1}, {42, 23}, SymbolType::Declaration}}; FilePathIds sourceFileIds{{1, 1}, {42, 23}}; + UsedDefines usedDefines{{"Foo", {1, 1}}}; NiceMock mockSqliteTransactionBackend; NiceMock mockCollector; NiceMock mockStorage; @@ -176,6 +179,14 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsUpdateProjectPartSources) indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved)); } +TEST_F(SymbolIndexer, UpdateProjectPartsCallsInsertOrUpdateUsedDefines) +{ + EXPECT_CALL(mockStorage, insertOrUpdateUsedDefines(Eq(usedDefines))) + .Times(2); + + indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved)); +} + TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrder) { InSequence s; @@ -188,6 +199,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrder) EXPECT_CALL(mockStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations)); EXPECT_CALL(mockStorage, insertOrUpdateProjectPart(_, _)); EXPECT_CALL(mockStorage, updateProjectPartSources(_, _)); + EXPECT_CALL(mockStorage, insertOrUpdateUsedDefines(Eq(usedDefines))); EXPECT_CALL(mockSqliteTransactionBackend, commit()); indexer.updateProjectParts({projectPart1}, Utils::clone(unsaved));