forked from qt-creator/qt-creator
CppTools: Move RawProjectPart to ProjectExplorer
Doesn't have any dependencies into CppTools anymore, therefore moving it reduces the dependencies of the project managers to CppTools as well. Change-Id: Ibe728abe59eb88a8877943dca1f48a85163e27ac Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -63,7 +63,6 @@ add_qtc_plugin(CppTools
|
||||
cppprojectpartchooser.cpp cppprojectpartchooser.h
|
||||
cppprojectupdater.cpp cppprojectupdater.h
|
||||
cppqtstyleindenter.cpp cppqtstyleindenter.h
|
||||
cpprawprojectpart.cpp cpprawprojectpart.h
|
||||
cpprefactoringchanges.cpp cpprefactoringchanges.h
|
||||
cpprefactoringengine.cpp cpprefactoringengine.h
|
||||
cppselectionchanger.cpp cppselectionchanger.h
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "projectpart.h"
|
||||
#include <projectexplorer/rawprojectpart.h>
|
||||
|
||||
#include "cpptools_global.h"
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "cppprojectfile.h"
|
||||
#include "cpprawprojectpart.h"
|
||||
|
||||
#include <projectexplorer/rawprojectpart.h>
|
||||
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
@@ -36,8 +37,8 @@ namespace CppTools {
|
||||
class ProjectFileCategorizer
|
||||
{
|
||||
public:
|
||||
using FileIsActive = RawProjectPart::FileIsActive;
|
||||
using GetMimeType = RawProjectPart::GetMimeType;
|
||||
using FileIsActive = ProjectExplorer::RawProjectPart::FileIsActive;
|
||||
using GetMimeType = ProjectExplorer::RawProjectPart::GetMimeType;
|
||||
|
||||
public:
|
||||
ProjectFileCategorizer(const QString &projectPartName,
|
||||
|
||||
@@ -46,7 +46,7 @@ ProjectInfo ProjectInfoGenerator::generate()
|
||||
{
|
||||
ProjectInfo projectInfo(m_projectUpdateInfo.project);
|
||||
|
||||
for (const RawProjectPart &rpp : m_projectUpdateInfo.rawProjectParts) {
|
||||
for (const ProjectExplorer::RawProjectPart &rpp : m_projectUpdateInfo.rawProjectParts) {
|
||||
if (m_futureInterface.isCanceled())
|
||||
return ProjectInfo();
|
||||
|
||||
@@ -57,8 +57,8 @@ ProjectInfo ProjectInfoGenerator::generate()
|
||||
return projectInfo;
|
||||
}
|
||||
|
||||
static ProjectPart::Ptr projectPartFromRawProjectPart(const RawProjectPart &rawProjectPart,
|
||||
ProjectExplorer::Project *project)
|
||||
static ProjectPart::Ptr projectPartFromRawProjectPart(
|
||||
const ProjectExplorer::RawProjectPart &rawProjectPart, ProjectExplorer::Project *project)
|
||||
{
|
||||
ProjectPart::Ptr part(new ProjectPart);
|
||||
part->project = project;
|
||||
@@ -80,7 +80,8 @@ static ProjectPart::Ptr projectPartFromRawProjectPart(const RawProjectPart &rawP
|
||||
return part;
|
||||
}
|
||||
|
||||
QVector<ProjectPart::Ptr> ProjectInfoGenerator::createProjectParts(const RawProjectPart &rawProjectPart)
|
||||
QVector<ProjectPart::Ptr> ProjectInfoGenerator::createProjectParts(
|
||||
const ProjectExplorer::RawProjectPart &rawProjectPart)
|
||||
{
|
||||
using Utils::LanguageExtension;
|
||||
|
||||
@@ -138,14 +139,14 @@ QVector<ProjectPart::Ptr> ProjectInfoGenerator::createProjectParts(const RawProj
|
||||
}
|
||||
|
||||
ProjectPart::Ptr ProjectInfoGenerator::createProjectPart(
|
||||
const RawProjectPart &rawProjectPart,
|
||||
const ProjectExplorer::RawProjectPart &rawProjectPart,
|
||||
const ProjectPart::Ptr &templateProjectPart,
|
||||
const ProjectFiles &projectFiles,
|
||||
const QString &partName,
|
||||
Language language,
|
||||
Utils::LanguageExtensions languageExtensions)
|
||||
{
|
||||
RawProjectPartFlags flags;
|
||||
ProjectExplorer::RawProjectPartFlags flags;
|
||||
ToolChainInfo tcInfo;
|
||||
if (language == Language::C) {
|
||||
flags = rawProjectPart.flagsForC;
|
||||
|
||||
@@ -42,8 +42,9 @@ public:
|
||||
ProjectInfo generate();
|
||||
|
||||
private:
|
||||
QVector<ProjectPart::Ptr> createProjectParts(const RawProjectPart &rawProjectPart);
|
||||
ProjectPart::Ptr createProjectPart(const RawProjectPart &rawProjectPart,
|
||||
QVector<ProjectPart::Ptr> createProjectParts(
|
||||
const ProjectExplorer::RawProjectPart &rawProjectPart);
|
||||
ProjectPart::Ptr createProjectPart(const ProjectExplorer::RawProjectPart &rawProjectPart,
|
||||
const ProjectPart::Ptr &templateProjectPart,
|
||||
const ProjectFiles &projectFiles,
|
||||
const QString &partName,
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cpprawprojectpart.h"
|
||||
|
||||
#include <projectexplorer/abi.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
RawProjectPartFlags::RawProjectPartFlags(const ProjectExplorer::ToolChain *toolChain,
|
||||
const QStringList &commandLineFlags)
|
||||
{
|
||||
// Keep the following cheap/non-blocking for the ui thread. Expensive
|
||||
// operations are encapsulated in ToolChainInfo as "runners".
|
||||
this->commandLineFlags = commandLineFlags;
|
||||
if (toolChain) {
|
||||
warningFlags = toolChain->warningFlags(commandLineFlags);
|
||||
languageExtensions = toolChain->languageExtensions(commandLineFlags);
|
||||
}
|
||||
}
|
||||
|
||||
void RawProjectPart::setDisplayName(const QString &displayName)
|
||||
{
|
||||
this->displayName = displayName;
|
||||
}
|
||||
|
||||
void RawProjectPart::setFiles(const QStringList &files,
|
||||
const FileIsActive &fileIsActive,
|
||||
const GetMimeType &getMimeType)
|
||||
{
|
||||
this->files = files;
|
||||
this->fileIsActive = fileIsActive;
|
||||
this->getMimeType = getMimeType;
|
||||
}
|
||||
|
||||
static QString trimTrailingSlashes(const QString &path) {
|
||||
QString p = path;
|
||||
while (p.endsWith('/') && p.count() > 1) {
|
||||
p.chop(1);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
ProjectExplorer::HeaderPath RawProjectPart::frameworkDetectionHeuristic(const ProjectExplorer::HeaderPath &header)
|
||||
{
|
||||
QString path = trimTrailingSlashes(header.path);
|
||||
|
||||
if (path.endsWith(".framework")) {
|
||||
path = path.left(path.lastIndexOf(QLatin1Char('/')));
|
||||
return {path, ProjectExplorer::HeaderPathType::Framework};
|
||||
}
|
||||
return header;
|
||||
}
|
||||
|
||||
void RawProjectPart::setProjectFileLocation(const QString &projectFile, int line, int column)
|
||||
{
|
||||
this->projectFile = projectFile;
|
||||
projectFileLine = line;
|
||||
projectFileColumn = column;
|
||||
}
|
||||
|
||||
void RawProjectPart::setConfigFileName(const QString &configFileName)
|
||||
{
|
||||
this->projectConfigFile = configFileName;
|
||||
}
|
||||
|
||||
void RawProjectPart::setBuildSystemTarget(const QString &target)
|
||||
{
|
||||
buildSystemTarget = target;
|
||||
}
|
||||
|
||||
void RawProjectPart::setCallGroupId(const QString &id)
|
||||
{
|
||||
callGroupId = id;
|
||||
}
|
||||
|
||||
void RawProjectPart::setQtVersion(Utils::QtVersion qtVersion)
|
||||
{
|
||||
this->qtVersion = qtVersion;
|
||||
}
|
||||
|
||||
void RawProjectPart::setMacros(const ProjectExplorer::Macros ¯os)
|
||||
{
|
||||
this->projectMacros = macros;
|
||||
}
|
||||
|
||||
void RawProjectPart::setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths)
|
||||
{
|
||||
this->headerPaths = headerPaths;
|
||||
}
|
||||
|
||||
void RawProjectPart::setIncludePaths(const QStringList &includePaths)
|
||||
{
|
||||
this->headerPaths = Utils::transform<QVector>(includePaths, [](const QString &path) {
|
||||
ProjectExplorer::HeaderPath hp(path, ProjectExplorer::HeaderPathType::User);
|
||||
return RawProjectPart::frameworkDetectionHeuristic(hp);
|
||||
});
|
||||
}
|
||||
|
||||
void RawProjectPart::setPreCompiledHeaders(const QStringList &preCompiledHeaders)
|
||||
{
|
||||
this->precompiledHeaders = preCompiledHeaders;
|
||||
}
|
||||
|
||||
void RawProjectPart::setSelectedForBuilding(bool yesno)
|
||||
{
|
||||
this->selectedForBuilding = yesno;
|
||||
}
|
||||
|
||||
void RawProjectPart::setFlagsForC(const RawProjectPartFlags &flags)
|
||||
{
|
||||
flagsForC = flags;
|
||||
}
|
||||
|
||||
void RawProjectPart::setFlagsForCxx(const RawProjectPartFlags &flags)
|
||||
{
|
||||
flagsForCxx = flags;
|
||||
}
|
||||
|
||||
void RawProjectPart::setBuildTargetType(ProjectExplorer::BuildTargetType type)
|
||||
{
|
||||
buildTargetType = type;
|
||||
}
|
||||
|
||||
} // namespace CppTools
|
||||
@@ -1,115 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cpptools_global.h"
|
||||
|
||||
#include <projectexplorer/buildtargettype.h>
|
||||
#include <projectexplorer/projectexplorer_global.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <utils/cpplanguage_details.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
class CPPTOOLS_EXPORT RawProjectPartFlags
|
||||
{
|
||||
public:
|
||||
RawProjectPartFlags() = default;
|
||||
RawProjectPartFlags(const ProjectExplorer::ToolChain *toolChain,
|
||||
const QStringList &commandLineFlags);
|
||||
|
||||
public:
|
||||
QStringList commandLineFlags;
|
||||
// The following are deduced from commandLineFlags.
|
||||
ProjectExplorer::WarningFlags warningFlags = ProjectExplorer::WarningFlags::Default;
|
||||
Utils::LanguageExtensions languageExtensions = Utils::LanguageExtension::None;
|
||||
};
|
||||
|
||||
class CPPTOOLS_EXPORT RawProjectPart
|
||||
{
|
||||
public:
|
||||
void setDisplayName(const QString &displayName);
|
||||
|
||||
void setProjectFileLocation(const QString &projectFile, int line = -1, int column = -1);
|
||||
void setConfigFileName(const QString &configFileName);
|
||||
void setCallGroupId(const QString &id);
|
||||
|
||||
// FileIsActive and GetMimeType must be thread-safe.
|
||||
using FileIsActive = std::function<bool(const QString &filePath)>;
|
||||
using GetMimeType = std::function<QString(const QString &filePath)>;
|
||||
void setFiles(const QStringList &files,
|
||||
const FileIsActive &fileIsActive = {},
|
||||
const GetMimeType &getMimeType = {});
|
||||
static ProjectExplorer::HeaderPath frameworkDetectionHeuristic(const ProjectExplorer::HeaderPath &header);
|
||||
void setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths);
|
||||
void setIncludePaths(const QStringList &includePaths);
|
||||
void setPreCompiledHeaders(const QStringList &preCompiledHeaders);
|
||||
|
||||
void setBuildSystemTarget(const QString &target);
|
||||
void setBuildTargetType(ProjectExplorer::BuildTargetType type);
|
||||
void setSelectedForBuilding(bool yesno);
|
||||
|
||||
void setFlagsForC(const RawProjectPartFlags &flags);
|
||||
void setFlagsForCxx(const RawProjectPartFlags &flags);
|
||||
|
||||
void setMacros(const ProjectExplorer::Macros ¯os);
|
||||
void setQtVersion(Utils::QtVersion qtVersion);
|
||||
|
||||
public:
|
||||
QString displayName;
|
||||
|
||||
QString projectFile;
|
||||
int projectFileLine = -1;
|
||||
int projectFileColumn = -1;
|
||||
QString callGroupId;
|
||||
|
||||
// Files
|
||||
QStringList files;
|
||||
FileIsActive fileIsActive;
|
||||
GetMimeType getMimeType;
|
||||
QStringList precompiledHeaders;
|
||||
ProjectExplorer::HeaderPaths headerPaths;
|
||||
QString projectConfigFile; // Generic Project Manager only
|
||||
|
||||
// Build system
|
||||
QString buildSystemTarget;
|
||||
ProjectExplorer::BuildTargetType buildTargetType = ProjectExplorer::BuildTargetType::Unknown;
|
||||
bool selectedForBuilding = true;
|
||||
|
||||
// Flags
|
||||
RawProjectPartFlags flagsForC;
|
||||
RawProjectPartFlags flagsForCxx;
|
||||
|
||||
// Misc
|
||||
ProjectExplorer::Macros projectMacros;
|
||||
Utils::QtVersion qtVersion = Utils::QtVersion::Unknown;
|
||||
};
|
||||
|
||||
using RawProjectParts = QVector<RawProjectPart>;
|
||||
|
||||
} // namespace CppTools
|
||||
@@ -54,7 +54,6 @@ HEADERS += \
|
||||
cppprojectfile.h \
|
||||
cppprojectupdater.h \
|
||||
cppqtstyleindenter.h \
|
||||
cpprawprojectpart.h \
|
||||
cpprefactoringchanges.h \
|
||||
cpprefactoringengine.h \
|
||||
cppselectionchanger.h \
|
||||
@@ -155,7 +154,6 @@ SOURCES += \
|
||||
cppprojectfile.cpp \
|
||||
cppprojectupdater.cpp \
|
||||
cppqtstyleindenter.cpp \
|
||||
cpprawprojectpart.cpp \
|
||||
cpprefactoringchanges.cpp \
|
||||
cpprefactoringengine.cpp \
|
||||
cppselectionchanger.cpp \
|
||||
|
||||
@@ -144,8 +144,6 @@ Project {
|
||||
"cppprojectupdater.h",
|
||||
"cppqtstyleindenter.cpp",
|
||||
"cppqtstyleindenter.h",
|
||||
"cpprawprojectpart.cpp",
|
||||
"cpprawprojectpart.h",
|
||||
"cpprefactoringchanges.cpp",
|
||||
"cpprefactoringchanges.h",
|
||||
"cpprefactoringengine.cpp",
|
||||
|
||||
@@ -57,7 +57,7 @@ ToolChainInfo::ToolChainInfo(const ProjectExplorer::ToolChain *toolChain,
|
||||
ProjectUpdateInfo::ProjectUpdateInfo(ProjectExplorer::Project *project,
|
||||
const KitInfo &kitInfo,
|
||||
const Utils::Environment &env,
|
||||
const RawProjectParts &rawProjectParts)
|
||||
const ProjectExplorer::RawProjectParts &rawProjectParts)
|
||||
: project(project)
|
||||
, rawProjectParts(rawProjectParts)
|
||||
, cToolChain(kitInfo.cToolChain)
|
||||
|
||||
@@ -27,10 +27,10 @@
|
||||
|
||||
#include "cpptools_global.h"
|
||||
|
||||
#include "cpprawprojectpart.h"
|
||||
#include "projectpart.h"
|
||||
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/rawprojectpart.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
||||
#include <QHash>
|
||||
@@ -70,12 +70,12 @@ public:
|
||||
ProjectUpdateInfo(ProjectExplorer::Project *project,
|
||||
const KitInfo &kitInfo,
|
||||
const Utils::Environment &env,
|
||||
const RawProjectParts &rawProjectParts);
|
||||
const ProjectExplorer::RawProjectParts &rawProjectParts);
|
||||
bool isValid() const { return project && !rawProjectParts.isEmpty(); }
|
||||
|
||||
public:
|
||||
QPointer<ProjectExplorer::Project> project;
|
||||
QVector<RawProjectPart> rawProjectParts;
|
||||
ProjectExplorer::RawProjectParts rawProjectParts;
|
||||
|
||||
const ProjectExplorer::ToolChain *cToolChain = nullptr;
|
||||
const ProjectExplorer::ToolChain *cxxToolChain = nullptr;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <projectexplorer/headerpath.h>
|
||||
#include <projectexplorer/projectexplorer_global.h>
|
||||
#include <projectexplorer/projectmacro.h>
|
||||
#include <projectexplorer/rawprojectpart.h>
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user