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

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,8 +3,7 @@
#pragma once
namespace Cppcheck {
namespace Constants {
namespace Cppcheck::Constants {
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 PERSPECTIVE_ID[] = "Cppcheck.Perspective";
} // namespace Constants
} // namespace Cppcheck
} // Cppcheck::Constants

View File

@@ -3,8 +3,7 @@
#include "cppcheckdiagnostic.h"
namespace Cppcheck {
namespace Internal {
namespace Cppcheck::Internal {
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;
}
} // namespace Internal
} // namespace Cppcheck

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -11,41 +11,41 @@
#include <QAction>
#include <QMap>
namespace Cppcheck {
namespace Internal {
using namespace TextEditor;
using namespace Utils;
namespace Cppcheck::Internal {
struct Visual
{
Visual(Utils::Theme::Color color, TextEditor::TextMark::Priority priority,
Visual(Utils::Theme::Color color, TextMark::Priority priority,
const QIcon &icon)
: color(color),
priority(priority),
icon(icon)
{}
Utils::Theme::Color color;
TextEditor::TextMark::Priority priority;
TextMark::Priority priority;
QIcon icon;
};
static Visual getVisual(Diagnostic::Severity type)
{
using Color = Utils::Theme::Color;
using Priority = TextEditor::TextMark::Priority;
using Color = Theme::Color;
using Priority = TextMark::Priority;
static const QMap<Diagnostic::Severity, Visual> visuals{
{Diagnostic::Severity::Error, {Color::IconsErrorColor, Priority::HighPriority,
Utils::Icons::CRITICAL.icon()}},
Icons::CRITICAL.icon()}},
{Diagnostic::Severity::Warning, {Color::IconsWarningColor, Priority::NormalPriority,
Utils::Icons::WARNING.icon()}},
Icons::WARNING.icon()}},
};
return visuals.value(type, {Color::IconsInfoColor, Priority::LowPriority,
Utils::Icons::INFO.icon()});
return visuals.value(type, {Color::IconsInfoColor, Priority::LowPriority, Icons::INFO.icon()});
}
CppcheckTextMark::CppcheckTextMark (const Diagnostic &diagnostic)
: TextEditor::TextMark (diagnostic.fileName, diagnostic.lineNumber,
Utils::Id(Constants::TEXTMARK_CATEGORY_ID)),
: TextMark(diagnostic.fileName, diagnostic.lineNumber, Id(Constants::TEXTMARK_CATEGORY_ID)),
m_severity(diagnostic.severity),
m_checkId(diagnostic.checkId),
m_message(diagnostic.message)
@@ -60,7 +60,7 @@ CppcheckTextMark::CppcheckTextMark (const Diagnostic &diagnostic)
setActionsProvider([diagnostic] {
// Copy to clipboard action
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"));
QObject::connect(action, &QAction::triggered, [diagnostic]() {
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);
}
} // namespace Internal
} // namespace Cppcheck
} // Cppcheck::Internal

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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