forked from qt-creator/qt-creator
Clang: Add Symbol Indexing
It is a first step and now a database is generated if you start QtCreator. Some code is now shared with the PchManager which can be improved in the future. Change-Id: Ic267fe7960f6c455d91832859a673ce98f269aa2 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -11,12 +11,14 @@ HEADERS += \
|
||||
$$PWD/pchmanagernotifierinterface.h \
|
||||
$$PWD/pchmanagerconnectionclient.h \
|
||||
$$PWD/clangpchmanager_global.h \
|
||||
$$PWD/projectupdater.h
|
||||
$$PWD/projectupdater.h \
|
||||
$$PWD/pchmanagerprojectupdater.h
|
||||
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/pchmanagerclient.cpp \
|
||||
$$PWD/pchmanagernotifierinterface.cpp \
|
||||
$$PWD/pchmanagerconnectionclient.cpp \
|
||||
$$PWD/projectupdater.cpp
|
||||
$$PWD/projectupdater.cpp \
|
||||
$$PWD/pchmanagerprojectupdater.cpp
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class ClangPchManagerPluginData
|
||||
public:
|
||||
PchManagerClient pchManagerClient;
|
||||
PchManagerConnectionClient connectionClient{&pchManagerClient};
|
||||
QtCreatorProjectUpdater projectUpdate{connectionClient.serverProxy(), pchManagerClient};
|
||||
QtCreatorProjectUpdater<PchManagerProjectUpdater> projectUpdate{connectionClient.serverProxy(), pchManagerClient};
|
||||
};
|
||||
|
||||
std::unique_ptr<ClangPchManagerPluginData> ClangPchManagerPlugin::d;
|
||||
|
||||
47
src/plugins/clangpchmanager/pchmanagerprojectupdater.cpp
Normal file
47
src/plugins/clangpchmanager/pchmanagerprojectupdater.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "pchmanagerprojectupdater.h"
|
||||
|
||||
#include "pchmanagerclient.h"
|
||||
|
||||
namespace ClangPchManager {
|
||||
|
||||
PchManagerProjectUpdater::PchManagerProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server,
|
||||
PchManagerClient &client)
|
||||
: ProjectUpdater(server),
|
||||
m_client(client)
|
||||
{
|
||||
}
|
||||
|
||||
void PchManagerProjectUpdater::removeProjectParts(const QStringList &projectPartIds)
|
||||
{
|
||||
ProjectUpdater::removeProjectParts(projectPartIds);
|
||||
|
||||
for (const QString &projectPartiId : projectPartIds)
|
||||
m_client.precompiledHeaderRemoved(projectPartiId);
|
||||
}
|
||||
|
||||
} // namespace ClangPchManager
|
||||
44
src/plugins/clangpchmanager/pchmanagerprojectupdater.h
Normal file
44
src/plugins/clangpchmanager/pchmanagerprojectupdater.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "projectupdater.h"
|
||||
|
||||
namespace ClangPchManager {
|
||||
|
||||
class PchManagerProjectUpdater : public ProjectUpdater
|
||||
{
|
||||
public:
|
||||
PchManagerProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server,
|
||||
PchManagerClient &client);
|
||||
|
||||
void removeProjectParts(const QStringList &projectPartIds);
|
||||
|
||||
private:
|
||||
PchManagerClient &m_client;
|
||||
};
|
||||
|
||||
} // namespace ClangPchManager
|
||||
@@ -52,10 +52,8 @@ public:
|
||||
Utils::PathStringVector sources;
|
||||
};
|
||||
|
||||
ProjectUpdater::ProjectUpdater(ClangBackEnd::PchManagerServerInterface &server,
|
||||
PchManagerClient &client)
|
||||
: m_server(server),
|
||||
m_client(client)
|
||||
ProjectUpdater::ProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server)
|
||||
: m_server(server)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -75,9 +73,6 @@ void ProjectUpdater::removeProjectParts(const QStringList &projectPartIds)
|
||||
ClangBackEnd::RemovePchProjectPartsMessage message{Utils::SmallStringVector(projectPartIds)};
|
||||
|
||||
m_server.removePchProjectParts(std::move(message));
|
||||
|
||||
for (const QString &projectPartiId : projectPartIds)
|
||||
m_client.precompiledHeaderRemoved(projectPartiId);
|
||||
}
|
||||
|
||||
void ProjectUpdater::setExcludedPaths(Utils::PathStringVector &&excludedPaths)
|
||||
|
||||
@@ -35,7 +35,7 @@ class ProjectFile;
|
||||
}
|
||||
|
||||
namespace ClangBackEnd {
|
||||
class PchManagerServerInterface;
|
||||
class ProjectManagementServerInterface;
|
||||
|
||||
namespace V2 {
|
||||
class ProjectPartContainer;
|
||||
@@ -51,11 +51,10 @@ namespace ClangPchManager {
|
||||
class HeaderAndSources;
|
||||
class PchManagerClient;
|
||||
|
||||
class ProjectUpdater
|
||||
class CLANGPCHMANAGER_EXPORT ProjectUpdater
|
||||
{
|
||||
public:
|
||||
ProjectUpdater(ClangBackEnd::PchManagerServerInterface &server,
|
||||
PchManagerClient &client);
|
||||
ProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server);
|
||||
|
||||
void updateProjectParts(const std::vector<CppTools::ProjectPart *> &projectParts,
|
||||
ClangBackEnd::V2::FileContainers &&generatedFiles);
|
||||
@@ -77,8 +76,7 @@ unittest_public:
|
||||
|
||||
private:
|
||||
Utils::PathStringVector m_excludedPaths;
|
||||
ClangBackEnd::PchManagerServerInterface &m_server;
|
||||
PchManagerClient &m_client;
|
||||
ClangBackEnd::ProjectManagementServerInterface &m_server;
|
||||
};
|
||||
|
||||
} // namespace ClangPchManager
|
||||
|
||||
@@ -26,26 +26,18 @@
|
||||
#include "qtcreatorprojectupdater.h"
|
||||
|
||||
#include <cpptools/abstracteditorsupport.h>
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
|
||||
namespace ClangPchManager {
|
||||
|
||||
static CppTools::CppModelManager *cppModelManager()
|
||||
namespace Internal {
|
||||
|
||||
CppTools::CppModelManager *cppModelManager()
|
||||
{
|
||||
return CppTools::CppModelManager::instance();
|
||||
}
|
||||
|
||||
QtCreatorProjectUpdater::QtCreatorProjectUpdater(ClangBackEnd::PchManagerServerInterface &server,
|
||||
PchManagerClient &client)
|
||||
: ProjectUpdater(server, client)
|
||||
{
|
||||
connectToCppModelManager();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
std::vector<ClangBackEnd::V2::FileContainer> createGeneratedFiles()
|
||||
{
|
||||
auto abstractEditors = CppTools::CppModelManager::instance()->abstractEditorSupports();
|
||||
@@ -85,30 +77,7 @@ std::vector<CppTools::ProjectPart*> createProjectParts(ProjectExplorer::Project
|
||||
convertToRawPointer);
|
||||
|
||||
return projectParts;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void QtCreatorProjectUpdater::projectPartsUpdated(ProjectExplorer::Project *project)
|
||||
{
|
||||
updateProjectParts(createProjectParts(project), createGeneratedFiles());
|
||||
}
|
||||
|
||||
void QtCreatorProjectUpdater::projectPartsRemoved(const QStringList &projectPartIds)
|
||||
{
|
||||
removeProjectParts(projectPartIds);
|
||||
}
|
||||
|
||||
void QtCreatorProjectUpdater::connectToCppModelManager()
|
||||
{
|
||||
connect(cppModelManager(),
|
||||
&CppTools::CppModelManager::projectPartsUpdated,
|
||||
this,
|
||||
&QtCreatorProjectUpdater::projectPartsUpdated);
|
||||
connect(cppModelManager(),
|
||||
&CppTools::CppModelManager::projectPartsRemoved,
|
||||
this,
|
||||
&QtCreatorProjectUpdater::projectPartsRemoved);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangPchManager
|
||||
|
||||
@@ -25,7 +25,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "projectupdater.h"
|
||||
#include "pchmanagerprojectupdater.h"
|
||||
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
|
||||
#include <filecontainerv2.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
@@ -33,19 +37,57 @@ namespace ProjectExplorer {
|
||||
class Project;
|
||||
}
|
||||
|
||||
namespace CppTools {
|
||||
class CppModelManager;
|
||||
}
|
||||
|
||||
namespace ClangPchManager {
|
||||
|
||||
class QtCreatorProjectUpdater : public QObject, public ProjectUpdater
|
||||
namespace Internal {
|
||||
CLANGPCHMANAGER_EXPORT CppTools::CppModelManager *cppModelManager();
|
||||
CLANGPCHMANAGER_EXPORT std::vector<ClangBackEnd::V2::FileContainer> createGeneratedFiles();
|
||||
CLANGPCHMANAGER_EXPORT std::vector<CppTools::ProjectPart*> createProjectParts(ProjectExplorer::Project *project);
|
||||
}
|
||||
|
||||
template <typename ProjectUpdaterType>
|
||||
class QtCreatorProjectUpdater : public ProjectUpdaterType
|
||||
{
|
||||
public:
|
||||
QtCreatorProjectUpdater(ClangBackEnd::PchManagerServerInterface &server,
|
||||
PchManagerClient &client);
|
||||
template <typename ClientType>
|
||||
QtCreatorProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server,
|
||||
ClientType &client)
|
||||
: ProjectUpdaterType(server, client)
|
||||
{
|
||||
connectToCppModelManager();
|
||||
}
|
||||
|
||||
void projectPartsUpdated(ProjectExplorer::Project *project);
|
||||
void projectPartsRemoved(const QStringList &projectPartIds);
|
||||
QtCreatorProjectUpdater(ClangBackEnd::ProjectManagementServerInterface &server)
|
||||
: ProjectUpdaterType(server)
|
||||
{
|
||||
connectToCppModelManager();
|
||||
}
|
||||
|
||||
void projectPartsUpdated(ProjectExplorer::Project *project)
|
||||
{
|
||||
ProjectUpdaterType::updateProjectParts(Internal::createProjectParts(project),
|
||||
Internal::createGeneratedFiles());
|
||||
}
|
||||
|
||||
void projectPartsRemoved(const QStringList &projectPartIds)
|
||||
{
|
||||
ProjectUpdaterType::removeProjectParts(projectPartIds);
|
||||
}
|
||||
|
||||
private:
|
||||
void connectToCppModelManager();
|
||||
void connectToCppModelManager()
|
||||
{
|
||||
QObject::connect(Internal::cppModelManager(),
|
||||
&CppTools::CppModelManager::projectPartsUpdated,
|
||||
[&] (ProjectExplorer::Project *project) { projectPartsUpdated(project); });
|
||||
QObject::connect(Internal::cppModelManager(),
|
||||
&CppTools::CppModelManager::projectPartsRemoved,
|
||||
[&] (const QStringList &projectPartIds) { projectPartsRemoved(projectPartIds); });
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ClangPchManager
|
||||
|
||||
Reference in New Issue
Block a user