Clang: Improve project part updating

The project part ids are now already created very early in the database.
This removes some checks because we can assume that an id already exists.
The project part are now completely persistent, so we can read them from
the database and compare them with new generated from a new creator
session. This should help to not recreate the same PCH again and again.

Task-number: QTCREATORBUG-21151
Change-Id: Iced818ff9f7431eaed3e37978087cc0a43b9afda
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2019-03-13 15:09:30 +01:00
parent 7249427749
commit 6effa1822b
111 changed files with 2657 additions and 1803 deletions

View File

@@ -36,6 +36,7 @@
#include <clangpchmanager/clangpchmanagerplugin.h>
#include <clangpchmanager/progressmanager.h>
#include <clangsupport/refactoringdatabaseinitializer.h>
#include <projectpartsstorage.h>
#include <cpptools/cppmodelmanager.h>
@@ -61,6 +62,8 @@ namespace ClangRefactoring {
namespace {
using ClangPchManager::ClangPchManagerPlugin;
QString backendProcessPath()
{
return Core::ICore::libexecPath()
@@ -91,14 +94,16 @@ public:
ClangBackEnd::RefactoringConnectionClient connectionClient{&refactoringClient};
QuerySqliteReadStatementFactory statementFactory{database};
SymbolQuery<QuerySqliteReadStatementFactory> symbolQuery{statementFactory};
ClangBackEnd::ProjectPartsStorage<Sqlite::Database> projectPartsStorage{database};
RefactoringEngine engine{connectionClient.serverProxy(), refactoringClient, filePathCache, symbolQuery};
QtCreatorSearch qtCreatorSearch;
QtCreatorClangQueryFindFilter qtCreatorfindFilter{connectionClient.serverProxy(),
qtCreatorSearch,
refactoringClient};
QtCreatorRefactoringProjectUpdater projectUpdate{connectionClient.serverProxy(),
ClangPchManager::ClangPchManagerPlugin::pchManagerClient(),
filePathCache};
ClangPchManagerPlugin::pchManagerClient(),
filePathCache,
projectPartsStorage};
};
ClangRefactoringPlugin::ClangRefactoringPlugin()

View File

@@ -60,10 +60,16 @@ std::vector<ClangBackEnd::V2::FileContainer> createGeneratedFiles()
}
}
QtCreatorRefactoringProjectUpdater::QtCreatorRefactoringProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server,
ClangPchManager::PchManagerClient &pchManagerClient,
ClangBackEnd::FilePathCachingInterface &filePathCache)
: RefactoringProjectUpdater(server, pchManagerClient, *cppModelManager(), filePathCache)
QtCreatorRefactoringProjectUpdater::QtCreatorRefactoringProjectUpdater(
ClangBackEnd::ProjectManagementServerInterface &server,
ClangPchManager::PchManagerClient &pchManagerClient,
ClangBackEnd::FilePathCachingInterface &filePathCache,
ClangBackEnd::ProjectPartsStorageInterface &projectPartsStorage)
: RefactoringProjectUpdater(server,
pchManagerClient,
*cppModelManager(),
filePathCache,
projectPartsStorage)
{
connectToCppModelManager();
}

View File

@@ -32,9 +32,11 @@ namespace ClangRefactoring {
class QtCreatorRefactoringProjectUpdater final : public RefactoringProjectUpdater
{
public:
QtCreatorRefactoringProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server,
ClangPchManager::PchManagerClient &pchManagerClient,
ClangBackEnd::FilePathCachingInterface &filePathCache);
QtCreatorRefactoringProjectUpdater(
ClangBackEnd::ProjectManagementServerInterface &server,
ClangPchManager::PchManagerClient &pchManagerClient,
ClangBackEnd::FilePathCachingInterface &filePathCache,
ClangBackEnd::ProjectPartsStorageInterface &projectPartsStorage);
private:
void abstractEditorUpdated(const QString &filePath, const QByteArray &contents);

View File

@@ -26,19 +26,22 @@
#include "refactoringprojectupdater.h"
#include <cpptools/cppmodelmanager.h>
#include <projectpartsstorageinterface.h>
namespace ClangRefactoring {
void RefactoringProjectUpdater::precompiledHeaderUpdated(const QString &projectPartId,
void RefactoringProjectUpdater::precompiledHeaderUpdated(ClangBackEnd::ProjectPartId projectPartId,
const QString &,
long long)
{
auto projectPart = m_cppModelManager.projectPartForId(projectPartId);
const QString projectPartName = fetchProjectPartName(projectPartId);
auto projectPart = m_cppModelManager.projectPartForId(projectPartName);
if (projectPart)
updateProjectParts({projectPart.data()}, {});
}
void RefactoringProjectUpdater::precompiledHeaderRemoved(const QString &projectPartId)
void RefactoringProjectUpdater::precompiledHeaderRemoved(ClangBackEnd::ProjectPartId projectPartId)
{
removeProjectParts({projectPartId});
}

View File

@@ -39,18 +39,18 @@ public:
RefactoringProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server,
ClangPchManager::PchManagerClient &pchManagerClient,
CppTools::CppModelManagerInterface &cppModelManager,
ClangBackEnd::FilePathCachingInterface &filePathCache)
: ClangPchManager::ProjectUpdater(server, filePathCache),
ClangPchManager::PchManagerNotifierInterface(pchManagerClient),
m_cppModelManager(cppModelManager)
ClangBackEnd::FilePathCachingInterface &filePathCache,
ClangBackEnd::ProjectPartsStorageInterface &projectPartsStorage)
: ClangPchManager::ProjectUpdater(server, filePathCache, projectPartsStorage)
, ClangPchManager::PchManagerNotifierInterface(pchManagerClient)
, m_cppModelManager(cppModelManager)
{
}
void precompiledHeaderUpdated(const QString &projectPartId,
void precompiledHeaderUpdated(ClangBackEnd::ProjectPartId projectPartId,
const QString &pchFilePath,
long long lastModified) override;
void precompiledHeaderRemoved(const QString &projectPartId) override;
void precompiledHeaderRemoved(ClangBackEnd::ProjectPartId projectPartId) override;
private:
CppTools::CppModelManagerInterface &m_cppModelManager;