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:
@@ -29,6 +29,10 @@
|
||||
#include "pchmanagerclient.h"
|
||||
#include "qtcreatorprojectupdater.h"
|
||||
|
||||
#include <filepathcaching.h>
|
||||
#include <refactoringdatabaseinitializer.h>
|
||||
#include <sqlitedatabase.h>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
@@ -50,9 +54,14 @@ QString backendProcessPath()
|
||||
class ClangPchManagerPluginData
|
||||
{
|
||||
public:
|
||||
Sqlite::Database database{Utils::PathString{Core::ICore::userResourcePath() + "/symbol-experimental-v1.db"}};
|
||||
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
|
||||
ClangBackEnd::FilePathCaching filePathCache{database};
|
||||
PchManagerClient pchManagerClient;
|
||||
PchManagerConnectionClient connectionClient{&pchManagerClient};
|
||||
QtCreatorProjectUpdater<PchManagerProjectUpdater> projectUpdate{connectionClient.serverProxy(), pchManagerClient};
|
||||
QtCreatorProjectUpdater<PchManagerProjectUpdater> projectUpdate{connectionClient.serverProxy(),
|
||||
pchManagerClient,
|
||||
filePathCache};
|
||||
};
|
||||
|
||||
std::unique_ptr<ClangPchManagerPluginData> ClangPchManagerPlugin::d;
|
||||
|
||||
@@ -30,8 +30,9 @@
|
||||
namespace ClangPchManager {
|
||||
|
||||
PchManagerProjectUpdater::PchManagerProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server,
|
||||
PchManagerClient &client)
|
||||
: ProjectUpdater(server),
|
||||
PchManagerClient &client,
|
||||
ClangBackEnd::FilePathCachingInterface &filePathCache)
|
||||
: ProjectUpdater(server, filePathCache),
|
||||
m_client(client)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ class PchManagerProjectUpdater : public ProjectUpdater
|
||||
{
|
||||
public:
|
||||
PchManagerProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server,
|
||||
PchManagerClient &client);
|
||||
PchManagerClient &client,
|
||||
ClangBackEnd::FilePathCachingInterface &filePathCache);
|
||||
|
||||
void removeProjectParts(const QStringList &projectPartIds);
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "pchmanagerclient.h"
|
||||
|
||||
#include <filepathid.h>
|
||||
#include <pchmanagerserverinterface.h>
|
||||
#include <removepchprojectpartsmessage.h>
|
||||
#include <updatepchprojectpartsmessage.h>
|
||||
@@ -48,12 +49,14 @@ public:
|
||||
sources.reserve(size);
|
||||
}
|
||||
|
||||
Utils::PathStringVector headers;
|
||||
Utils::PathStringVector sources;
|
||||
ClangBackEnd::FilePathIds headers;
|
||||
ClangBackEnd::FilePathIds sources;
|
||||
};
|
||||
|
||||
ProjectUpdater::ProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server)
|
||||
: m_server(server)
|
||||
ProjectUpdater::ProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server,
|
||||
ClangBackEnd::FilePathCachingInterface &filePathCache)
|
||||
: m_server(server),
|
||||
m_filePathCache(filePathCache)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -83,14 +86,17 @@ void ProjectUpdater::setExcludedPaths(Utils::PathStringVector &&excludedPaths)
|
||||
void ProjectUpdater::addToHeaderAndSources(HeaderAndSources &headerAndSources,
|
||||
const CppTools::ProjectFile &projectFile) const
|
||||
{
|
||||
using ClangBackEnd::FilePathView;
|
||||
|
||||
Utils::PathString path = projectFile.path;
|
||||
bool exclude = std::binary_search(m_excludedPaths.begin(), m_excludedPaths.end(), path);
|
||||
|
||||
if (!exclude) {
|
||||
ClangBackEnd::FilePathId filePathId = m_filePathCache.filePathId(FilePathView(path));
|
||||
if (projectFile.isSource())
|
||||
headerAndSources.sources.push_back(path);
|
||||
headerAndSources.sources.push_back(filePathId);
|
||||
else if (projectFile.isHeader())
|
||||
headerAndSources.headers.push_back(path);
|
||||
headerAndSources.headers.push_back(filePathId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "clangpchmanager_global.h"
|
||||
|
||||
#include <filecontainerv2.h>
|
||||
#include <filepathcachinginterface.h>
|
||||
|
||||
namespace CppTools {
|
||||
class ProjectPart;
|
||||
@@ -54,7 +55,8 @@ class PchManagerClient;
|
||||
class CLANGPCHMANAGER_EXPORT ProjectUpdater
|
||||
{
|
||||
public:
|
||||
ProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server);
|
||||
ProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server,
|
||||
ClangBackEnd::FilePathCachingInterface &filePathCache);
|
||||
|
||||
void updateProjectParts(const std::vector<CppTools::ProjectPart *> &projectParts,
|
||||
ClangBackEnd::V2::FileContainers &&generatedFiles);
|
||||
@@ -77,6 +79,7 @@ unittest_public:
|
||||
private:
|
||||
Utils::PathStringVector m_excludedPaths;
|
||||
ClangBackEnd::ProjectManagementServerInterface &m_server;
|
||||
ClangBackEnd::FilePathCachingInterface &m_filePathCache;
|
||||
};
|
||||
|
||||
} // namespace ClangPchManager
|
||||
|
||||
@@ -55,14 +55,16 @@ class QtCreatorProjectUpdater : public ProjectUpdaterType
|
||||
public:
|
||||
template <typename ClientType>
|
||||
QtCreatorProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server,
|
||||
ClientType &client)
|
||||
: ProjectUpdaterType(server, client)
|
||||
ClientType &client,
|
||||
ClangBackEnd::FilePathCachingInterface &filePathCache)
|
||||
: ProjectUpdaterType(server, client, filePathCache)
|
||||
{
|
||||
connectToCppModelManager();
|
||||
}
|
||||
|
||||
QtCreatorProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server)
|
||||
: ProjectUpdaterType(server)
|
||||
QtCreatorProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server,
|
||||
ClangBackEnd::FilePathCachingInterface &filePathCache)
|
||||
: ProjectUpdaterType(server, filePathCache)
|
||||
{
|
||||
connectToCppModelManager();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user