forked from qt-creator/qt-creator
CppTools: Use only const pointers for ProjectInfo and ProjectPart
All members were already const, but this makes it clear at all points of use that these data structures are immutable. Change-Id: Iea615c090bde462c445d15223caccc561b0c713d Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -255,7 +255,7 @@ void AutoTestUnitTests::testCodeParserBoostTest()
|
|||||||
QFETCH(QString, projectFilePath);
|
QFETCH(QString, projectFilePath);
|
||||||
QFETCH(QString, extension);
|
QFETCH(QString, extension);
|
||||||
CppTools::Tests::ProjectOpenerAndCloser projectManager;
|
CppTools::Tests::ProjectOpenerAndCloser projectManager;
|
||||||
const CppTools::ProjectInfo::Ptr projectInfo
|
const CppTools::ProjectInfo::ConstPtr projectInfo
|
||||||
= projectManager.open(projectFilePath, true, m_kit);
|
= projectManager.open(projectFilePath, true, m_kit);
|
||||||
QVERIFY(projectInfo);
|
QVERIFY(projectInfo);
|
||||||
|
|
||||||
|
@@ -126,10 +126,11 @@ bool BoostTestParser::processDocument(QFutureInterface<TestParseResultPtr> futur
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
const CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
|
const CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
|
||||||
const QList<CppTools::ProjectPart::Ptr> projectParts = modelManager->projectPart(fileName);
|
const QList<CppTools::ProjectPart::ConstPtr> projectParts
|
||||||
|
= modelManager->projectPart(fileName);
|
||||||
if (projectParts.isEmpty()) // happens if shutting down while parsing
|
if (projectParts.isEmpty()) // happens if shutting down while parsing
|
||||||
return false;
|
return false;
|
||||||
const CppTools::ProjectPart::Ptr projectPart = projectParts.first();
|
const CppTools::ProjectPart::ConstPtr projectPart = projectParts.first();
|
||||||
const auto projectFile = Utils::FilePath::fromString(projectPart->projectFile);
|
const auto projectFile = Utils::FilePath::fromString(projectPart->projectFile);
|
||||||
const QByteArray &fileContent = getFileContent(fileName);
|
const QByteArray &fileContent = getFileContent(fileName);
|
||||||
|
|
||||||
|
@@ -133,11 +133,11 @@ bool CatchTestParser::processDocument(QFutureInterface<TestParseResultPtr> futur
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const QList<CppTools::ProjectPart::Ptr> projectParts = modelManager->projectPart(fileName);
|
const QList<CppTools::ProjectPart::ConstPtr> projectParts = modelManager->projectPart(fileName);
|
||||||
if (projectParts.isEmpty()) // happens if shutting down while parsing
|
if (projectParts.isEmpty()) // happens if shutting down while parsing
|
||||||
return false;
|
return false;
|
||||||
Utils::FilePath proFile;
|
Utils::FilePath proFile;
|
||||||
const CppTools::ProjectPart::Ptr projectPart = projectParts.first();
|
const CppTools::ProjectPart::ConstPtr projectPart = projectParts.first();
|
||||||
proFile = Utils::FilePath::fromString(projectPart->projectFile);
|
proFile = Utils::FilePath::fromString(projectPart->projectFile);
|
||||||
|
|
||||||
CatchCodeParser codeParser(fileContent, projectPart->languageFeatures);
|
CatchCodeParser codeParser(fileContent, projectPart->languageFeatures);
|
||||||
|
@@ -116,7 +116,7 @@ bool GTestParser::processDocument(QFutureInterface<TestParseResultPtr> futureInt
|
|||||||
|
|
||||||
const QMap<GTestCaseSpec, GTestCodeLocationList> result = visitor.gtestFunctions();
|
const QMap<GTestCaseSpec, GTestCodeLocationList> result = visitor.gtestFunctions();
|
||||||
Utils::FilePath proFile;
|
Utils::FilePath proFile;
|
||||||
const QList<CppTools::ProjectPart::Ptr> &ppList = modelManager->projectPart(filePath);
|
const QList<CppTools::ProjectPart::ConstPtr> &ppList = modelManager->projectPart(filePath);
|
||||||
if (!ppList.isEmpty())
|
if (!ppList.isEmpty())
|
||||||
proFile = Utils::FilePath::fromString(ppList.first()->projectFile);
|
proFile = Utils::FilePath::fromString(ppList.first()->projectFile);
|
||||||
else
|
else
|
||||||
|
@@ -528,10 +528,10 @@ QSet<QString> internalTargets(const TestTreeItem &item)
|
|||||||
return {};
|
return {};
|
||||||
const Utils::FilePath filePath = item.filePath();
|
const Utils::FilePath filePath = item.filePath();
|
||||||
const QString file = filePath.toString();
|
const QString file = filePath.toString();
|
||||||
const QVector<CppTools::ProjectPart::Ptr> projectParts = projectInfo->projectParts();
|
const QVector<CppTools::ProjectPart::ConstPtr> projectParts = projectInfo->projectParts();
|
||||||
if (projectParts.isEmpty())
|
if (projectParts.isEmpty())
|
||||||
return cppMM->dependingInternalTargets(item.filePath());
|
return cppMM->dependingInternalTargets(item.filePath());
|
||||||
for (const CppTools::ProjectPart::Ptr &projectPart : projectParts) {
|
for (const CppTools::ProjectPart::ConstPtr &projectPart : projectParts) {
|
||||||
if (Utils::FilePath::fromString(projectPart->projectFile) == item.proFile()
|
if (Utils::FilePath::fromString(projectPart->projectFile) == item.proFile()
|
||||||
&& Utils::anyOf(projectPart->files, [&file] (const CppTools::ProjectFile &pf) {
|
&& Utils::anyOf(projectPart->files, [&file] (const CppTools::ProjectFile &pf) {
|
||||||
return pf.path == file;
|
return pf.path == file;
|
||||||
|
@@ -54,7 +54,7 @@ void CppParser::init(const Utils::FilePaths &filesToParse, bool fullParse)
|
|||||||
|
|
||||||
bool CppParser::selectedForBuilding(const Utils::FilePath &fileName)
|
bool CppParser::selectedForBuilding(const Utils::FilePath &fileName)
|
||||||
{
|
{
|
||||||
QList<CppTools::ProjectPart::Ptr> projParts =
|
QList<CppTools::ProjectPart::ConstPtr> projParts =
|
||||||
CppTools::CppModelManager::instance()->projectPart(fileName);
|
CppTools::CppModelManager::instance()->projectPart(fileName);
|
||||||
|
|
||||||
return !projParts.isEmpty() && projParts.at(0)->selectedForBuilding;
|
return !projParts.isEmpty() && projParts.at(0)->selectedForBuilding;
|
||||||
@@ -83,7 +83,7 @@ bool precompiledHeaderContains(const CPlusPlus::Snapshot &snapshot,
|
|||||||
const std::function<bool(const QString &)> &checker)
|
const std::function<bool(const QString &)> &checker)
|
||||||
{
|
{
|
||||||
const CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
|
const CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
|
||||||
const QList<CppTools::ProjectPart::Ptr> projectParts = modelManager->projectPart(filePath);
|
const QList<CppTools::ProjectPart::ConstPtr> projectParts = modelManager->projectPart(filePath);
|
||||||
if (projectParts.isEmpty())
|
if (projectParts.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
const QStringList precompiledHeaders = projectParts.first()->precompiledHeaders;
|
const QStringList precompiledHeaders = projectParts.first()->precompiledHeaders;
|
||||||
|
@@ -92,7 +92,8 @@ bool LoadProjectScenario::loadProject()
|
|||||||
|
|
||||||
CppTools::Tests::ProjectOpenerAndCloser projectManager;
|
CppTools::Tests::ProjectOpenerAndCloser projectManager;
|
||||||
// This code must trigger a call to PluginManager::finishScenario() at some later point.
|
// This code must trigger a call to PluginManager::finishScenario() at some later point.
|
||||||
const CppTools::ProjectInfo::Ptr projectInfo = projectManager.open(projectFilePath, true, m_kit);
|
const CppTools::ProjectInfo::ConstPtr projectInfo = projectManager.open(projectFilePath,
|
||||||
|
true, m_kit);
|
||||||
return projectInfo.get();
|
return projectInfo.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -93,7 +93,7 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CPlusPlus:
|
|||||||
|
|
||||||
static bool qtTestLibDefined(const Utils::FilePath &fileName)
|
static bool qtTestLibDefined(const Utils::FilePath &fileName)
|
||||||
{
|
{
|
||||||
const QList<CppTools::ProjectPart::Ptr> parts =
|
const QList<CppTools::ProjectPart::ConstPtr> parts =
|
||||||
CppTools::CppModelManager::instance()->projectPart(fileName);
|
CppTools::CppModelManager::instance()->projectPart(fileName);
|
||||||
if (parts.size() > 0) {
|
if (parts.size() > 0) {
|
||||||
return Utils::anyOf(parts.at(0)->projectMacros, [] (const ProjectExplorer::Macro ¯o) {
|
return Utils::anyOf(parts.at(0)->projectMacros, [] (const ProjectExplorer::Macro ¯o) {
|
||||||
@@ -327,7 +327,8 @@ bool QtTestParser::processDocument(QFutureInterface<TestParseResultPtr> futureIn
|
|||||||
if (earlyReturn.has_value() || !data.valid)
|
if (earlyReturn.has_value() || !data.valid)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QList<CppTools::ProjectPart::Ptr> projectParts = modelManager->projectPart(fileName);
|
QList<CppTools::ProjectPart::ConstPtr> projectParts
|
||||||
|
= modelManager->projectPart(fileName);
|
||||||
if (projectParts.isEmpty()) // happens if shutting down while parsing
|
if (projectParts.isEmpty()) // happens if shutting down while parsing
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@@ -101,7 +101,7 @@ static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc,
|
|||||||
static QString quickTestSrcDir(const CppTools::CppModelManager *cppMM,
|
static QString quickTestSrcDir(const CppTools::CppModelManager *cppMM,
|
||||||
const Utils::FilePath &fileName)
|
const Utils::FilePath &fileName)
|
||||||
{
|
{
|
||||||
const QList<CppTools::ProjectPart::Ptr> parts = cppMM->projectPart(fileName);
|
const QList<CppTools::ProjectPart::ConstPtr> parts = cppMM->projectPart(fileName);
|
||||||
if (parts.size() > 0) {
|
if (parts.size() > 0) {
|
||||||
const ProjectExplorer::Macros ¯os = parts.at(0)->projectMacros;
|
const ProjectExplorer::Macros ¯os = parts.at(0)->projectMacros;
|
||||||
auto found = std::find_if(
|
auto found = std::find_if(
|
||||||
@@ -267,7 +267,7 @@ bool QuickTestParser::handleQtQuickTest(QFutureInterface<TestParseResultPtr> fut
|
|||||||
if (quickTestName(document).isEmpty())
|
if (quickTestName(document).isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QList<CppTools::ProjectPart::Ptr> ppList = modelManager->projectPart(document->fileName());
|
QList<CppTools::ProjectPart::ConstPtr> ppList = modelManager->projectPart(document->fileName());
|
||||||
if (ppList.isEmpty()) // happens if shutting down while parsing
|
if (ppList.isEmpty()) // happens if shutting down while parsing
|
||||||
return false;
|
return false;
|
||||||
const Utils::FilePath cppFileName = Utils::FilePath::fromString(document->fileName());
|
const Utils::FilePath cppFileName = Utils::FilePath::fromString(document->fileName());
|
||||||
|
@@ -391,7 +391,7 @@ QSet<QString> internalTargets(const Utils::FilePath &proFile)
|
|||||||
const auto projectInfo = cppMM->projectInfo(ProjectExplorer::SessionManager::startupProject());
|
const auto projectInfo = cppMM->projectInfo(ProjectExplorer::SessionManager::startupProject());
|
||||||
if (!projectInfo)
|
if (!projectInfo)
|
||||||
return {};
|
return {};
|
||||||
for (const CppTools::ProjectPart::Ptr &projectPart : projectInfo->projectParts()) {
|
for (const CppTools::ProjectPart::ConstPtr &projectPart : projectInfo->projectParts()) {
|
||||||
if (projectPart->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
|
if (projectPart->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
|
||||||
continue;
|
continue;
|
||||||
if (projectPart->projectFile == proFile.toString())
|
if (projectPart->projectFile == proFile.toString())
|
||||||
|
@@ -90,11 +90,11 @@ static void extractAllFiles(const DebuggerRunTool *runTool, QStringList &include
|
|||||||
FilePaths &headers, FilePaths &sources, FilePaths &assemblers)
|
FilePaths &headers, FilePaths &sources, FilePaths &assemblers)
|
||||||
{
|
{
|
||||||
const auto project = runTool->runControl()->project();
|
const auto project = runTool->runControl()->project();
|
||||||
const CppTools::ProjectInfo::Ptr info = CppModelManager::instance()->projectInfo(project);
|
const CppTools::ProjectInfo::ConstPtr info = CppModelManager::instance()->projectInfo(project);
|
||||||
if (!info)
|
if (!info)
|
||||||
return;
|
return;
|
||||||
const QVector<ProjectPart::Ptr> parts = info->projectParts();
|
const QVector<ProjectPart::ConstPtr> parts = info->projectParts();
|
||||||
for (const ProjectPart::Ptr &part : parts) {
|
for (const ProjectPart::ConstPtr &part : parts) {
|
||||||
for (const ProjectFile &file : qAsConst(part->files)) {
|
for (const ProjectFile &file : qAsConst(part->files)) {
|
||||||
if (!file.active)
|
if (!file.active)
|
||||||
continue;
|
continue;
|
||||||
|
@@ -94,7 +94,7 @@ static bool isDBGenerationEnabled(ProjectExplorer::Project *project)
|
|||||||
using namespace CppTools;
|
using namespace CppTools;
|
||||||
if (!project)
|
if (!project)
|
||||||
return false;
|
return false;
|
||||||
const ProjectInfo::Ptr projectInfo = CppModelManager::instance()->projectInfo(project);
|
const ProjectInfo::ConstPtr projectInfo = CppModelManager::instance()->projectInfo(project);
|
||||||
return projectInfo && !projectInfo->projectParts().isEmpty();
|
return projectInfo && !projectInfo->projectParts().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -66,7 +66,7 @@ TextEditor::AssistInterface *ClangCompletionAssistProvider::createAssistInterfac
|
|||||||
int position,
|
int position,
|
||||||
TextEditor::AssistReason reason) const
|
TextEditor::AssistReason reason) const
|
||||||
{
|
{
|
||||||
const CppTools::ProjectPart::Ptr projectPart = projectPartForFileBasedOnProcessor(
|
const CppTools::ProjectPart::ConstPtr projectPart = projectPartForFileBasedOnProcessor(
|
||||||
filePath.toString());
|
filePath.toString());
|
||||||
if (projectPart) {
|
if (projectPart) {
|
||||||
return new ClangCompletionAssistInterface(m_communicator,
|
return new ClangCompletionAssistInterface(m_communicator,
|
||||||
|
@@ -171,7 +171,7 @@ bool ClangEditorDocumentProcessor::hasProjectPart() const
|
|||||||
return !m_projectPart.isNull();
|
return !m_projectPart.isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
CppTools::ProjectPart::Ptr ClangEditorDocumentProcessor::projectPart() const
|
CppTools::ProjectPart::ConstPtr ClangEditorDocumentProcessor::projectPart() const
|
||||||
{
|
{
|
||||||
return m_projectPart;
|
return m_projectPart;
|
||||||
}
|
}
|
||||||
@@ -421,7 +421,7 @@ ClangEditorDocumentProcessor *ClangEditorDocumentProcessor::get(const QString &f
|
|||||||
return qobject_cast<ClangEditorDocumentProcessor*>(processor);
|
return qobject_cast<ClangEditorDocumentProcessor*>(processor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isProjectPartLoadedOrIsFallback(CppTools::ProjectPart::Ptr projectPart)
|
static bool isProjectPartLoadedOrIsFallback(CppTools::ProjectPart::ConstPtr projectPart)
|
||||||
{
|
{
|
||||||
return projectPart
|
return projectPart
|
||||||
&& (projectPart->id().isEmpty() || isProjectPartLoaded(projectPart));
|
&& (projectPart->id().isEmpty() || isProjectPartLoaded(projectPart));
|
||||||
@@ -429,7 +429,7 @@ static bool isProjectPartLoadedOrIsFallback(CppTools::ProjectPart::Ptr projectPa
|
|||||||
|
|
||||||
void ClangEditorDocumentProcessor::updateBackendProjectPartAndDocument()
|
void ClangEditorDocumentProcessor::updateBackendProjectPartAndDocument()
|
||||||
{
|
{
|
||||||
const CppTools::ProjectPart::Ptr projectPart = m_parser->projectPartInfo().projectPart;
|
const CppTools::ProjectPart::ConstPtr projectPart = m_parser->projectPartInfo().projectPart;
|
||||||
|
|
||||||
if (isProjectPartLoadedOrIsFallback(projectPart)) {
|
if (isProjectPartLoadedOrIsFallback(projectPart)) {
|
||||||
updateBackendDocument(*projectPart.data());
|
updateBackendDocument(*projectPart.data());
|
||||||
@@ -448,7 +448,7 @@ void ClangEditorDocumentProcessor::onParserFinished()
|
|||||||
updateBackendProjectPartAndDocument();
|
updateBackendProjectPartAndDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangEditorDocumentProcessor::updateBackendDocument(CppTools::ProjectPart &projectPart)
|
void ClangEditorDocumentProcessor::updateBackendDocument(const CppTools::ProjectPart &projectPart)
|
||||||
{
|
{
|
||||||
// On registration we send the document content immediately as an unsaved
|
// On registration we send the document content immediately as an unsaved
|
||||||
// file, because
|
// file, because
|
||||||
|
@@ -67,7 +67,7 @@ public:
|
|||||||
bool isParserRunning() const override;
|
bool isParserRunning() const override;
|
||||||
|
|
||||||
bool hasProjectPart() const;
|
bool hasProjectPart() const;
|
||||||
CppTools::ProjectPart::Ptr projectPart() const;
|
CppTools::ProjectPart::ConstPtr projectPart() const;
|
||||||
void clearProjectPart();
|
void clearProjectPart();
|
||||||
|
|
||||||
::Utils::Id diagnosticConfigId() const;
|
::Utils::Id diagnosticConfigId() const;
|
||||||
@@ -120,7 +120,7 @@ private:
|
|||||||
void onParserFinished();
|
void onParserFinished();
|
||||||
|
|
||||||
void updateBackendProjectPartAndDocument();
|
void updateBackendProjectPartAndDocument();
|
||||||
void updateBackendDocument(CppTools::ProjectPart &projectPart);
|
void updateBackendDocument(const CppTools::ProjectPart &projectPart);
|
||||||
void updateBackendDocumentIfProjectPartExists();
|
void updateBackendDocumentIfProjectPartExists();
|
||||||
void requestAnnotationsFromBackend();
|
void requestAnnotationsFromBackend();
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ private:
|
|||||||
ClangDiagnosticManager m_diagnosticManager;
|
ClangDiagnosticManager m_diagnosticManager;
|
||||||
BackendCommunicator &m_communicator;
|
BackendCommunicator &m_communicator;
|
||||||
QSharedPointer<ClangEditorDocumentParser> m_parser;
|
QSharedPointer<ClangEditorDocumentParser> m_parser;
|
||||||
CppTools::ProjectPart::Ptr m_projectPart;
|
CppTools::ProjectPart::ConstPtr m_projectPart;
|
||||||
::Utils::Id m_diagnosticConfigId;
|
::Utils::Id m_diagnosticConfigId;
|
||||||
bool m_isProjectFile = false;
|
bool m_isProjectFile = false;
|
||||||
QFutureWatcher<void> m_parserWatcher;
|
QFutureWatcher<void> m_parserWatcher;
|
||||||
|
@@ -274,8 +274,8 @@ void ClangModelManagerSupport::connectToWidgetsMarkContextMenuRequested(QWidget
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangModelManagerSupport::updateLanguageClient(ProjectExplorer::Project *project,
|
void ClangModelManagerSupport::updateLanguageClient(
|
||||||
const CppTools::ProjectInfo::Ptr &projectInfo)
|
ProjectExplorer::Project *project, const CppTools::ProjectInfo::ConstPtr &projectInfo)
|
||||||
{
|
{
|
||||||
if (!CppTools::ClangdProjectSettings(project).settings().useClangd)
|
if (!CppTools::ClangdProjectSettings(project).settings().useClangd)
|
||||||
return;
|
return;
|
||||||
@@ -300,7 +300,8 @@ void ClangModelManagerSupport::updateLanguageClient(ProjectExplorer::Project *pr
|
|||||||
return;
|
return;
|
||||||
if (!CppTools::ClangdProjectSettings(project).settings().useClangd)
|
if (!CppTools::ClangdProjectSettings(project).settings().useClangd)
|
||||||
return;
|
return;
|
||||||
const CppTools::ProjectInfo::Ptr newProjectInfo = cppModelManager()->projectInfo(project);
|
const CppTools::ProjectInfo::ConstPtr newProjectInfo
|
||||||
|
= cppModelManager()->projectInfo(project);
|
||||||
if (!newProjectInfo || *newProjectInfo != *projectInfo)
|
if (!newProjectInfo || *newProjectInfo != *projectInfo)
|
||||||
return;
|
return;
|
||||||
if (getJsonDbDir() != jsonDbDir)
|
if (getJsonDbDir() != jsonDbDir)
|
||||||
@@ -321,7 +322,7 @@ void ClangModelManagerSupport::updateLanguageClient(ProjectExplorer::Project *pr
|
|||||||
return;
|
return;
|
||||||
if (!CppTools::ClangdProjectSettings(project).settings().useClangd)
|
if (!CppTools::ClangdProjectSettings(project).settings().useClangd)
|
||||||
return;
|
return;
|
||||||
const CppTools::ProjectInfo::Ptr newProjectInfo
|
const CppTools::ProjectInfo::ConstPtr newProjectInfo
|
||||||
= cppModelManager()->projectInfo(project);
|
= cppModelManager()->projectInfo(project);
|
||||||
if (!newProjectInfo || *newProjectInfo != *projectInfo)
|
if (!newProjectInfo || *newProjectInfo != *projectInfo)
|
||||||
return;
|
return;
|
||||||
@@ -615,13 +616,13 @@ void ClangModelManagerSupport::onAboutToRemoveProject(ProjectExplorer::Project *
|
|||||||
void ClangModelManagerSupport::onProjectPartsUpdated(ProjectExplorer::Project *project)
|
void ClangModelManagerSupport::onProjectPartsUpdated(ProjectExplorer::Project *project)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(project, return);
|
QTC_ASSERT(project, return);
|
||||||
const CppTools::ProjectInfo::Ptr projectInfo = cppModelManager()->projectInfo(project);
|
const CppTools::ProjectInfo::ConstPtr projectInfo = cppModelManager()->projectInfo(project);
|
||||||
QTC_ASSERT(projectInfo, return);
|
QTC_ASSERT(projectInfo, return);
|
||||||
|
|
||||||
updateLanguageClient(project, projectInfo);
|
updateLanguageClient(project, projectInfo);
|
||||||
|
|
||||||
QStringList projectPartIds;
|
QStringList projectPartIds;
|
||||||
for (const CppTools::ProjectPart::Ptr &projectPart : projectInfo->projectParts())
|
for (const CppTools::ProjectPart::ConstPtr &projectPart : projectInfo->projectParts())
|
||||||
projectPartIds.append(projectPart->id());
|
projectPartIds.append(projectPart->id());
|
||||||
onProjectPartsRemoved(projectPartIds);
|
onProjectPartsRemoved(projectPartIds);
|
||||||
}
|
}
|
||||||
|
@@ -130,7 +130,7 @@ private:
|
|||||||
void connectToWidgetsMarkContextMenuRequested(QWidget *editorWidget);
|
void connectToWidgetsMarkContextMenuRequested(QWidget *editorWidget);
|
||||||
|
|
||||||
void updateLanguageClient(ProjectExplorer::Project *project,
|
void updateLanguageClient(ProjectExplorer::Project *project,
|
||||||
const CppTools::ProjectInfo::Ptr &projectInfo);
|
const CppTools::ProjectInfo::ConstPtr &projectInfo);
|
||||||
ClangdClient *createClient(ProjectExplorer::Project *project, const Utils::FilePath &jsonDbDir);
|
ClangdClient *createClient(ProjectExplorer::Project *project, const Utils::FilePath &jsonDbDir);
|
||||||
void claimNonProjectSources(ClangdClient *fallbackClient);
|
void claimNonProjectSources(ClangdClient *fallbackClient);
|
||||||
|
|
||||||
|
@@ -39,7 +39,7 @@ namespace ClangCodeModel {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
void RefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &data,
|
void RefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &data,
|
||||||
CppTools::ProjectPart *,
|
const CppTools::ProjectPart *,
|
||||||
RenameCallback &&renameSymbolsCallback)
|
RenameCallback &&renameSymbolsCallback)
|
||||||
{
|
{
|
||||||
ClangdClient * const client
|
ClangdClient * const client
|
||||||
|
@@ -42,7 +42,7 @@ class RefactoringEngine : public CppTools::RefactoringEngineInterface
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void startLocalRenaming(const CppTools::CursorInEditor &data,
|
void startLocalRenaming(const CppTools::CursorInEditor &data,
|
||||||
CppTools::ProjectPart *projectPart,
|
const CppTools::ProjectPart *projectPart,
|
||||||
RenameCallback &&renameSymbolsCallback) override;
|
RenameCallback &&renameSymbolsCallback) override;
|
||||||
void globalRename(const CppTools::CursorInEditor &cursor, CppTools::UsagesCallback &&callback,
|
void globalRename(const CppTools::CursorInEditor &cursor, CppTools::UsagesCallback &&callback,
|
||||||
const QString &replacement) override;
|
const QString &replacement) override;
|
||||||
|
@@ -87,7 +87,7 @@ ProjectExplorer::Project *projectForCurrentEditor()
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (auto processor = ClangEditorDocumentProcessor::get(filePath)) {
|
if (auto processor = ClangEditorDocumentProcessor::get(filePath)) {
|
||||||
if (ProjectPart::Ptr projectPart = processor->projectPart())
|
if (ProjectPart::ConstPtr projectPart = processor->projectPart())
|
||||||
return projectForProjectPart(*projectPart);
|
return projectForProjectPart(*projectPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -109,21 +109,21 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ProjectPart::Ptr projectPartForFile(const QString &filePath)
|
ProjectPart::ConstPtr projectPartForFile(const QString &filePath)
|
||||||
{
|
{
|
||||||
if (const auto parser = CppTools::BaseEditorDocumentParser::get(filePath))
|
if (const auto parser = CppTools::BaseEditorDocumentParser::get(filePath))
|
||||||
return parser->projectPartInfo().projectPart;
|
return parser->projectPartInfo().projectPart;
|
||||||
return ProjectPart::Ptr();
|
return ProjectPart::ConstPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectPart::Ptr projectPartForFileBasedOnProcessor(const QString &filePath)
|
ProjectPart::ConstPtr projectPartForFileBasedOnProcessor(const QString &filePath)
|
||||||
{
|
{
|
||||||
if (const auto processor = ClangEditorDocumentProcessor::get(filePath))
|
if (const auto processor = ClangEditorDocumentProcessor::get(filePath))
|
||||||
return processor->projectPart();
|
return processor->projectPart();
|
||||||
return ProjectPart::Ptr();
|
return ProjectPart::ConstPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isProjectPartLoaded(const ProjectPart::Ptr projectPart)
|
bool isProjectPartLoaded(const ProjectPart::ConstPtr projectPart)
|
||||||
{
|
{
|
||||||
if (projectPart)
|
if (projectPart)
|
||||||
return !CppModelManager::instance()->projectPartForId(projectPart->id()).isNull();
|
return !CppModelManager::instance()->projectPartForId(projectPart->id()).isNull();
|
||||||
@@ -132,7 +132,7 @@ bool isProjectPartLoaded(const ProjectPart::Ptr projectPart)
|
|||||||
|
|
||||||
QString projectPartIdForFile(const QString &filePath)
|
QString projectPartIdForFile(const QString &filePath)
|
||||||
{
|
{
|
||||||
const ProjectPart::Ptr projectPart = projectPartForFile(filePath);
|
const ProjectPart::ConstPtr projectPart = projectPartForFile(filePath);
|
||||||
|
|
||||||
if (isProjectPartLoaded(projectPart))
|
if (isProjectPartLoaded(projectPart))
|
||||||
return projectPart->id(); // OK, Project Part is still loaded
|
return projectPart->id(); // OK, Project Part is still loaded
|
||||||
@@ -371,7 +371,7 @@ static QJsonObject createFileObject(const FilePath &buildDir,
|
|||||||
return fileObject;
|
return fileObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
GenerateCompilationDbResult generateCompilationDB(const CppTools::ProjectInfo::Ptr projectInfo,
|
GenerateCompilationDbResult generateCompilationDB(const CppTools::ProjectInfo::ConstPtr projectInfo,
|
||||||
CompilationDbPurpose purpose,
|
CompilationDbPurpose purpose,
|
||||||
const ClangDiagnosticConfig &warningsConfig,
|
const ClangDiagnosticConfig &warningsConfig,
|
||||||
const QStringList &projectOptions)
|
const QStringList &projectOptions)
|
||||||
@@ -392,7 +392,7 @@ GenerateCompilationDbResult generateCompilationDB(const CppTools::ProjectInfo::P
|
|||||||
}
|
}
|
||||||
compileCommandsFile.write("[");
|
compileCommandsFile.write("[");
|
||||||
|
|
||||||
for (ProjectPart::Ptr projectPart : projectInfo->projectParts()) {
|
for (ProjectPart::ConstPtr projectPart : projectInfo->projectParts()) {
|
||||||
QStringList args;
|
QStringList args;
|
||||||
if (purpose == CompilationDbPurpose::Project)
|
if (purpose == CompilationDbPurpose::Project)
|
||||||
args = projectPartArguments(*projectPart);
|
args = projectPartArguments(*projectPart);
|
||||||
|
@@ -61,9 +61,9 @@ QStringList createClangOptions(const CppTools::ProjectPart &projectPart, const Q
|
|||||||
const CppTools::ClangDiagnosticConfig &warningsConfig,
|
const CppTools::ClangDiagnosticConfig &warningsConfig,
|
||||||
const QStringList &projectOptions);
|
const QStringList &projectOptions);
|
||||||
|
|
||||||
CppTools::ProjectPart::Ptr projectPartForFile(const QString &filePath);
|
CppTools::ProjectPart::ConstPtr projectPartForFile(const QString &filePath);
|
||||||
CppTools::ProjectPart::Ptr projectPartForFileBasedOnProcessor(const QString &filePath);
|
CppTools::ProjectPart::ConstPtr projectPartForFileBasedOnProcessor(const QString &filePath);
|
||||||
bool isProjectPartLoaded(const CppTools::ProjectPart::Ptr projectPart);
|
bool isProjectPartLoaded(const CppTools::ProjectPart::ConstPtr projectPart);
|
||||||
QString projectPartIdForFile(const QString &filePath);
|
QString projectPartIdForFile(const QString &filePath);
|
||||||
int clangColumn(const QTextBlock &line, int cppEditorColumn);
|
int clangColumn(const QTextBlock &line, int cppEditorColumn);
|
||||||
int cppEditorColumn(const QTextBlock &line, int clangColumn);
|
int cppEditorColumn(const QTextBlock &line, int clangColumn);
|
||||||
@@ -87,7 +87,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum class CompilationDbPurpose { Project, CodeModel };
|
enum class CompilationDbPurpose { Project, CodeModel };
|
||||||
GenerateCompilationDbResult generateCompilationDB(const CppTools::ProjectInfo::Ptr projectInfo,
|
GenerateCompilationDbResult generateCompilationDB(const CppTools::ProjectInfo::ConstPtr projectInfo,
|
||||||
CompilationDbPurpose purpose, const CppTools::ClangDiagnosticConfig &warningsConfig,
|
CompilationDbPurpose purpose, const CppTools::ClangDiagnosticConfig &warningsConfig,
|
||||||
const QStringList &projectOptions);
|
const QStringList &projectOptions);
|
||||||
|
|
||||||
|
@@ -246,7 +246,7 @@ bool OpenEditorAtCursorPosition::waitUntil(const std::function<bool ()> &conditi
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CppTools::ProjectPart::Ptr createProjectPart(const Utils::FilePath &projectFilePath,
|
CppTools::ProjectPart::ConstPtr createProjectPart(const Utils::FilePath &projectFilePath,
|
||||||
const QStringList &files,
|
const QStringList &files,
|
||||||
const ProjectExplorer::Macros ¯os)
|
const ProjectExplorer::Macros ¯os)
|
||||||
{
|
{
|
||||||
@@ -262,15 +262,15 @@ CppTools::ProjectPart::Ptr createProjectPart(const Utils::FilePath &projectFileP
|
|||||||
return ProjectPart::create(projectFilePath, rpp, {}, projectFiles);
|
return ProjectPart::create(projectFilePath, rpp, {}, projectFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
CppTools::ProjectInfo::Ptr createProjectInfo(ProjectExplorer::Project *project,
|
CppTools::ProjectInfo::ConstPtr createProjectInfo(ProjectExplorer::Project *project,
|
||||||
const QStringList &files,
|
const QStringList &files,
|
||||||
const ProjectExplorer::Macros ¯os)
|
const ProjectExplorer::Macros ¯os)
|
||||||
{
|
{
|
||||||
using namespace CppTools;
|
using namespace CppTools;
|
||||||
QTC_ASSERT(project, return {});
|
QTC_ASSERT(project, return {});
|
||||||
|
|
||||||
const CppTools::ProjectPart::Ptr projectPart = createProjectPart(project->projectFilePath(),
|
const CppTools::ProjectPart::ConstPtr projectPart
|
||||||
files, macros);
|
= createProjectPart(project->projectFilePath(), files, macros);
|
||||||
const auto projectInfo = ProjectInfo::create(
|
const auto projectInfo = ProjectInfo::create(
|
||||||
{project, ProjectExplorer::KitInfo(nullptr), {}, {}}, {projectPart});
|
{project, ProjectExplorer::KitInfo(nullptr), {}, {}}, {projectPart});
|
||||||
return projectInfo;
|
return projectInfo;
|
||||||
@@ -292,7 +292,7 @@ public:
|
|||||||
bool load()
|
bool load()
|
||||||
{
|
{
|
||||||
m_project = m_helper.createProject(QLatin1String("testProject"));
|
m_project = m_helper.createProject(QLatin1String("testProject"));
|
||||||
const CppTools::ProjectInfo::Ptr projectInfo = createProjectInfo(m_project,
|
const CppTools::ProjectInfo::ConstPtr projectInfo = createProjectInfo(m_project,
|
||||||
m_projectFiles,
|
m_projectFiles,
|
||||||
m_projectMacros);
|
m_projectMacros);
|
||||||
const QSet<QString> filesIndexedAfterLoading = m_helper.updateProjectInfo(projectInfo);
|
const QSet<QString> filesIndexedAfterLoading = m_helper.updateProjectInfo(projectInfo);
|
||||||
@@ -302,14 +302,14 @@ public:
|
|||||||
bool updateProject(const ProjectExplorer::Macros &updatedProjectMacros)
|
bool updateProject(const ProjectExplorer::Macros &updatedProjectMacros)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_project, return false);
|
QTC_ASSERT(m_project, return false);
|
||||||
const CppTools::ProjectInfo::Ptr updatedProjectInfo
|
const CppTools::ProjectInfo::ConstPtr updatedProjectInfo
|
||||||
= createProjectInfo(m_project, m_projectFiles, updatedProjectMacros);
|
= createProjectInfo(m_project, m_projectFiles, updatedProjectMacros);
|
||||||
return updateProjectInfo(updatedProjectInfo);
|
return updateProjectInfo(updatedProjectInfo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool updateProjectInfo(const CppTools::ProjectInfo::Ptr &projectInfo)
|
bool updateProjectInfo(const CppTools::ProjectInfo::ConstPtr &projectInfo)
|
||||||
{
|
{
|
||||||
const QSet<QString> filesIndexedAfterLoading = m_helper.updateProjectInfo(projectInfo);
|
const QSet<QString> filesIndexedAfterLoading = m_helper.updateProjectInfo(projectInfo);
|
||||||
return m_projectFiles.size() == filesIndexedAfterLoading.size();
|
return m_projectFiles.size() == filesIndexedAfterLoading.size();
|
||||||
|
@@ -41,14 +41,14 @@ public:
|
|||||||
FileInfo() = default;
|
FileInfo() = default;
|
||||||
FileInfo(Utils::FilePath file,
|
FileInfo(Utils::FilePath file,
|
||||||
CppTools::ProjectFile::Kind kind,
|
CppTools::ProjectFile::Kind kind,
|
||||||
CppTools::ProjectPart::Ptr projectPart)
|
CppTools::ProjectPart::ConstPtr projectPart)
|
||||||
: file(std::move(file))
|
: file(std::move(file))
|
||||||
, kind(kind)
|
, kind(kind)
|
||||||
, projectPart(projectPart)
|
, projectPart(projectPart)
|
||||||
{}
|
{}
|
||||||
Utils::FilePath file;
|
Utils::FilePath file;
|
||||||
CppTools::ProjectFile::Kind kind;
|
CppTools::ProjectFile::Kind kind;
|
||||||
CppTools::ProjectPart::Ptr projectPart;
|
CppTools::ProjectPart::ConstPtr projectPart;
|
||||||
};
|
};
|
||||||
using FileInfos = std::vector<FileInfo>;
|
using FileInfos = std::vector<FileInfo>;
|
||||||
|
|
||||||
|
@@ -325,11 +325,11 @@ private:
|
|||||||
QMap<Utils::FilePath, RefactoringFileInfo> m_refactoringFileInfos;
|
QMap<Utils::FilePath, RefactoringFileInfo> m_refactoringFileInfos;
|
||||||
};
|
};
|
||||||
|
|
||||||
static FileInfos sortedFileInfos(const QVector<CppTools::ProjectPart::Ptr> &projectParts)
|
static FileInfos sortedFileInfos(const QVector<CppTools::ProjectPart::ConstPtr> &projectParts)
|
||||||
{
|
{
|
||||||
FileInfos fileInfos;
|
FileInfos fileInfos;
|
||||||
|
|
||||||
for (const CppTools::ProjectPart::Ptr &projectPart : projectParts) {
|
for (const CppTools::ProjectPart::ConstPtr &projectPart : projectParts) {
|
||||||
QTC_ASSERT(projectPart, continue);
|
QTC_ASSERT(projectPart, continue);
|
||||||
if (!projectPart->selectedForBuilding)
|
if (!projectPart->selectedForBuilding)
|
||||||
continue;
|
continue;
|
||||||
|
@@ -114,8 +114,8 @@ private:
|
|||||||
Utils::Environment m_environment;
|
Utils::Environment m_environment;
|
||||||
Utils::TemporaryDirectory m_temporaryDir;
|
Utils::TemporaryDirectory m_temporaryDir;
|
||||||
|
|
||||||
CppTools::ProjectInfo::Ptr m_projectInfoBeforeBuild;
|
CppTools::ProjectInfo::ConstPtr m_projectInfoBeforeBuild;
|
||||||
CppTools::ProjectInfo::Ptr m_projectInfo;
|
CppTools::ProjectInfo::ConstPtr m_projectInfo;
|
||||||
QString m_targetTriple;
|
QString m_targetTriple;
|
||||||
Utils::Id m_toolChainType;
|
Utils::Id m_toolChainType;
|
||||||
|
|
||||||
|
@@ -141,12 +141,12 @@ static VirtualFileSystemOverlay &vfso()
|
|||||||
|
|
||||||
static FileInfo getFileInfo(const FilePath &file, Project *project)
|
static FileInfo getFileInfo(const FilePath &file, Project *project)
|
||||||
{
|
{
|
||||||
const ProjectInfo::Ptr projectInfo = CppModelManager::instance()->projectInfo(project);
|
const ProjectInfo::ConstPtr projectInfo = CppModelManager::instance()->projectInfo(project);
|
||||||
if (!projectInfo)
|
if (!projectInfo)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
FileInfo candidate;
|
FileInfo candidate;
|
||||||
for (const ProjectPart::Ptr &projectPart : projectInfo->projectParts()) {
|
for (const ProjectPart::ConstPtr &projectPart : projectInfo->projectParts()) {
|
||||||
QTC_ASSERT(projectPart, continue);
|
QTC_ASSERT(projectPart, continue);
|
||||||
|
|
||||||
for (const ProjectFile &projectFile : qAsConst(projectPart->files)) {
|
for (const ProjectFile &projectFile : qAsConst(projectPart->files)) {
|
||||||
|
@@ -77,13 +77,13 @@ void CompilationDatabaseTests::testProject()
|
|||||||
QFETCH(QString, projectFilePath);
|
QFETCH(QString, projectFilePath);
|
||||||
|
|
||||||
CppTools::Tests::ProjectOpenerAndCloser projectManager;
|
CppTools::Tests::ProjectOpenerAndCloser projectManager;
|
||||||
const CppTools::ProjectInfo::Ptr projectInfo = projectManager.open(projectFilePath, true);
|
const CppTools::ProjectInfo::ConstPtr projectInfo = projectManager.open(projectFilePath, true);
|
||||||
QVERIFY(projectInfo);
|
QVERIFY(projectInfo);
|
||||||
|
|
||||||
QVector<CppTools::ProjectPart::Ptr> projectParts = projectInfo->projectParts();
|
QVector<CppTools::ProjectPart::ConstPtr> projectParts = projectInfo->projectParts();
|
||||||
QVERIFY(!projectParts.isEmpty());
|
QVERIFY(!projectParts.isEmpty());
|
||||||
|
|
||||||
CppTools::ProjectPart &projectPart = *projectParts.first();
|
const CppTools::ProjectPart &projectPart = *projectParts.first();
|
||||||
QVERIFY(!projectPart.headerPaths.isEmpty());
|
QVERIFY(!projectPart.headerPaths.isEmpty());
|
||||||
QVERIFY(!projectPart.projectMacros.isEmpty());
|
QVERIFY(!projectPart.projectMacros.isEmpty());
|
||||||
QVERIFY(!projectPart.toolChainMacros.isEmpty());
|
QVERIFY(!projectPart.toolChainMacros.isEmpty());
|
||||||
|
@@ -204,21 +204,21 @@ void CppcheckTool::check(const Utils::FilePaths &files)
|
|||||||
if (filtered.isEmpty())
|
if (filtered.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const CppTools::ProjectInfo::Ptr info
|
const CppTools::ProjectInfo::ConstPtr info
|
||||||
= CppTools::CppModelManager::instance()->projectInfo(m_project);
|
= CppTools::CppModelManager::instance()->projectInfo(m_project);
|
||||||
if (!info)
|
if (!info)
|
||||||
return;
|
return;
|
||||||
const QVector<CppTools::ProjectPart::Ptr> parts = info->projectParts();
|
const QVector<CppTools::ProjectPart::ConstPtr> parts = info->projectParts();
|
||||||
if (parts.size() == 1) {
|
if (parts.size() == 1) {
|
||||||
QTC_ASSERT(parts.first(), return);
|
QTC_ASSERT(parts.first(), return);
|
||||||
addToQueue(filtered, *parts.first());
|
addToQueue(filtered, *parts.first());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<CppTools::ProjectPart::Ptr, Utils::FilePaths> groups;
|
std::map<CppTools::ProjectPart::ConstPtr, Utils::FilePaths> groups;
|
||||||
for (const Utils::FilePath &file : qAsConst(filtered)) {
|
for (const Utils::FilePath &file : qAsConst(filtered)) {
|
||||||
const QString stringed = file.toString();
|
const QString stringed = file.toString();
|
||||||
for (const CppTools::ProjectPart::Ptr &part : parts) {
|
for (const CppTools::ProjectPart::ConstPtr &part : parts) {
|
||||||
using CppTools::ProjectFile;
|
using CppTools::ProjectFile;
|
||||||
QTC_ASSERT(part, continue);
|
QTC_ASSERT(part, continue);
|
||||||
const auto match = [stringed](const ProjectFile &pFile){return pFile.path == stringed;};
|
const auto match = [stringed](const ProjectFile &pFile){return pFile.path == stringed;};
|
||||||
@@ -231,7 +231,7 @@ void CppcheckTool::check(const Utils::FilePaths &files)
|
|||||||
addToQueue(group.second, *group.first);
|
addToQueue(group.second, *group.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppcheckTool::addToQueue(const Utils::FilePaths &files, CppTools::ProjectPart &part)
|
void CppcheckTool::addToQueue(const Utils::FilePaths &files, const CppTools::ProjectPart &part)
|
||||||
{
|
{
|
||||||
const QString key = part.id();
|
const QString key = part.id();
|
||||||
if (!m_cachedAdditionalArguments.contains(key))
|
if (!m_cachedAdditionalArguments.contains(key))
|
||||||
|
@@ -75,7 +75,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void updateArguments();
|
void updateArguments();
|
||||||
void addToQueue(const Utils::FilePaths &files, CppTools::ProjectPart &part);
|
void addToQueue(const Utils::FilePaths &files, const CppTools::ProjectPart &part);
|
||||||
QStringList additionalArguments(const CppTools::ProjectPart &part) const;
|
QStringList additionalArguments(const CppTools::ProjectPart &part) const;
|
||||||
|
|
||||||
CppcheckDiagnosticManager &m_manager;
|
CppcheckDiagnosticManager &m_manager;
|
||||||
|
@@ -76,7 +76,7 @@ void CppcheckTrigger::checkEditors(const QList<Core::IEditor *> &editors)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
using CppModelManager = CppTools::CppModelManager;
|
using CppModelManager = CppTools::CppModelManager;
|
||||||
const CppTools::ProjectInfo::Ptr info
|
const CppTools::ProjectInfo::ConstPtr info
|
||||||
= CppModelManager::instance()->projectInfo(m_currentProject);
|
= CppModelManager::instance()->projectInfo(m_currentProject);
|
||||||
if (!info)
|
if (!info)
|
||||||
return;
|
return;
|
||||||
|
@@ -1112,11 +1112,11 @@ class ProjectPartsModel : public QAbstractListModel
|
|||||||
public:
|
public:
|
||||||
ProjectPartsModel(QObject *parent);
|
ProjectPartsModel(QObject *parent);
|
||||||
|
|
||||||
void configure(const QList<ProjectInfo::Ptr> &projectInfos,
|
void configure(const QList<ProjectInfo::ConstPtr> &projectInfos,
|
||||||
const ProjectPart::Ptr ¤tEditorsProjectPart);
|
const ProjectPart::ConstPtr ¤tEditorsProjectPart);
|
||||||
|
|
||||||
QModelIndex indexForCurrentEditorsProjectPart() const;
|
QModelIndex indexForCurrentEditorsProjectPart() const;
|
||||||
ProjectPart::Ptr projectPartForProjectId(const QString &projectPartId) const;
|
ProjectPart::ConstPtr projectPartForProjectId(const QString &projectPartId) const;
|
||||||
|
|
||||||
enum Columns { PartNameColumn, PartFilePathColumn, ColumnCount };
|
enum Columns { PartNameColumn, PartFilePathColumn, ColumnCount };
|
||||||
|
|
||||||
@@ -1126,7 +1126,7 @@ public:
|
|||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<ProjectPart::Ptr> m_projectPartsList;
|
QList<ProjectPart::ConstPtr> m_projectPartsList;
|
||||||
int m_currentEditorsProjectPartIndex;
|
int m_currentEditorsProjectPartIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1135,13 +1135,13 @@ ProjectPartsModel::ProjectPartsModel(QObject *parent)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectPartsModel::configure(const QList<ProjectInfo::Ptr> &projectInfos,
|
void ProjectPartsModel::configure(const QList<ProjectInfo::ConstPtr> &projectInfos,
|
||||||
const ProjectPart::Ptr ¤tEditorsProjectPart)
|
const ProjectPart::ConstPtr ¤tEditorsProjectPart)
|
||||||
{
|
{
|
||||||
emit layoutAboutToBeChanged();
|
emit layoutAboutToBeChanged();
|
||||||
m_projectPartsList.clear();
|
m_projectPartsList.clear();
|
||||||
foreach (const ProjectInfo::Ptr &info, projectInfos) {
|
foreach (const ProjectInfo::ConstPtr &info, projectInfos) {
|
||||||
foreach (const ProjectPart::Ptr &projectPart, info->projectParts()) {
|
foreach (const ProjectPart::ConstPtr &projectPart, info->projectParts()) {
|
||||||
if (!m_projectPartsList.contains(projectPart)) {
|
if (!m_projectPartsList.contains(projectPart)) {
|
||||||
m_projectPartsList << projectPart;
|
m_projectPartsList << projectPart;
|
||||||
if (projectPart == currentEditorsProjectPart)
|
if (projectPart == currentEditorsProjectPart)
|
||||||
@@ -1159,13 +1159,13 @@ QModelIndex ProjectPartsModel::indexForCurrentEditorsProjectPart() const
|
|||||||
return createIndex(m_currentEditorsProjectPartIndex, PartFilePathColumn);
|
return createIndex(m_currentEditorsProjectPartIndex, PartFilePathColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectPart::Ptr ProjectPartsModel::projectPartForProjectId(const QString &projectPartId) const
|
ProjectPart::ConstPtr ProjectPartsModel::projectPartForProjectId(const QString &projectPartId) const
|
||||||
{
|
{
|
||||||
foreach (const ProjectPart::Ptr &part, m_projectPartsList) {
|
foreach (const ProjectPart::ConstPtr &part, m_projectPartsList) {
|
||||||
if (part->id() == projectPartId)
|
if (part->id() == projectPartId)
|
||||||
return part;
|
return part;
|
||||||
}
|
}
|
||||||
return ProjectPart::Ptr();
|
return ProjectPart::ConstPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ProjectPartsModel::rowCount(const QModelIndex &/*parent*/) const
|
int ProjectPartsModel::rowCount(const QModelIndex &/*parent*/) const
|
||||||
@@ -1589,11 +1589,11 @@ void CppCodeModelInspectorDialog::refresh()
|
|||||||
onSnapshotSelected(snapshotIndex);
|
onSnapshotSelected(snapshotIndex);
|
||||||
|
|
||||||
// Project Parts
|
// Project Parts
|
||||||
const ProjectPart::Ptr editorsProjectPart = cppEditorDocument
|
const ProjectPart::ConstPtr editorsProjectPart = cppEditorDocument
|
||||||
? cppEditorDocument->processor()->parser()->projectPartInfo().projectPart
|
? cppEditorDocument->processor()->parser()->projectPartInfo().projectPart
|
||||||
: ProjectPart::Ptr();
|
: ProjectPart::ConstPtr();
|
||||||
|
|
||||||
const QList<ProjectInfo::Ptr> projectInfos = cmmi->projectInfos();
|
const QList<ProjectInfo::ConstPtr> projectInfos = cmmi->projectInfos();
|
||||||
dumper.dumpProjectInfos(projectInfos);
|
dumper.dumpProjectInfos(projectInfos);
|
||||||
m_projectPartsModel->configure(projectInfos, editorsProjectPart);
|
m_projectPartsModel->configure(projectInfos, editorsProjectPart);
|
||||||
m_projectPartsView->resizeColumns(ProjectPartsModel::ColumnCount);
|
m_projectPartsView->resizeColumns(ProjectPartsModel::ColumnCount);
|
||||||
@@ -1778,7 +1778,7 @@ static int defineCount(const ProjectExplorer::Macros ¯os)
|
|||||||
[](const Macro ¯o) { return macro.type == ProjectExplorer::MacroType::Define; }));
|
[](const Macro ¯o) { return macro.type == ProjectExplorer::MacroType::Define; }));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppCodeModelInspectorDialog::updateProjectPartData(const ProjectPart::Ptr &part)
|
void CppCodeModelInspectorDialog::updateProjectPartData(const ProjectPart::ConstPtr &part)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(part, return);
|
QTC_ASSERT(part, return);
|
||||||
|
|
||||||
|
@@ -88,7 +88,7 @@ private:
|
|||||||
void updateDocumentData(const CPlusPlus::Document::Ptr &document);
|
void updateDocumentData(const CPlusPlus::Document::Ptr &document);
|
||||||
|
|
||||||
void clearProjectPartData();
|
void clearProjectPartData();
|
||||||
void updateProjectPartData(const CppTools::ProjectPart::Ptr &part);
|
void updateProjectPartData(const CppTools::ProjectPart::ConstPtr &part);
|
||||||
|
|
||||||
bool event(QEvent *e) override;
|
bool event(QEvent *e) override;
|
||||||
|
|
||||||
|
@@ -591,10 +591,10 @@ bool CppEditorWidget::isWidgetHighlighted(QWidget *widget)
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
QList<ProjectPart::Ptr> fetchProjectParts(CppTools::CppModelManager *modelManager,
|
QList<ProjectPart::ConstPtr> fetchProjectParts(CppTools::CppModelManager *modelManager,
|
||||||
const Utils::FilePath &filePath)
|
const Utils::FilePath &filePath)
|
||||||
{
|
{
|
||||||
QList<ProjectPart::Ptr> projectParts = modelManager->projectPart(filePath);
|
QList<ProjectPart::ConstPtr> projectParts = modelManager->projectPart(filePath);
|
||||||
|
|
||||||
if (projectParts.isEmpty())
|
if (projectParts.isEmpty())
|
||||||
projectParts = modelManager->projectPartFromDependencies(filePath);
|
projectParts = modelManager->projectPartFromDependencies(filePath);
|
||||||
@@ -604,12 +604,13 @@ QList<ProjectPart::Ptr> fetchProjectParts(CppTools::CppModelManager *modelManage
|
|||||||
return projectParts;
|
return projectParts;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectPart *findProjectPartForCurrentProject(const QList<ProjectPart::Ptr> &projectParts,
|
const ProjectPart *findProjectPartForCurrentProject(
|
||||||
ProjectExplorer::Project *currentProject)
|
const QList<ProjectPart::ConstPtr> &projectParts,
|
||||||
|
ProjectExplorer::Project *currentProject)
|
||||||
{
|
{
|
||||||
const auto found = std::find_if(projectParts.cbegin(),
|
const auto found = std::find_if(projectParts.cbegin(),
|
||||||
projectParts.cend(),
|
projectParts.cend(),
|
||||||
[&](const CppTools::ProjectPart::Ptr &projectPart) {
|
[&](const CppTools::ProjectPart::ConstPtr &projectPart) {
|
||||||
return projectPart->belongsToProject(currentProject);
|
return projectPart->belongsToProject(currentProject);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -621,7 +622,7 @@ ProjectPart *findProjectPartForCurrentProject(const QList<ProjectPart::Ptr> &pro
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ProjectPart *CppEditorWidget::projectPart() const
|
const ProjectPart *CppEditorWidget::projectPart() const
|
||||||
{
|
{
|
||||||
if (!d->m_modelManager)
|
if (!d->m_modelManager)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -680,7 +681,7 @@ void CppEditorWidget::renameSymbolUnderCursor()
|
|||||||
{
|
{
|
||||||
using ClangBackEnd::SourceLocationsContainer;
|
using ClangBackEnd::SourceLocationsContainer;
|
||||||
|
|
||||||
ProjectPart *projPart = projectPart();
|
const ProjectPart *projPart = projectPart();
|
||||||
if (!projPart)
|
if (!projPart)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -151,7 +151,7 @@ private:
|
|||||||
|
|
||||||
CppTools::FollowSymbolInterface &followSymbolInterface() const;
|
CppTools::FollowSymbolInterface &followSymbolInterface() const;
|
||||||
|
|
||||||
CppTools::ProjectPart *projectPart() const;
|
const CppTools::ProjectPart *projectPart() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<CppEditorWidgetPrivate> d;
|
QScopedPointer<CppEditorWidgetPrivate> d;
|
||||||
|
@@ -87,7 +87,7 @@ void ParseContextModel::reset(const CppTools::ProjectPartInfo &projectPartInfo)
|
|||||||
|
|
||||||
// Determine index for current
|
// Determine index for current
|
||||||
const QString id = projectPartInfo.projectPart->id();
|
const QString id = projectPartInfo.projectPart->id();
|
||||||
m_currentIndex = Utils::indexOf(m_projectParts, [id](const CppTools::ProjectPart::Ptr &pp) {
|
m_currentIndex = Utils::indexOf(m_projectParts, [id](const CppTools::ProjectPart::ConstPtr &pp) {
|
||||||
return pp->id() == id;
|
return pp->id() == id;
|
||||||
});
|
});
|
||||||
QTC_CHECK(m_currentIndex >= 0);
|
QTC_CHECK(m_currentIndex >= 0);
|
||||||
|
@@ -62,7 +62,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
CppTools::ProjectPartInfo::Hints m_hints;
|
CppTools::ProjectPartInfo::Hints m_hints;
|
||||||
QList<CppTools::ProjectPart::Ptr> m_projectParts;
|
QList<CppTools::ProjectPart::ConstPtr> m_projectParts;
|
||||||
int m_currentIndex = -1;
|
int m_currentIndex = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1913,11 +1913,11 @@ ProjectExplorer::HeaderPaths relevantHeaderPaths(const QString &filePath)
|
|||||||
ProjectExplorer::HeaderPaths headerPaths;
|
ProjectExplorer::HeaderPaths headerPaths;
|
||||||
|
|
||||||
CppModelManager *modelManager = CppModelManager::instance();
|
CppModelManager *modelManager = CppModelManager::instance();
|
||||||
const QList<ProjectPart::Ptr> projectParts = modelManager->projectPart(filePath);
|
const QList<ProjectPart::ConstPtr> projectParts = modelManager->projectPart(filePath);
|
||||||
if (projectParts.isEmpty()) { // Not part of any project, better use all include paths than none
|
if (projectParts.isEmpty()) { // Not part of any project, better use all include paths than none
|
||||||
headerPaths += modelManager->headerPaths();
|
headerPaths += modelManager->headerPaths();
|
||||||
} else {
|
} else {
|
||||||
foreach (const ProjectPart::Ptr &part, projectParts)
|
foreach (const ProjectPart::ConstPtr &part, projectParts)
|
||||||
headerPaths += part->headerPaths;
|
headerPaths += part->headerPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -152,9 +152,9 @@ TestActionsTestCase::TestActionsTestCase(const Actions &tokenActions, const Acti
|
|||||||
// Collect files to process
|
// Collect files to process
|
||||||
QStringList filesToOpen;
|
QStringList filesToOpen;
|
||||||
QList<QPointer<ProjectExplorer::Project> > projects;
|
QList<QPointer<ProjectExplorer::Project> > projects;
|
||||||
const QList<ProjectInfo::Ptr> projectInfos = m_modelManager->projectInfos();
|
const QList<ProjectInfo::ConstPtr> projectInfos = m_modelManager->projectInfos();
|
||||||
|
|
||||||
foreach (const ProjectInfo::Ptr &info, projectInfos) {
|
foreach (const ProjectInfo::ConstPtr &info, projectInfos) {
|
||||||
qDebug() << "Project" << info->projectFilePath().toUserOutput() << "- files to process:"
|
qDebug() << "Project" << info->projectFilePath().toUserOutput() << "- files to process:"
|
||||||
<< info->sourceFiles().size();
|
<< info->sourceFiles().size();
|
||||||
foreach (const QString &sourceFile, info->sourceFiles())
|
foreach (const QString &sourceFile, info->sourceFiles())
|
||||||
|
@@ -95,7 +95,7 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur
|
|||||||
state.forceSnapshotInvalidation = false;
|
state.forceSnapshotInvalidation = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const ProjectPart::Ptr part = baseState.projectPartInfo.projectPart) {
|
if (const ProjectPart::ConstPtr part = baseState.projectPartInfo.projectPart) {
|
||||||
configFile += ProjectExplorer::Macro::toByteArray(part->toolChainMacros);
|
configFile += ProjectExplorer::Macro::toByteArray(part->toolChainMacros);
|
||||||
configFile += overwrittenToolchainDefines(*part.data());
|
configFile += overwrittenToolchainDefines(*part.data());
|
||||||
configFile += ProjectExplorer::Macro::toByteArray(part->projectMacros);
|
configFile += ProjectExplorer::Macro::toByteArray(part->projectMacros);
|
||||||
|
@@ -211,7 +211,7 @@ void index(QFutureInterface<void> &indexingFuture,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
const QString fileName = files.at(i);
|
const QString fileName = files.at(i);
|
||||||
const QList<ProjectPart::Ptr> parts = cmm->projectPart(fileName);
|
const QList<ProjectPart::ConstPtr> parts = cmm->projectPart(fileName);
|
||||||
const CPlusPlus::LanguageFeatures languageFeatures = parts.isEmpty()
|
const CPlusPlus::LanguageFeatures languageFeatures = parts.isEmpty()
|
||||||
? defaultFeatures
|
? defaultFeatures
|
||||||
: parts.first()->languageFeatures;
|
: parts.first()->languageFeatures;
|
||||||
|
@@ -110,7 +110,7 @@ public:
|
|||||||
Utils::optional<CompilerOptionsBuilder> compilerOptionsBuilder;
|
Utils::optional<CompilerOptionsBuilder> compilerOptionsBuilder;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProjectPart::Ptr projectPart;
|
ProjectPart::ConstPtr projectPart;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -410,10 +410,10 @@ QString Utils::toString(ProjectPart::ToolChainWordWidth width)
|
|||||||
|
|
||||||
QString Utils::partsForFile(const QString &fileName)
|
QString Utils::partsForFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
const QList<ProjectPart::Ptr> parts
|
const QList<ProjectPart::ConstPtr> parts
|
||||||
= CppModelManager::instance()->projectPart(fileName);
|
= CppModelManager::instance()->projectPart(fileName);
|
||||||
QString result;
|
QString result;
|
||||||
foreach (const ProjectPart::Ptr &part, parts)
|
foreach (const ProjectPart::ConstPtr &part, parts)
|
||||||
result += part->displayName + QLatin1Char(',');
|
result += part->displayName + QLatin1Char(',');
|
||||||
if (result.endsWith(QLatin1Char(',')))
|
if (result.endsWith(QLatin1Char(',')))
|
||||||
result.chop(1);
|
result.chop(1);
|
||||||
@@ -503,7 +503,7 @@ static void printIncludeType(QTextStream &out, ProjectExplorer::HeaderPathType t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dumper::dumpProjectInfos(const QList<ProjectInfo::Ptr> &projectInfos)
|
void Dumper::dumpProjectInfos(const QList<ProjectInfo::ConstPtr> &projectInfos)
|
||||||
{
|
{
|
||||||
const QByteArray i1 = indent(1);
|
const QByteArray i1 = indent(1);
|
||||||
const QByteArray i2 = indent(2);
|
const QByteArray i2 = indent(2);
|
||||||
@@ -511,12 +511,12 @@ void Dumper::dumpProjectInfos(const QList<ProjectInfo::Ptr> &projectInfos)
|
|||||||
const QByteArray i4 = indent(4);
|
const QByteArray i4 = indent(4);
|
||||||
|
|
||||||
m_out << "Projects loaded: " << projectInfos.size() << "{{{1\n";
|
m_out << "Projects loaded: " << projectInfos.size() << "{{{1\n";
|
||||||
foreach (const ProjectInfo::Ptr &info, projectInfos) {
|
foreach (const ProjectInfo::ConstPtr &info, projectInfos) {
|
||||||
m_out << i1 << "Project " << info->projectName()
|
m_out << i1 << "Project " << info->projectName()
|
||||||
<< " (" << info->projectFilePath().toUserOutput() << "){{{2\n";
|
<< " (" << info->projectFilePath().toUserOutput() << "){{{2\n";
|
||||||
|
|
||||||
const QVector<ProjectPart::Ptr> projectParts = info->projectParts();
|
const QVector<ProjectPart::ConstPtr> projectParts = info->projectParts();
|
||||||
foreach (const ProjectPart::Ptr &part, projectParts) {
|
foreach (const ProjectPart::ConstPtr &part, projectParts) {
|
||||||
QString projectName = QLatin1String("<None>");
|
QString projectName = QLatin1String("<None>");
|
||||||
QString projectFilePath = "<None>";
|
QString projectFilePath = "<None>";
|
||||||
if (part->hasProject()) {
|
if (part->hasProject()) {
|
||||||
|
@@ -70,7 +70,7 @@ public:
|
|||||||
const QString &logFileId = QString());
|
const QString &logFileId = QString());
|
||||||
~Dumper();
|
~Dumper();
|
||||||
|
|
||||||
void dumpProjectInfos(const QList<CppTools::ProjectInfo::Ptr> &projectInfos);
|
void dumpProjectInfos(const QList<CppTools::ProjectInfo::ConstPtr> &projectInfos);
|
||||||
void dumpSnapshot(const CPlusPlus::Snapshot &snapshot,
|
void dumpSnapshot(const CPlusPlus::Snapshot &snapshot,
|
||||||
const QString &title,
|
const QString &title,
|
||||||
bool isGlobalSnapshot = false);
|
bool isGlobalSnapshot = false);
|
||||||
|
@@ -150,7 +150,7 @@ static CppModelManager *m_instance;
|
|||||||
class ProjectData
|
class ProjectData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProjectInfo::Ptr projectInfo;
|
ProjectInfo::ConstPtr projectInfo;
|
||||||
QFutureWatcher<void> *indexer = nullptr;
|
QFutureWatcher<void> *indexer = nullptr;
|
||||||
bool fullyIndexed = false;
|
bool fullyIndexed = false;
|
||||||
};
|
};
|
||||||
@@ -168,8 +168,9 @@ public:
|
|||||||
// Project integration
|
// Project integration
|
||||||
QReadWriteLock m_projectLock;
|
QReadWriteLock m_projectLock;
|
||||||
QHash<ProjectExplorer::Project *, ProjectData> m_projectData;
|
QHash<ProjectExplorer::Project *, ProjectData> m_projectData;
|
||||||
QMap<Utils::FilePath, QList<ProjectPart::Ptr> > m_fileToProjectParts;
|
QMap<Utils::FilePath, QList<ProjectPart::ConstPtr> > m_fileToProjectParts;
|
||||||
QMap<QString, ProjectPart::Ptr> m_projectPartIdToProjectProjectPart;
|
QMap<QString, ProjectPart::ConstPtr> m_projectPartIdToProjectProjectPart;
|
||||||
|
|
||||||
// The members below are cached/(re)calculated from the projects and/or their project parts
|
// The members below are cached/(re)calculated from the projects and/or their project parts
|
||||||
bool m_dirty;
|
bool m_dirty;
|
||||||
QStringList m_projectFiles;
|
QStringList m_projectFiles;
|
||||||
@@ -190,7 +191,7 @@ public:
|
|||||||
bool m_indexerEnabled;
|
bool m_indexerEnabled;
|
||||||
|
|
||||||
QMutex m_fallbackProjectPartMutex;
|
QMutex m_fallbackProjectPartMutex;
|
||||||
ProjectPart::Ptr m_fallbackProjectPart;
|
ProjectPart::ConstPtr m_fallbackProjectPart;
|
||||||
|
|
||||||
CppFindReferences *m_findReferences;
|
CppFindReferences *m_findReferences;
|
||||||
|
|
||||||
@@ -325,7 +326,7 @@ static RefactoringEngineInterface *getRefactoringEngine(CppModelManagerPrivate::
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CppModelManager::startLocalRenaming(const CursorInEditor &data,
|
void CppModelManager::startLocalRenaming(const CursorInEditor &data,
|
||||||
CppTools::ProjectPart *projectPart,
|
const CppTools::ProjectPart *projectPart,
|
||||||
RenameCallback &&renameSymbolsCallback)
|
RenameCallback &&renameSymbolsCallback)
|
||||||
{
|
{
|
||||||
RefactoringEngineInterface *engine = getRefactoringEngine(d->m_refactoringEngines);
|
RefactoringEngineInterface *engine = getRefactoringEngine(d->m_refactoringEngines);
|
||||||
@@ -761,7 +762,7 @@ QStringList CppModelManager::internalProjectFiles() const
|
|||||||
{
|
{
|
||||||
QStringList files;
|
QStringList files;
|
||||||
for (const ProjectData &projectData : qAsConst(d->m_projectData)) {
|
for (const ProjectData &projectData : qAsConst(d->m_projectData)) {
|
||||||
for (const ProjectPart::Ptr &part : projectData.projectInfo->projectParts()) {
|
for (const ProjectPart::ConstPtr &part : projectData.projectInfo->projectParts()) {
|
||||||
for (const ProjectFile &file : part->files)
|
for (const ProjectFile &file : part->files)
|
||||||
files += file.path;
|
files += file.path;
|
||||||
}
|
}
|
||||||
@@ -774,7 +775,7 @@ ProjectExplorer::HeaderPaths CppModelManager::internalHeaderPaths() const
|
|||||||
{
|
{
|
||||||
ProjectExplorer::HeaderPaths headerPaths;
|
ProjectExplorer::HeaderPaths headerPaths;
|
||||||
for (const ProjectData &projectData: qAsConst(d->m_projectData)) {
|
for (const ProjectData &projectData: qAsConst(d->m_projectData)) {
|
||||||
for (const ProjectPart::Ptr &part : projectData.projectInfo->projectParts()) {
|
for (const ProjectPart::ConstPtr &part : projectData.projectInfo->projectParts()) {
|
||||||
for (const ProjectExplorer::HeaderPath &path : part->headerPaths) {
|
for (const ProjectExplorer::HeaderPath &path : part->headerPaths) {
|
||||||
ProjectExplorer::HeaderPath hp(QDir::cleanPath(path.path), path.type);
|
ProjectExplorer::HeaderPath hp(QDir::cleanPath(path.path), path.type);
|
||||||
if (!headerPaths.contains(hp))
|
if (!headerPaths.contains(hp))
|
||||||
@@ -802,7 +803,7 @@ ProjectExplorer::Macros CppModelManager::internalDefinedMacros() const
|
|||||||
ProjectExplorer::Macros macros;
|
ProjectExplorer::Macros macros;
|
||||||
QSet<ProjectExplorer::Macro> alreadyIn;
|
QSet<ProjectExplorer::Macro> alreadyIn;
|
||||||
for (const ProjectData &projectData : qAsConst(d->m_projectData)) {
|
for (const ProjectData &projectData : qAsConst(d->m_projectData)) {
|
||||||
for (const ProjectPart::Ptr &part : projectData.projectInfo->projectParts()) {
|
for (const ProjectPart::ConstPtr &part : projectData.projectInfo->projectParts()) {
|
||||||
addUnique(part->toolChainMacros, macros, alreadyIn);
|
addUnique(part->toolChainMacros, macros, alreadyIn);
|
||||||
addUnique(part->projectMacros, macros, alreadyIn);
|
addUnique(part->projectMacros, macros, alreadyIn);
|
||||||
}
|
}
|
||||||
@@ -982,14 +983,14 @@ QFuture<void> CppModelManager::updateSourceFiles(const QSet<QString> &sourceFile
|
|||||||
return d->m_internalIndexingSupport->refreshSourceFiles(filteredFiles, mode);
|
return d->m_internalIndexingSupport->refreshSourceFiles(filteredFiles, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ProjectInfo::Ptr> CppModelManager::projectInfos() const
|
QList<ProjectInfo::ConstPtr> CppModelManager::projectInfos() const
|
||||||
{
|
{
|
||||||
QReadLocker locker(&d->m_projectLock);
|
QReadLocker locker(&d->m_projectLock);
|
||||||
return Utils::transform<QList<ProjectInfo::Ptr>>(d->m_projectData,
|
return Utils::transform<QList<ProjectInfo::ConstPtr>>(d->m_projectData,
|
||||||
[](const ProjectData &d) { return d.projectInfo; });
|
[](const ProjectData &d) { return d.projectInfo; });
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectInfo::Ptr CppModelManager::projectInfo(ProjectExplorer::Project *project) const
|
ProjectInfo::ConstPtr CppModelManager::projectInfo(ProjectExplorer::Project *project) const
|
||||||
{
|
{
|
||||||
QReadLocker locker(&d->m_projectLock);
|
QReadLocker locker(&d->m_projectLock);
|
||||||
return d->m_projectData.value(project).projectInfo;
|
return d->m_projectData.value(project).projectInfo;
|
||||||
@@ -999,7 +1000,7 @@ ProjectInfo::Ptr CppModelManager::projectInfo(ProjectExplorer::Project *project)
|
|||||||
void CppModelManager::removeProjectInfoFilesAndIncludesFromSnapshot(const ProjectInfo &projectInfo)
|
void CppModelManager::removeProjectInfoFilesAndIncludesFromSnapshot(const ProjectInfo &projectInfo)
|
||||||
{
|
{
|
||||||
QMutexLocker snapshotLocker(&d->m_snapshotMutex);
|
QMutexLocker snapshotLocker(&d->m_snapshotMutex);
|
||||||
foreach (const ProjectPart::Ptr &projectPart, projectInfo.projectParts()) {
|
foreach (const ProjectPart::ConstPtr &projectPart, projectInfo.projectParts()) {
|
||||||
foreach (const ProjectFile &cxxFile, projectPart->files) {
|
foreach (const ProjectFile &cxxFile, projectPart->files) {
|
||||||
foreach (const QString &fileName, d->m_snapshot.allIncludesForDocument(cxxFile.path))
|
foreach (const QString &fileName, d->m_snapshot.allIncludesForDocument(cxxFile.path))
|
||||||
d->m_snapshot.remove(fileName);
|
d->m_snapshot.remove(fileName);
|
||||||
@@ -1074,11 +1075,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QSet<QString> projectPartIds(const QVector<ProjectPart::Ptr> &projectParts)
|
static QSet<QString> projectPartIds(const QVector<ProjectPart::ConstPtr> &projectParts)
|
||||||
{
|
{
|
||||||
QSet<QString> ids;
|
QSet<QString> ids;
|
||||||
|
|
||||||
foreach (const ProjectPart::Ptr &projectPart, projectParts)
|
foreach (const ProjectPart::ConstPtr &projectPart, projectParts)
|
||||||
ids.insert(projectPart->id());
|
ids.insert(projectPart->id());
|
||||||
|
|
||||||
return ids;
|
return ids;
|
||||||
@@ -1098,7 +1099,7 @@ void CppModelManager::recalculateProjectPartMappings()
|
|||||||
d->m_projectPartIdToProjectProjectPart.clear();
|
d->m_projectPartIdToProjectProjectPart.clear();
|
||||||
d->m_fileToProjectParts.clear();
|
d->m_fileToProjectParts.clear();
|
||||||
for (const ProjectData &projectData : qAsConst(d->m_projectData)) {
|
for (const ProjectData &projectData : qAsConst(d->m_projectData)) {
|
||||||
for (const ProjectPart::Ptr &projectPart : projectData.projectInfo->projectParts()) {
|
for (const ProjectPart::ConstPtr &projectPart : projectData.projectInfo->projectParts()) {
|
||||||
d->m_projectPartIdToProjectProjectPart[projectPart->id()] = projectPart;
|
d->m_projectPartIdToProjectProjectPart[projectPart->id()] = projectPart;
|
||||||
for (const ProjectFile &cxxFile : projectPart->files)
|
for (const ProjectFile &cxxFile : projectPart->files)
|
||||||
d->m_fileToProjectParts[Utils::FilePath::fromString(cxxFile.path)].append(
|
d->m_fileToProjectParts[Utils::FilePath::fromString(cxxFile.path)].append(
|
||||||
@@ -1157,7 +1158,7 @@ void CppModelManager::updateCppEditorDocuments(bool projectsUpdated) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo::Ptr &newProjectInfo,
|
QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo::ConstPtr &newProjectInfo,
|
||||||
const QSet<QString> &additionalFiles)
|
const QSet<QString> &additionalFiles)
|
||||||
{
|
{
|
||||||
if (!newProjectInfo)
|
if (!newProjectInfo)
|
||||||
@@ -1181,7 +1182,6 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo::Ptr &newProj
|
|||||||
const auto it = d->m_projectData.find(project);
|
const auto it = d->m_projectData.find(project);
|
||||||
if (it != d->m_projectData.end() && it->projectInfo && it->fullyIndexed) {
|
if (it != d->m_projectData.end() && it->projectInfo && it->fullyIndexed) {
|
||||||
ProjectInfoComparer comparer(*it->projectInfo, *newProjectInfo);
|
ProjectInfoComparer comparer(*it->projectInfo, *newProjectInfo);
|
||||||
|
|
||||||
if (comparer.configurationOrFilesChanged()) {
|
if (comparer.configurationOrFilesChanged()) {
|
||||||
d->m_dirty = true;
|
d->m_dirty = true;
|
||||||
|
|
||||||
@@ -1268,22 +1268,22 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo::Ptr &newProj
|
|||||||
return indexingFuture;
|
return indexingFuture;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectPart::Ptr CppModelManager::projectPartForId(const QString &projectPartId) const
|
ProjectPart::ConstPtr CppModelManager::projectPartForId(const QString &projectPartId) const
|
||||||
{
|
{
|
||||||
QReadLocker locker(&d->m_projectLock);
|
QReadLocker locker(&d->m_projectLock);
|
||||||
return d->m_projectPartIdToProjectProjectPart.value(projectPartId);
|
return d->m_projectPartIdToProjectProjectPart.value(projectPartId);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ProjectPart::Ptr> CppModelManager::projectPart(const Utils::FilePath &fileName) const
|
QList<ProjectPart::ConstPtr> CppModelManager::projectPart(const Utils::FilePath &fileName) const
|
||||||
{
|
{
|
||||||
QReadLocker locker(&d->m_projectLock);
|
QReadLocker locker(&d->m_projectLock);
|
||||||
return d->m_fileToProjectParts.value(fileName);
|
return d->m_fileToProjectParts.value(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ProjectPart::Ptr> CppModelManager::projectPartFromDependencies(
|
QList<ProjectPart::ConstPtr> CppModelManager::projectPartFromDependencies(
|
||||||
const Utils::FilePath &fileName) const
|
const Utils::FilePath &fileName) const
|
||||||
{
|
{
|
||||||
QSet<ProjectPart::Ptr> parts;
|
QSet<ProjectPart::ConstPtr> parts;
|
||||||
const Utils::FilePaths deps = snapshot().filesDependingOn(fileName);
|
const Utils::FilePaths deps = snapshot().filesDependingOn(fileName);
|
||||||
|
|
||||||
QReadLocker locker(&d->m_projectLock);
|
QReadLocker locker(&d->m_projectLock);
|
||||||
@@ -1293,7 +1293,7 @@ QList<ProjectPart::Ptr> CppModelManager::projectPartFromDependencies(
|
|||||||
return parts.values();
|
return parts.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectPart::Ptr CppModelManager::fallbackProjectPart()
|
ProjectPart::ConstPtr CppModelManager::fallbackProjectPart()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&d->m_fallbackProjectPartMutex);
|
QMutexLocker locker(&d->m_fallbackProjectPartMutex);
|
||||||
return d->m_fallbackProjectPart;
|
return d->m_fallbackProjectPart;
|
||||||
@@ -1431,7 +1431,7 @@ QSet<QString> CppModelManager::dependingInternalTargets(const Utils::FilePath &f
|
|||||||
const Utils::FilePaths dependingFiles = snapshot.filesDependingOn(
|
const Utils::FilePaths dependingFiles = snapshot.filesDependingOn(
|
||||||
wasHeader ? file : Utils::FilePath::fromString(correspondingFile));
|
wasHeader ? file : Utils::FilePath::fromString(correspondingFile));
|
||||||
for (const Utils::FilePath &fn : qAsConst(dependingFiles)) {
|
for (const Utils::FilePath &fn : qAsConst(dependingFiles)) {
|
||||||
for (const ProjectPart::Ptr &part : projectPart(fn))
|
for (const ProjectPart::ConstPtr &part : projectPart(fn))
|
||||||
result.insert(part->buildSystemTarget);
|
result.insert(part->buildSystemTarget);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -1439,12 +1439,12 @@ QSet<QString> CppModelManager::dependingInternalTargets(const Utils::FilePath &f
|
|||||||
|
|
||||||
QSet<QString> CppModelManager::internalTargets(const Utils::FilePath &filePath) const
|
QSet<QString> CppModelManager::internalTargets(const Utils::FilePath &filePath) const
|
||||||
{
|
{
|
||||||
const QList<ProjectPart::Ptr> projectParts = projectPart(filePath);
|
const QList<ProjectPart::ConstPtr> projectParts = projectPart(filePath);
|
||||||
// if we have no project parts it's most likely a header with declarations only and CMake based
|
// if we have no project parts it's most likely a header with declarations only and CMake based
|
||||||
if (projectParts.isEmpty())
|
if (projectParts.isEmpty())
|
||||||
return dependingInternalTargets(filePath);
|
return dependingInternalTargets(filePath);
|
||||||
QSet<QString> targets;
|
QSet<QString> targets;
|
||||||
for (const ProjectPart::Ptr &part : projectParts) {
|
for (const ProjectPart::ConstPtr &part : projectParts) {
|
||||||
targets.insert(part->buildSystemTarget);
|
targets.insert(part->buildSystemTarget);
|
||||||
if (part->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
|
if (part->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
|
||||||
targets.unite(dependingInternalTargets(filePath));
|
targets.unite(dependingInternalTargets(filePath));
|
||||||
|
@@ -114,23 +114,23 @@ public:
|
|||||||
QByteArray codeModelConfiguration() const;
|
QByteArray codeModelConfiguration() const;
|
||||||
CppLocatorData *locatorData() const;
|
CppLocatorData *locatorData() const;
|
||||||
|
|
||||||
QList<ProjectInfo::Ptr> projectInfos() const;
|
QList<ProjectInfo::ConstPtr> projectInfos() const;
|
||||||
ProjectInfo::Ptr projectInfo(ProjectExplorer::Project *project) const;
|
ProjectInfo::ConstPtr projectInfo(ProjectExplorer::Project *project) const;
|
||||||
QFuture<void> updateProjectInfo(const ProjectInfo::Ptr &newProjectInfo,
|
QFuture<void> updateProjectInfo(const ProjectInfo::ConstPtr &newProjectInfo,
|
||||||
const QSet<QString> &additionalFiles = {});
|
const QSet<QString> &additionalFiles = {});
|
||||||
|
|
||||||
/// \return The project part with the given project file
|
/// \return The project part with the given project file
|
||||||
ProjectPart::Ptr projectPartForId(const QString &projectPartId) const override;
|
ProjectPart::ConstPtr projectPartForId(const QString &projectPartId) const override;
|
||||||
/// \return All project parts that mention the given file name as one of the sources/headers.
|
/// \return All project parts that mention the given file name as one of the sources/headers.
|
||||||
QList<ProjectPart::Ptr> projectPart(const Utils::FilePath &fileName) const;
|
QList<ProjectPart::ConstPtr> projectPart(const Utils::FilePath &fileName) const;
|
||||||
QList<ProjectPart::Ptr> projectPart(const QString &fileName) const
|
QList<ProjectPart::ConstPtr> projectPart(const QString &fileName) const
|
||||||
{ return projectPart(Utils::FilePath::fromString(fileName)); }
|
{ return projectPart(Utils::FilePath::fromString(fileName)); }
|
||||||
/// This is a fall-back function: find all files that includes the file directly or indirectly,
|
/// This is a fall-back function: find all files that includes the file directly or indirectly,
|
||||||
/// and return its \c ProjectPart list for use with this file.
|
/// and return its \c ProjectPart list for use with this file.
|
||||||
QList<ProjectPart::Ptr> projectPartFromDependencies(const Utils::FilePath &fileName) const;
|
QList<ProjectPart::ConstPtr> projectPartFromDependencies(const Utils::FilePath &fileName) const;
|
||||||
/// \return A synthetic \c ProjectPart which consists of all defines/includes/frameworks from
|
/// \return A synthetic \c ProjectPart which consists of all defines/includes/frameworks from
|
||||||
/// all loaded projects.
|
/// all loaded projects.
|
||||||
ProjectPart::Ptr fallbackProjectPart();
|
ProjectPart::ConstPtr fallbackProjectPart();
|
||||||
|
|
||||||
CPlusPlus::Snapshot snapshot() const override;
|
CPlusPlus::Snapshot snapshot() const override;
|
||||||
Document::Ptr document(const QString &fileName) const;
|
Document::Ptr document(const QString &fileName) const;
|
||||||
@@ -158,7 +158,7 @@ public:
|
|||||||
QList<int> references(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context);
|
QList<int> references(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context);
|
||||||
|
|
||||||
void startLocalRenaming(const CursorInEditor &data,
|
void startLocalRenaming(const CursorInEditor &data,
|
||||||
CppTools::ProjectPart *projectPart,
|
const ProjectPart *projectPart,
|
||||||
RenameCallback &&renameSymbolsCallback) final;
|
RenameCallback &&renameSymbolsCallback) final;
|
||||||
void globalRename(const CursorInEditor &data, UsagesCallback &&renameCallback,
|
void globalRename(const CursorInEditor &data, UsagesCallback &&renameCallback,
|
||||||
const QString &replacement) final;
|
const QString &replacement) final;
|
||||||
|
@@ -118,7 +118,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
ModelManagerTestHelper *modelManagerTestHelper;
|
ModelManagerTestHelper *modelManagerTestHelper;
|
||||||
ProjectInfo::Ptr projectInfo;
|
ProjectInfo::ConstPtr projectInfo;
|
||||||
QStringList projectFiles;
|
QStringList projectFiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -164,10 +164,10 @@ private:
|
|||||||
const QString &m_filePath;
|
const QString &m_filePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
ProjectPart::Ptr projectPartOfEditorDocument(const QString &filePath)
|
ProjectPart::ConstPtr projectPartOfEditorDocument(const QString &filePath)
|
||||||
{
|
{
|
||||||
auto *editorDocument = CppModelManager::instance()->cppEditorDocument(filePath);
|
auto *editorDocument = CppModelManager::instance()->cppEditorDocument(filePath);
|
||||||
QTC_ASSERT(editorDocument, return ProjectPart::Ptr());
|
QTC_ASSERT(editorDocument, return ProjectPart::ConstPtr());
|
||||||
return editorDocument->processor()->parser()->projectPartInfo().projectPart;
|
return editorDocument->processor()->parser()->projectPartInfo().projectPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -948,7 +948,7 @@ void ModelManagerTest::testUpdateEditorsAfterProjectUpdate()
|
|||||||
EditorCloser closerA(editorA);
|
EditorCloser closerA(editorA);
|
||||||
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
|
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
|
||||||
QVERIFY(TestCase::waitForProcessedEditorDocument(fileA));
|
QVERIFY(TestCase::waitForProcessedEditorDocument(fileA));
|
||||||
ProjectPart::Ptr documentAProjectPart = projectPartOfEditorDocument(fileA);
|
ProjectPart::ConstPtr documentAProjectPart = projectPartOfEditorDocument(fileA);
|
||||||
QVERIFY(!documentAProjectPart->hasProject());
|
QVERIFY(!documentAProjectPart->hasProject());
|
||||||
|
|
||||||
// Open file B in editor
|
// Open file B in editor
|
||||||
@@ -957,7 +957,7 @@ void ModelManagerTest::testUpdateEditorsAfterProjectUpdate()
|
|||||||
EditorCloser closerB(editorB);
|
EditorCloser closerB(editorB);
|
||||||
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 2);
|
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 2);
|
||||||
QVERIFY(TestCase::waitForProcessedEditorDocument(fileB));
|
QVERIFY(TestCase::waitForProcessedEditorDocument(fileB));
|
||||||
ProjectPart::Ptr documentBProjectPart = projectPartOfEditorDocument(fileB);
|
ProjectPart::ConstPtr documentBProjectPart = projectPartOfEditorDocument(fileB);
|
||||||
QVERIFY(!documentBProjectPart->hasProject());
|
QVERIFY(!documentBProjectPart->hasProject());
|
||||||
|
|
||||||
// Switch back to document A
|
// Switch back to document A
|
||||||
|
@@ -32,7 +32,7 @@ namespace CppTools {
|
|||||||
class CppModelManagerInterface
|
class CppModelManagerInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ProjectPart::Ptr projectPartForId(const QString &projectPartId) const = 0;
|
virtual ProjectPart::ConstPtr projectPartForId(const QString &projectPartId) const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~CppModelManagerInterface() = default;
|
virtual ~CppModelManagerInterface() = default;
|
||||||
|
@@ -42,21 +42,24 @@ using namespace ProjectExplorer;
|
|||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
ProjectInfoGenerator::ProjectInfoGenerator(const QFutureInterface<ProjectInfo::Ptr> &futureInterface,
|
ProjectInfoGenerator::ProjectInfoGenerator(
|
||||||
const ProjectUpdateInfo &projectUpdateInfo)
|
const QFutureInterface<ProjectInfo::ConstPtr> &futureInterface,
|
||||||
|
const ProjectUpdateInfo &projectUpdateInfo)
|
||||||
: m_futureInterface(futureInterface)
|
: m_futureInterface(futureInterface)
|
||||||
, m_projectUpdateInfo(projectUpdateInfo)
|
, m_projectUpdateInfo(projectUpdateInfo)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectInfo::Ptr ProjectInfoGenerator::generate()
|
ProjectInfo::ConstPtr ProjectInfoGenerator::generate()
|
||||||
{
|
{
|
||||||
QVector<ProjectPart::Ptr> projectParts;
|
QVector<ProjectPart::ConstPtr> projectParts;
|
||||||
for (const RawProjectPart &rpp : m_projectUpdateInfo.rawProjectParts) {
|
for (const RawProjectPart &rpp : m_projectUpdateInfo.rawProjectParts) {
|
||||||
if (m_futureInterface.isCanceled())
|
if (m_futureInterface.isCanceled())
|
||||||
return {};
|
return {};
|
||||||
for (const ProjectPart::Ptr &part : createProjectParts(rpp, m_projectUpdateInfo.projectFilePath))
|
for (const ProjectPart::ConstPtr &part : createProjectParts(
|
||||||
|
rpp, m_projectUpdateInfo.projectFilePath)) {
|
||||||
projectParts << part;
|
projectParts << part;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const auto projectInfo = ProjectInfo::create(m_projectUpdateInfo, projectParts);
|
const auto projectInfo = ProjectInfo::create(m_projectUpdateInfo, projectParts);
|
||||||
|
|
||||||
@@ -78,12 +81,12 @@ ProjectInfo::Ptr ProjectInfoGenerator::generate()
|
|||||||
return projectInfo;
|
return projectInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QVector<ProjectPart::Ptr> ProjectInfoGenerator::createProjectParts(
|
const QVector<ProjectPart::ConstPtr> ProjectInfoGenerator::createProjectParts(
|
||||||
const RawProjectPart &rawProjectPart, const Utils::FilePath &projectFilePath)
|
const RawProjectPart &rawProjectPart, const Utils::FilePath &projectFilePath)
|
||||||
{
|
{
|
||||||
using Utils::LanguageExtension;
|
using Utils::LanguageExtension;
|
||||||
|
|
||||||
QVector<ProjectPart::Ptr> result;
|
QVector<ProjectPart::ConstPtr> result;
|
||||||
ProjectFileCategorizer cat(rawProjectPart.displayName,
|
ProjectFileCategorizer cat(rawProjectPart.displayName,
|
||||||
rawProjectPart.files,
|
rawProjectPart.files,
|
||||||
rawProjectPart.fileIsActive);
|
rawProjectPart.fileIsActive);
|
||||||
@@ -137,7 +140,7 @@ const QVector<ProjectPart::Ptr> ProjectInfoGenerator::createProjectParts(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectPart::Ptr ProjectInfoGenerator::createProjectPart(
|
ProjectPart::ConstPtr ProjectInfoGenerator::createProjectPart(
|
||||||
const Utils::FilePath &projectFilePath,
|
const Utils::FilePath &projectFilePath,
|
||||||
const RawProjectPart &rawProjectPart,
|
const RawProjectPart &rawProjectPart,
|
||||||
const ProjectFiles &projectFiles,
|
const ProjectFiles &projectFiles,
|
||||||
|
@@ -36,14 +36,16 @@ namespace Internal {
|
|||||||
class ProjectInfoGenerator
|
class ProjectInfoGenerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProjectInfoGenerator(const QFutureInterface<ProjectInfo::Ptr> &futureInterface,
|
ProjectInfoGenerator(const QFutureInterface<ProjectInfo::ConstPtr> &futureInterface,
|
||||||
const ProjectExplorer::ProjectUpdateInfo &projectUpdateInfo);
|
const ProjectExplorer::ProjectUpdateInfo &projectUpdateInfo);
|
||||||
|
|
||||||
ProjectInfo::Ptr generate();
|
ProjectInfo::ConstPtr generate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QVector<ProjectPart::Ptr> createProjectParts(const ProjectExplorer::RawProjectPart &rawProjectPart, const Utils::FilePath &projectFilePath);
|
const QVector<ProjectPart::ConstPtr> createProjectParts(
|
||||||
ProjectPart::Ptr createProjectPart(const Utils::FilePath &projectFilePath,
|
const ProjectExplorer::RawProjectPart &rawProjectPart,
|
||||||
|
const Utils::FilePath &projectFilePath);
|
||||||
|
ProjectPart::ConstPtr createProjectPart(const Utils::FilePath &projectFilePath,
|
||||||
const ProjectExplorer::RawProjectPart &rawProjectPart,
|
const ProjectExplorer::RawProjectPart &rawProjectPart,
|
||||||
const ProjectFiles &projectFiles,
|
const ProjectFiles &projectFiles,
|
||||||
const QString &partName,
|
const QString &partName,
|
||||||
@@ -51,7 +53,7 @@ private:
|
|||||||
Utils::LanguageExtensions languageExtensions);
|
Utils::LanguageExtensions languageExtensions);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QFutureInterface<ProjectInfo::Ptr> m_futureInterface;
|
const QFutureInterface<ProjectInfo::ConstPtr> m_futureInterface;
|
||||||
const ProjectExplorer::ProjectUpdateInfo &m_projectUpdateInfo;
|
const ProjectExplorer::ProjectUpdateInfo &m_projectUpdateInfo;
|
||||||
bool m_cToolchainMissing = false;
|
bool m_cToolchainMissing = false;
|
||||||
bool m_cxxToolchainMissing = false;
|
bool m_cxxToolchainMissing = false;
|
||||||
|
@@ -36,14 +36,14 @@ class ProjectPartPrioritizer
|
|||||||
public:
|
public:
|
||||||
struct PrioritizedProjectPart
|
struct PrioritizedProjectPart
|
||||||
{
|
{
|
||||||
PrioritizedProjectPart(const ProjectPart::Ptr &projectPart, int priority)
|
PrioritizedProjectPart(const ProjectPart::ConstPtr &projectPart, int priority)
|
||||||
: projectPart(projectPart), priority(priority) {}
|
: projectPart(projectPart), priority(priority) {}
|
||||||
|
|
||||||
ProjectPart::Ptr projectPart;
|
ProjectPart::ConstPtr projectPart;
|
||||||
int priority = 0;
|
int priority = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
ProjectPartPrioritizer(const QList<ProjectPart::Ptr> &projectParts,
|
ProjectPartPrioritizer(const QList<ProjectPart::ConstPtr> &projectParts,
|
||||||
const QString &preferredProjectPartId,
|
const QString &preferredProjectPartId,
|
||||||
const ProjectExplorer::Project *activeProject,
|
const ProjectExplorer::Project *activeProject,
|
||||||
Language languagePreference,
|
Language languagePreference,
|
||||||
@@ -77,11 +77,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<PrioritizedProjectPart> prioritize(const QList<ProjectPart::Ptr> &projectParts) const
|
QList<PrioritizedProjectPart> prioritize(const QList<ProjectPart::ConstPtr> &projectParts) const
|
||||||
{
|
{
|
||||||
// Prioritize
|
// Prioritize
|
||||||
QList<PrioritizedProjectPart> prioritized = Utils::transform(projectParts,
|
QList<PrioritizedProjectPart> prioritized = Utils::transform(projectParts,
|
||||||
[&](const ProjectPart::Ptr &projectPart) {
|
[&](const ProjectPart::ConstPtr &projectPart) {
|
||||||
return PrioritizedProjectPart{projectPart, priority(*projectPart)};
|
return PrioritizedProjectPart{projectPart, priority(*projectPart)};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -143,8 +143,8 @@ ProjectPartInfo ProjectPartChooser::choose(
|
|||||||
QTC_CHECK(m_projectPartsFromDependenciesForFile);
|
QTC_CHECK(m_projectPartsFromDependenciesForFile);
|
||||||
QTC_CHECK(m_fallbackProjectPart);
|
QTC_CHECK(m_fallbackProjectPart);
|
||||||
|
|
||||||
ProjectPart::Ptr projectPart = currentProjectPartInfo.projectPart;
|
ProjectPart::ConstPtr projectPart = currentProjectPartInfo.projectPart;
|
||||||
QList<ProjectPart::Ptr> projectParts = m_projectPartsForFile(filePath);
|
QList<ProjectPart::ConstPtr> projectParts = m_projectPartsForFile(filePath);
|
||||||
bool areProjectPartsFromDependencies = false;
|
bool areProjectPartsFromDependencies = false;
|
||||||
|
|
||||||
if (projectParts.isEmpty()) {
|
if (projectParts.isEmpty()) {
|
||||||
|
@@ -38,10 +38,10 @@ namespace Internal {
|
|||||||
class ProjectPartChooser
|
class ProjectPartChooser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using FallBackProjectPart = std::function<ProjectPart::Ptr()>;
|
using FallBackProjectPart = std::function<ProjectPart::ConstPtr()>;
|
||||||
using ProjectPartsForFile = std::function<QList<ProjectPart::Ptr>(const QString &filePath)>;
|
using ProjectPartsForFile = std::function<QList<ProjectPart::ConstPtr>(const QString &filePath)>;
|
||||||
using ProjectPartsFromDependenciesForFile
|
using ProjectPartsFromDependenciesForFile
|
||||||
= std::function<QList<ProjectPart::Ptr>(const QString &filePath)>;
|
= std::function<QList<ProjectPart::ConstPtr>(const QString &filePath)>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setFallbackProjectPart(const FallBackProjectPart &getter);
|
void setFallbackProjectPart(const FallBackProjectPart &getter);
|
||||||
|
@@ -77,7 +77,7 @@ void CppProjectUpdater::update(const ProjectUpdateInfo &projectUpdateInfo,
|
|||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
|
||||||
// Run the project info generator in a worker thread and continue if that one is finished.
|
// Run the project info generator in a worker thread and continue if that one is finished.
|
||||||
auto generateFuture = Utils::runAsync([=](QFutureInterface<ProjectInfo::Ptr> &futureInterface) {
|
auto generateFuture = Utils::runAsync([=](QFutureInterface<ProjectInfo::ConstPtr> &futureInterface) {
|
||||||
ProjectUpdateInfo fullProjectUpdateInfo = projectUpdateInfo;
|
ProjectUpdateInfo fullProjectUpdateInfo = projectUpdateInfo;
|
||||||
if (fullProjectUpdateInfo.rppGenerator)
|
if (fullProjectUpdateInfo.rppGenerator)
|
||||||
fullProjectUpdateInfo.rawProjectParts = fullProjectUpdateInfo.rppGenerator();
|
fullProjectUpdateInfo.rawProjectParts = fullProjectUpdateInfo.rppGenerator();
|
||||||
|
@@ -70,7 +70,7 @@ private:
|
|||||||
ProjectExplorer::ProjectUpdateInfo m_projectUpdateInfo;
|
ProjectExplorer::ProjectUpdateInfo m_projectUpdateInfo;
|
||||||
QList<QPointer<ProjectExplorer::ExtraCompiler>> m_extraCompilers;
|
QList<QPointer<ProjectExplorer::ExtraCompiler>> m_extraCompilers;
|
||||||
|
|
||||||
QFutureWatcher<ProjectInfo::Ptr> m_generateFutureWatcher;
|
QFutureWatcher<ProjectInfo::ConstPtr> m_generateFutureWatcher;
|
||||||
bool m_isProjectInfoGenerated = false;
|
bool m_isProjectInfoGenerated = false;
|
||||||
QSet<QFutureWatcher<void> *> m_extraCompilersFutureWatchers;
|
QSet<QFutureWatcher<void> *> m_extraCompilersFutureWatchers;
|
||||||
std::unique_ptr<QFutureInterface<void>> m_projectUpdateFutureInterface;
|
std::unique_ptr<QFutureInterface<void>> m_projectUpdateFutureInterface;
|
||||||
|
@@ -38,7 +38,7 @@
|
|||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
|
|
||||||
void CppRefactoringEngine::startLocalRenaming(const CursorInEditor &data,
|
void CppRefactoringEngine::startLocalRenaming(const CursorInEditor &data,
|
||||||
ProjectPart *,
|
const ProjectPart *,
|
||||||
RenameCallback &&renameSymbolsCallback)
|
RenameCallback &&renameSymbolsCallback)
|
||||||
{
|
{
|
||||||
CppEditorWidgetInterface *editorWidget = data.editorWidget();
|
CppEditorWidgetInterface *editorWidget = data.editorWidget();
|
||||||
|
@@ -33,7 +33,7 @@ class CPPTOOLS_EXPORT CppRefactoringEngine : public RefactoringEngineInterface
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void startLocalRenaming(const CursorInEditor &data,
|
void startLocalRenaming(const CursorInEditor &data,
|
||||||
ProjectPart *projectPart,
|
const ProjectPart *projectPart,
|
||||||
RenameCallback &&renameSymbolsCallback) override;
|
RenameCallback &&renameSymbolsCallback) override;
|
||||||
void globalRename(const CursorInEditor &data, UsagesCallback &&,
|
void globalRename(const CursorInEditor &data, UsagesCallback &&,
|
||||||
const QString &replacement) override;
|
const QString &replacement) override;
|
||||||
|
@@ -44,8 +44,8 @@ public:
|
|||||||
Q_DECLARE_FLAGS(Hints, Hint)
|
Q_DECLARE_FLAGS(Hints, Hint)
|
||||||
|
|
||||||
ProjectPartInfo() = default;
|
ProjectPartInfo() = default;
|
||||||
ProjectPartInfo(const ProjectPart::Ptr &projectPart,
|
ProjectPartInfo(const ProjectPart::ConstPtr &projectPart,
|
||||||
const QList<ProjectPart::Ptr> &projectParts,
|
const QList<ProjectPart::ConstPtr> &projectParts,
|
||||||
Hints hints)
|
Hints hints)
|
||||||
: projectPart(projectPart)
|
: projectPart(projectPart)
|
||||||
, projectParts(projectParts)
|
, projectParts(projectParts)
|
||||||
@@ -54,8 +54,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ProjectPart::Ptr projectPart;
|
ProjectPart::ConstPtr projectPart;
|
||||||
QList<ProjectPart::Ptr> projectParts; // The one above as first plus alternatives.
|
QList<ProjectPart::ConstPtr> projectParts; // The one above as first plus alternatives.
|
||||||
Hints hints = NoHint;
|
Hints hints = NoHint;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -44,15 +44,15 @@ CppToolsBridgeQtCreatorImplementation::cppEditorDocument(const QString &filePath
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
CppTools::ProjectPart::Ptr projectPartForFile(const QString &filePath)
|
CppTools::ProjectPart::ConstPtr projectPartForFile(const QString &filePath)
|
||||||
{
|
{
|
||||||
if (const auto parser = BaseEditorDocumentParser::get(filePath))
|
if (const auto parser = BaseEditorDocumentParser::get(filePath))
|
||||||
return parser->projectPartInfo().projectPart;
|
return parser->projectPartInfo().projectPart;
|
||||||
|
|
||||||
return CppTools::ProjectPart::Ptr();
|
return CppTools::ProjectPart::ConstPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isProjectPartValid(const CppTools::ProjectPart::Ptr projectPart)
|
bool isProjectPartValid(const CppTools::ProjectPart::ConstPtr projectPart)
|
||||||
{
|
{
|
||||||
if (projectPart)
|
if (projectPart)
|
||||||
return !CppTools::CppModelManager::instance()->projectPartForId(projectPart->id()).isNull();
|
return !CppTools::CppModelManager::instance()->projectPartForId(projectPart->id()).isNull();
|
||||||
@@ -64,7 +64,7 @@ bool isProjectPartValid(const CppTools::ProjectPart::Ptr projectPart)
|
|||||||
|
|
||||||
QString CppToolsBridgeQtCreatorImplementation::projectPartIdForFile(const QString &filePath) const
|
QString CppToolsBridgeQtCreatorImplementation::projectPartIdForFile(const QString &filePath) const
|
||||||
{
|
{
|
||||||
const CppTools::ProjectPart::Ptr projectPart = projectPartForFile(filePath);
|
const CppTools::ProjectPart::ConstPtr projectPart = projectPartForFile(filePath);
|
||||||
|
|
||||||
if (isProjectPartValid(projectPart))
|
if (isProjectPartValid(projectPart))
|
||||||
return projectPart->id(); // OK, Project Part is still loaded
|
return projectPart->id(); // OK, Project Part is still loaded
|
||||||
|
@@ -514,8 +514,8 @@ QString correspondingHeaderOrSource(const QString &fileName, bool *wasHeader, Ca
|
|||||||
// Find files in other projects
|
// Find files in other projects
|
||||||
} else {
|
} else {
|
||||||
CppModelManager *modelManager = CppModelManager::instance();
|
CppModelManager *modelManager = CppModelManager::instance();
|
||||||
const QList<ProjectInfo::Ptr> projectInfos = modelManager->projectInfos();
|
const QList<ProjectInfo::ConstPtr> projectInfos = modelManager->projectInfos();
|
||||||
for (const ProjectInfo::Ptr &projectInfo : projectInfos) {
|
for (const ProjectInfo::ConstPtr &projectInfo : projectInfos) {
|
||||||
const Project *project = projectForProjectInfo(*projectInfo);
|
const Project *project = projectForProjectInfo(*projectInfo);
|
||||||
if (project == currentProject)
|
if (project == currentProject)
|
||||||
continue; // We have already checked the current project.
|
continue; // We have already checked the current project.
|
||||||
|
@@ -278,7 +278,7 @@ ProjectOpenerAndCloser::~ProjectOpenerAndCloser()
|
|||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectInfo::Ptr ProjectOpenerAndCloser::open(const QString &projectFile,
|
ProjectInfo::ConstPtr ProjectOpenerAndCloser::open(const QString &projectFile,
|
||||||
bool configureAsExampleProject, Kit *kit)
|
bool configureAsExampleProject, Kit *kit)
|
||||||
{
|
{
|
||||||
ProjectExplorerPlugin::OpenProjectResult result =
|
ProjectExplorerPlugin::OpenProjectResult result =
|
||||||
|
@@ -141,8 +141,10 @@ public:
|
|||||||
ProjectOpenerAndCloser();
|
ProjectOpenerAndCloser();
|
||||||
~ProjectOpenerAndCloser(); // Closes opened projects
|
~ProjectOpenerAndCloser(); // Closes opened projects
|
||||||
|
|
||||||
CppTools::ProjectInfo::Ptr open(const QString &projectFile, bool configureAsExampleProject = false,
|
CppTools::ProjectInfo::ConstPtr open(
|
||||||
ProjectExplorer::Kit *kit = nullptr);
|
const QString &projectFile,
|
||||||
|
bool configureAsExampleProject = false,
|
||||||
|
ProjectExplorer::Kit *kit = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<ProjectExplorer::Project *> m_openProjects;
|
QList<ProjectExplorer::Project *> m_openProjects;
|
||||||
|
@@ -77,7 +77,7 @@ ModelManagerTestHelper::~ModelManagerTestHelper()
|
|||||||
void ModelManagerTestHelper::cleanup()
|
void ModelManagerTestHelper::cleanup()
|
||||||
{
|
{
|
||||||
CppModelManager *mm = CppModelManager::instance();
|
CppModelManager *mm = CppModelManager::instance();
|
||||||
QList<ProjectInfo::Ptr> pies = mm->projectInfos();
|
QList<ProjectInfo::ConstPtr> pies = mm->projectInfos();
|
||||||
for (Project * const p : qAsConst(m_projects)) {
|
for (Project * const p : qAsConst(m_projects)) {
|
||||||
ProjectExplorer::SessionManager::removeProject(p);
|
ProjectExplorer::SessionManager::removeProject(p);
|
||||||
emit aboutToRemoveProject(p);
|
emit aboutToRemoveProject(p);
|
||||||
@@ -98,7 +98,7 @@ ModelManagerTestHelper::Project *ModelManagerTestHelper::createProject(
|
|||||||
}
|
}
|
||||||
|
|
||||||
QSet<QString> ModelManagerTestHelper::updateProjectInfo(
|
QSet<QString> ModelManagerTestHelper::updateProjectInfo(
|
||||||
const CppTools::ProjectInfo::Ptr &projectInfo)
|
const CppTools::ProjectInfo::ConstPtr &projectInfo)
|
||||||
{
|
{
|
||||||
resetRefreshedSourceFiles();
|
resetRefreshedSourceFiles();
|
||||||
CppModelManager::instance()->updateProjectInfo(projectInfo).waitForFinished();
|
CppModelManager::instance()->updateProjectInfo(projectInfo).waitForFinished();
|
||||||
|
@@ -63,7 +63,7 @@ public:
|
|||||||
|
|
||||||
Project *createProject(const QString &name, const Utils::FilePath &filePath = {});
|
Project *createProject(const QString &name, const Utils::FilePath &filePath = {});
|
||||||
|
|
||||||
QSet<QString> updateProjectInfo(const ProjectInfo::Ptr &projectInfo);
|
QSet<QString> updateProjectInfo(const ProjectInfo::ConstPtr &projectInfo);
|
||||||
|
|
||||||
void resetRefreshedSourceFiles();
|
void resetRefreshedSourceFiles();
|
||||||
QSet<QString> waitForRefreshedSourceFiles();
|
QSet<QString> waitForRefreshedSourceFiles();
|
||||||
|
@@ -33,13 +33,13 @@
|
|||||||
|
|
||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
|
|
||||||
ProjectInfo::Ptr ProjectInfo::create(const ProjectExplorer::ProjectUpdateInfo &updateInfo,
|
ProjectInfo::ConstPtr ProjectInfo::create(const ProjectExplorer::ProjectUpdateInfo &updateInfo,
|
||||||
const QVector<ProjectPart::Ptr> &projectParts)
|
const QVector<ProjectPart::ConstPtr> &projectParts)
|
||||||
{
|
{
|
||||||
return Ptr(new ProjectInfo(updateInfo, projectParts));
|
return ConstPtr(new ProjectInfo(updateInfo, projectParts));
|
||||||
}
|
}
|
||||||
|
|
||||||
const QVector<ProjectPart::Ptr> ProjectInfo::projectParts() const
|
const QVector<ProjectPart::ConstPtr> ProjectInfo::projectParts() const
|
||||||
{
|
{
|
||||||
return m_projectParts;
|
return m_projectParts;
|
||||||
}
|
}
|
||||||
@@ -80,30 +80,31 @@ bool ProjectInfo::configurationOrFilesChanged(const ProjectInfo &other) const
|
|||||||
return configurationChanged(other) || m_sourceFiles != other.m_sourceFiles;
|
return configurationChanged(other) || m_sourceFiles != other.m_sourceFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QSet<QString> getSourceFiles(const QVector<ProjectPart::Ptr> &projectParts)
|
static QSet<QString> getSourceFiles(const QVector<ProjectPart::ConstPtr> &projectParts)
|
||||||
{
|
{
|
||||||
QSet<QString> sourceFiles;
|
QSet<QString> sourceFiles;
|
||||||
for (const ProjectPart::Ptr &part : projectParts) {
|
for (const ProjectPart::ConstPtr &part : projectParts) {
|
||||||
for (const ProjectFile &file : qAsConst(part->files))
|
for (const ProjectFile &file : qAsConst(part->files))
|
||||||
sourceFiles.insert(file.path);
|
sourceFiles.insert(file.path);
|
||||||
}
|
}
|
||||||
return sourceFiles;
|
return sourceFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ProjectExplorer::Macros getDefines(const QVector<ProjectPart::Ptr> &projectParts)
|
static ProjectExplorer::Macros getDefines(const QVector<ProjectPart::ConstPtr> &projectParts)
|
||||||
{
|
{
|
||||||
ProjectExplorer::Macros defines;
|
ProjectExplorer::Macros defines;
|
||||||
for (const ProjectPart::Ptr &part : projectParts) {
|
for (const ProjectPart::ConstPtr &part : projectParts) {
|
||||||
defines.append(part->toolChainMacros);
|
defines.append(part->toolChainMacros);
|
||||||
defines.append(part->projectMacros);
|
defines.append(part->projectMacros);
|
||||||
}
|
}
|
||||||
return defines;
|
return defines;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ProjectExplorer::HeaderPaths getHeaderPaths(const QVector<ProjectPart::Ptr> &projectParts)
|
static ProjectExplorer::HeaderPaths getHeaderPaths(
|
||||||
|
const QVector<ProjectPart::ConstPtr> &projectParts)
|
||||||
{
|
{
|
||||||
QSet<ProjectExplorer::HeaderPath> uniqueHeaderPaths;
|
QSet<ProjectExplorer::HeaderPath> uniqueHeaderPaths;
|
||||||
for (const ProjectPart::Ptr &part : projectParts) {
|
for (const ProjectPart::ConstPtr &part : projectParts) {
|
||||||
for (const ProjectExplorer::HeaderPath &headerPath : qAsConst(part->headerPaths))
|
for (const ProjectExplorer::HeaderPath &headerPath : qAsConst(part->headerPaths))
|
||||||
uniqueHeaderPaths.insert(headerPath);
|
uniqueHeaderPaths.insert(headerPath);
|
||||||
}
|
}
|
||||||
@@ -111,7 +112,7 @@ static ProjectExplorer::HeaderPaths getHeaderPaths(const QVector<ProjectPart::Pt
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProjectInfo::ProjectInfo(const ProjectExplorer::ProjectUpdateInfo &updateInfo,
|
ProjectInfo::ProjectInfo(const ProjectExplorer::ProjectUpdateInfo &updateInfo,
|
||||||
const QVector<ProjectPart::Ptr> &projectParts)
|
const QVector<ProjectPart::ConstPtr> &projectParts)
|
||||||
: m_projectParts(projectParts),
|
: m_projectParts(projectParts),
|
||||||
m_projectName(updateInfo.projectName),
|
m_projectName(updateInfo.projectName),
|
||||||
m_projectFilePath(updateInfo.projectFilePath),
|
m_projectFilePath(updateInfo.projectFilePath),
|
||||||
|
@@ -45,11 +45,11 @@ namespace CppTools {
|
|||||||
class CPPTOOLS_EXPORT ProjectInfo
|
class CPPTOOLS_EXPORT ProjectInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Ptr = std::shared_ptr<ProjectInfo>;
|
using ConstPtr = std::shared_ptr<const ProjectInfo>;
|
||||||
static Ptr create(const ProjectExplorer::ProjectUpdateInfo &updateInfo,
|
static ConstPtr create(const ProjectExplorer::ProjectUpdateInfo &updateInfo,
|
||||||
const QVector<ProjectPart::Ptr> &projectParts);
|
const QVector<ProjectPart::ConstPtr> &projectParts);
|
||||||
|
|
||||||
const QVector<ProjectPart::Ptr> projectParts() const;
|
const QVector<ProjectPart::ConstPtr> projectParts() const;
|
||||||
const QSet<QString> sourceFiles() const;
|
const QSet<QString> sourceFiles() const;
|
||||||
QString projectName() const { return m_projectName; }
|
QString projectName() const { return m_projectName; }
|
||||||
Utils::FilePath projectFilePath() const { return m_projectFilePath; }
|
Utils::FilePath projectFilePath() const { return m_projectFilePath; }
|
||||||
@@ -65,9 +65,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ProjectInfo(const ProjectExplorer::ProjectUpdateInfo &updateInfo,
|
ProjectInfo(const ProjectExplorer::ProjectUpdateInfo &updateInfo,
|
||||||
const QVector<ProjectPart::Ptr> &projectParts);
|
const QVector<ProjectPart::ConstPtr> &projectParts);
|
||||||
|
|
||||||
const QVector<ProjectPart::Ptr> m_projectParts;
|
const QVector<ProjectPart::ConstPtr> m_projectParts;
|
||||||
const QString m_projectName;
|
const QString m_projectName;
|
||||||
const Utils::FilePath m_projectFilePath;
|
const Utils::FilePath m_projectFilePath;
|
||||||
const Utils::FilePath m_buildRoot;
|
const Utils::FilePath m_buildRoot;
|
||||||
|
@@ -66,9 +66,9 @@ public:
|
|||||||
languagePreference, projectsChanged);
|
languagePreference, projectsChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QList<ProjectPart::Ptr> createProjectPartsWithDifferentProjects()
|
static QList<ProjectPart::ConstPtr> createProjectPartsWithDifferentProjects()
|
||||||
{
|
{
|
||||||
QList<ProjectPart::Ptr> projectParts;
|
QList<ProjectPart::ConstPtr> projectParts;
|
||||||
|
|
||||||
const auto p1 = std::make_shared<Project>(
|
const auto p1 = std::make_shared<Project>(
|
||||||
QString(), Utils::FilePath::fromString("p1.pro"));
|
QString(), Utils::FilePath::fromString("p1.pro"));
|
||||||
@@ -82,16 +82,16 @@ public:
|
|||||||
return projectParts;
|
return projectParts;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QList<ProjectPart::Ptr> createCAndCxxProjectParts()
|
static QList<ProjectPart::ConstPtr> createCAndCxxProjectParts()
|
||||||
{
|
{
|
||||||
QList<ProjectPart::Ptr> projectParts;
|
QList<ProjectPart::ConstPtr> projectParts;
|
||||||
ToolChainInfo tcInfo;
|
ToolChainInfo tcInfo;
|
||||||
|
|
||||||
// Create project part for C
|
// Create project part for C
|
||||||
tcInfo.macroInspectionRunner = [](const QStringList &) {
|
tcInfo.macroInspectionRunner = [](const QStringList &) {
|
||||||
return ToolChain::MacroInspectionReport{{}, Utils::LanguageVersion::C11};
|
return ToolChain::MacroInspectionReport{{}, Utils::LanguageVersion::C11};
|
||||||
};
|
};
|
||||||
const ProjectPart::Ptr cprojectpart = ProjectPart::create({}, {}, {}, {}, {}, {}, {},
|
const ProjectPart::ConstPtr cprojectpart = ProjectPart::create({}, {}, {}, {}, {}, {}, {},
|
||||||
tcInfo);
|
tcInfo);
|
||||||
projectParts.append(cprojectpart);
|
projectParts.append(cprojectpart);
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ public:
|
|||||||
tcInfo.macroInspectionRunner = [](const QStringList &) {
|
tcInfo.macroInspectionRunner = [](const QStringList &) {
|
||||||
return ToolChain::MacroInspectionReport{{}, Utils::LanguageVersion::CXX98};
|
return ToolChain::MacroInspectionReport{{}, Utils::LanguageVersion::CXX98};
|
||||||
};
|
};
|
||||||
const ProjectPart::Ptr cxxprojectpart = ProjectPart::create({}, {}, {}, {}, {}, {}, {},
|
const ProjectPart::ConstPtr cxxprojectpart = ProjectPart::create({}, {}, {}, {}, {}, {}, {},
|
||||||
tcInfo);
|
tcInfo);
|
||||||
projectParts.append(cxxprojectpart);
|
projectParts.append(cxxprojectpart);
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString filePath;
|
QString filePath;
|
||||||
ProjectPart::Ptr currentProjectPart = ProjectPart::create({});
|
ProjectPart::ConstPtr currentProjectPart = ProjectPart::create({});
|
||||||
ProjectPartInfo currentProjectPartInfo{currentProjectPart,
|
ProjectPartInfo currentProjectPartInfo{currentProjectPart,
|
||||||
{currentProjectPart},
|
{currentProjectPart},
|
||||||
ProjectPartInfo::NoHint};
|
ProjectPartInfo::NoHint};
|
||||||
@@ -117,9 +117,9 @@ public:
|
|||||||
bool projectsChanged = false;
|
bool projectsChanged = false;
|
||||||
ProjectPartChooser chooser;
|
ProjectPartChooser chooser;
|
||||||
|
|
||||||
QList<ProjectPart::Ptr> projectPartsForFile;
|
QList<ProjectPart::ConstPtr> projectPartsForFile;
|
||||||
QList<ProjectPart::Ptr> projectPartsFromDependenciesForFile;
|
QList<ProjectPart::ConstPtr> projectPartsFromDependenciesForFile;
|
||||||
ProjectPart::Ptr fallbackProjectPart;
|
ProjectPart::ConstPtr fallbackProjectPart;
|
||||||
|
|
||||||
static QHash<Utils::FilePath, std::shared_ptr<Project>> projectMap;
|
static QHash<Utils::FilePath, std::shared_ptr<Project>> projectMap;
|
||||||
};
|
};
|
||||||
@@ -130,10 +130,10 @@ ProjectPartChooserTestHelper::projectMap;
|
|||||||
|
|
||||||
void ProjectPartChooserTest::testChooseManuallySet()
|
void ProjectPartChooserTest::testChooseManuallySet()
|
||||||
{
|
{
|
||||||
ProjectPart::Ptr p1 = ProjectPart::create({});
|
ProjectPart::ConstPtr p1 = ProjectPart::create({});
|
||||||
RawProjectPart rpp2;
|
RawProjectPart rpp2;
|
||||||
rpp2.setProjectFileLocation("someId");
|
rpp2.setProjectFileLocation("someId");
|
||||||
ProjectPart::Ptr p2 = ProjectPart::create({}, rpp2);
|
ProjectPart::ConstPtr p2 = ProjectPart::create({}, rpp2);
|
||||||
ProjectPartChooserTestHelper t;
|
ProjectPartChooserTestHelper t;
|
||||||
t.preferredProjectPartId = p2->projectFile;
|
t.preferredProjectPartId = p2->projectFile;
|
||||||
t.projectPartsForFile += {p1, p2};
|
t.projectPartsForFile += {p1, p2};
|
||||||
@@ -143,10 +143,10 @@ void ProjectPartChooserTest::testChooseManuallySet()
|
|||||||
|
|
||||||
void ProjectPartChooserTest::testIndicateManuallySet()
|
void ProjectPartChooserTest::testIndicateManuallySet()
|
||||||
{
|
{
|
||||||
ProjectPart::Ptr p1 = ProjectPart::create({});
|
ProjectPart::ConstPtr p1 = ProjectPart::create({});
|
||||||
RawProjectPart rpp2;
|
RawProjectPart rpp2;
|
||||||
rpp2.setProjectFileLocation("someId");
|
rpp2.setProjectFileLocation("someId");
|
||||||
ProjectPart::Ptr p2 = ProjectPart::create({}, rpp2);
|
ProjectPart::ConstPtr p2 = ProjectPart::create({}, rpp2);
|
||||||
ProjectPartChooserTestHelper t;
|
ProjectPartChooserTestHelper t;
|
||||||
t.preferredProjectPartId = p2->projectFile;
|
t.preferredProjectPartId = p2->projectFile;
|
||||||
t.projectPartsForFile += {p1, p2};
|
t.projectPartsForFile += {p1, p2};
|
||||||
@@ -156,10 +156,10 @@ void ProjectPartChooserTest::testIndicateManuallySet()
|
|||||||
|
|
||||||
void ProjectPartChooserTest::testIndicateManuallySetForFallbackToProjectPartFromDependencies()
|
void ProjectPartChooserTest::testIndicateManuallySetForFallbackToProjectPartFromDependencies()
|
||||||
{
|
{
|
||||||
ProjectPart::Ptr p1 = ProjectPart::create({});
|
ProjectPart::ConstPtr p1 = ProjectPart::create({});
|
||||||
RawProjectPart rpp2;
|
RawProjectPart rpp2;
|
||||||
rpp2.setProjectFileLocation("someId");
|
rpp2.setProjectFileLocation("someId");
|
||||||
ProjectPart::Ptr p2 = ProjectPart::create({}, rpp2);
|
ProjectPart::ConstPtr p2 = ProjectPart::create({}, rpp2);
|
||||||
ProjectPartChooserTestHelper t;
|
ProjectPartChooserTestHelper t;
|
||||||
t.preferredProjectPartId = p2->projectFile;
|
t.preferredProjectPartId = p2->projectFile;
|
||||||
t.projectPartsFromDependenciesForFile += {p1, p2};
|
t.projectPartsFromDependenciesForFile += {p1, p2};
|
||||||
@@ -175,8 +175,8 @@ void ProjectPartChooserTest::testDoNotIndicateNotManuallySet()
|
|||||||
void ProjectPartChooserTest::testForMultipleChooseFromActiveProject()
|
void ProjectPartChooserTest::testForMultipleChooseFromActiveProject()
|
||||||
{
|
{
|
||||||
ProjectPartChooserTestHelper t;
|
ProjectPartChooserTestHelper t;
|
||||||
const QList<ProjectPart::Ptr> projectParts = t.createProjectPartsWithDifferentProjects();
|
const QList<ProjectPart::ConstPtr> projectParts = t.createProjectPartsWithDifferentProjects();
|
||||||
const ProjectPart::Ptr secondProjectPart = projectParts.at(1);
|
const ProjectPart::ConstPtr secondProjectPart = projectParts.at(1);
|
||||||
t.projectPartsForFile += projectParts;
|
t.projectPartsForFile += projectParts;
|
||||||
t.activeProject = secondProjectPart->topLevelProject;
|
t.activeProject = secondProjectPart->topLevelProject;
|
||||||
|
|
||||||
@@ -189,8 +189,8 @@ void ProjectPartChooserTest::testForMultiplePreferSelectedForBuilding()
|
|||||||
rpp1.setSelectedForBuilding(false);
|
rpp1.setSelectedForBuilding(false);
|
||||||
RawProjectPart rpp2;
|
RawProjectPart rpp2;
|
||||||
rpp2.setSelectedForBuilding(true);
|
rpp2.setSelectedForBuilding(true);
|
||||||
const ProjectPart::Ptr firstProjectPart = ProjectPart::create({}, rpp1);
|
const ProjectPart::ConstPtr firstProjectPart = ProjectPart::create({}, rpp1);
|
||||||
const ProjectPart::Ptr secondProjectPart = ProjectPart::create({}, rpp2);
|
const ProjectPart::ConstPtr secondProjectPart = ProjectPart::create({}, rpp2);
|
||||||
ProjectPartChooserTestHelper t;
|
ProjectPartChooserTestHelper t;
|
||||||
t.projectPartsForFile += firstProjectPart;
|
t.projectPartsForFile += firstProjectPart;
|
||||||
t.projectPartsForFile += secondProjectPart;
|
t.projectPartsForFile += secondProjectPart;
|
||||||
@@ -201,8 +201,8 @@ void ProjectPartChooserTest::testForMultiplePreferSelectedForBuilding()
|
|||||||
void ProjectPartChooserTest::testForMultipleFromDependenciesChooseFromActiveProject()
|
void ProjectPartChooserTest::testForMultipleFromDependenciesChooseFromActiveProject()
|
||||||
{
|
{
|
||||||
ProjectPartChooserTestHelper t;
|
ProjectPartChooserTestHelper t;
|
||||||
const QList<ProjectPart::Ptr> projectParts = t.createProjectPartsWithDifferentProjects();
|
const QList<ProjectPart::ConstPtr> projectParts = t.createProjectPartsWithDifferentProjects();
|
||||||
const ProjectPart::Ptr secondProjectPart = projectParts.at(1);
|
const ProjectPart::ConstPtr secondProjectPart = projectParts.at(1);
|
||||||
t.projectPartsFromDependenciesForFile += projectParts;
|
t.projectPartsFromDependenciesForFile += projectParts;
|
||||||
t.activeProject = secondProjectPart->topLevelProject;
|
t.activeProject = secondProjectPart->topLevelProject;
|
||||||
|
|
||||||
@@ -212,9 +212,9 @@ void ProjectPartChooserTest::testForMultipleFromDependenciesChooseFromActiveProj
|
|||||||
void ProjectPartChooserTest::testForMultipleCheckIfActiveProjectChanged()
|
void ProjectPartChooserTest::testForMultipleCheckIfActiveProjectChanged()
|
||||||
{
|
{
|
||||||
ProjectPartChooserTestHelper t;
|
ProjectPartChooserTestHelper t;
|
||||||
const QList<ProjectPart::Ptr> projectParts = t.createProjectPartsWithDifferentProjects();
|
const QList<ProjectPart::ConstPtr> projectParts = t.createProjectPartsWithDifferentProjects();
|
||||||
const ProjectPart::Ptr firstProjectPart = projectParts.at(0);
|
const ProjectPart::ConstPtr firstProjectPart = projectParts.at(0);
|
||||||
const ProjectPart::Ptr secondProjectPart = projectParts.at(1);
|
const ProjectPart::ConstPtr secondProjectPart = projectParts.at(1);
|
||||||
t.projectPartsForFile += projectParts;
|
t.projectPartsForFile += projectParts;
|
||||||
t.currentProjectPartInfo.projectPart = firstProjectPart;
|
t.currentProjectPartInfo.projectPart = firstProjectPart;
|
||||||
t.activeProject = secondProjectPart->topLevelProject;
|
t.activeProject = secondProjectPart->topLevelProject;
|
||||||
@@ -227,7 +227,7 @@ void ProjectPartChooserTest::testForMultipleAndAmbigiousHeaderPreferCProjectPart
|
|||||||
ProjectPartChooserTestHelper t;
|
ProjectPartChooserTestHelper t;
|
||||||
t.languagePreference = Language::C;
|
t.languagePreference = Language::C;
|
||||||
t.projectPartsForFile = t.createCAndCxxProjectParts();
|
t.projectPartsForFile = t.createCAndCxxProjectParts();
|
||||||
const ProjectPart::Ptr cProjectPart = t.projectPartsForFile.at(0);
|
const ProjectPart::ConstPtr cProjectPart = t.projectPartsForFile.at(0);
|
||||||
|
|
||||||
QCOMPARE(t.choose().projectPart, cProjectPart);
|
QCOMPARE(t.choose().projectPart, cProjectPart);
|
||||||
}
|
}
|
||||||
@@ -237,15 +237,15 @@ void ProjectPartChooserTest::testForMultipleAndAmbigiousHeaderPreferCxxProjectPa
|
|||||||
ProjectPartChooserTestHelper t;
|
ProjectPartChooserTestHelper t;
|
||||||
t.languagePreference = Language::Cxx;
|
t.languagePreference = Language::Cxx;
|
||||||
t.projectPartsForFile = t.createCAndCxxProjectParts();
|
t.projectPartsForFile = t.createCAndCxxProjectParts();
|
||||||
const ProjectPart::Ptr cxxProjectPart = t.projectPartsForFile.at(1);
|
const ProjectPart::ConstPtr cxxProjectPart = t.projectPartsForFile.at(1);
|
||||||
|
|
||||||
QCOMPARE(t.choose().projectPart, cxxProjectPart);
|
QCOMPARE(t.choose().projectPart, cxxProjectPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectPartChooserTest::testIndicateMultiple()
|
void ProjectPartChooserTest::testIndicateMultiple()
|
||||||
{
|
{
|
||||||
const ProjectPart::Ptr p1 = ProjectPart::create({});
|
const ProjectPart::ConstPtr p1 = ProjectPart::create({});
|
||||||
const ProjectPart::Ptr p2 = ProjectPart::create({});
|
const ProjectPart::ConstPtr p2 = ProjectPart::create({});
|
||||||
ProjectPartChooserTestHelper t;
|
ProjectPartChooserTestHelper t;
|
||||||
t.projectPartsForFile += {p1, p2};
|
t.projectPartsForFile += {p1, p2};
|
||||||
|
|
||||||
@@ -254,8 +254,8 @@ void ProjectPartChooserTest::testIndicateMultiple()
|
|||||||
|
|
||||||
void ProjectPartChooserTest::testIndicateMultipleForFallbackToProjectPartFromDependencies()
|
void ProjectPartChooserTest::testIndicateMultipleForFallbackToProjectPartFromDependencies()
|
||||||
{
|
{
|
||||||
const ProjectPart::Ptr p1 = ProjectPart::create({});
|
const ProjectPart::ConstPtr p1 = ProjectPart::create({});
|
||||||
const ProjectPart::Ptr p2 = ProjectPart::create({});
|
const ProjectPart::ConstPtr p2 = ProjectPart::create({});
|
||||||
ProjectPartChooserTestHelper t;
|
ProjectPartChooserTestHelper t;
|
||||||
t.projectPartsFromDependenciesForFile += {p1, p2};
|
t.projectPartsFromDependenciesForFile += {p1, p2};
|
||||||
|
|
||||||
@@ -264,7 +264,7 @@ void ProjectPartChooserTest::testIndicateMultipleForFallbackToProjectPartFromDep
|
|||||||
|
|
||||||
void ProjectPartChooserTest::testForMultipleChooseNewIfPreviousIsGone()
|
void ProjectPartChooserTest::testForMultipleChooseNewIfPreviousIsGone()
|
||||||
{
|
{
|
||||||
const ProjectPart::Ptr newProjectPart = ProjectPart::create({});
|
const ProjectPart::ConstPtr newProjectPart = ProjectPart::create({});
|
||||||
ProjectPartChooserTestHelper t;
|
ProjectPartChooserTestHelper t;
|
||||||
t.projectPartsForFile += newProjectPart;
|
t.projectPartsForFile += newProjectPart;
|
||||||
|
|
||||||
@@ -273,7 +273,7 @@ void ProjectPartChooserTest::testForMultipleChooseNewIfPreviousIsGone()
|
|||||||
|
|
||||||
void ProjectPartChooserTest::testFallbackToProjectPartFromDependencies()
|
void ProjectPartChooserTest::testFallbackToProjectPartFromDependencies()
|
||||||
{
|
{
|
||||||
const ProjectPart::Ptr fromDependencies = ProjectPart::create({});
|
const ProjectPart::ConstPtr fromDependencies = ProjectPart::create({});
|
||||||
ProjectPartChooserTestHelper t;
|
ProjectPartChooserTestHelper t;
|
||||||
t.projectPartsFromDependenciesForFile += fromDependencies;
|
t.projectPartsFromDependenciesForFile += fromDependencies;
|
||||||
|
|
||||||
@@ -306,7 +306,7 @@ void ProjectPartChooserTest::testStopUsingFallbackFromModelManagerIfProjectChang
|
|||||||
t.fallbackProjectPart = ProjectPart::create({});
|
t.fallbackProjectPart = ProjectPart::create({});
|
||||||
t.currentProjectPartInfo.projectPart = t.fallbackProjectPart;
|
t.currentProjectPartInfo.projectPart = t.fallbackProjectPart;
|
||||||
t.currentProjectPartInfo.hints |= ProjectPartInfo::IsFallbackMatch;
|
t.currentProjectPartInfo.hints |= ProjectPartInfo::IsFallbackMatch;
|
||||||
const ProjectPart::Ptr addedProject = ProjectPart::create({});
|
const ProjectPart::ConstPtr addedProject = ProjectPart::create({});
|
||||||
t.projectPartsForFile += addedProject;
|
t.projectPartsForFile += addedProject;
|
||||||
|
|
||||||
QCOMPARE(t.choose().projectPart, addedProject);
|
QCOMPARE(t.choose().projectPart, addedProject);
|
||||||
@@ -318,7 +318,7 @@ void ProjectPartChooserTest::testStopUsingFallbackFromModelManagerIfProjectChang
|
|||||||
t.fallbackProjectPart = ProjectPart::create({});
|
t.fallbackProjectPart = ProjectPart::create({});
|
||||||
t.currentProjectPartInfo.projectPart = t.fallbackProjectPart;
|
t.currentProjectPartInfo.projectPart = t.fallbackProjectPart;
|
||||||
t.currentProjectPartInfo.hints |= ProjectPartInfo::IsFallbackMatch;
|
t.currentProjectPartInfo.hints |= ProjectPartInfo::IsFallbackMatch;
|
||||||
const ProjectPart::Ptr addedProject = ProjectPart::create({});
|
const ProjectPart::ConstPtr addedProject = ProjectPart::create({});
|
||||||
t.projectPartsFromDependenciesForFile += addedProject;
|
t.projectPartsFromDependenciesForFile += addedProject;
|
||||||
t.projectsChanged = true;
|
t.projectsChanged = true;
|
||||||
|
|
||||||
@@ -380,9 +380,9 @@ public:
|
|||||||
projectUpdateInfo.cToolChainInfo = {&aToolChain, {}, {}};
|
projectUpdateInfo.cToolChainInfo = {&aToolChain, {}, {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectInfo::Ptr generate()
|
ProjectInfo::ConstPtr generate()
|
||||||
{
|
{
|
||||||
QFutureInterface<ProjectInfo::Ptr> fi;
|
QFutureInterface<ProjectInfo::ConstPtr> fi;
|
||||||
|
|
||||||
projectUpdateInfo.rawProjectParts += rawProjectPart;
|
projectUpdateInfo.rawProjectParts += rawProjectPart;
|
||||||
ProjectInfoGenerator generator(fi, projectUpdateInfo);
|
ProjectInfoGenerator generator(fi, projectUpdateInfo);
|
||||||
@@ -398,7 +398,7 @@ public:
|
|||||||
void ProjectInfoGeneratorTest::testCreateNoProjectPartsForEmptyFileList()
|
void ProjectInfoGeneratorTest::testCreateNoProjectPartsForEmptyFileList()
|
||||||
{
|
{
|
||||||
ProjectInfoGeneratorTestHelper t;
|
ProjectInfoGeneratorTestHelper t;
|
||||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
const ProjectInfo::ConstPtr projectInfo = t.generate();
|
||||||
|
|
||||||
QVERIFY(projectInfo->projectParts().isEmpty());
|
QVERIFY(projectInfo->projectParts().isEmpty());
|
||||||
}
|
}
|
||||||
@@ -407,7 +407,7 @@ void ProjectInfoGeneratorTest::testCreateSingleProjectPart()
|
|||||||
{
|
{
|
||||||
ProjectInfoGeneratorTestHelper t;
|
ProjectInfoGeneratorTestHelper t;
|
||||||
t.rawProjectPart.files = QStringList{ "foo.cpp", "foo.h"};
|
t.rawProjectPart.files = QStringList{ "foo.cpp", "foo.h"};
|
||||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
const ProjectInfo::ConstPtr projectInfo = t.generate();
|
||||||
|
|
||||||
QCOMPARE(projectInfo->projectParts().size(), 1);
|
QCOMPARE(projectInfo->projectParts().size(), 1);
|
||||||
}
|
}
|
||||||
@@ -416,7 +416,7 @@ void ProjectInfoGeneratorTest::testCreateMultipleProjectParts()
|
|||||||
{
|
{
|
||||||
ProjectInfoGeneratorTestHelper t;
|
ProjectInfoGeneratorTestHelper t;
|
||||||
t.rawProjectPart.files = QStringList{ "foo.cpp", "foo.h", "bar.c", "bar.h" };
|
t.rawProjectPart.files = QStringList{ "foo.cpp", "foo.h", "bar.c", "bar.h" };
|
||||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
const ProjectInfo::ConstPtr projectInfo = t.generate();
|
||||||
|
|
||||||
QCOMPARE(projectInfo->projectParts().size(), 2);
|
QCOMPARE(projectInfo->projectParts().size(), 2);
|
||||||
}
|
}
|
||||||
@@ -425,7 +425,7 @@ void ProjectInfoGeneratorTest::testProjectPartIndicatesObjectiveCExtensionsByDef
|
|||||||
{
|
{
|
||||||
ProjectInfoGeneratorTestHelper t;
|
ProjectInfoGeneratorTestHelper t;
|
||||||
t.rawProjectPart.files = QStringList{ "foo.mm" };
|
t.rawProjectPart.files = QStringList{ "foo.mm" };
|
||||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
const ProjectInfo::ConstPtr projectInfo = t.generate();
|
||||||
QCOMPARE(projectInfo->projectParts().size(), 1);
|
QCOMPARE(projectInfo->projectParts().size(), 1);
|
||||||
|
|
||||||
const ProjectPart &projectPart = *projectInfo->projectParts().at(0);
|
const ProjectPart &projectPart = *projectInfo->projectParts().at(0);
|
||||||
@@ -436,7 +436,7 @@ void ProjectInfoGeneratorTest::testProjectPartHasLatestLanguageVersionByDefault(
|
|||||||
{
|
{
|
||||||
ProjectInfoGeneratorTestHelper t;
|
ProjectInfoGeneratorTestHelper t;
|
||||||
t.rawProjectPart.files = QStringList{ "foo.cpp" };
|
t.rawProjectPart.files = QStringList{ "foo.cpp" };
|
||||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
const ProjectInfo::ConstPtr projectInfo = t.generate();
|
||||||
QCOMPARE(projectInfo->projectParts().size(), 1);
|
QCOMPARE(projectInfo->projectParts().size(), 1);
|
||||||
|
|
||||||
const ProjectPart &projectPart = *projectInfo->projectParts().at(0);
|
const ProjectPart &projectPart = *projectInfo->projectParts().at(0);
|
||||||
@@ -450,7 +450,7 @@ void ProjectInfoGeneratorTest::testUseMacroInspectionReportForLanguageVersion()
|
|||||||
return TestToolchain::MacroInspectionReport{Macros(), Utils::LanguageVersion::CXX17};
|
return TestToolchain::MacroInspectionReport{Macros(), Utils::LanguageVersion::CXX17};
|
||||||
};
|
};
|
||||||
t.rawProjectPart.files = QStringList{ "foo.cpp" };
|
t.rawProjectPart.files = QStringList{ "foo.cpp" };
|
||||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
const ProjectInfo::ConstPtr projectInfo = t.generate();
|
||||||
|
|
||||||
QCOMPARE(projectInfo->projectParts().size(), 1);
|
QCOMPARE(projectInfo->projectParts().size(), 1);
|
||||||
|
|
||||||
@@ -463,7 +463,7 @@ void ProjectInfoGeneratorTest::testUseCompilerFlagsForLanguageExtensions()
|
|||||||
ProjectInfoGeneratorTestHelper t;
|
ProjectInfoGeneratorTestHelper t;
|
||||||
t.rawProjectPart.files = QStringList{ "foo.cpp" };
|
t.rawProjectPart.files = QStringList{ "foo.cpp" };
|
||||||
t.rawProjectPart.flagsForCxx.languageExtensions = Utils::LanguageExtension::Microsoft;
|
t.rawProjectPart.flagsForCxx.languageExtensions = Utils::LanguageExtension::Microsoft;
|
||||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
const ProjectInfo::ConstPtr projectInfo = t.generate();
|
||||||
|
|
||||||
QCOMPARE(projectInfo->projectParts().size(), 1);
|
QCOMPARE(projectInfo->projectParts().size(), 1);
|
||||||
|
|
||||||
@@ -475,22 +475,22 @@ void ProjectInfoGeneratorTest::testProjectFileKindsMatchProjectPartVersion()
|
|||||||
{
|
{
|
||||||
ProjectInfoGeneratorTestHelper t;
|
ProjectInfoGeneratorTestHelper t;
|
||||||
t.rawProjectPart.files = QStringList{ "foo.h" };
|
t.rawProjectPart.files = QStringList{ "foo.h" };
|
||||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
const ProjectInfo::ConstPtr projectInfo = t.generate();
|
||||||
|
|
||||||
QCOMPARE(projectInfo->projectParts().size(), 4);
|
QCOMPARE(projectInfo->projectParts().size(), 4);
|
||||||
QVERIFY(Utils::contains(projectInfo->projectParts(), [](const ProjectPart::Ptr &p) {
|
QVERIFY(Utils::contains(projectInfo->projectParts(), [](const ProjectPart::ConstPtr &p) {
|
||||||
return p->languageVersion == Utils::LanguageVersion::LatestC
|
return p->languageVersion == Utils::LanguageVersion::LatestC
|
||||||
&& p->files.first().kind == ProjectFile::CHeader;
|
&& p->files.first().kind == ProjectFile::CHeader;
|
||||||
}));
|
}));
|
||||||
QVERIFY(Utils::contains(projectInfo->projectParts(), [](const ProjectPart::Ptr &p) {
|
QVERIFY(Utils::contains(projectInfo->projectParts(), [](const ProjectPart::ConstPtr &p) {
|
||||||
return p->languageVersion == Utils::LanguageVersion::LatestC
|
return p->languageVersion == Utils::LanguageVersion::LatestC
|
||||||
&& p->files.first().kind == ProjectFile::ObjCHeader;
|
&& p->files.first().kind == ProjectFile::ObjCHeader;
|
||||||
}));
|
}));
|
||||||
QVERIFY(Utils::contains(projectInfo->projectParts(), [](const ProjectPart::Ptr &p) {
|
QVERIFY(Utils::contains(projectInfo->projectParts(), [](const ProjectPart::ConstPtr &p) {
|
||||||
return p->languageVersion == Utils::LanguageVersion::LatestCxx
|
return p->languageVersion == Utils::LanguageVersion::LatestCxx
|
||||||
&& p->files.first().kind == ProjectFile::CXXHeader;
|
&& p->files.first().kind == ProjectFile::CXXHeader;
|
||||||
}));
|
}));
|
||||||
QVERIFY(Utils::contains(projectInfo->projectParts(), [](const ProjectPart::Ptr &p) {
|
QVERIFY(Utils::contains(projectInfo->projectParts(), [](const ProjectPart::ConstPtr &p) {
|
||||||
return p->languageVersion == Utils::LanguageVersion::LatestCxx
|
return p->languageVersion == Utils::LanguageVersion::LatestCxx
|
||||||
&& p->files.first().kind == ProjectFile::ObjCXXHeader;
|
&& p->files.first().kind == ProjectFile::ObjCXXHeader;
|
||||||
}));
|
}));
|
||||||
@@ -548,7 +548,7 @@ public:
|
|||||||
Utils::optional<HeaderPathFilter> filter;
|
Utils::optional<HeaderPathFilter> filter;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProjectPart::Ptr projectPart;
|
ProjectPart::ConstPtr projectPart;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -55,10 +55,10 @@ public:
|
|||||||
WordWidth64Bit,
|
WordWidth64Bit,
|
||||||
};
|
};
|
||||||
|
|
||||||
using Ptr = QSharedPointer<ProjectPart>;
|
using ConstPtr = QSharedPointer<const ProjectPart>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Ptr create(const Utils::FilePath &topLevelProject,
|
static ConstPtr create(const Utils::FilePath &topLevelProject,
|
||||||
const ProjectExplorer::RawProjectPart &rpp = {},
|
const ProjectExplorer::RawProjectPart &rpp = {},
|
||||||
const QString &displayName = {},
|
const QString &displayName = {},
|
||||||
const ProjectFiles &files = {},
|
const ProjectFiles &files = {},
|
||||||
@@ -67,7 +67,7 @@ public:
|
|||||||
const ProjectExplorer::RawProjectPartFlags &flags = {},
|
const ProjectExplorer::RawProjectPartFlags &flags = {},
|
||||||
const ProjectExplorer::ToolChainInfo &tcInfo = {})
|
const ProjectExplorer::ToolChainInfo &tcInfo = {})
|
||||||
{
|
{
|
||||||
return Ptr(new ProjectPart(topLevelProject, rpp, displayName, files, language,
|
return ConstPtr(new ProjectPart(topLevelProject, rpp, displayName, files, language,
|
||||||
languageExtensions, flags, tcInfo));
|
languageExtensions, flags, tcInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -65,7 +65,7 @@ public:
|
|||||||
virtual ~RefactoringEngineInterface() = default;
|
virtual ~RefactoringEngineInterface() = default;
|
||||||
|
|
||||||
virtual void startLocalRenaming(const CursorInEditor &data,
|
virtual void startLocalRenaming(const CursorInEditor &data,
|
||||||
CppTools::ProjectPart *projectPart,
|
const CppTools::ProjectPart *projectPart,
|
||||||
RenameCallback &&renameSymbolsCallback) = 0;
|
RenameCallback &&renameSymbolsCallback) = 0;
|
||||||
virtual void globalRename(const CursorInEditor &data,
|
virtual void globalRename(const CursorInEditor &data,
|
||||||
UsagesCallback &&renameCallback,
|
UsagesCallback &&renameCallback,
|
||||||
|
@@ -492,7 +492,7 @@ void SymbolFinder::checkCacheConsistency(const QString &referenceFile, const Sna
|
|||||||
|
|
||||||
const QString projectPartIdForFile(const QString &filePath)
|
const QString projectPartIdForFile(const QString &filePath)
|
||||||
{
|
{
|
||||||
const QList<ProjectPart::Ptr> parts = CppModelManager::instance()->projectPart(filePath);
|
const QList<ProjectPart::ConstPtr> parts = CppModelManager::instance()->projectPart(filePath);
|
||||||
if (!parts.isEmpty())
|
if (!parts.isEmpty())
|
||||||
return parts.first()->id();
|
return parts.first()->id();
|
||||||
return QString();
|
return QString();
|
||||||
|
@@ -58,7 +58,7 @@ void CppTodoItemsScanner::scannerParamsChanged()
|
|||||||
CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
|
CppTools::CppModelManager *modelManager = CppTools::CppModelManager::instance();
|
||||||
|
|
||||||
QSet<QString> filesToBeUpdated;
|
QSet<QString> filesToBeUpdated;
|
||||||
foreach (const CppTools::ProjectInfo::Ptr &info, modelManager->projectInfos())
|
foreach (const CppTools::ProjectInfo::ConstPtr &info, modelManager->projectInfos())
|
||||||
filesToBeUpdated.unite(info->sourceFiles());
|
filesToBeUpdated.unite(info->sourceFiles());
|
||||||
|
|
||||||
modelManager->updateSourceFiles(filesToBeUpdated);
|
modelManager->updateSourceFiles(filesToBeUpdated);
|
||||||
|
Reference in New Issue
Block a user