CppTools: Move ProjectUpdateInfo to ProjectExplorer

Used for updating project parts, so move it near RawProjectPart.

Change-Id: I77aeffbdbfb3d2ec0de600f61dcf7fbb7a355a98
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Eike Ziller
2019-08-29 09:59:45 +02:00
parent 295fb99cc6
commit ed9177f74c
17 changed files with 147 additions and 225 deletions

View File

@@ -29,7 +29,6 @@
#include "compilationdbparser.h"
#include <coreplugin/icontext.h>
#include <cpptools/cppkitinfo.h>
#include <cpptools/cppprojectupdater.h>
#include <cpptools/projectinfo.h>
#include <projectexplorer/buildinfo.h>
@@ -170,7 +169,7 @@ void addDriverModeFlagIfNeeded(const ToolChain *toolchain,
RawProjectPart makeRawProjectPart(const Utils::FilePath &projectFile,
Kit *kit,
CppTools::KitInfo &kitInfo,
ProjectExplorer::KitInfo &kitInfo,
const QString &workingDir,
const Utils::FilePath &fileName,
QStringList flags)
@@ -338,7 +337,7 @@ void createTree(std::unique_ptr<ProjectNode> &root,
void CompilationDatabaseProject::buildTreeAndProjectParts()
{
CppTools::KitInfo kitInfo(this);
ProjectExplorer::KitInfo kitInfo(this);
QTC_ASSERT(kitInfo.isValid(), return);
// Reset toolchains to pick them based on the database entries.
kitInfo.cToolChain = nullptr;

View File

@@ -48,7 +48,6 @@ add_qtc_plugin(CppTools
cpphoverhandler.cpp cpphoverhandler.h
cppincludesfilter.cpp cppincludesfilter.h
cppindexingsupport.cpp cppindexingsupport.h
cppkitinfo.cpp cppkitinfo.h
cpplocalsymbols.cpp cpplocalsymbols.h
cpplocatordata.cpp cpplocatordata.h
cpplocatorfilter.cpp cpplocatorfilter.h

View File

@@ -1,64 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "cppkitinfo.h"
#include <projectexplorer/kit.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/kitmanager.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <qtsupport/qtkitinformation.h>
namespace CppTools {
using namespace ProjectExplorer;
KitInfo::KitInfo(Project *project)
{
// Kit
if (Target *target = project->activeTarget())
kit = target->kit();
else
kit = KitManager::defaultKit();
// Toolchains
if (kit) {
cToolChain = ToolChainKitAspect::toolChain(kit, Constants::C_LANGUAGE_ID);
cxxToolChain = ToolChainKitAspect::toolChain(kit, Constants::CXX_LANGUAGE_ID);
}
// Sysroot
sysRootPath = ProjectExplorer::SysRootKitAspect::sysRoot(kit).toString();
}
bool KitInfo::isValid() const
{
return kit;
}
} // namespace CppTools

View File

@@ -1,56 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <projectexplorer/rawprojectpart.h>
#include "cpptools_global.h"
namespace ProjectExplorer {
class Kit;
class Project;
class ToolChain;
} // namespace ProjectExplorer
namespace CppTools {
class CPPTOOLS_EXPORT KitInfo
{
public:
explicit KitInfo(ProjectExplorer::Project *project);
bool isValid() const;
ProjectExplorer::Kit *kit = nullptr;
ProjectExplorer::ToolChain *cToolChain = nullptr;
ProjectExplorer::ToolChain *cxxToolChain = nullptr;
Utils::QtVersion projectPartQtVersion = Utils::QtVersion::None;
QString sysRootPath;
};
} // namespace CppTools

View File

@@ -35,8 +35,9 @@
namespace CppTools {
namespace Internal {
ProjectInfoGenerator::ProjectInfoGenerator(const QFutureInterface<void> &futureInterface,
const ProjectUpdateInfo &projectUpdateInfo)
ProjectInfoGenerator::ProjectInfoGenerator(
const QFutureInterface<void> &futureInterface,
const ProjectExplorer::ProjectUpdateInfo &projectUpdateInfo)
: m_futureInterface(futureInterface)
, m_projectUpdateInfo(projectUpdateInfo)
{
@@ -147,7 +148,7 @@ ProjectPart::Ptr ProjectInfoGenerator::createProjectPart(
Utils::LanguageExtensions languageExtensions)
{
ProjectExplorer::RawProjectPartFlags flags;
ToolChainInfo tcInfo;
ProjectExplorer::ToolChainInfo tcInfo;
if (language == Language::C) {
flags = rawProjectPart.flagsForC;
tcInfo = m_projectUpdateInfo.cToolChainInfo;

View File

@@ -37,7 +37,7 @@ class ProjectInfoGenerator
{
public:
ProjectInfoGenerator(const QFutureInterface<void> &futureInterface,
const ProjectUpdateInfo &projectUpdateInfo);
const ProjectExplorer::ProjectUpdateInfo &projectUpdateInfo);
ProjectInfo generate();
@@ -53,7 +53,7 @@ private:
private:
const QFutureInterface<void> m_futureInterface;
const ProjectUpdateInfo &m_projectUpdateInfo;
const ProjectExplorer::ProjectUpdateInfo &m_projectUpdateInfo;
};
} // namespace Internal
} // namespace CppTools

View File

@@ -46,7 +46,7 @@ CppProjectUpdater::~CppProjectUpdater()
cancelAndWaitForFinished();
}
void CppProjectUpdater::update(const ProjectUpdateInfo &projectUpdateInfo)
void CppProjectUpdater::update(const ProjectExplorer::ProjectUpdateInfo &projectUpdateInfo)
{
// Stop previous update.
cancelAndWaitForFinished();

View File

@@ -34,7 +34,6 @@
namespace CppTools {
class ProjectInfo;
class ProjectUpdateInfo;
class CPPTOOLS_EXPORT CppProjectUpdater : public QObject
{
@@ -44,7 +43,7 @@ public:
CppProjectUpdater();
~CppProjectUpdater() override;
void update(const ProjectUpdateInfo &projectUpdateInfo);
void update(const ProjectExplorer::ProjectUpdateInfo &projectUpdateInfo);
void cancel();
private:
@@ -54,7 +53,7 @@ private:
void onProjectInfoGenerated();
private:
ProjectUpdateInfo m_projectUpdateInfo;
ProjectExplorer::ProjectUpdateInfo m_projectUpdateInfo;
QFutureInterface<void> m_futureInterface;
QFutureWatcher<ProjectInfo> m_generateFutureWatcher;

View File

@@ -103,7 +103,6 @@ HEADERS += \
cppmodelmanagerinterface.h \
cppbuiltinmodelmanagersupport.h \
headerpathfilter.h \
cppkitinfo.h \
cpptools_clazychecks.h
SOURCES += \
@@ -190,8 +189,7 @@ SOURCES += \
cppprojectpartchooser.cpp \
wrappablelineedit.cpp \
cppbuiltinmodelmanagersupport.cpp \
headerpathfilter.cpp \
cppkitinfo.cpp
headerpathfilter.cpp
FORMS += \
clangdiagnosticconfigswidget.ui \

View File

@@ -116,8 +116,6 @@ Project {
"cppincludesfilter.h",
"cppindexingsupport.cpp",
"cppindexingsupport.h",
"cppkitinfo.cpp",
"cppkitinfo.h",
"cpplocalsymbols.cpp",
"cpplocalsymbols.h",
"cpplocatordata.cpp",

View File

@@ -25,48 +25,14 @@
#include "projectinfo.h"
#include "cppkitinfo.h"
#include <projectexplorer/abi.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/rawprojectpart.h>
#include <projectexplorer/toolchain.h>
namespace CppTools {
ToolChainInfo::ToolChainInfo(const ProjectExplorer::ToolChain *toolChain,
const QString &sysRootPath, const Utils::Environment &env)
{
if (toolChain) {
// Keep the following cheap/non-blocking for the ui thread...
type = toolChain->typeId();
isMsvc2015ToolChain
= toolChain->targetAbi().osFlavor() == ProjectExplorer::Abi::WindowsMsvc2015Flavor;
wordWidth = toolChain->targetAbi().wordWidth();
targetTriple = toolChain->originalTargetTriple();
extraCodeModelFlags = toolChain->extraCodeModelFlags();
// ...and save the potentially expensive operations for later so that
// they can be run from a worker thread.
this->sysRootPath = sysRootPath;
headerPathsRunner = toolChain->createBuiltInHeaderPathsRunner(env);
macroInspectionRunner = toolChain->createMacroInspectionRunner();
}
}
ProjectUpdateInfo::ProjectUpdateInfo(ProjectExplorer::Project *project,
const KitInfo &kitInfo,
const Utils::Environment &env,
const ProjectExplorer::RawProjectParts &rawProjectParts)
: project(project)
, rawProjectParts(rawProjectParts)
, cToolChain(kitInfo.cToolChain)
, cxxToolChain(kitInfo.cxxToolChain)
, cToolChainInfo(ToolChainInfo(cToolChain, kitInfo.sysRootPath, env))
, cxxToolChainInfo(ToolChainInfo(cxxToolChain, kitInfo.sysRootPath, env))
{
}
ProjectInfo::ProjectInfo(QPointer<ProjectExplorer::Project> project)
: m_project(project)
{

View File

@@ -40,50 +40,6 @@
namespace CppTools {
class KitInfo;
class ToolChainInfo
{
public:
ToolChainInfo() = default;
ToolChainInfo(const ProjectExplorer::ToolChain *toolChain,
const QString &sysRootPath, const Utils::Environment &env);
bool isValid() const { return type.isValid(); }
public:
Core::Id type;
bool isMsvc2015ToolChain = false;
unsigned wordWidth = 0;
QString targetTriple;
QStringList extraCodeModelFlags;
QString sysRootPath; // For headerPathsRunner.
ProjectExplorer::ToolChain::BuiltInHeaderPathsRunner headerPathsRunner;
ProjectExplorer::ToolChain::MacroInspectionRunner macroInspectionRunner;
};
class CPPTOOLS_EXPORT ProjectUpdateInfo
{
public:
ProjectUpdateInfo() = default;
ProjectUpdateInfo(ProjectExplorer::Project *project,
const KitInfo &kitInfo,
const Utils::Environment &env,
const ProjectExplorer::RawProjectParts &rawProjectParts);
bool isValid() const { return project && !rawProjectParts.isEmpty(); }
public:
QPointer<ProjectExplorer::Project> project;
ProjectExplorer::RawProjectParts rawProjectParts;
const ProjectExplorer::ToolChain *cToolChain = nullptr;
const ProjectExplorer::ToolChain *cxxToolChain = nullptr;
ToolChainInfo cToolChainInfo;
ToolChainInfo cxxToolChainInfo;
};
class CPPTOOLS_EXPORT ProjectInfo
{
public:

View File

@@ -27,7 +27,9 @@
#include "abi.h"
#include "kitinformation.h"
#include "project.h"
#include "projectexplorerconstants.h"
#include "target.h"
#include <utils/algorithm.h>
@@ -148,4 +150,64 @@ void RawProjectPart::setBuildTargetType(BuildTargetType type)
buildTargetType = type;
}
KitInfo::KitInfo(Project *project)
{
// Kit
if (Target *target = project->activeTarget())
kit = target->kit();
else
kit = KitManager::defaultKit();
// Toolchains
if (kit) {
cToolChain = ToolChainKitAspect::toolChain(kit, Constants::C_LANGUAGE_ID);
cxxToolChain = ToolChainKitAspect::toolChain(kit, Constants::CXX_LANGUAGE_ID);
}
// Sysroot
sysRootPath = SysRootKitAspect::sysRoot(kit).toString();
}
bool KitInfo::isValid() const
{
return kit;
}
ToolChainInfo::ToolChainInfo(const ToolChain *toolChain,
const QString &sysRootPath,
const Utils::Environment &env)
{
if (toolChain) {
// Keep the following cheap/non-blocking for the ui thread...
type = toolChain->typeId();
isMsvc2015ToolChain = toolChain->targetAbi().osFlavor() == Abi::WindowsMsvc2015Flavor;
wordWidth = toolChain->targetAbi().wordWidth();
targetTriple = toolChain->originalTargetTriple();
extraCodeModelFlags = toolChain->extraCodeModelFlags();
// ...and save the potentially expensive operations for later so that
// they can be run from a worker thread.
this->sysRootPath = sysRootPath;
headerPathsRunner = toolChain->createBuiltInHeaderPathsRunner(env);
macroInspectionRunner = toolChain->createMacroInspectionRunner();
}
}
ProjectUpdateInfo::ProjectUpdateInfo(Project *project,
const KitInfo &kitInfo,
const Utils::Environment &env,
const RawProjectParts &rawProjectParts)
: project(project)
, rawProjectParts(rawProjectParts)
, cToolChain(kitInfo.cToolChain)
, cxxToolChain(kitInfo.cxxToolChain)
, cToolChainInfo(ToolChainInfo(cToolChain, kitInfo.sysRootPath, env))
, cxxToolChainInfo(ToolChainInfo(cxxToolChain, kitInfo.sysRootPath, env))
{}
bool ProjectUpdateInfo::isValid() const
{
return project && !rawProjectParts.isEmpty();
}
} // namespace ProjectExplorer

View File

@@ -31,13 +31,20 @@
#include "projectexplorer_global.h"
#include "projectmacro.h"
// this include style is forced for the cpp unit test mocks
#include <projectexplorer/toolchain.h>
#include <utils/cpplanguage_details.h>
#include <utils/environment.h>
#include <QPointer>
#include <functional>
namespace ProjectExplorer {
class ToolChain;
class Kit;
class Project;
class PROJECTEXPLORER_EXPORT RawProjectPartFlags
{
@@ -114,4 +121,63 @@ public:
using RawProjectParts = QVector<RawProjectPart>;
class PROJECTEXPLORER_EXPORT KitInfo
{
public:
explicit KitInfo(Project *project);
bool isValid() const;
Kit *kit = nullptr;
ToolChain *cToolChain = nullptr;
ToolChain *cxxToolChain = nullptr;
Utils::QtVersion projectPartQtVersion = Utils::QtVersion::None;
QString sysRootPath;
};
class PROJECTEXPLORER_EXPORT ToolChainInfo
{
public:
ToolChainInfo() = default;
ToolChainInfo(const ProjectExplorer::ToolChain *toolChain,
const QString &sysRootPath,
const Utils::Environment &env);
bool isValid() const { return type.isValid(); }
public:
Core::Id type;
bool isMsvc2015ToolChain = false;
unsigned wordWidth = 0;
QString targetTriple;
QStringList extraCodeModelFlags;
QString sysRootPath; // For headerPathsRunner.
ProjectExplorer::ToolChain::BuiltInHeaderPathsRunner headerPathsRunner;
ProjectExplorer::ToolChain::MacroInspectionRunner macroInspectionRunner;
};
class PROJECTEXPLORER_EXPORT ProjectUpdateInfo
{
public:
ProjectUpdateInfo() = default;
ProjectUpdateInfo(Project *project,
const KitInfo &kitInfo,
const Utils::Environment &env,
const RawProjectParts &rawProjectParts);
bool isValid() const;
public:
QPointer<Project> project;
RawProjectParts rawProjectParts;
const ToolChain *cToolChain = nullptr;
const ToolChain *cxxToolChain = nullptr;
ToolChainInfo cToolChainInfo;
ToolChainInfo cxxToolChainInfo;
};
} // namespace ProjectExplorer

View File

@@ -30,10 +30,8 @@
namespace QtSupport {
using namespace CppTools;
CppKitInfo::CppKitInfo(ProjectExplorer::Project *project)
: KitInfo(project)
: ProjectExplorer::KitInfo(project)
{
if (kit && (qtVersion = QtKitAspect::qtVersion(kit))) {
if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5, 0, 0))

View File

@@ -27,13 +27,13 @@
#include "qtsupport_global.h"
#include <cpptools/cppkitinfo.h>
#include <projectexplorer/rawprojectpart.h>
namespace QtSupport {
class BaseQtVersion;
class QTSUPPORT_EXPORT CppKitInfo : public CppTools::KitInfo
class QTSUPPORT_EXPORT CppKitInfo : public ProjectExplorer::KitInfo
{
public:
CppKitInfo(ProjectExplorer::Project *project);

View File

@@ -35,10 +35,10 @@
using CppTools::Internal::ProjectInfoGenerator;
using CppTools::ProjectFile;
using CppTools::ProjectInfo;
using CppTools::ProjectUpdateInfo;
using CppTools::ProjectPart;
using ProjectExplorer::Macros;
using ProjectExplorer::ProjectUpdateInfo;
using ProjectExplorer::RawProjectPart;
using ProjectExplorer::ToolChain;