forked from qt-creator/qt-creator
ClangTools: Pass context object to lambda connections
Remove some unneeded lambda () brackets. Change-Id: I502eb5cd89505fb77c02abf44b7ce19541a8ac2f Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -125,7 +125,7 @@ void ClangCodeModelPlugin::createCompilationDBButton()
|
|||||||
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
|
mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD);
|
||||||
|
|
||||||
connect(&m_generatorWatcher, &QFutureWatcher<GenerateCompilationDbResult>::finished,
|
connect(&m_generatorWatcher, &QFutureWatcher<GenerateCompilationDbResult>::finished,
|
||||||
this, [this] () {
|
this, [this] {
|
||||||
const GenerateCompilationDbResult result = m_generatorWatcher.result();
|
const GenerateCompilationDbResult result = m_generatorWatcher.result();
|
||||||
QString message;
|
QString message;
|
||||||
if (result.error.isEmpty()) {
|
if (result.error.isEmpty()) {
|
||||||
|
@@ -483,7 +483,7 @@ void ClangModelManagerSupport::updateLanguageClient(ProjectExplorer::Project *pr
|
|||||||
return;
|
return;
|
||||||
const auto generatorWatcher = new QFutureWatcher<GenerateCompilationDbResult>;
|
const auto generatorWatcher = new QFutureWatcher<GenerateCompilationDbResult>;
|
||||||
connect(generatorWatcher, &QFutureWatcher<GenerateCompilationDbResult>::finished,
|
connect(generatorWatcher, &QFutureWatcher<GenerateCompilationDbResult>::finished,
|
||||||
[this, project, projectInfo, jsonDbDir, generatorWatcher] {
|
this, [this, project, projectInfo, jsonDbDir, generatorWatcher] {
|
||||||
generatorWatcher->deleteLater();
|
generatorWatcher->deleteLater();
|
||||||
if (!isProjectDataUpToDate(project, projectInfo, jsonDbDir))
|
if (!isProjectDataUpToDate(project, projectInfo, jsonDbDir))
|
||||||
return;
|
return;
|
||||||
@@ -781,7 +781,7 @@ void addFixItsActionsToMenu(QMenu *menu, const TextEditor::QuickFixOperations &f
|
|||||||
{
|
{
|
||||||
for (const TextEditor::QuickFixOperation::Ptr &fixItOperation : fixItOperations) {
|
for (const TextEditor::QuickFixOperation::Ptr &fixItOperation : fixItOperations) {
|
||||||
QAction *action = menu->addAction(fixItOperation->description());
|
QAction *action = menu->addAction(fixItOperation->description());
|
||||||
QObject::connect(action, &QAction::triggered, [fixItOperation]() {
|
QObject::connect(action, &QAction::triggered, [fixItOperation] {
|
||||||
fixItOperation->perform();
|
fixItOperation->perform();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -704,7 +704,7 @@ bool runClangBatchFile(const QString &filePath)
|
|||||||
QTC_ASSERT(parser.parse(), return false);
|
QTC_ASSERT(parser.parse(), return false);
|
||||||
const QVector<Command::Ptr> commands = parser.commands();
|
const QVector<Command::Ptr> commands = parser.commands();
|
||||||
|
|
||||||
Utils::ExecuteOnDestruction closeAllEditors([](){
|
Utils::ExecuteOnDestruction closeAllEditors([] {
|
||||||
qWarning("ClangBatchFileProcessor: Finished, closing all documents.");
|
qWarning("ClangBatchFileProcessor: Finished, closing all documents.");
|
||||||
QTC_CHECK(Core::EditorManager::closeAllEditors(/*askAboutModifiedEditors=*/ false));
|
QTC_CHECK(Core::EditorManager::closeAllEditors(/*askAboutModifiedEditors=*/ false));
|
||||||
});
|
});
|
||||||
|
@@ -112,7 +112,7 @@ bool ClangFormatPlugin::initialize(const QStringList &arguments, QString *errorS
|
|||||||
connect(openClangFormatConfigAction,
|
connect(openClangFormatConfigAction,
|
||||||
&QAction::triggered,
|
&QAction::triggered,
|
||||||
this,
|
this,
|
||||||
[openClangFormatConfigAction]() {
|
[openClangFormatConfigAction] {
|
||||||
const FilePath fileName = FilePath::fromVariant(openClangFormatConfigAction->data());
|
const FilePath fileName = FilePath::fromVariant(openClangFormatConfigAction->data());
|
||||||
if (!fileName.isEmpty())
|
if (!fileName.isEmpty())
|
||||||
EditorManager::openEditor(FilePath::fromString(configForFile(fileName)));
|
EditorManager::openEditor(FilePath::fromString(configForFile(fileName)));
|
||||||
|
@@ -294,7 +294,7 @@ SelectableFilesDialog::SelectableFilesDialog(Project *project,
|
|||||||
buttons->setStandardButtons(QDialogButtonBox::Cancel);
|
buttons->setStandardButtons(QDialogButtonBox::Cancel);
|
||||||
buttons->addButton(analyzeButton, QDialogButtonBox::AcceptRole);
|
buttons->addButton(analyzeButton, QDialogButtonBox::AcceptRole);
|
||||||
|
|
||||||
connect(m_filesModel.get(), &QAbstractItemModel::dataChanged, [this, analyzeButton] {
|
connect(m_filesModel.get(), &QAbstractItemModel::dataChanged, this, [this, analyzeButton] {
|
||||||
analyzeButton->setEnabled(m_filesModel->hasCheckedFiles());
|
analyzeButton->setEnabled(m_filesModel->hasCheckedFiles());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -452,7 +452,7 @@ ClangTool::ClangTool()
|
|||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
action->setIcon(Utils::Icons::EXPAND_ALL_TOOLBAR.icon());
|
action->setIcon(Utils::Icons::EXPAND_ALL_TOOLBAR.icon());
|
||||||
action->setToolTip(tr("Expand All"));
|
action->setToolTip(tr("Expand All"));
|
||||||
connect(action, &QAction::toggled, [this](bool checked){
|
connect(action, &QAction::toggled, this, [this](bool checked){
|
||||||
if (checked) {
|
if (checked) {
|
||||||
m_expandCollapse->setToolTip(tr("Collapse All"));
|
m_expandCollapse->setToolTip(tr("Collapse All"));
|
||||||
m_diagnosticView->expandAll();
|
m_diagnosticView->expandAll();
|
||||||
@@ -502,7 +502,7 @@ ClangTool::ClangTool()
|
|||||||
|
|
||||||
updateForCurrentState();
|
updateForCurrentState();
|
||||||
});
|
});
|
||||||
connect(m_applyFixitsButton, &QToolButton::clicked, [this] {
|
connect(m_applyFixitsButton, &QToolButton::clicked, this, [this] {
|
||||||
QVector<DiagnosticItem *> diagnosticItems;
|
QVector<DiagnosticItem *> diagnosticItems;
|
||||||
m_diagnosticModel->forItemsAtLevel<2>([&](DiagnosticItem *item){
|
m_diagnosticModel->forItemsAtLevel<2>([&](DiagnosticItem *item){
|
||||||
diagnosticItems += item;
|
diagnosticItems += item;
|
||||||
@@ -515,7 +515,7 @@ ClangTool::ClangTool()
|
|||||||
action = new QAction(this);
|
action = new QAction(this);
|
||||||
action->setIcon(Utils::Icons::SETTINGS_TOOLBAR.icon());
|
action->setIcon(Utils::Icons::SETTINGS_TOOLBAR.icon());
|
||||||
//action->setToolTip(tr("Open Project Settings")); // TODO: Uncomment in master.
|
//action->setToolTip(tr("Open Project Settings")); // TODO: Uncomment in master.
|
||||||
connect(action, &QAction::triggered, []() {
|
connect(action, &QAction::triggered, [] {
|
||||||
ProjectExplorerPlugin::activateProjectPanel(Constants::PROJECT_PANEL_ID);
|
ProjectExplorerPlugin::activateProjectPanel(Constants::PROJECT_PANEL_ID);
|
||||||
});
|
});
|
||||||
m_openProjectSettings = action;
|
m_openProjectSettings = action;
|
||||||
@@ -911,9 +911,8 @@ void ClangTool::updateForInitialState()
|
|||||||
switch (result.kind)
|
switch (result.kind)
|
||||||
case CheckResult::InvalidTidyExecutable: {
|
case CheckResult::InvalidTidyExecutable: {
|
||||||
case CheckResult::InvalidClazyExecutable:
|
case CheckResult::InvalidClazyExecutable:
|
||||||
m_infoBarWidget->setError(InfoBarWidget::Warning,
|
m_infoBarWidget->setError(InfoBarWidget::Warning, makeLink(result.errorText),
|
||||||
makeLink(result.errorText),
|
[] { ICore::showOptionsDialog(Constants::SETTINGS_PAGE_ID); });
|
||||||
[](){ ICore::showOptionsDialog(Constants::SETTINGS_PAGE_ID); });
|
|
||||||
break;
|
break;
|
||||||
case CheckResult::ProjectNotSuitable:
|
case CheckResult::ProjectNotSuitable:
|
||||||
case CheckResult::ProjectNotOpen:
|
case CheckResult::ProjectNotOpen:
|
||||||
|
@@ -124,7 +124,7 @@ void ClangToolsPlugin::onCurrentEditorChanged()
|
|||||||
if (d->documentRunners.contains(document))
|
if (d->documentRunners.contains(document))
|
||||||
continue;
|
continue;
|
||||||
auto runner = new DocumentClangToolRunner(document);
|
auto runner = new DocumentClangToolRunner(document);
|
||||||
connect(runner, &DocumentClangToolRunner::destroyed, this, [this, document]() {
|
connect(runner, &DocumentClangToolRunner::destroyed, this, [this, document] {
|
||||||
d->documentRunners.remove(document);
|
d->documentRunners.remove(document);
|
||||||
});
|
});
|
||||||
d->documentRunners[document] = runner;
|
d->documentRunners[document] = runner;
|
||||||
@@ -159,7 +159,7 @@ void ClangToolsPlugin::registerAnalyzeActions()
|
|||||||
const QIcon icon = Utils::Icon({{":/debugger/images/debugger_singleinstructionmode.png",
|
const QIcon icon = Utils::Icon({{":/debugger/images/debugger_singleinstructionmode.png",
|
||||||
Utils::Theme::IconsBaseColor}})
|
Utils::Theme::IconsBaseColor}})
|
||||||
.icon();
|
.icon();
|
||||||
QAction *action = widget->toolBar()->addAction(icon, tr("Analyze File"), [this, editor]() {
|
QAction *action = widget->toolBar()->addAction(icon, tr("Analyze File"), [this, editor] {
|
||||||
d->clangTool.startTool(editor->document()->filePath());
|
d->clangTool.startTool(editor->document()->filePath());
|
||||||
});
|
});
|
||||||
cmd->augmentActionWithShortcutToolTip(action);
|
cmd->augmentActionWithShortcutToolTip(action);
|
||||||
|
@@ -984,9 +984,8 @@ DiagnosticConfigsWidget::DiagnosticConfigsWidget(const ClangDiagnosticConfigs &c
|
|||||||
m_clazyChecks->topicsView->clearSelection();
|
m_clazyChecks->topicsView->clearSelection();
|
||||||
});
|
});
|
||||||
m_clazyChecks->topicsView->setSelectionMode(QAbstractItemView::MultiSelection);
|
m_clazyChecks->topicsView->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||||
connect(m_clazyChecks->topicsView->selectionModel(),
|
connect(m_clazyChecks->topicsView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||||
&QItemSelectionModel::selectionChanged,
|
this, [this, topicsModel](const QItemSelection &, const QItemSelection &) {
|
||||||
[this, topicsModel](const QItemSelection &, const QItemSelection &) {
|
|
||||||
const auto indexes = m_clazyChecks->topicsView->selectionModel()->selectedIndexes();
|
const auto indexes = m_clazyChecks->topicsView->selectionModel()->selectedIndexes();
|
||||||
const QStringList topics
|
const QStringList topics
|
||||||
= Utils::transform(indexes, [topicsModel](const QModelIndex &index) {
|
= Utils::transform(indexes, [topicsModel](const QModelIndex &index) {
|
||||||
@@ -996,12 +995,11 @@ DiagnosticConfigsWidget::DiagnosticConfigsWidget(const ClangDiagnosticConfigs &c
|
|||||||
this->syncClazyChecksGroupBox();
|
this->syncClazyChecksGroupBox();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(m_clazyChecks->checksView,
|
connect(m_clazyChecks->checksView, &QTreeView::clicked,
|
||||||
&QTreeView::clicked,
|
this, [model = m_clazySortFilterProxyModel](const QModelIndex &index) {
|
||||||
[model = m_clazySortFilterProxyModel](const QModelIndex &index) {
|
|
||||||
openUrl(model, index);
|
openUrl(model, index);
|
||||||
});
|
});
|
||||||
connect(m_clazyChecks->enableLowerLevelsCheckBox, &QCheckBox::stateChanged, [this](int) {
|
connect(m_clazyChecks->enableLowerLevelsCheckBox, &QCheckBox::stateChanged, this, [this] {
|
||||||
const bool enable = m_clazyChecks->enableLowerLevelsCheckBox->isChecked();
|
const bool enable = m_clazyChecks->enableLowerLevelsCheckBox->isChecked();
|
||||||
m_clazyTreeModel->setEnableLowerLevels(enable);
|
m_clazyTreeModel->setEnableLowerLevels(enable);
|
||||||
codeModelSettings()->setEnableLowerClazyLevels(enable);
|
codeModelSettings()->setEnableLowerClazyLevels(enable);
|
||||||
@@ -1020,9 +1018,8 @@ DiagnosticConfigsWidget::DiagnosticConfigsWidget(const ClangDiagnosticConfigs &c
|
|||||||
connect(m_tidyChecks->filterLineEdit, &Utils::FancyLineEdit::filterChanged, tidyFilterModel,
|
connect(m_tidyChecks->filterLineEdit, &Utils::FancyLineEdit::filterChanged, tidyFilterModel,
|
||||||
qOverload<const QString &>(&QSortFilterProxyModel::setFilterRegularExpression));
|
qOverload<const QString &>(&QSortFilterProxyModel::setFilterRegularExpression));
|
||||||
|
|
||||||
connect(m_tidyChecks->checksPrefixesTree,
|
connect(m_tidyChecks->checksPrefixesTree, &QTreeView::clicked,
|
||||||
&QTreeView::clicked,
|
this, [this, tidyFilterModel](const QModelIndex &proxyIndex) {
|
||||||
[this, tidyFilterModel](const QModelIndex &proxyIndex) {
|
|
||||||
const QModelIndex index = tidyFilterModel->mapToSource(proxyIndex);
|
const QModelIndex index = tidyFilterModel->mapToSource(proxyIndex);
|
||||||
if (index.column() == 2) {
|
if (index.column() == 2) {
|
||||||
if (m_tidyTreeModel->hasChildren(index))
|
if (m_tidyTreeModel->hasChildren(index))
|
||||||
@@ -1070,7 +1067,7 @@ DiagnosticConfigsWidget::DiagnosticConfigsWidget(const ClangDiagnosticConfigs &c
|
|||||||
buttonsBox
|
buttonsBox
|
||||||
}.attachTo(&dialog);
|
}.attachTo(&dialog);
|
||||||
|
|
||||||
QObject::connect(&dialog, &QDialog::accepted, [=, &initialChecks]() {
|
QObject::connect(&dialog, &QDialog::accepted, this, [=, &initialChecks] {
|
||||||
const QString updatedChecks = textEdit->toPlainText();
|
const QString updatedChecks = textEdit->toPlainText();
|
||||||
if (updatedChecks == initialChecks)
|
if (updatedChecks == initialChecks)
|
||||||
return;
|
return;
|
||||||
|
@@ -38,7 +38,7 @@ DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic)
|
|||||||
QAction *action = new QAction();
|
QAction *action = new QAction();
|
||||||
action->setIcon(QIcon::fromTheme("edit-copy", Utils::Icons::COPY.icon()));
|
action->setIcon(QIcon::fromTheme("edit-copy", Utils::Icons::COPY.icon()));
|
||||||
action->setToolTip(tr("Copy to Clipboard"));
|
action->setToolTip(tr("Copy to Clipboard"));
|
||||||
QObject::connect(action, &QAction::triggered, [diagnostic]() {
|
QObject::connect(action, &QAction::triggered, [diagnostic] {
|
||||||
const QString text = createFullLocationString(diagnostic.location)
|
const QString text = createFullLocationString(diagnostic.location)
|
||||||
+ ": "
|
+ ": "
|
||||||
+ diagnostic.description;
|
+ diagnostic.description;
|
||||||
|
@@ -198,12 +198,12 @@ void DocumentClangToolRunner::run()
|
|||||||
|
|
||||||
Environment env = projectBuildEnvironment(project);
|
Environment env = projectBuildEnvironment(project);
|
||||||
if (config.isClangTidyEnabled()) {
|
if (config.isClangTidyEnabled()) {
|
||||||
m_runnerCreators << [this, env, config]() {
|
m_runnerCreators << [this, env, config] {
|
||||||
return createRunner<ClangTidyRunner>(config, env);
|
return createRunner<ClangTidyRunner>(config, env);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (config.isClazyEnabled()) {
|
if (config.isClazyEnabled()) {
|
||||||
m_runnerCreators << [this, env, config]() {
|
m_runnerCreators << [this, env, config] {
|
||||||
return createRunner<ClazyStandaloneRunner>(config, env);
|
return createRunner<ClazyStandaloneRunner>(config, env);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -101,7 +101,7 @@ void RunSettingsWidget::fromSettings(const RunSettings &s)
|
|||||||
disconnect(m_buildBeforeAnalysis, 0, 0, 0);
|
disconnect(m_buildBeforeAnalysis, 0, 0, 0);
|
||||||
m_buildBeforeAnalysis->setToolTip(hintAboutBuildBeforeAnalysis());
|
m_buildBeforeAnalysis->setToolTip(hintAboutBuildBeforeAnalysis());
|
||||||
m_buildBeforeAnalysis->setCheckState(s.buildBeforeAnalysis() ? Qt::Checked : Qt::Unchecked);
|
m_buildBeforeAnalysis->setCheckState(s.buildBeforeAnalysis() ? Qt::Checked : Qt::Unchecked);
|
||||||
connect(m_buildBeforeAnalysis, &QCheckBox::toggled, [this](bool checked) {
|
connect(m_buildBeforeAnalysis, &QCheckBox::toggled, this, [this](bool checked) {
|
||||||
if (!checked)
|
if (!checked)
|
||||||
showHintAboutBuildBeforeAnalysis();
|
showHintAboutBuildBeforeAnalysis();
|
||||||
emit changed();
|
emit changed();
|
||||||
|
Reference in New Issue
Block a user