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