forked from qt-creator/qt-creator
Meson: Replace most std::for_each by range based for
Change-Id: I18aa38bb84264e0f6a99f431c1caaded9bbbe248 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -65,12 +65,10 @@ public:
|
||||
auto arr = get<QJsonArray>(js.object(), "projectinfo", "buildsystem_files");
|
||||
appendFiles(arr, m_files);
|
||||
auto subprojects = get<QJsonArray>(js.object(), "projectinfo", "subprojects");
|
||||
std::for_each(std::cbegin(*subprojects),
|
||||
std::cend(*subprojects),
|
||||
[this](const auto &subproject) {
|
||||
auto arr = get<QJsonArray>(subproject.toObject(), "buildsystem_files");
|
||||
appendFiles(arr, m_files);
|
||||
});
|
||||
for (const auto &subproject : *subprojects) {
|
||||
auto arr = get<QJsonArray>(subproject.toObject(), "buildsystem_files");
|
||||
appendFiles(arr, m_files);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Utils::FilePath> files() { return m_files; };
|
||||
|
@@ -55,17 +55,13 @@ inline void groupPerSubprojectAndSection(
|
||||
QMap<QString, QMap<QString, std::vector<CancellableOption *>>> &subprojectOptions,
|
||||
QMap<QString, std::vector<CancellableOption *>> &perSectionOptions)
|
||||
{
|
||||
std::for_each(std::cbegin(options),
|
||||
std::cend(options),
|
||||
[&subprojectOptions,
|
||||
&perSectionOptions](const std::unique_ptr<CancellableOption> &option) {
|
||||
if (option->subproject()) {
|
||||
subprojectOptions[*option->subproject()][option->section()].push_back(
|
||||
option.get());
|
||||
} else {
|
||||
perSectionOptions[option->section()].push_back(option.get());
|
||||
}
|
||||
});
|
||||
for (const std::unique_ptr<CancellableOption> &option : options) {
|
||||
if (option->subproject()) {
|
||||
subprojectOptions[*option->subproject()][option->section()].push_back(option.get());
|
||||
} else {
|
||||
perSectionOptions[option->section()].push_back(option.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void makeTree(Utils::TreeItem *root,
|
||||
@@ -76,11 +72,9 @@ void makeTree(Utils::TreeItem *root,
|
||||
[root](const std::pair<QString, std::vector<CancellableOption *>> kv) {
|
||||
const auto &options = kv.second;
|
||||
auto sectionNode = new Utils::StaticTreeItem(kv.first);
|
||||
std::for_each(std::cbegin(options),
|
||||
std::cend(options),
|
||||
[sectionNode](CancellableOption *option) {
|
||||
sectionNode->appendChild(makeBuildOptionTreeItem(option));
|
||||
});
|
||||
for (CancellableOption *option : options) {
|
||||
sectionNode->appendChild(makeBuildOptionTreeItem(option));
|
||||
}
|
||||
root->appendChild(sectionNode);
|
||||
});
|
||||
}
|
||||
@@ -89,13 +83,10 @@ void BuidOptionsModel::setConfiguration(const BuildOptionsList &options)
|
||||
{
|
||||
clear();
|
||||
m_options = decltype(m_options)();
|
||||
std::for_each(std::cbegin(options),
|
||||
std::cend(options),
|
||||
[this](const BuildOptionsList::value_type &option) {
|
||||
m_options.emplace_back(
|
||||
std::make_unique<CancellableOption>(option.get(),
|
||||
lockedOptions.contains(option->name)));
|
||||
});
|
||||
for (const BuildOptionsList::value_type &option : options) {
|
||||
m_options.emplace_back(
|
||||
std::make_unique<CancellableOption>(option.get(), lockedOptions.contains(option->name)));
|
||||
}
|
||||
{
|
||||
QMap<QString, QMap<QString, std::vector<CancellableOption *>>> subprojectOptions;
|
||||
QMap<QString, std::vector<CancellableOption *>> perSectionOptions;
|
||||
@@ -106,8 +97,7 @@ void BuidOptionsModel::setConfiguration(const BuildOptionsList &options)
|
||||
std::for_each(subprojectOptions.constKeyValueBegin(),
|
||||
subprojectOptions.constKeyValueEnd(),
|
||||
[subProjects](
|
||||
const std::pair<QString, QMap<QString, std::vector<CancellableOption *>>>
|
||||
kv) {
|
||||
const std::pair<QString, QMap<QString, std::vector<CancellableOption *>>> kv) {
|
||||
auto subProject = new Utils::StaticTreeItem{kv.first};
|
||||
makeTree(subProject, kv.second);
|
||||
subProjects->appendChild(subProject);
|
||||
@@ -128,13 +118,11 @@ bool BuidOptionsModel::setData(const QModelIndex &idx, const QVariant &data, int
|
||||
QStringList BuidOptionsModel::changesAsMesonArgs()
|
||||
{
|
||||
QStringList args;
|
||||
std::for_each(std::cbegin(m_options),
|
||||
std::cend(m_options),
|
||||
[&](const std::unique_ptr<CancellableOption> &option) {
|
||||
if (option->hasChanged()) {
|
||||
args.push_back(option->mesonArg());
|
||||
}
|
||||
});
|
||||
for (const std::unique_ptr<CancellableOption> &option : m_options) {
|
||||
if (option->hasChanged()) {
|
||||
args.push_back(option->mesonArg());
|
||||
}
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
|
@@ -75,7 +75,7 @@ inline Utils::optional<ProjectExplorer::Macro> extractMacro(const QString &arg)
|
||||
CompilerArgs splitArgs(const QStringList &args)
|
||||
{
|
||||
CompilerArgs splited;
|
||||
std::for_each(std::cbegin(args), std::cend(args), [&splited](const QString &arg) {
|
||||
for (const QString &arg : args) {
|
||||
auto inc = extractInclude(arg);
|
||||
if (inc) {
|
||||
splited.includePaths << *inc;
|
||||
@@ -87,7 +87,7 @@ CompilerArgs splitArgs(const QStringList &args)
|
||||
splited.args << arg;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return splited;
|
||||
}
|
||||
|
||||
@@ -198,22 +198,19 @@ bool MesonProjectParser::parse(const Utils::FilePath &sourcePath)
|
||||
QList<ProjectExplorer::BuildTargetInfo> MesonProjectParser::appsTargets() const
|
||||
{
|
||||
QList<ProjectExplorer::BuildTargetInfo> apps;
|
||||
std::for_each(std::cbegin(m_parserResult.targets),
|
||||
std::cend(m_parserResult.targets),
|
||||
[&apps, srcDir = m_srcDir](const Target &target) {
|
||||
if (target.type == Target::Type::executable) {
|
||||
ProjectExplorer::BuildTargetInfo bti;
|
||||
bti.displayName = target.name;
|
||||
bti.buildKey = Target::fullName(srcDir, target);
|
||||
bti.displayNameUniquifier = bti.buildKey;
|
||||
bti.targetFilePath = Utils::FilePath::fromString(target.fileName.first());
|
||||
bti.workingDirectory
|
||||
= Utils::FilePath::fromString(target.fileName.first()).absolutePath();
|
||||
bti.projectFilePath = Utils::FilePath::fromString(target.definedIn);
|
||||
bti.usesTerminal = true;
|
||||
apps.append(bti);
|
||||
}
|
||||
});
|
||||
for (const Target &target : m_parserResult.targets) {
|
||||
if (target.type == Target::Type::executable) {
|
||||
ProjectExplorer::BuildTargetInfo bti;
|
||||
bti.displayName = target.name;
|
||||
bti.buildKey = Target::fullName(m_srcDir, target);
|
||||
bti.displayNameUniquifier = bti.buildKey;
|
||||
bti.targetFilePath = Utils::FilePath::fromString(target.fileName.first());
|
||||
bti.workingDirectory = Utils::FilePath::fromString(target.fileName.first()).absolutePath();
|
||||
bti.projectFilePath = Utils::FilePath::fromString(target.definedIn);
|
||||
bti.usesTerminal = true;
|
||||
apps.append(bti);
|
||||
}
|
||||
}
|
||||
return apps;
|
||||
}
|
||||
bool MesonProjectParser::startParser()
|
||||
|
@@ -198,9 +198,9 @@ void NinjaBuildStep::setupOutputFormatter(Utils::OutputFormatter *formatter)
|
||||
m_ninjaParser->setSourceDirectory(project()->projectDirectory());
|
||||
formatter->addLineParser(m_ninjaParser);
|
||||
auto additionalParsers = kit()->createOutputParsers();
|
||||
std::for_each(std::cbegin(additionalParsers),
|
||||
std::cend(additionalParsers),
|
||||
[this](const auto parser) { parser->setRedirectionDetector(m_ninjaParser); });
|
||||
for (const auto parser : additionalParsers) {
|
||||
parser->setRedirectionDetector(m_ninjaParser);
|
||||
}
|
||||
formatter->addLineParsers(additionalParsers);
|
||||
formatter->addSearchDir(processParameters()->effectiveWorkingDirectory());
|
||||
AbstractProcessStep::setupOutputFormatter(formatter);
|
||||
|
@@ -80,14 +80,11 @@ std::unique_ptr<MesonProjectNode> ProjectTree::buildTree(const Utils::FilePath &
|
||||
using namespace ProjectExplorer;
|
||||
std::set<Utils::FilePath> targetPaths;
|
||||
auto root = std::make_unique<MesonProjectNode>(srcDir);
|
||||
std::for_each(std::cbegin(targets),
|
||||
std::cend(targets),
|
||||
[&root, &targetPaths](const Target &target) {
|
||||
buildTargetTree(root, target);
|
||||
targetPaths.insert(
|
||||
Utils::FilePath::fromString(target.definedIn).absolutePath());
|
||||
addTargetNode(root, target);
|
||||
});
|
||||
for (const Target &target : targets) {
|
||||
buildTargetTree(root, target);
|
||||
targetPaths.insert(Utils::FilePath::fromString(target.definedIn).absolutePath());
|
||||
addTargetNode(root, target);
|
||||
}
|
||||
for (Utils::FilePath bsFile : bsFiles) {
|
||||
if (!bsFile.toFileInfo().isAbsolute())
|
||||
bsFile = srcDir.pathAppended(bsFile.toString());
|
||||
|
@@ -116,9 +116,9 @@ bool ToolKitAspectWidget::isCompatible(const MesonTools::Tool_t &tool)
|
||||
|
||||
void ToolKitAspectWidget::loadTools()
|
||||
{
|
||||
std::for_each(std::cbegin(MesonTools::tools()),
|
||||
std::cend(MesonTools::tools()),
|
||||
[this](const MesonTools::Tool_t &tool) { addTool(tool); });
|
||||
for (const MesonTools::Tool_t &tool : MesonTools::tools()) {
|
||||
addTool(tool);
|
||||
}
|
||||
refresh();
|
||||
m_toolsComboBox->setEnabled(m_toolsComboBox->count());
|
||||
}
|
||||
|
@@ -59,20 +59,17 @@ void ToolsSettingsAccessor::saveMesonTools(const std::vector<MesonTools::Tool_t>
|
||||
using namespace Constants;
|
||||
QVariantMap data;
|
||||
int entry_count = 0;
|
||||
std::for_each(std::cbegin(tools),
|
||||
std::cend(tools),
|
||||
[&data, &entry_count](const MesonTools::Tool_t &tool) {
|
||||
auto asMeson = std::dynamic_pointer_cast<MesonWrapper>(tool);
|
||||
if (asMeson)
|
||||
data.insert(entryName(entry_count), toVariantMap<MesonWrapper>(*asMeson));
|
||||
else {
|
||||
auto asNinja = std::dynamic_pointer_cast<NinjaWrapper>(tool);
|
||||
if (asNinja)
|
||||
data.insert(entryName(entry_count),
|
||||
toVariantMap<NinjaWrapper>(*asNinja));
|
||||
}
|
||||
entry_count++;
|
||||
});
|
||||
for (const MesonTools::Tool_t &tool : tools) {
|
||||
auto asMeson = std::dynamic_pointer_cast<MesonWrapper>(tool);
|
||||
if (asMeson)
|
||||
data.insert(entryName(entry_count), toVariantMap<MesonWrapper>(*asMeson));
|
||||
else {
|
||||
auto asNinja = std::dynamic_pointer_cast<NinjaWrapper>(tool);
|
||||
if (asNinja)
|
||||
data.insert(entryName(entry_count), toVariantMap<NinjaWrapper>(*asNinja));
|
||||
}
|
||||
entry_count++;
|
||||
}
|
||||
data.insert(ToolsSettings::ENTRY_COUNT, entry_count);
|
||||
saveSettings(data, parent);
|
||||
}
|
||||
|
Reference in New Issue
Block a user