CppCheck: Tr::tr and code cosmetics

Change-Id: I5e6583984f7dc94e998df3c20840f2ba2e801ab8
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2023-01-09 18:08:30 +01:00
parent 677fd6ba9a
commit 0a0dd9ea31
29 changed files with 163 additions and 286 deletions

View File

@@ -43156,14 +43156,11 @@ Was soll %1 tun?</translation>
</message> </message>
</context> </context>
<context> <context>
<name>Cppcheck::Internal::CppcheckOptionsPage</name> <name>Cppcheck</name>
<message> <message>
<source>Cppcheck</source> <source>Cppcheck</source>
<translation>Cppcheck</translation> <translation>Cppcheck</translation>
</message> </message>
</context>
<context>
<name>Cppcheck::Internal::CppcheckTool</name>
<message> <message>
<source>Cppcheck started: &quot;%1&quot;.</source> <source>Cppcheck started: &quot;%1&quot;.</source>
<translation>Cppcheck gestartet: &quot;%1&quot;.</translation> <translation>Cppcheck gestartet: &quot;%1&quot;.</translation>
@@ -43357,7 +43354,7 @@ Was soll %1 tun?</translation>
</message> </message>
</context> </context>
<context> <context>
<name>CppcheckOptionsPage</name> <name>Cppcheck</name>
<message> <message>
<source>Warnings</source> <source>Warnings</source>
<translation>Warnungen</translation> <translation>Warnungen</translation>
@@ -46119,14 +46116,11 @@ Doppelklicken Sie einen Eintrag um ihn zu ändern.</translation>
</message> </message>
</context> </context>
<context> <context>
<name>Cppcheck::Internal::DiagnosticsModel</name> <name>Cppcheck</name>
<message> <message>
<source>Diagnostic</source> <source>Diagnostic</source>
<translation>Diagnose</translation> <translation>Diagnose</translation>
</message> </message>
</context>
<context>
<name>Cppcheck::Internal::ManualRunDialog</name>
<message> <message>
<source>Cppcheck Run Configuration</source> <source>Cppcheck Run Configuration</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -46135,13 +46129,6 @@ Doppelklicken Sie einen Eintrag um ihn zu ändern.</translation>
<source>Analyze</source> <source>Analyze</source>
<translation>Analysieren</translation> <translation>Analysieren</translation>
</message> </message>
</context>
<context>
<name>Cppcheck::Internal::CppcheckPlugin</name>
<message>
<source>Cppcheck</source>
<translation>Cppcheck</translation>
</message>
<message> <message>
<source>Go to previous diagnostic.</source> <source>Go to previous diagnostic.</source>
<translation>Gehe zum vorherigen Eintrag.</translation> <translation>Gehe zum vorherigen Eintrag.</translation>
@@ -53131,7 +53118,7 @@ in &quot;%2&quot; aus.
</message> </message>
</context> </context>
<context> <context>
<name>Cppcheck::Internal::DiagnosticView</name> <name>Cppcheck</name>
<message> <message>
<source>Cppcheck Diagnostics</source> <source>Cppcheck Diagnostics</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>

View File

@@ -20134,7 +20134,7 @@ u kontrolu verzija (%2)
</message> </message>
</context> </context>
<context> <context>
<name>CppcheckOptionsPage</name> <name>Cppcheck</name>
<message> <message>
<source>Warnings</source> <source>Warnings</source>
<translation>Upozorenja</translation> <translation>Upozorenja</translation>
@@ -20215,23 +20215,14 @@ u kontrolu verzija (%2)
<source>Ignored file patterns:</source> <source>Ignored file patterns:</source>
<translation>Zanemari mustre datoteke:</translation> <translation>Zanemari mustre datoteke:</translation>
</message> </message>
</context>
<context>
<name>Cppcheck::Internal::CppcheckOptionsPage</name>
<message> <message>
<source>Cppcheck</source> <source>Cppcheck</source>
<translation>Cppcheck</translation> <translation>Cppcheck</translation>
</message> </message>
</context>
<context>
<name>Cppcheck::Internal::CppcheckRunner</name>
<message> <message>
<source>Cppcheck failed to start: &quot;%1&quot;.</source> <source>Cppcheck failed to start: &quot;%1&quot;.</source>
<translation>Cppcheck se nije uspio pokrenuti: &quot;%1&quot;.</translation> <translation>Cppcheck se nije uspio pokrenuti: &quot;%1&quot;.</translation>
</message> </message>
</context>
<context>
<name>Cppcheck::Internal::CppcheckTool</name>
<message> <message>
<source>Cppcheck started: &quot;%1&quot;.</source> <source>Cppcheck started: &quot;%1&quot;.</source>
<translation>Cppcheck je pokrenut: &quot;%1&quot;.</translation> <translation>Cppcheck je pokrenut: &quot;%1&quot;.</translation>

View File

@@ -48204,14 +48204,11 @@ Continue?</source>
</message> </message>
</context> </context>
<context> <context>
<name>Cppcheck::Internal::DiagnosticsModel</name> <name>Cppcheck</name>
<message> <message>
<source>Diagnostic</source> <source>Diagnostic</source>
<translation></translation> <translation></translation>
</message> </message>
</context>
<context>
<name>CppcheckOptionsPage</name>
<message> <message>
<source>Warnings</source> <source>Warnings</source>
<translation></translation> <translation></translation>
@@ -48228,9 +48225,6 @@ Continue?</source>
<source>Ignored file patterns:</source> <source>Ignored file patterns:</source>
<translation>:</translation> <translation>:</translation>
</message> </message>
</context>
<context>
<name>Cppcheck::Internal::CppcheckPlugin</name>
<message> <message>
<source>Clear</source> <source>Clear</source>
<translation></translation> <translation></translation>

View File

@@ -12897,14 +12897,7 @@ Flags: %3</source>
</message> </message>
</context> </context>
<context> <context>
<name>Cppcheck::Internal::CppcheckOptionsPage</name> <name>Cppcheck</name>
<message>
<source>Cppcheck</source>
<translation>Cppcheck</translation>
</message>
</context>
<context>
<name>Cppcheck::Internal::CppcheckPlugin</name>
<message> <message>
<source>Cppcheck</source> <source>Cppcheck</source>
<translation>Cppcheck</translation> <translation>Cppcheck</translation>
@@ -12925,16 +12918,10 @@ Flags: %3</source>
<source>Cppcheck...</source> <source>Cppcheck...</source>
<translation>Cppcheck...</translation> <translation>Cppcheck...</translation>
</message> </message>
</context>
<context>
<name>Cppcheck::Internal::CppcheckRunner</name>
<message> <message>
<source>Cppcheck failed to start: &quot;%1&quot;.</source> <source>Cppcheck failed to start: &quot;%1&quot;.</source>
<translation>Не удалось запустить Cppcheck: «%1».</translation> <translation>Не удалось запустить Cppcheck: «%1».</translation>
</message> </message>
</context>
<context>
<name>Cppcheck::Internal::CppcheckTool</name>
<message> <message>
<source>Cppcheck started: &quot;%1&quot;.</source> <source>Cppcheck started: &quot;%1&quot;.</source>
<translation>Cppcheck запустился: «%1».</translation> <translation>Cppcheck запустился: «%1».</translation>
@@ -12943,23 +12930,14 @@ Flags: %3</source>
<source>Cppcheck finished.</source> <source>Cppcheck finished.</source>
<translation>Cppcheck завершился.</translation> <translation>Cppcheck завершился.</translation>
</message> </message>
</context>
<context>
<name>Cppcheck::Internal::DiagnosticView</name>
<message> <message>
<source>Cppcheck Diagnostics</source> <source>Cppcheck Diagnostics</source>
<translation>Проблемы Cppcheck</translation> <translation>Проблемы Cppcheck</translation>
</message> </message>
</context>
<context>
<name>Cppcheck::Internal::DiagnosticsModel</name>
<message> <message>
<source>Diagnostic</source> <source>Diagnostic</source>
<translation>Проблема</translation> <translation>Проблема</translation>
</message> </message>
</context>
<context>
<name>Cppcheck::Internal::ManualRunDialog</name>
<message> <message>
<source>Cppcheck Run Configuration</source> <source>Cppcheck Run Configuration</source>
<translation>Конфигурация запуска Cppcheck</translation> <translation>Конфигурация запуска Cppcheck</translation>
@@ -12968,9 +12946,6 @@ Flags: %3</source>
<source>Analyze</source> <source>Analyze</source>
<translation>Анализировать</translation> <translation>Анализировать</translation>
</message> </message>
</context>
<context>
<name>CppcheckOptionsPage</name>
<message> <message>
<source>Warnings</source> <source>Warnings</source>
<translation>Предупреждения</translation> <translation>Предупреждения</translation>

View File

@@ -14006,14 +14006,7 @@ e.g. name = &quot;m_test_foo_&quot;:
</message> </message>
</context> </context>
<context> <context>
<name>Cppcheck::Internal::CppcheckOptionsPage</name> <name>Cppcheck</name>
<message>
<source>Cppcheck</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Cppcheck::Internal::CppcheckPlugin</name>
<message> <message>
<source>Cppcheck</source> <source>Cppcheck</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -14034,9 +14027,6 @@ e.g. name = &quot;m_test_foo_&quot;:
<source>Cppcheck...</source> <source>Cppcheck...</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context>
<context>
<name>Cppcheck::Internal::CppcheckTool</name>
<message> <message>
<source>Cppcheck started: &quot;%1&quot;.</source> <source>Cppcheck started: &quot;%1&quot;.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -14045,23 +14035,14 @@ e.g. name = &quot;m_test_foo_&quot;:
<source>Cppcheck finished.</source> <source>Cppcheck finished.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context>
<context>
<name>Cppcheck::Internal::DiagnosticView</name>
<message> <message>
<source>Cppcheck Diagnostics</source> <source>Cppcheck Diagnostics</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context>
<context>
<name>Cppcheck::Internal::DiagnosticsModel</name>
<message> <message>
<source>Diagnostic</source> <source>Diagnostic</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context>
<context>
<name>Cppcheck::Internal::ManualRunDialog</name>
<message> <message>
<source>Cppcheck Run Configuration</source> <source>Cppcheck Run Configuration</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@@ -14070,9 +14051,6 @@ e.g. name = &quot;m_test_foo_&quot;:
<source>Analyze</source> <source>Analyze</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context>
<context>
<name>CppcheckOptionsPage</name>
<message> <message>
<source>Warnings</source> <source>Warnings</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>

View File

@@ -3,8 +3,7 @@
#pragma once #pragma once
namespace Cppcheck { namespace Cppcheck::Constants {
namespace Constants {
const char TEXTMARK_CATEGORY_ID[] = "Cppcheck"; const char TEXTMARK_CATEGORY_ID[] = "Cppcheck";
@@ -33,5 +32,4 @@ const char MANUAL_CHECK_PROGRESS_ID[] = "Cppcheck.ManualCheckingTask";
const char MANUAL_RUN_ACTION[] = "Cppcheck.ManualRun"; const char MANUAL_RUN_ACTION[] = "Cppcheck.ManualRun";
const char PERSPECTIVE_ID[] = "Cppcheck.Perspective"; const char PERSPECTIVE_ID[] = "Cppcheck.Perspective";
} // namespace Constants } // Cppcheck::Constants
} // namespace Cppcheck

View File

@@ -3,8 +3,7 @@
#include "cppcheckdiagnostic.h" #include "cppcheckdiagnostic.h"
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
bool Diagnostic::operator==(const Diagnostic &r) const bool Diagnostic::operator==(const Diagnostic &r) const
{ {
@@ -16,5 +15,5 @@ size_t qHash(const Diagnostic &diagnostic)
{ {
return qHash(diagnostic.message) ^ qHash(diagnostic.fileName) ^ diagnostic.lineNumber; return qHash(diagnostic.message) ^ qHash(diagnostic.fileName) ^ diagnostic.lineNumber;
} }
} // namespace Internal
} // namespace Cppcheck } // namespace Cppcheck

View File

@@ -3,10 +3,9 @@
#pragma once #pragma once
#include <utils/fileutils.h> #include <utils/filepath.h>
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
class Diagnostic final class Diagnostic final
{ {
@@ -29,5 +28,4 @@ public:
size_t qHash(const Diagnostic &diagnostic); size_t qHash(const Diagnostic &diagnostic);
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -3,8 +3,7 @@
#pragma once #pragma once
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
class Diagnostic; class Diagnostic;
@@ -15,5 +14,4 @@ public:
virtual void add(const Diagnostic &diagnostic) = 0; virtual void add(const Diagnostic &diagnostic) = 0;
}; };
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -3,16 +3,17 @@
#include "cppcheckdiagnosticsmodel.h" #include "cppcheckdiagnosticsmodel.h"
#include "cppchecktr.h"
#include <debugger/analyzer/diagnosticlocation.h> #include <debugger/analyzer/diagnosticlocation.h>
#include <utils/fsengine/fileiconprovider.h> #include <utils/fsengine/fileiconprovider.h>
#include <utils/utilsicons.h> #include <utils/utilsicons.h>
namespace Cppcheck {
namespace Internal {
using namespace Debugger; using namespace Debugger;
namespace Cppcheck::Internal {
FilePathItem::FilePathItem(const QString &filePath) FilePathItem::FilePathItem(const QString &filePath)
: m_filePath(filePath) : m_filePath(filePath)
{} {}
@@ -83,7 +84,7 @@ QVariant DiagnosticItem::data(int column, int role) const
DiagnosticsModel::DiagnosticsModel(QObject *parent) DiagnosticsModel::DiagnosticsModel(QObject *parent)
: BaseModel(parent) : BaseModel(parent)
{ {
setHeader({tr("Diagnostic")}); setHeader({Tr::tr("Diagnostic")});
} }
void DiagnosticsModel::clear() void DiagnosticsModel::clear()
@@ -116,5 +117,4 @@ void DiagnosticsModel::add(const Diagnostic &diagnostic)
filePathItem->appendChild(new DiagnosticItem(diagnostic)); filePathItem->appendChild(new DiagnosticItem(diagnostic));
} }
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -10,8 +10,7 @@
#include <utils/treemodel.h> #include <utils/treemodel.h>
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
class DiagnosticsModel; class DiagnosticsModel;
@@ -55,5 +54,4 @@ private:
QSet<Diagnostic> m_diagnostics; QSet<Diagnostic> m_diagnostics;
}; };
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -3,15 +3,16 @@
#include "cppcheckdiagnosticview.h" #include "cppcheckdiagnosticview.h"
#include "cppchecktr.h"
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <debugger/analyzer/diagnosticlocation.h> #include <debugger/analyzer/diagnosticlocation.h>
namespace Cppcheck {
namespace Internal {
using namespace Debugger; using namespace Debugger;
namespace Cppcheck::Internal {
DiagnosticView::DiagnosticView(QWidget *parent) DiagnosticView::DiagnosticView(QWidget *parent)
: DetailedErrorView(parent) : DetailedErrorView(parent)
{ {
@@ -21,7 +22,7 @@ DiagnosticView::DiagnosticView(QWidget *parent)
setAutoScroll(false); setAutoScroll(false);
sortByColumn(DiagnosticColumn, Qt::AscendingOrder); sortByColumn(DiagnosticColumn, Qt::AscendingOrder);
setObjectName("CppcheckIssuesView"); setObjectName("CppcheckIssuesView");
setWindowTitle(tr("Cppcheck Diagnostics")); setWindowTitle(Tr::tr("Cppcheck Diagnostics"));
setHeaderHidden(true); setHeaderHidden(true);
} }
@@ -90,7 +91,4 @@ void DiagnosticView::mouseDoubleClickEvent(QMouseEvent *event)
DetailedErrorView::mouseDoubleClickEvent(event); DetailedErrorView::mouseDoubleClickEvent(event);
} }
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck
//#include "clangtoolsdiagnosticview.moc"

View File

@@ -5,12 +5,10 @@
#include <debugger/analyzer/detailederrorview.h> #include <debugger/analyzer/detailederrorview.h>
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
class DiagnosticView : public Debugger::DetailedErrorView class DiagnosticView : public Debugger::DetailedErrorView
{ {
Q_OBJECT
public: public:
explicit DiagnosticView(QWidget *parent = nullptr); explicit DiagnosticView(QWidget *parent = nullptr);
~DiagnosticView() override; ~DiagnosticView() override;
@@ -23,5 +21,4 @@ private:
void mouseDoubleClickEvent(QMouseEvent *event) override; void mouseDoubleClickEvent(QMouseEvent *event) override;
}; };
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -2,7 +2,9 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "cppcheckmanualrundialog.h" #include "cppcheckmanualrundialog.h"
#include "cppcheckoptions.h" #include "cppcheckoptions.h"
#include "cppchecktr.h"
#include <projectexplorer/selectablefilesmodel.h> #include <projectexplorer/selectablefilesmodel.h>
@@ -14,8 +16,7 @@
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QPushButton> #include <QPushButton>
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
ManualRunDialog::ManualRunDialog(const CppcheckOptions &options, ManualRunDialog::ManualRunDialog(const CppcheckOptions &options,
const ProjectExplorer::Project *project) const ProjectExplorer::Project *project)
@@ -25,7 +26,7 @@ ManualRunDialog::ManualRunDialog(const CppcheckOptions &options,
{ {
QTC_ASSERT(project, return ); QTC_ASSERT(project, return );
setWindowTitle(tr("Cppcheck Run Configuration")); setWindowTitle(Tr::tr("Cppcheck Run Configuration"));
auto view = new QTreeView; auto view = new QTreeView;
view->setHeaderHidden(true); view->setHeaderHidden(true);
@@ -45,7 +46,7 @@ ManualRunDialog::ManualRunDialog(const CppcheckOptions &options,
connect(buttons, &QDialogButtonBox::rejected, connect(buttons, &QDialogButtonBox::rejected,
this, &QDialog::reject); this, &QDialog::reject);
auto analyzeButton = new QPushButton(tr("Analyze")); auto analyzeButton = new QPushButton(Tr::tr("Analyze"));
buttons->addButton(analyzeButton, QDialogButtonBox::AcceptRole); buttons->addButton(analyzeButton, QDialogButtonBox::AcceptRole);
analyzeButton->setEnabled(m_model->hasCheckedFiles()); analyzeButton->setEnabled(m_model->hasCheckedFiles());
connect(m_model, &QAbstractItemModel::dataChanged, connect(m_model, &QAbstractItemModel::dataChanged,
@@ -82,5 +83,4 @@ QSize ManualRunDialog::sizeHint() const
return {original.width() * 2, original.height()}; return {original.width() * 2, original.height()};
} }
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -8,22 +8,20 @@
namespace Utils { namespace Utils {
class FilePath; class FilePath;
using FilePaths = QList<FilePath>; using FilePaths = QList<FilePath>;
} // namespace Utils } // Utils
namespace ProjectExplorer { namespace ProjectExplorer {
class Project; class Project;
class SelectableFilesFromDirModel; class SelectableFilesFromDirModel;
} // namespace ProjectExplorer } // ProjectExplorer
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
class OptionsWidget; class OptionsWidget;
class CppcheckOptions; class CppcheckOptions;
class ManualRunDialog : public QDialog class ManualRunDialog : public QDialog
{ {
Q_OBJECT
public: public:
ManualRunDialog(const CppcheckOptions &options, ManualRunDialog(const CppcheckOptions &options,
const ProjectExplorer::Project *project); const ProjectExplorer::Project *project);
@@ -37,5 +35,4 @@ private:
ProjectExplorer::SelectableFilesFromDirModel *m_model; ProjectExplorer::SelectableFilesFromDirModel *m_model;
}; };
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -1,9 +1,11 @@
// Copyright (C) 2018 Sergey Morozov // Copyright (C) 2018 Sergey Morozov
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "cppcheckconstants.h"
#include "cppcheckoptions.h" #include "cppcheckoptions.h"
#include "cppcheckconstants.h"
#include "cppchecktool.h" #include "cppchecktool.h"
#include "cppchecktr.h"
#include "cppchecktrigger.h" #include "cppchecktrigger.h"
#include <utils/environment.h> #include <utils/environment.h>
@@ -22,26 +24,25 @@
using namespace Utils; using namespace Utils;
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
OptionsWidget::OptionsWidget(QWidget *parent) OptionsWidget::OptionsWidget(QWidget *parent)
: QWidget(parent), : QWidget(parent),
m_binary(new Utils::PathChooser(this)), m_binary(new Utils::PathChooser(this)),
m_customArguments(new QLineEdit(this)), m_customArguments(new QLineEdit(this)),
m_ignorePatterns(new QLineEdit(this)), m_ignorePatterns(new QLineEdit(this)),
m_warning(new QCheckBox(tr("Warnings"), this)), m_warning(new QCheckBox(Tr::tr("Warnings"), this)),
m_style(new QCheckBox(tr("Style"), this)), m_style(new QCheckBox(Tr::tr("Style"), this)),
m_performance(new QCheckBox(tr("Performance"), this)), m_performance(new QCheckBox(Tr::tr("Performance"), this)),
m_portability(new QCheckBox(tr("Portability"), this)), m_portability(new QCheckBox(Tr::tr("Portability"), this)),
m_information(new QCheckBox(tr("Information"), this)), m_information(new QCheckBox(Tr::tr("Information"), this)),
m_unusedFunction(new QCheckBox(tr("Unused functions"), this)), m_unusedFunction(new QCheckBox(Tr::tr("Unused functions"), this)),
m_missingInclude(new QCheckBox(tr("Missing includes"), this)), m_missingInclude(new QCheckBox(Tr::tr("Missing includes"), this)),
m_inconclusive(new QCheckBox(tr("Inconclusive errors"), this)), m_inconclusive(new QCheckBox(Tr::tr("Inconclusive errors"), this)),
m_forceDefines(new QCheckBox(tr("Check all define combinations"), this)), m_forceDefines(new QCheckBox(Tr::tr("Check all define combinations"), this)),
m_showOutput(new QCheckBox(tr("Show raw output"), this)), m_showOutput(new QCheckBox(Tr::tr("Show raw output"), this)),
m_addIncludePaths(new QCheckBox(tr("Add include paths"), this)), m_addIncludePaths(new QCheckBox(Tr::tr("Add include paths"), this)),
m_guessArguments(new QCheckBox(tr("Calculate additional arguments"), this)) m_guessArguments(new QCheckBox(Tr::tr("Calculate additional arguments"), this))
{ {
m_binary->setExpectedKind(Utils::PathChooser::ExistingCommand); m_binary->setExpectedKind(Utils::PathChooser::ExistingCommand);
m_binary->setCommandVersionArguments({"--version"}); m_binary->setCommandVersionArguments({"--version"});
@@ -49,18 +50,18 @@ OptionsWidget::OptionsWidget(QWidget *parent)
auto variableChooser = new Utils::VariableChooser(this); auto variableChooser = new Utils::VariableChooser(this);
variableChooser->addSupportedWidget (m_customArguments); variableChooser->addSupportedWidget (m_customArguments);
m_unusedFunction->setToolTip(tr("Disables multithreaded check.")); m_unusedFunction->setToolTip(Tr::tr("Disables multithreaded check."));
m_ignorePatterns->setToolTip(tr("Comma-separated wildcards of full file paths. " m_ignorePatterns->setToolTip(Tr::tr("Comma-separated wildcards of full file paths. "
"Files still can be checked if others include them.")); "Files still can be checked if others include them."));
m_addIncludePaths->setToolTip(tr("Can find missing includes but makes " m_addIncludePaths->setToolTip(Tr::tr("Can find missing includes but makes "
"checking slower. Use only when needed.")); "checking slower. Use only when needed."));
m_guessArguments->setToolTip(tr("Like C++ standard and language.")); m_guessArguments->setToolTip(Tr::tr("Like C++ standard and language."));
auto layout = new QFormLayout(this); auto layout = new QFormLayout(this);
layout->addRow(tr("Binary:"), m_binary); layout->addRow(Tr::tr("Binary:"), m_binary);
auto checks = new Utils::FlowLayout; auto checks = new Utils::FlowLayout;
layout->addRow(tr("Checks:"), checks); layout->addRow(Tr::tr("Checks:"), checks);
checks->addWidget(m_warning); checks->addWidget(m_warning);
checks->addWidget(m_style); checks->addWidget(m_style);
checks->addWidget(m_performance); checks->addWidget(m_performance);
@@ -69,8 +70,8 @@ OptionsWidget::OptionsWidget(QWidget *parent)
checks->addWidget(m_unusedFunction); checks->addWidget(m_unusedFunction);
checks->addWidget(m_missingInclude); checks->addWidget(m_missingInclude);
layout->addRow(tr("Custom arguments:"), m_customArguments); layout->addRow(Tr::tr("Custom arguments:"), m_customArguments);
layout->addRow(tr("Ignored file patterns:"), m_ignorePatterns); layout->addRow(Tr::tr("Ignored file patterns:"), m_ignorePatterns);
auto flags = new Utils::FlowLayout; auto flags = new Utils::FlowLayout;
layout->addRow(flags); layout->addRow(flags);
flags->addWidget(m_inconclusive); flags->addWidget(m_inconclusive);
@@ -123,7 +124,7 @@ CppcheckOptionsPage::CppcheckOptionsPage(CppcheckTool &tool, CppcheckTrigger &tr
m_trigger(trigger) m_trigger(trigger)
{ {
setId(Constants::OPTIONS_PAGE_ID); setId(Constants::OPTIONS_PAGE_ID);
setDisplayName(tr("Cppcheck")); setDisplayName(Tr::tr("Cppcheck"));
setCategory("T.Analyzer"); setCategory("T.Analyzer");
setDisplayCategory(QCoreApplication::translate("Analyzer", "Analyzer")); setDisplayCategory(QCoreApplication::translate("Analyzer", "Analyzer"));
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER); setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
@@ -225,5 +226,4 @@ void CppcheckOptionsPage::load(CppcheckOptions &options) const
s->endGroup(); s->endGroup();
} }
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -17,8 +17,7 @@ QT_END_NAMESPACE
namespace Utils { class PathChooser; } namespace Utils { class PathChooser; }
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
class CppcheckTool; class CppcheckTool;
class CppcheckTrigger; class CppcheckTrigger;
@@ -48,7 +47,6 @@ public:
class OptionsWidget final : public QWidget class OptionsWidget final : public QWidget
{ {
Q_DECLARE_TR_FUNCTIONS(CppcheckOptionsPage)
public: public:
explicit OptionsWidget(QWidget *parent = nullptr); explicit OptionsWidget(QWidget *parent = nullptr);
void load(const CppcheckOptions &options); void load(const CppcheckOptions &options);
@@ -74,7 +72,6 @@ private:
class CppcheckOptionsPage final : public Core::IOptionsPage class CppcheckOptionsPage final : public Core::IOptionsPage
{ {
Q_OBJECT
public: public:
explicit CppcheckOptionsPage(CppcheckTool &tool, CppcheckTrigger &trigger); explicit CppcheckOptionsPage(CppcheckTool &tool, CppcheckTrigger &trigger);
@@ -91,5 +88,4 @@ private:
QPointer<OptionsWidget> m_widget; QPointer<OptionsWidget> m_widget;
}; };
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -2,10 +2,12 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "cppcheckplugin.h" #include "cppcheckplugin.h"
#include "cppcheckconstants.h" #include "cppcheckconstants.h"
#include "cppcheckdiagnosticview.h" #include "cppcheckdiagnosticview.h"
#include "cppchecktextmarkmanager.h" #include "cppchecktextmarkmanager.h"
#include "cppchecktool.h" #include "cppchecktool.h"
#include "cppchecktr.h"
#include "cppchecktrigger.h" #include "cppchecktrigger.h"
#include "cppcheckdiagnosticsmodel.h" #include "cppcheckdiagnosticsmodel.h"
#include "cppcheckmanualrundialog.h" #include "cppcheckmanualrundialog.h"
@@ -26,32 +28,28 @@
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/utilsicons.h> #include <utils/utilsicons.h>
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
class CppcheckPluginPrivate final : public QObject class CppcheckPluginPrivate final : public QObject
{ {
public: public:
explicit CppcheckPluginPrivate(); explicit CppcheckPluginPrivate();
CppcheckTextMarkManager marks; CppcheckTextMarkManager marks;
CppcheckTool tool; CppcheckTool tool{marks, Constants::CHECK_PROGRESS_ID};
CppcheckTrigger trigger; CppcheckTrigger trigger{marks, tool};
CppcheckOptionsPage options; CppcheckOptionsPage options{tool, trigger};
DiagnosticsModel manualRunModel; DiagnosticsModel manualRunModel;
CppcheckTool manualRunTool; CppcheckTool manualRunTool{manualRunModel, Constants::MANUAL_CHECK_PROGRESS_ID};
Utils::Perspective perspective{Constants::PERSPECTIVE_ID, Utils::Perspective perspective{Constants::PERSPECTIVE_ID, ::Cppcheck::Tr::tr("Cppcheck")};
::Cppcheck::Internal::CppcheckPlugin::tr("Cppcheck")};
QAction *manualRunAction; QAction *manualRunAction;
void startManualRun(); void startManualRun();
void updateManualRunAction(); void updateManualRunAction();
}; };
CppcheckPluginPrivate::CppcheckPluginPrivate() : CppcheckPluginPrivate::CppcheckPluginPrivate()
tool(marks, Constants::CHECK_PROGRESS_ID),
trigger(marks, tool),
options(tool, trigger),
manualRunTool(manualRunModel, Constants::MANUAL_CHECK_PROGRESS_ID)
{ {
manualRunTool.updateOptions(tool.options()); manualRunTool.updateOptions(tool.options());
@@ -64,7 +62,7 @@ CppcheckPluginPrivate::CppcheckPluginPrivate() :
auto action = new QAction(this); auto action = new QAction(this);
action->setEnabled(false); action->setEnabled(false);
action->setIcon(Utils::Icons::PREV_TOOLBAR.icon()); action->setIcon(Utils::Icons::PREV_TOOLBAR.icon());
action->setToolTip(CppcheckPlugin::tr("Go to previous diagnostic.")); action->setToolTip(Tr::tr("Go to previous diagnostic."));
connect(action, &QAction::triggered, connect(action, &QAction::triggered,
manualRunView, &Debugger::DetailedErrorView::goBack); manualRunView, &Debugger::DetailedErrorView::goBack);
connect (&manualRunModel, &DiagnosticsModel::hasDataChanged, connect (&manualRunModel, &DiagnosticsModel::hasDataChanged,
@@ -77,7 +75,7 @@ CppcheckPluginPrivate::CppcheckPluginPrivate() :
auto action = new QAction(this); auto action = new QAction(this);
action->setEnabled(false); action->setEnabled(false);
action->setIcon(Utils::Icons::NEXT_TOOLBAR.icon()); action->setIcon(Utils::Icons::NEXT_TOOLBAR.icon());
action->setToolTip(CppcheckPlugin::tr("Go to next diagnostic.")); action->setToolTip(Tr::tr("Go to next diagnostic."));
connect(action, &QAction::triggered, connect(action, &QAction::triggered,
manualRunView, &Debugger::DetailedErrorView::goNext); manualRunView, &Debugger::DetailedErrorView::goNext);
connect (&manualRunModel, &DiagnosticsModel::hasDataChanged, connect (&manualRunModel, &DiagnosticsModel::hasDataChanged,
@@ -90,7 +88,7 @@ CppcheckPluginPrivate::CppcheckPluginPrivate() :
auto action = new QAction(this); auto action = new QAction(this);
action->setEnabled(false); action->setEnabled(false);
action->setIcon(Utils::Icons::CLEAN_TOOLBAR.icon()); action->setIcon(Utils::Icons::CLEAN_TOOLBAR.icon());
action->setToolTip(CppcheckPlugin::tr("Clear")); action->setToolTip(Tr::tr("Clear"));
connect(action, &QAction::triggered, connect(action, &QAction::triggered,
&manualRunModel, &DiagnosticsModel::clear); &manualRunModel, &DiagnosticsModel::clear);
connect (&manualRunModel, &DiagnosticsModel::hasDataChanged, connect (&manualRunModel, &DiagnosticsModel::hasDataChanged,
@@ -146,7 +144,7 @@ bool CppcheckPlugin::initialize(const QStringList &arguments, QString *errorStri
ActionContainer *menu = ActionManager::actionContainer(Debugger::Constants::M_DEBUG_ANALYZER); ActionContainer *menu = ActionManager::actionContainer(Debugger::Constants::M_DEBUG_ANALYZER);
{ {
auto action = new QAction(tr("Cppcheck..."), this); auto action = new QAction(Tr::tr("Cppcheck..."), this);
menu->addAction(ActionManager::registerAction(action, Constants::MANUAL_RUN_ACTION), menu->addAction(ActionManager::registerAction(action, Constants::MANUAL_RUN_ACTION),
Debugger::Constants::G_ANALYZER_TOOLS); Debugger::Constants::G_ANALYZER_TOOLS);
connect(action, &QAction::triggered, connect(action, &QAction::triggered,
@@ -162,5 +160,4 @@ bool CppcheckPlugin::initialize(const QStringList &arguments, QString *errorStri
return true; return true;
} }
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -7,8 +7,7 @@
#include <memory> #include <memory>
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
class CppcheckPluginPrivate; class CppcheckPluginPrivate;
@@ -27,5 +26,4 @@ private:
std::unique_ptr<CppcheckPluginPrivate> d; std::unique_ptr<CppcheckPluginPrivate> d;
}; };
} // namespace Internal } // Cppcheck
} // namespace Cppcheck

View File

@@ -11,8 +11,7 @@
using namespace Utils; using namespace Utils;
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
CppcheckRunner::CppcheckRunner(CppcheckTool &tool) : m_tool(tool) CppcheckRunner::CppcheckRunner(CppcheckTool &tool) : m_tool(tool)
{ {
@@ -149,5 +148,4 @@ void CppcheckRunner::handleDone()
checkQueued(); checkQueued();
} }
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -9,15 +9,12 @@
#include <QHash> #include <QHash>
#include <QTimer> #include <QTimer>
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
class CppcheckTool; class CppcheckTool;
class CppcheckRunner final : public QObject class CppcheckRunner final : public QObject
{ {
Q_OBJECT
public: public:
explicit CppcheckRunner(CppcheckTool &tool); explicit CppcheckRunner(CppcheckTool &tool);
~CppcheckRunner() override; ~CppcheckRunner() override;
@@ -47,5 +44,4 @@ private:
int m_maxArgumentsLength = 32767; int m_maxArgumentsLength = 32767;
}; };
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -11,41 +11,41 @@
#include <QAction> #include <QAction>
#include <QMap> #include <QMap>
namespace Cppcheck { using namespace TextEditor;
namespace Internal { using namespace Utils;
namespace Cppcheck::Internal {
struct Visual struct Visual
{ {
Visual(Utils::Theme::Color color, TextEditor::TextMark::Priority priority, Visual(Utils::Theme::Color color, TextMark::Priority priority,
const QIcon &icon) const QIcon &icon)
: color(color), : color(color),
priority(priority), priority(priority),
icon(icon) icon(icon)
{} {}
Utils::Theme::Color color; Utils::Theme::Color color;
TextEditor::TextMark::Priority priority; TextMark::Priority priority;
QIcon icon; QIcon icon;
}; };
static Visual getVisual(Diagnostic::Severity type) static Visual getVisual(Diagnostic::Severity type)
{ {
using Color = Utils::Theme::Color; using Color = Theme::Color;
using Priority = TextEditor::TextMark::Priority; using Priority = TextMark::Priority;
static const QMap<Diagnostic::Severity, Visual> visuals{ static const QMap<Diagnostic::Severity, Visual> visuals{
{Diagnostic::Severity::Error, {Color::IconsErrorColor, Priority::HighPriority, {Diagnostic::Severity::Error, {Color::IconsErrorColor, Priority::HighPriority,
Utils::Icons::CRITICAL.icon()}}, Icons::CRITICAL.icon()}},
{Diagnostic::Severity::Warning, {Color::IconsWarningColor, Priority::NormalPriority, {Diagnostic::Severity::Warning, {Color::IconsWarningColor, Priority::NormalPriority,
Utils::Icons::WARNING.icon()}}, Icons::WARNING.icon()}},
}; };
return visuals.value(type, {Color::IconsInfoColor, Priority::LowPriority, return visuals.value(type, {Color::IconsInfoColor, Priority::LowPriority, Icons::INFO.icon()});
Utils::Icons::INFO.icon()});
} }
CppcheckTextMark::CppcheckTextMark (const Diagnostic &diagnostic) CppcheckTextMark::CppcheckTextMark (const Diagnostic &diagnostic)
: TextEditor::TextMark (diagnostic.fileName, diagnostic.lineNumber, : TextMark(diagnostic.fileName, diagnostic.lineNumber, Id(Constants::TEXTMARK_CATEGORY_ID)),
Utils::Id(Constants::TEXTMARK_CATEGORY_ID)),
m_severity(diagnostic.severity), m_severity(diagnostic.severity),
m_checkId(diagnostic.checkId), m_checkId(diagnostic.checkId),
m_message(diagnostic.message) m_message(diagnostic.message)
@@ -60,7 +60,7 @@ CppcheckTextMark::CppcheckTextMark (const Diagnostic &diagnostic)
setActionsProvider([diagnostic] { setActionsProvider([diagnostic] {
// Copy to clipboard action // Copy to clipboard action
QAction *action = new QAction; QAction *action = new QAction;
action->setIcon(QIcon::fromTheme("edit-copy", Utils::Icons::COPY.icon())); action->setIcon(QIcon::fromTheme("edit-copy", Icons::COPY.icon()));
action->setToolTip(TextMark::tr("Copy to Clipboard")); action->setToolTip(TextMark::tr("Copy to Clipboard"));
QObject::connect(action, &QAction::triggered, [diagnostic]() { QObject::connect(action, &QAction::triggered, [diagnostic]() {
const QString text = QString("%1:%2: %3") const QString text = QString("%1:%2: %3")
@@ -87,5 +87,4 @@ QString CppcheckTextMark::toolTipText(const QString &severityText) const
"</table>").arg(m_checkId, severityText, m_message); "</table>").arg(m_checkId, severityText, m_message);
} }
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -7,8 +7,7 @@
#include <texteditor/textmark.h> #include <texteditor/textmark.h>
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
class CppcheckTextMark final : public TextEditor::TextMark class CppcheckTextMark final : public TextEditor::TextMark
{ {
@@ -29,5 +28,4 @@ private:
QString m_message; QString m_message;
}; };
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -1,14 +1,14 @@
// Copyright (C) 2018 Sergey Morozov // Copyright (C) 2018 Sergey Morozov
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "cppchecktextmarkmanager.h"
#include "cppcheckdiagnostic.h" #include "cppcheckdiagnostic.h"
#include "cppchecktextmark.h" #include "cppchecktextmark.h"
#include "cppchecktextmarkmanager.h"
#include <utils/algorithm.h> #include <utils/algorithm.h>
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
CppcheckTextMarkManager::CppcheckTextMarkManager() = default; CppcheckTextMarkManager::CppcheckTextMarkManager() = default;
@@ -36,5 +36,4 @@ void CppcheckTextMarkManager::clearFiles(const Utils::FilePaths &files)
} }
} }
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -9,8 +9,7 @@
#include <unordered_map> #include <unordered_map>
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
class Diagnostic; class Diagnostic;
class CppcheckTextMark; class CppcheckTextMark;
@@ -29,5 +28,4 @@ private:
std::unordered_map<Utils::FilePath, std::vector<MarkPtr>> m_marks; std::unordered_map<Utils::FilePath, std::vector<MarkPtr>> m_marks;
}; };
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -1,11 +1,13 @@
// Copyright (C) 2018 Sergey Morozov // Copyright (C) 2018 Sergey Morozov
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "cppchecktool.h"
#include "cppcheckdiagnostic.h" #include "cppcheckdiagnostic.h"
#include "cppcheckoptions.h" #include "cppcheckoptions.h"
#include "cppcheckrunner.h" #include "cppcheckrunner.h"
#include "cppchecktextmarkmanager.h" #include "cppchecktextmarkmanager.h"
#include "cppchecktool.h" #include "cppchecktr.h"
#include <coreplugin/messagemanager.h> #include <coreplugin/messagemanager.h>
#include <coreplugin/progressmanager/futureprogress.h> #include <coreplugin/progressmanager/futureprogress.h>
@@ -20,8 +22,7 @@
#include <QThread> #include <QThread>
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
CppcheckTool::CppcheckTool(CppcheckDiagnosticManager &manager, CppcheckTool::CppcheckTool(CppcheckDiagnosticManager &manager,
const Utils::Id &progressId) : const Utils::Id &progressId) :
@@ -226,13 +227,13 @@ void CppcheckTool::stop(const Utils::FilePaths &files)
void CppcheckTool::startParsing() void CppcheckTool::startParsing()
{ {
if (m_options.showOutput) { if (m_options.showOutput) {
const QString message = tr("Cppcheck started: \"%1\".").arg(m_runner->currentCommand()); const QString message = Tr::tr("Cppcheck started: \"%1\".").arg(m_runner->currentCommand());
Core::MessageManager::writeSilently(message); Core::MessageManager::writeSilently(message);
} }
m_progress = std::make_unique<QFutureInterface<void>>(); m_progress = std::make_unique<QFutureInterface<void>>();
const Core::FutureProgress *progress = Core::ProgressManager::addTask( const Core::FutureProgress *progress = Core::ProgressManager::addTask(
m_progress->future(), QObject::tr("Cppcheck"), m_progressId); m_progress->future(), Tr::tr("Cppcheck"), m_progressId);
QObject::connect(progress, &Core::FutureProgress::canceled, QObject::connect(progress, &Core::FutureProgress::canceled,
this, [this]{stop({});}); this, [this]{stop({});});
m_progress->setProgressRange(0, 100); m_progress->setProgressRange(0, 100);
@@ -301,11 +302,10 @@ void CppcheckTool::parseErrorLine(const QString &line)
void CppcheckTool::finishParsing() void CppcheckTool::finishParsing()
{ {
if (m_options.showOutput) if (m_options.showOutput)
Core::MessageManager::writeSilently(tr("Cppcheck finished.")); Core::MessageManager::writeSilently(Tr::tr("Cppcheck finished."));
QTC_ASSERT(m_progress, return); QTC_ASSERT(m_progress, return);
m_progress->reportFinished(); m_progress->reportFinished();
} }
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -14,18 +14,13 @@
namespace Utils { namespace Utils {
class FilePath; class FilePath;
using FilePaths = QList<FilePath>; using FilePaths = QList<FilePath>;
} } // Utils
namespace CppEditor { namespace CppEditor { class ProjectPart; }
class ProjectPart;
}
namespace ProjectExplorer { namespace ProjectExplorer { class Project; }
class Project;
}
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
class CppcheckRunner; class CppcheckRunner;
class CppcheckDiagnosticManager; class CppcheckDiagnosticManager;
@@ -68,5 +63,4 @@ private:
Utils::Id m_progressId; Utils::Id m_progressId;
}; };
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -15,19 +15,20 @@
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
#include <projectexplorer/session.h> #include <projectexplorer/session.h>
namespace Cppcheck { using namespace Core;
namespace Internal { using namespace ProjectExplorer;
using namespace Utils;
namespace Cppcheck::Internal {
CppcheckTrigger::CppcheckTrigger(CppcheckTextMarkManager &marks, CppcheckTool &tool) : CppcheckTrigger::CppcheckTrigger(CppcheckTextMarkManager &marks, CppcheckTool &tool) :
m_marks(marks), m_marks(marks),
m_tool(tool) m_tool(tool)
{ {
using EditorManager = Core::EditorManager;
using SessionManager = ProjectExplorer::SessionManager;
using CppModelManager = CppEditor::CppModelManager; using CppModelManager = CppEditor::CppModelManager;
connect(EditorManager::instance(), &EditorManager::editorOpened, connect(EditorManager::instance(), &EditorManager::editorOpened,
this, [this](Core::IEditor *editor) {checkEditors({editor});}); this, [this](IEditor *editor) {checkEditors({editor});});
connect(EditorManager::instance(), &EditorManager::editorsClosed, connect(EditorManager::instance(), &EditorManager::editorsClosed,
this, &CppcheckTrigger::removeEditors); this, &CppcheckTrigger::removeEditors);
connect(EditorManager::instance(), &EditorManager::aboutToSave, connect(EditorManager::instance(), &EditorManager::aboutToSave,
@@ -48,7 +49,7 @@ void CppcheckTrigger::recheck()
checkEditors(); checkEditors();
} }
void CppcheckTrigger::checkEditors(const QList<Core::IEditor *> &editors) void CppcheckTrigger::checkEditors(const QList<IEditor *> &editors)
{ {
if (!m_currentProject) if (!m_currentProject)
return; return;
@@ -59,15 +60,15 @@ void CppcheckTrigger::checkEditors(const QList<Core::IEditor *> &editors)
if (!info) if (!info)
return; return;
const QList<Core::IEditor *> editorList = !editors.isEmpty() const QList<IEditor *> editorList = !editors.isEmpty()
? editors : Core::DocumentModel::editorsForOpenedDocuments(); ? editors : DocumentModel::editorsForOpenedDocuments();
Utils::FilePaths toCheck; FilePaths toCheck;
for (const Core::IEditor *editor : editorList) { for (const IEditor *editor : editorList) {
QTC_ASSERT(editor, continue); QTC_ASSERT(editor, continue);
Core::IDocument *document = editor->document(); IDocument *document = editor->document();
QTC_ASSERT(document, continue); QTC_ASSERT(document, continue);
const Utils::FilePath &path = document->filePath(); const FilePath &path = document->filePath();
if (path.isEmpty()) if (path.isEmpty())
continue; continue;
@@ -81,9 +82,9 @@ void CppcheckTrigger::checkEditors(const QList<Core::IEditor *> &editors)
if (!info->sourceFiles().contains(pathString)) if (!info->sourceFiles().contains(pathString))
continue; continue;
connect(document, &Core::IDocument::aboutToReload, connect(document, &IDocument::aboutToReload,
this, [this, document]{checkChangedDocument(document);}); this, [this, document]{checkChangedDocument(document);});
connect(document, &Core::IDocument::contentsChanged, connect(document, &IDocument::contentsChanged,
this, [this, document] { this, [this, document] {
if (!document->isModified()) if (!document->isModified())
checkChangedDocument(document); checkChangedDocument(document);
@@ -99,20 +100,20 @@ void CppcheckTrigger::checkEditors(const QList<Core::IEditor *> &editors)
} }
} }
void CppcheckTrigger::removeEditors(const QList<Core::IEditor *> &editors) void CppcheckTrigger::removeEditors(const QList<IEditor *> &editors)
{ {
if (!m_currentProject) if (!m_currentProject)
return; return;
const QList<Core::IEditor *> editorList = !editors.isEmpty() const QList<IEditor *> editorList = !editors.isEmpty()
? editors : Core::DocumentModel::editorsForOpenedDocuments(); ? editors : DocumentModel::editorsForOpenedDocuments();
Utils::FilePaths toRemove; FilePaths toRemove;
for (const Core::IEditor *editor : editorList) { for (const IEditor *editor : editorList) {
QTC_ASSERT(editor, return); QTC_ASSERT(editor, return);
const Core::IDocument *document = editor->document(); const IDocument *document = editor->document();
QTC_ASSERT(document, return); QTC_ASSERT(document, return);
const Utils::FilePath &path = document->filePath(); const FilePath &path = document->filePath();
if (path.isEmpty()) if (path.isEmpty())
return; return;
@@ -128,14 +129,14 @@ void CppcheckTrigger::removeEditors(const QList<Core::IEditor *> &editors)
remove(toRemove); remove(toRemove);
} }
void CppcheckTrigger::checkChangedDocument(Core::IDocument *document) void CppcheckTrigger::checkChangedDocument(IDocument *document)
{ {
QTC_ASSERT(document, return); QTC_ASSERT(document, return);
if (!m_currentProject) if (!m_currentProject)
return; return;
const Utils::FilePath &path = document->filePath(); const FilePath &path = document->filePath();
QTC_ASSERT(!path.isEmpty(), return); QTC_ASSERT(!path.isEmpty(), return);
if (!m_checkedFiles.contains(path)) if (!m_checkedFiles.contains(path))
return; return;
@@ -144,16 +145,16 @@ void CppcheckTrigger::checkChangedDocument(Core::IDocument *document)
check({path}); check({path});
} }
void CppcheckTrigger::changeCurrentProject(ProjectExplorer::Project *project) void CppcheckTrigger::changeCurrentProject(Project *project)
{ {
m_currentProject = project; m_currentProject = project;
m_checkedFiles.clear(); m_checkedFiles.clear();
remove({}); remove({});
m_tool.setProject(project); m_tool.setProject(project);
checkEditors(Core::DocumentModel::editorsForOpenedDocuments()); checkEditors(DocumentModel::editorsForOpenedDocuments());
} }
void CppcheckTrigger::updateProjectFiles(ProjectExplorer::Project *project) void CppcheckTrigger::updateProjectFiles(Project *project)
{ {
if (project != m_currentProject) if (project != m_currentProject)
return; return;
@@ -161,19 +162,18 @@ void CppcheckTrigger::updateProjectFiles(ProjectExplorer::Project *project)
m_checkedFiles.clear(); m_checkedFiles.clear();
remove({}); remove({});
m_tool.setProject(project); m_tool.setProject(project);
checkEditors(Core::DocumentModel::editorsForOpenedDocuments()); checkEditors(DocumentModel::editorsForOpenedDocuments());
} }
void CppcheckTrigger::check(const Utils::FilePaths &files) void CppcheckTrigger::check(const FilePaths &files)
{ {
m_tool.check(files); m_tool.check(files);
} }
void CppcheckTrigger::remove(const Utils::FilePaths &files) void CppcheckTrigger::remove(const FilePaths &files)
{ {
m_marks.clearFiles(files); m_marks.clearFiles(files);
m_tool.stop(files); m_tool.stop(files);
} }
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck

View File

@@ -20,16 +20,13 @@ class IDocument;
class IEditor; class IEditor;
} }
namespace Cppcheck { namespace Cppcheck::Internal {
namespace Internal {
class CppcheckTextMarkManager; class CppcheckTextMarkManager;
class CppcheckTool; class CppcheckTool;
class CppcheckTrigger final : public QObject class CppcheckTrigger final : public QObject
{ {
Q_OBJECT
public: public:
explicit CppcheckTrigger(CppcheckTextMarkManager &marks, CppcheckTool &tool); explicit CppcheckTrigger(CppcheckTextMarkManager &marks, CppcheckTool &tool);
~CppcheckTrigger() override; ~CppcheckTrigger() override;
@@ -51,5 +48,4 @@ private:
QHash<Utils::FilePath, QDateTime> m_checkedFiles; QHash<Utils::FilePath, QDateTime> m_checkedFiles;
}; };
} // namespace Internal } // Cppcheck::Internal
} // namespace Cppcheck