forked from qt-creator/qt-creator
Clang: Add links to web pages in Clang-Tidy configuration
Each Clang-Tidy check get the separate link except clang-analyzer which has only a whole group page. Change-Id: I0b63cce8475109812280d9d44ac2d36aaa66e03b Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
|
||||||
|
#include <cpptools/cpptoolsconstants.h>
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/tooltip/tooltip.h>
|
#include <utils/tooltip/tooltip.h>
|
||||||
|
|
||||||
@@ -46,14 +48,8 @@ namespace {
|
|||||||
|
|
||||||
// CLANG-UPGRADE-CHECK: Checks/update URLs.
|
// CLANG-UPGRADE-CHECK: Checks/update URLs.
|
||||||
//
|
//
|
||||||
// For tidy, upgrade the version in the URL. Note that we cannot use the macro
|
// Once it gets dedicated documentation pages for released versions,
|
||||||
// CLANG_VERSION here because it might denote a version that was not yet
|
|
||||||
// released (e.g. 6.0.1, but only 6.0.0 was released).
|
|
||||||
//
|
|
||||||
// For clazy, once it gets dedicated documentation pages for released versions,
|
|
||||||
// use them instead of pointing to master, as checks might vanish.
|
// use them instead of pointing to master, as checks might vanish.
|
||||||
const char TIDY_DOCUMENTATION_URL_TEMPLATE[]
|
|
||||||
= "https://releases.llvm.org/6.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/%1.html";
|
|
||||||
const char CLAZY_DOCUMENTATION_URL_TEMPLATE[]
|
const char CLAZY_DOCUMENTATION_URL_TEMPLATE[]
|
||||||
= "https://github.com/KDE/clazy/blob/master/docs/checks/README-%1.md";
|
= "https://github.com/KDE/clazy/blob/master/docs/checks/README-%1.md";
|
||||||
|
|
||||||
@@ -283,7 +279,7 @@ private:
|
|||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
// Clang-Tidy
|
// Clang-Tidy
|
||||||
return QString::fromUtf8(TIDY_DOCUMENTATION_URL_TEMPLATE).arg(option);
|
return QString::fromUtf8(CppTools::Constants::TIDY_DOCUMENTATION_URL_TEMPLATE).arg(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString maybeClickableOption(const Utf8String &option)
|
static QString maybeClickableOption(const Utf8String &option)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "cppcodemodelsettings.h"
|
#include "cppcodemodelsettings.h"
|
||||||
#include "cpptools_clangtidychecks.h"
|
#include "cpptools_clangtidychecks.h"
|
||||||
|
#include "cpptoolsconstants.h"
|
||||||
#include "cpptoolsreuse.h"
|
#include "cpptoolsreuse.h"
|
||||||
#include "ui_clangdiagnosticconfigswidget.h"
|
#include "ui_clangdiagnosticconfigswidget.h"
|
||||||
#include "ui_clangbasechecks.h"
|
#include "ui_clangbasechecks.h"
|
||||||
@@ -40,6 +41,7 @@
|
|||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QDesktopServices>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
@@ -47,6 +49,9 @@
|
|||||||
|
|
||||||
namespace CppTools {
|
namespace CppTools {
|
||||||
|
|
||||||
|
static constexpr const char CLANG_STATIC_ANALYZER_URL[]
|
||||||
|
= "https://clang-analyzer.llvm.org/available_checks.html";
|
||||||
|
|
||||||
static void buildTree(ProjectExplorer::Tree *parent,
|
static void buildTree(ProjectExplorer::Tree *parent,
|
||||||
ProjectExplorer::Tree *current,
|
ProjectExplorer::Tree *current,
|
||||||
const Constants::TidyNode &node)
|
const Constants::TidyNode &node)
|
||||||
@@ -64,6 +69,12 @@ static void buildTree(ProjectExplorer::Tree *parent,
|
|||||||
buildTree(current, new ProjectExplorer::Tree, nodeChild);
|
buildTree(current, new ProjectExplorer::Tree, nodeChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool needsLink(ProjectExplorer::Tree *node) {
|
||||||
|
if (node->name == "clang-analyzer-")
|
||||||
|
return true;
|
||||||
|
return !node->isDir && !node->fullPath.toString().startsWith("clang-analyzer-");
|
||||||
|
}
|
||||||
|
|
||||||
class TidyChecksTreeModel final : public ProjectExplorer::SelectableFilesModel
|
class TidyChecksTreeModel final : public ProjectExplorer::SelectableFilesModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -108,14 +119,45 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const final
|
int columnCount(const QModelIndex &/*parent*/) const override
|
||||||
{
|
{
|
||||||
if (!index.isValid() || role == Qt::DecorationRole)
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant data(const QModelIndex &fullIndex, int role = Qt::DisplayRole) const final
|
||||||
|
{
|
||||||
|
if (!fullIndex.isValid() || role == Qt::DecorationRole)
|
||||||
|
return QVariant();
|
||||||
|
QModelIndex index = this->index(fullIndex.row(), 0, fullIndex.parent());
|
||||||
|
auto *node = static_cast<ProjectExplorer::Tree *>(index.internalPointer());
|
||||||
|
|
||||||
|
if (fullIndex.column() == 1) {
|
||||||
|
if (!needsLink(node))
|
||||||
|
return QVariant();
|
||||||
|
switch (role) {
|
||||||
|
case Qt::DisplayRole:
|
||||||
|
return tr("Web Page");
|
||||||
|
case Qt::FontRole: {
|
||||||
|
QFont font = QApplication::font();
|
||||||
|
font.setUnderline(true);
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
case Qt::ForegroundRole:
|
||||||
|
return QApplication::palette().link().color();
|
||||||
|
case Qt::UserRole: {
|
||||||
|
// 'clang-analyzer-' group
|
||||||
|
if (node->isDir)
|
||||||
|
return QString::fromUtf8(CLANG_STATIC_ANALYZER_URL);
|
||||||
|
return QString::fromUtf8(Constants::TIDY_DOCUMENTATION_URL_TEMPLATE)
|
||||||
|
.arg(node->fullPath.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
if (role == Qt::DisplayRole) {
|
|
||||||
auto *node = static_cast<ProjectExplorer::Tree *>(index.internalPointer());
|
|
||||||
return node->isDir ? (node->name + "*") : node->name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (role == Qt::DisplayRole)
|
||||||
|
return node->isDir ? (node->name + "*") : node->name;
|
||||||
|
|
||||||
return ProjectExplorer::SelectableFilesModel::data(index, role);
|
return ProjectExplorer::SelectableFilesModel::data(index, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,10 +202,7 @@ private:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!check.startsWith(nodeName))
|
return check.startsWith(nodeName);
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -203,6 +242,15 @@ ClangDiagnosticConfigsWidget::ClangDiagnosticConfigsWidget(const Core::Id &confi
|
|||||||
this, &ClangDiagnosticConfigsWidget::onRemoveButtonClicked);
|
this, &ClangDiagnosticConfigsWidget::onRemoveButtonClicked);
|
||||||
connectDiagnosticOptionsChanged();
|
connectDiagnosticOptionsChanged();
|
||||||
|
|
||||||
|
connect(m_tidyChecks->checksPrefixesTree, &QTreeView::clicked,
|
||||||
|
[this](const QModelIndex &index) {
|
||||||
|
const QString link = m_tidyTreeModel->data(index, Qt::UserRole).toString();
|
||||||
|
if (link.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QDesktopServices::openUrl(QUrl(link));
|
||||||
|
});
|
||||||
|
|
||||||
syncWidgetsToModel(configToSelect);
|
syncWidgetsToModel(configToSelect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -599,6 +647,8 @@ void ClangDiagnosticConfigsWidget::setupTabs()
|
|||||||
m_tidyChecks->setupUi(m_tidyChecksWidget);
|
m_tidyChecks->setupUi(m_tidyChecksWidget);
|
||||||
m_tidyChecks->checksPrefixesTree->setModel(m_tidyTreeModel.get());
|
m_tidyChecks->checksPrefixesTree->setModel(m_tidyTreeModel.get());
|
||||||
m_tidyChecks->checksPrefixesTree->expandToDepth(0);
|
m_tidyChecks->checksPrefixesTree->expandToDepth(0);
|
||||||
|
m_tidyChecks->checksPrefixesTree->header()->setStretchLastSection(false);
|
||||||
|
m_tidyChecks->checksPrefixesTree->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||||
connect(m_tidyChecks->plainTextEditButton, &QPushButton::clicked, this, [this]() {
|
connect(m_tidyChecks->plainTextEditButton, &QPushButton::clicked, this, [this]() {
|
||||||
QDialog dialog;
|
QDialog dialog;
|
||||||
dialog.setWindowTitle(tr("Checks"));
|
dialog.setWindowTitle(tr("Checks"));
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ private:
|
|||||||
void onRemoveButtonClicked();
|
void onRemoveButtonClicked();
|
||||||
void onClangTidyModeChanged(int index);
|
void onClangTidyModeChanged(int index);
|
||||||
void onClangTidyTreeChanged();
|
void onClangTidyTreeChanged();
|
||||||
|
void onClangTidyTreeItemClicked(const QModelIndex &index);
|
||||||
void onClazyRadioButtonChanged(bool checked);
|
void onClazyRadioButtonChanged(bool checked);
|
||||||
|
|
||||||
void onDiagnosticOptionsEdited();
|
void onDiagnosticOptionsEdited();
|
||||||
|
|||||||
@@ -93,5 +93,13 @@ const char LOCATOR_FILTER_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("CppTools", "C++ Cl
|
|||||||
const char SYMBOLS_FIND_FILTER_ID[] = "Symbols";
|
const char SYMBOLS_FIND_FILTER_ID[] = "Symbols";
|
||||||
const char SYMBOLS_FIND_FILTER_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("CppTools", "C++ Symbols");
|
const char SYMBOLS_FIND_FILTER_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("CppTools", "C++ Symbols");
|
||||||
|
|
||||||
|
// CLANG-UPGRADE-CHECK: Checks/update URLs.
|
||||||
|
//
|
||||||
|
// Upgrade the version in the URL. Note that we cannot use the macro
|
||||||
|
// CLANG_VERSION here because it might denote a version that was not yet
|
||||||
|
// released (e.g. 6.0.1, but only 6.0.0 was released).
|
||||||
|
constexpr const char TIDY_DOCUMENTATION_URL_TEMPLATE[]
|
||||||
|
= "https://releases.llvm.org/6.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/%1.html";
|
||||||
|
|
||||||
} // namespace Constants
|
} // namespace Constants
|
||||||
} // namespace CppTools
|
} // namespace CppTools
|
||||||
|
|||||||
Reference in New Issue
Block a user