forked from qt-creator/qt-creator
Clang: Improve code model plugins settings UI
Describe clazy levels, improve layouts. Change-Id: I4895682ea7d10ea910c2d53725073c9c870bb306 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -570,6 +570,17 @@ static QStringList warningOptions(CppTools::ProjectPart *projectPart)
|
||||
return CppTools::codeModelSettings()->clangDiagnosticConfig().commandLineWarnings();
|
||||
}
|
||||
|
||||
static void addXclangArg(QStringList &list, const QString &argName,
|
||||
const QString &argValue = QString())
|
||||
{
|
||||
list.append("-Xclang");
|
||||
list.append(argName);
|
||||
if (!argValue.isEmpty()) {
|
||||
list.append("-Xclang");
|
||||
list.append(argValue);
|
||||
}
|
||||
}
|
||||
|
||||
static QStringList tidyCommandLine()
|
||||
{
|
||||
const QString tidyChecks = CppTools::codeModelSettings()->tidyChecks();
|
||||
@@ -578,14 +589,8 @@ static QStringList tidyCommandLine()
|
||||
return QStringList();
|
||||
|
||||
QStringList result;
|
||||
result.append("-Xclang");
|
||||
result.append("-add-plugin");
|
||||
result.append("-Xclang");
|
||||
result.append("clang-tidy");
|
||||
result.append("-Xclang");
|
||||
result.append("-plugin-arg-clang-tidy");
|
||||
result.append("-Xclang");
|
||||
result.append("-checks='-*" + tidyChecks + "'");
|
||||
addXclangArg(result, "-add-plugin", "clang-tidy");
|
||||
addXclangArg(result, "-plugin-arg-clang-tidy", "-checks='-*" + tidyChecks + "'");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -597,14 +602,8 @@ static QStringList clazyCommandLine()
|
||||
return QStringList();
|
||||
|
||||
QStringList result;
|
||||
result.append("-Xclang");
|
||||
result.append("-add-plugin");
|
||||
result.append("-Xclang");
|
||||
result.append("clang-lazy");
|
||||
result.append("-Xclang");
|
||||
result.append("-plugin-arg-clang-lazy");
|
||||
result.append("-Xclang");
|
||||
result.append(clazyChecks);
|
||||
addXclangArg(result, "-add-plugin", "clang-lazy");
|
||||
addXclangArg(result, "-plugin-arg-clang-lazy", clazyChecks);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>503</width>
|
||||
<height>40</height>
|
||||
<height>73</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@@ -19,7 +19,7 @@
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@@ -73,6 +73,42 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="levelDescription">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
@@ -87,6 +87,7 @@ void CppCodeModelSettingsWidget::setupClangCodeModelWidgets()
|
||||
m_settings->clangDiagnosticConfigId());
|
||||
m_ui->clangSettingsGroupBox->layout()->addWidget(m_clangDiagnosticConfigsWidget);
|
||||
|
||||
m_ui->clangPlugins->setEnabled(isClangActive);
|
||||
setupPluginsWidgets();
|
||||
}
|
||||
|
||||
@@ -100,14 +101,14 @@ void CppCodeModelSettingsWidget::setupPluginsWidgets()
|
||||
m_tidyChecksWidget = new QWidget();
|
||||
m_tidyChecks->setupUi(m_tidyChecksWidget);
|
||||
|
||||
m_ui->pluginChecks->layout()->addWidget(m_tidyChecksWidget);
|
||||
m_ui->pluginChecks->layout()->addWidget(m_clazyChecksWidget);
|
||||
m_clazyChecksWidget->setVisible(false);
|
||||
m_ui->pluginChecks->addWidget(m_tidyChecksWidget);
|
||||
m_ui->pluginChecks->addWidget(m_clazyChecksWidget);
|
||||
m_ui->pluginChecks->setCurrentIndex(0);
|
||||
|
||||
connect(m_ui->pluginSelection,
|
||||
static_cast<void (QComboBox::*)(int index)>(&QComboBox::currentIndexChanged),
|
||||
[this](int index) {
|
||||
(index ? m_clazyChecksWidget : m_tidyChecksWidget)->setVisible(true);
|
||||
(!index ? m_clazyChecksWidget : m_tidyChecksWidget)->setVisible(false);
|
||||
m_ui->pluginChecks->setCurrentIndex(index);
|
||||
});
|
||||
|
||||
setupTidyChecks();
|
||||
@@ -117,28 +118,47 @@ void CppCodeModelSettingsWidget::setupPluginsWidgets()
|
||||
void CppCodeModelSettingsWidget::setupTidyChecks()
|
||||
{
|
||||
m_currentTidyChecks = m_settings->tidyChecks();
|
||||
for (QObject *child : m_tidyChecksWidget->children()) {
|
||||
auto *check = qobject_cast<QCheckBox *>(child);
|
||||
if (!check)
|
||||
continue;
|
||||
if (m_currentTidyChecks.indexOf(check->text()) != -1)
|
||||
check->setChecked(true);
|
||||
connect(check, &QCheckBox::clicked, [this, check](bool checked) {
|
||||
const QString prefix = check->text();
|
||||
checked ? m_currentTidyChecks.append(',' + prefix)
|
||||
: m_currentTidyChecks.remove(',' + prefix);
|
||||
});
|
||||
for (int row = 0; row < m_tidyChecks->checksList->count(); ++row) {
|
||||
QListWidgetItem *item = m_tidyChecks->checksList->item(row);
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
if (m_currentTidyChecks.indexOf(item->text()) != -1)
|
||||
item->setCheckState(Qt::Checked);
|
||||
else
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
connect(m_tidyChecks->checksList, &QListWidget::itemChanged, [this](QListWidgetItem *item) {
|
||||
const QString prefix = item->text();
|
||||
item->checkState() == Qt::Checked
|
||||
? m_currentTidyChecks.append(',' + prefix)
|
||||
: m_currentTidyChecks.remove(',' + prefix);
|
||||
});
|
||||
}
|
||||
|
||||
void CppCodeModelSettingsWidget::setupClazyChecks()
|
||||
{
|
||||
// Levels descriptions are taken from https://github.com/KDE/clazy
|
||||
static const std::array<QString, 5> levelDescriptions {{
|
||||
"",
|
||||
tr("Very stable checks, 99.99% safe, no false-positives."),
|
||||
tr("Similar to level0, but sometimes (rarely) there might be\n"
|
||||
"some false-positives."),
|
||||
tr("Sometimes has false-positives (20-30%)."),
|
||||
tr("Not always correct, possibly very noisy, might require\n"
|
||||
"a knowledgeable developer to review, might have a very big\n"
|
||||
"rate of false-positives, might have bugs.")
|
||||
}};
|
||||
|
||||
m_currentClazyChecks = m_settings->clazyChecks();
|
||||
if (!m_currentClazyChecks.isEmpty())
|
||||
if (!m_currentClazyChecks.isEmpty()) {
|
||||
m_clazyChecks->clazyLevel->setCurrentText(m_currentClazyChecks);
|
||||
const unsigned index = static_cast<unsigned>(m_clazyChecks->clazyLevel->currentIndex());
|
||||
m_clazyChecks->levelDescription->setText(levelDescriptions[index]);
|
||||
}
|
||||
|
||||
connect(m_clazyChecks->clazyLevel,
|
||||
static_cast<void (QComboBox::*)(int index)>(&QComboBox::currentIndexChanged),
|
||||
[this](int index) {
|
||||
m_clazyChecks->levelDescription->setText(levelDescriptions[static_cast<unsigned>(index)]);
|
||||
if (index == 0) {
|
||||
m_currentClazyChecks.clear();
|
||||
return;
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>629</width>
|
||||
<height>374</height>
|
||||
<height>440</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -99,6 +99,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="clangSettingsGroupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Clang Code Model Warnings</string>
|
||||
</property>
|
||||
@@ -113,7 +119,7 @@
|
||||
<property name="title">
|
||||
<string>Clang Plugins</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QComboBox" name="pluginSelection">
|
||||
<property name="sizePolicy">
|
||||
@@ -135,12 +141,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="pluginChecks">
|
||||
<property name="title">
|
||||
<string>Checks</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5"/>
|
||||
</widget>
|
||||
<widget class="QStackedWidget" name="pluginChecks"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@@ -27,127 +27,87 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<widget class="QListWidget" name="checksList">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="androidCheck">
|
||||
<property name="text">
|
||||
<string>android-*</string>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>android-*</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="boostCheck">
|
||||
<property name="text">
|
||||
<string>boost-</string>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>boost-*</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="bugproneCheck">
|
||||
<property name="text">
|
||||
<string>bugprone-*</string>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>bugprone-*</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="certCheck">
|
||||
<property name="text">
|
||||
<string>cert-*</string>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>cert-*</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="coreCheck">
|
||||
<property name="text">
|
||||
<string>cppcoreguidelines-*</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="analyzerCheck">
|
||||
<property name="text">
|
||||
<string>clang-analyzer-*</string>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>cppcoreguidelines-*</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="diagnosticCheck">
|
||||
<property name="text">
|
||||
<string>clang-diagnostic-*</string>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>clang-analyzer-*</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="googleCheck">
|
||||
<property name="text">
|
||||
<string>google-*</string>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>clang-diagnostic-*</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="hicppCheck">
|
||||
<property name="text">
|
||||
<string>hicpp-*</string>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>google-*</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="llvmCheck">
|
||||
<property name="text">
|
||||
<string>llvm-*</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="miscCheck">
|
||||
<property name="text">
|
||||
<string>misc-*</string>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>hicpp-*</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="modernizeCheck">
|
||||
<property name="text">
|
||||
<string>modernize-*</string>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>llvm-*</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mpiCheck">
|
||||
<property name="text">
|
||||
<string>mpi-*</string>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>misc-*</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="objcCheck">
|
||||
<property name="text">
|
||||
<string>objc-*</string>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>modernize-*</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="performanceCheck">
|
||||
<property name="text">
|
||||
<string>performance-*</string>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="text">
|
||||
<string>mpi-*</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>objc-*</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>performance-*</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>readability-*</string>
|
||||
</property>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="readabilityCheck">
|
||||
<property name="text">
|
||||
<string>readability-*</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
Reference in New Issue
Block a user