ClangRefactoring: Fix indexing

We moved inside of loop so projectPart was used many times but was empty
after the first iteration.

Change-Id: Ie2441dbdd3bb9de73ae1fd076626255599f5dfea
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2019-04-25 17:58:15 +02:00
parent 2d520140d0
commit 24cadba480
2 changed files with 65 additions and 1 deletions

View File

@@ -102,7 +102,7 @@ void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart)
sourcePathId);
if (!m_modifiedTimeChecker.isUpToDate(dependentTimeStamps)) {
auto indexing = [projectPart = std::move(projectPart),
auto indexing = [projectPart,
sourcePathId,
preIncludeSearchPath = m_environment.preIncludeSearchPath(),
this](SymbolsCollectorInterface &symbolsCollector) {

View File

@@ -1743,4 +1743,68 @@ TEST_F(SymbolIndexer, DISABLED_UpToDateFilesAreNotParsedInUpdateProjectParts)
indexer.updateProjectParts({projectPart1});
}
TEST_F(SymbolIndexer, MultipleSourceFiles)
{
ProjectPartContainer projectPart{0,
{},
{{"BAR", "1", 1}, {"FOO", "1", 2}},
Utils::clone(systemIncludeSearchPaths),
Utils::clone(projectIncludeSearchPaths),
{header1PathId, header2PathId},
{main1PathId, main2PathId},
Utils::Language::Cxx,
Utils::LanguageVersion::CXX14,
Utils::LanguageExtension::None};
EXPECT_CALL(mockCollector,
setFile(main1PathId,
ElementsAre("clang++",
"-w",
"-DNOMINMAX",
"-x",
"c++",
"-std=c++14",
"-nostdinc",
"-nostdinc++",
"-DBAR=1",
"-DFOO=1",
"-isystem",
toNativePath(TESTDATA_DIR "/preincludes"),
"-I",
toNativePath("/project/includes"),
"-I",
toNativePath("/other/project/includes"),
"-isystem",
toNativePath(TESTDATA_DIR),
"-isystem",
toNativePath("/other/includes"),
"-isystem",
toNativePath("/includes"))));
EXPECT_CALL(mockCollector,
setFile(main2PathId,
ElementsAre("clang++",
"-w",
"-DNOMINMAX",
"-x",
"c++",
"-std=c++14",
"-nostdinc",
"-nostdinc++",
"-DBAR=1",
"-DFOO=1",
"-isystem",
toNativePath(TESTDATA_DIR "/preincludes"),
"-I",
toNativePath("/project/includes"),
"-I",
toNativePath("/other/project/includes"),
"-isystem",
toNativePath(TESTDATA_DIR),
"-isystem",
toNativePath("/other/includes"),
"-isystem",
toNativePath("/includes"))));
indexer.updateProjectParts({projectPart});
}
} // namespace