forked from qt-creator/qt-creator
Clang: On the road to update and preprocessor support
This patch has grown in a quite big change set and it is really hard to divide it in different parts. V2::ProjectPartContainer is now using FileIds instead of file paths. This cleans code up because it is a big step in the direction that internally only file ids are used. But it is depending on the file cache, so the file cache has to be provided as an argument. There is now an interface for transactions too which are ease the testing of them and enables the support of preprocessor. It adds macros as symbols and is saving used macros. The used macro support is enabling update improvements because only if a changed macro is used it needs to be recompiled. This is still in flux and can be changed in later patches. Change-Id: I492a2c9af1201d40fdd9f46a0045f7878bbbaa3d Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -31,14 +31,18 @@
|
||||
|
||||
#include <pchmanagerprojectupdater.h>
|
||||
|
||||
#include <filepathcaching.h>
|
||||
#include <pchmanagerclient.h>
|
||||
#include <precompiledheadersupdatedmessage.h>
|
||||
#include <refactoringdatabaseinitializer.h>
|
||||
#include <removepchprojectpartsmessage.h>
|
||||
#include <updatepchprojectpartsmessage.h>
|
||||
|
||||
#include <cpptools/compileroptionsbuilder.h>
|
||||
#include <cpptools/projectpart.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
namespace {
|
||||
|
||||
using testing::_;
|
||||
@@ -54,13 +58,43 @@ using CppTools::CompilerOptionsBuilder;
|
||||
class ProjectUpdater : public testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp() override;
|
||||
ClangBackEnd::FilePathId filePathId(Utils::SmallStringView path)
|
||||
{
|
||||
return filePathCache.filePathId(ClangBackEnd::FilePathView{path});
|
||||
}
|
||||
|
||||
ClangBackEnd::FilePathIds filePathIds(const Utils::PathStringVector &paths)
|
||||
{
|
||||
return filePathCache.filePathIds(Utils::transform(paths, [] (const Utils::PathString &path) {
|
||||
return ClangBackEnd::FilePathView(path);
|
||||
}));
|
||||
}
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
projectPart.files.push_back(header1ProjectFile);
|
||||
projectPart.files.push_back(header2ProjectFile);
|
||||
projectPart.files.push_back(source1ProjectFile);
|
||||
projectPart.files.push_back(source2ProjectFile);
|
||||
projectPart.displayName = QString(projectPartId);
|
||||
|
||||
Utils::SmallStringVector arguments{ClangPchManager::ProjectUpdater::compilerArguments(
|
||||
&projectPart)};
|
||||
|
||||
expectedContainer = {projectPartId.clone(),
|
||||
arguments.clone(),
|
||||
{filePathId(headerPaths[1])},
|
||||
{filePathIds(sourcePaths)}};
|
||||
}
|
||||
|
||||
protected:
|
||||
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
|
||||
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> initializer{database};
|
||||
ClangBackEnd::FilePathCaching filePathCache{database};
|
||||
ClangPchManager::PchManagerClient pchManagerClient;
|
||||
MockPchManagerNotifier mockPchManagerNotifier{pchManagerClient};
|
||||
NiceMock<MockPchManagerServer> mockPchManagerServer;
|
||||
ClangPchManager::ProjectUpdater updater{mockPchManagerServer};
|
||||
ClangPchManager::ProjectUpdater updater{mockPchManagerServer, filePathCache};
|
||||
Utils::SmallString projectPartId{"project1"};
|
||||
Utils::SmallString projectPartId2{"project2"};
|
||||
Utils::PathStringVector headerPaths = {"/path/to/header1.h", "/path/to/header2.h"};
|
||||
@@ -97,7 +131,7 @@ TEST_F(ProjectUpdater, CallRemovePchProjectParts)
|
||||
|
||||
TEST_F(ProjectUpdater, CallPrecompiledHeaderRemovedInPchManagerProjectUpdater)
|
||||
{
|
||||
ClangPchManager::PchManagerProjectUpdater pchUpdater{mockPchManagerServer, pchManagerClient};
|
||||
ClangPchManager::PchManagerProjectUpdater pchUpdater{mockPchManagerServer, pchManagerClient, filePathCache};
|
||||
ClangBackEnd::RemovePchProjectPartsMessage message{{projectPartId, projectPartId2}};
|
||||
|
||||
EXPECT_CALL(mockPchManagerNotifier, precompiledHeaderRemoved(projectPartId.toQString()));
|
||||
@@ -129,21 +163,6 @@ TEST_F(ProjectUpdater, CreateExcludedPaths)
|
||||
ASSERT_THAT(excludedPaths, ElementsAre("/path/to/header1.h"));
|
||||
}
|
||||
|
||||
void ProjectUpdater::SetUp()
|
||||
{
|
||||
projectPart.files.push_back(header1ProjectFile);
|
||||
projectPart.files.push_back(header2ProjectFile);
|
||||
projectPart.files.push_back(source1ProjectFile);
|
||||
projectPart.files.push_back(source2ProjectFile);
|
||||
projectPart.displayName = QString(projectPartId);
|
||||
|
||||
Utils::SmallStringVector arguments{ClangPchManager::ProjectUpdater::compilerArguments(
|
||||
&projectPart)};
|
||||
|
||||
expectedContainer = {projectPartId.clone(),
|
||||
arguments.clone(),
|
||||
{headerPaths[1]},
|
||||
sourcePaths.clone()};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user