ClangTools: Add help context menu entry

...that opens the documentation page for the current diagnostic.

Change-Id: I398fdc82bb118a80536acbb12420a9bac84e66c9
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Nikolai Kosjar
2019-11-29 09:52:02 +01:00
committed by Cristian Adam
parent 311779e53e
commit 1b4de8d769
11 changed files with 79 additions and 15 deletions

View File

@@ -31,6 +31,7 @@
#include "clangtoolssettings.h"
#include <coreplugin/icore.h>
#include <cpptools/cpptoolsconstants.h>
#include <cpptools/cpptoolsreuse.h>
#include <projectexplorer/projectexplorerconstants.h>
@@ -193,5 +194,27 @@ ClangDiagnosticConfigsModel diagnosticConfigsModel()
return Internal::diagnosticConfigsModel(ClangToolsSettings::instance()->diagnosticConfigs());
}
QString documentationUrl(const QString &checkName)
{
QString name = checkName;
const QString clangPrefix = "clang-diagnostic-";
if (name.startsWith(clangPrefix))
return {}; // No documentation for this.
QString url;
const QString clazyPrefix = "clazy-";
const QString clangStaticAnalyzerPrefix = "clang-analyzer-core.";
if (name.startsWith(clazyPrefix)) {
name = checkName.mid(clazyPrefix.length());
url = QString(CppTools::Constants::CLAZY_DOCUMENTATION_URL_TEMPLATE).arg(name);
} else if (name.startsWith(clangStaticAnalyzerPrefix)) {
url = CppTools::Constants::CLANG_STATIC_ANALYZER_DOCUMENTATION_URL;
} else {
url = QString(CppTools::Constants::TIDY_DOCUMENTATION_URL_TEMPLATE).arg(name);
}
return url;
}
} // namespace Internal
} // namespace ClangTools