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();
|
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()
|
static QStringList tidyCommandLine()
|
||||||
{
|
{
|
||||||
const QString tidyChecks = CppTools::codeModelSettings()->tidyChecks();
|
const QString tidyChecks = CppTools::codeModelSettings()->tidyChecks();
|
||||||
@@ -578,14 +589,8 @@ static QStringList tidyCommandLine()
|
|||||||
return QStringList();
|
return QStringList();
|
||||||
|
|
||||||
QStringList result;
|
QStringList result;
|
||||||
result.append("-Xclang");
|
addXclangArg(result, "-add-plugin", "clang-tidy");
|
||||||
result.append("-add-plugin");
|
addXclangArg(result, "-plugin-arg-clang-tidy", "-checks='-*" + tidyChecks + "'");
|
||||||
result.append("-Xclang");
|
|
||||||
result.append("clang-tidy");
|
|
||||||
result.append("-Xclang");
|
|
||||||
result.append("-plugin-arg-clang-tidy");
|
|
||||||
result.append("-Xclang");
|
|
||||||
result.append("-checks='-*" + tidyChecks + "'");
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,14 +602,8 @@ static QStringList clazyCommandLine()
|
|||||||
return QStringList();
|
return QStringList();
|
||||||
|
|
||||||
QStringList result;
|
QStringList result;
|
||||||
result.append("-Xclang");
|
addXclangArg(result, "-add-plugin", "clang-lazy");
|
||||||
result.append("-add-plugin");
|
addXclangArg(result, "-plugin-arg-clang-lazy", clazyChecks);
|
||||||
result.append("-Xclang");
|
|
||||||
result.append("clang-lazy");
|
|
||||||
result.append("-Xclang");
|
|
||||||
result.append("-plugin-arg-clang-lazy");
|
|
||||||
result.append("-Xclang");
|
|
||||||
result.append(clazyChecks);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>503</width>
|
<width>503</width>
|
||||||
<height>40</height>
|
<height>73</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
@@ -73,6 +73,42 @@
|
|||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@@ -87,6 +87,7 @@ void CppCodeModelSettingsWidget::setupClangCodeModelWidgets()
|
|||||||
m_settings->clangDiagnosticConfigId());
|
m_settings->clangDiagnosticConfigId());
|
||||||
m_ui->clangSettingsGroupBox->layout()->addWidget(m_clangDiagnosticConfigsWidget);
|
m_ui->clangSettingsGroupBox->layout()->addWidget(m_clangDiagnosticConfigsWidget);
|
||||||
|
|
||||||
|
m_ui->clangPlugins->setEnabled(isClangActive);
|
||||||
setupPluginsWidgets();
|
setupPluginsWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,14 +101,14 @@ void CppCodeModelSettingsWidget::setupPluginsWidgets()
|
|||||||
m_tidyChecksWidget = new QWidget();
|
m_tidyChecksWidget = new QWidget();
|
||||||
m_tidyChecks->setupUi(m_tidyChecksWidget);
|
m_tidyChecks->setupUi(m_tidyChecksWidget);
|
||||||
|
|
||||||
m_ui->pluginChecks->layout()->addWidget(m_tidyChecksWidget);
|
m_ui->pluginChecks->addWidget(m_tidyChecksWidget);
|
||||||
m_ui->pluginChecks->layout()->addWidget(m_clazyChecksWidget);
|
m_ui->pluginChecks->addWidget(m_clazyChecksWidget);
|
||||||
m_clazyChecksWidget->setVisible(false);
|
m_ui->pluginChecks->setCurrentIndex(0);
|
||||||
|
|
||||||
connect(m_ui->pluginSelection,
|
connect(m_ui->pluginSelection,
|
||||||
static_cast<void (QComboBox::*)(int index)>(&QComboBox::currentIndexChanged),
|
static_cast<void (QComboBox::*)(int index)>(&QComboBox::currentIndexChanged),
|
||||||
[this](int index) {
|
[this](int index) {
|
||||||
(index ? m_clazyChecksWidget : m_tidyChecksWidget)->setVisible(true);
|
m_ui->pluginChecks->setCurrentIndex(index);
|
||||||
(!index ? m_clazyChecksWidget : m_tidyChecksWidget)->setVisible(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
setupTidyChecks();
|
setupTidyChecks();
|
||||||
@@ -117,28 +118,47 @@ void CppCodeModelSettingsWidget::setupPluginsWidgets()
|
|||||||
void CppCodeModelSettingsWidget::setupTidyChecks()
|
void CppCodeModelSettingsWidget::setupTidyChecks()
|
||||||
{
|
{
|
||||||
m_currentTidyChecks = m_settings->tidyChecks();
|
m_currentTidyChecks = m_settings->tidyChecks();
|
||||||
for (QObject *child : m_tidyChecksWidget->children()) {
|
for (int row = 0; row < m_tidyChecks->checksList->count(); ++row) {
|
||||||
auto *check = qobject_cast<QCheckBox *>(child);
|
QListWidgetItem *item = m_tidyChecks->checksList->item(row);
|
||||||
if (!check)
|
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||||
continue;
|
if (m_currentTidyChecks.indexOf(item->text()) != -1)
|
||||||
if (m_currentTidyChecks.indexOf(check->text()) != -1)
|
item->setCheckState(Qt::Checked);
|
||||||
check->setChecked(true);
|
else
|
||||||
connect(check, &QCheckBox::clicked, [this, check](bool checked) {
|
item->setCheckState(Qt::Unchecked);
|
||||||
const QString prefix = check->text();
|
}
|
||||||
checked ? m_currentTidyChecks.append(',' + prefix)
|
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);
|
: m_currentTidyChecks.remove(',' + prefix);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void CppCodeModelSettingsWidget::setupClazyChecks()
|
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();
|
m_currentClazyChecks = m_settings->clazyChecks();
|
||||||
if (!m_currentClazyChecks.isEmpty())
|
if (!m_currentClazyChecks.isEmpty()) {
|
||||||
m_clazyChecks->clazyLevel->setCurrentText(m_currentClazyChecks);
|
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,
|
connect(m_clazyChecks->clazyLevel,
|
||||||
static_cast<void (QComboBox::*)(int index)>(&QComboBox::currentIndexChanged),
|
static_cast<void (QComboBox::*)(int index)>(&QComboBox::currentIndexChanged),
|
||||||
[this](int index) {
|
[this](int index) {
|
||||||
|
m_clazyChecks->levelDescription->setText(levelDescriptions[static_cast<unsigned>(index)]);
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
m_currentClazyChecks.clear();
|
m_currentClazyChecks.clear();
|
||||||
return;
|
return;
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>629</width>
|
<width>629</width>
|
||||||
<height>374</height>
|
<height>440</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -99,6 +99,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="clangSettingsGroupBox">
|
<widget class="QGroupBox" name="clangSettingsGroupBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Clang Code Model Warnings</string>
|
<string>Clang Code Model Warnings</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -113,7 +119,7 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Clang Plugins</string>
|
<string>Clang Plugins</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="pluginSelection">
|
<widget class="QComboBox" name="pluginSelection">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -135,12 +141,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="pluginChecks">
|
<widget class="QStackedWidget" name="pluginChecks"/>
|
||||||
<property name="title">
|
|
||||||
<string>Checks</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5"/>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@@ -27,127 +27,87 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<widget class="QListWidget" name="checksList">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="androidCheck">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>android-*</string>
|
<string>android-*</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="boostCheck">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>boost-</string>
|
<string>boost-*</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="bugproneCheck">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>bugprone-*</string>
|
<string>bugprone-*</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="certCheck">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>cert-*</string>
|
<string>cert-*</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="coreCheck">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>cppcoreguidelines-*</string>
|
<string>cppcoreguidelines-*</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="analyzerCheck">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>clang-analyzer-*</string>
|
<string>clang-analyzer-*</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="diagnosticCheck">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>clang-diagnostic-*</string>
|
<string>clang-diagnostic-*</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="googleCheck">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>google-*</string>
|
<string>google-*</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="hicppCheck">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>hicpp-*</string>
|
<string>hicpp-*</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="llvmCheck">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>llvm-*</string>
|
<string>llvm-*</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="miscCheck">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>misc-*</string>
|
<string>misc-*</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="modernizeCheck">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>modernize-*</string>
|
<string>modernize-*</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="mpiCheck">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>mpi-*</string>
|
<string>mpi-*</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="objcCheck">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>objc-*</string>
|
<string>objc-*</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="performanceCheck">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>performance-*</string>
|
<string>performance-*</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="readabilityCheck">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>readability-*</string>
|
<string>readability-*</string>
|
||||||
</property>
|
</property>
|
||||||
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
Reference in New Issue
Block a user