forked from qt-creator/qt-creator
ClangTools: Support doc urls for pre-relase clang-tidy
Change-Id: I9c28b5846d576d0b17c2e36f790d59b6bb005f6b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "clangtoolsconstants.h"
|
||||
#include "clangtoolsutils.h"
|
||||
#include "executableinfo.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <cppeditor/clangdiagnosticconfig.h>
|
||||
@@ -206,14 +207,18 @@ void ClangToolsSettings::setClazyStandaloneExecutable(const FilePath &path)
|
||||
m_clazyVersion = {};
|
||||
}
|
||||
|
||||
static QVersionNumber getVersionNumber(QVersionNumber &version, const FilePath &toolFilePath)
|
||||
static VersionAndSuffix getVersionNumber(VersionAndSuffix &version, const FilePath &toolFilePath)
|
||||
{
|
||||
if (version.isNull() && !toolFilePath.isEmpty())
|
||||
version = QVersionNumber::fromString(queryVersion(toolFilePath, QueryFailMode::Silent));
|
||||
if (version.first.isNull() && !toolFilePath.isEmpty()) {
|
||||
const QString versionString = queryVersion(toolFilePath, QueryFailMode::Silent);
|
||||
int suffixIndex = versionString.length() - 1;
|
||||
version.first = QVersionNumber::fromString(versionString, &suffixIndex);
|
||||
version.second = versionString.mid(suffixIndex);
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
QVersionNumber ClangToolsSettings::clangTidyVersion()
|
||||
VersionAndSuffix ClangToolsSettings::clangTidyVersion()
|
||||
{
|
||||
return getVersionNumber(instance()->m_clangTidyVersion, Internal::clangTidyExecutable());
|
||||
}
|
||||
|
@@ -25,13 +25,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "executableinfo.h"
|
||||
|
||||
#include <cppeditor/clangdiagnosticconfig.h>
|
||||
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/id.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
#include <QString>
|
||||
#include <QVersionNumber>
|
||||
|
||||
@@ -40,6 +40,8 @@ namespace Internal {
|
||||
|
||||
const char diagnosticConfigIdKey[] = "DiagnosticConfig";
|
||||
|
||||
using VersionAndSuffix = QPair<QVersionNumber, QString>;
|
||||
|
||||
class RunSettings
|
||||
{
|
||||
public:
|
||||
@@ -90,7 +92,7 @@ public:
|
||||
RunSettings runSettings() const { return m_runSettings; }
|
||||
void setRunSettings(const RunSettings &settings) { m_runSettings = settings; }
|
||||
|
||||
static QVersionNumber clangTidyVersion();
|
||||
static VersionAndSuffix clangTidyVersion();
|
||||
static QVersionNumber clazyVersion();
|
||||
|
||||
signals:
|
||||
@@ -111,7 +113,7 @@ private:
|
||||
RunSettings m_runSettings;
|
||||
|
||||
// Version info. Ephemeral.
|
||||
QVersionNumber m_clangTidyVersion;
|
||||
VersionAndSuffix m_clangTidyVersion;
|
||||
QVersionNumber m_clazyVersion;
|
||||
};
|
||||
|
||||
|
@@ -341,14 +341,18 @@ QStringList extraClangToolsAppendOptions()
|
||||
|
||||
QString clangTidyDocUrl(const QString &check)
|
||||
{
|
||||
QVersionNumber version = ClangToolsSettings::clangTidyVersion();
|
||||
version = QVersionNumber(version.majorVersion(), 0, 0);
|
||||
if (version == QVersionNumber(0))
|
||||
version = QVersionNumber(12);
|
||||
static const char urlTemplate[]
|
||||
= "https://releases.llvm.org/%1/tools/clang/tools/extra/docs/clang-tidy/checks/";
|
||||
QString url = QString::fromLatin1(urlTemplate).arg(version.toString());
|
||||
if (version.majorVersion() < 15) {
|
||||
VersionAndSuffix version = ClangToolsSettings::clangTidyVersion();
|
||||
version.first = QVersionNumber(version.first.majorVersion(), 0, 0);
|
||||
if (version.first == QVersionNumber(0))
|
||||
version.first = QVersionNumber(12);
|
||||
static const char versionedUrlPrefix[]
|
||||
= "https://releases.llvm.org/%1/tools/clang/tools/extra/docs/";
|
||||
static const char unversionedUrlPrefix[] = "https://clang.llvm.org/extra/";
|
||||
QString url = version.second.contains("git")
|
||||
? QString::fromLatin1(unversionedUrlPrefix)
|
||||
: QString::fromLatin1(versionedUrlPrefix).arg(version.first.toString());
|
||||
url.append("clang-tidy/checks/");
|
||||
if (version.first.majorVersion() < 15) {
|
||||
url.append(check);
|
||||
} else {
|
||||
const int hyphenIndex = check.indexOf('-');
|
||||
|
Reference in New Issue
Block a user