summaryrefslogtreecommitdiff
path: root/src/plugins/clangcodemodel/clangutils.cpp
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@qt.io>2018-05-09 15:12:01 +0200
committerNikolai Kosjar <nikolai.kosjar@qt.io>2018-05-14 07:01:46 +0000
commit6b70c27e3b5116bd27b17b007646836252d69225 (patch)
treed790eb331c8e02b4020c8566066da5c129930f1f /src/plugins/clangcodemodel/clangutils.cpp
parent851d56cda2a56bd37b94d977d41f0c0bda265614 (diff)
downloadqt-creator-6b70c27e3b5116bd27b17b007646836252d69225.tar.gz
Clang: Do not show diagnostic category in inline annotations and issues pane
For build system diagnostics they are not displayed either. Also, the error/warning is already encoded in the icon and the color. However, the category is still shown in the tooltip. Change-Id: I190ab17691c32786cefc20d058010c65cda5ace9 Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/clangcodemodel/clangutils.cpp')
-rw-r--r--src/plugins/clangcodemodel/clangutils.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/plugins/clangcodemodel/clangutils.cpp b/src/plugins/clangcodemodel/clangutils.cpp
index 0b82c90f00..4a55973bed 100644
--- a/src/plugins/clangcodemodel/clangutils.cpp
+++ b/src/plugins/clangcodemodel/clangutils.cpp
@@ -307,5 +307,30 @@ CPlusPlus::Icons::IconType iconTypeForToken(const ClangBackEnd::TokenInfoContain
return CPlusPlus::Icons::UnknownIconType;
}
+QString diagnosticCategoryPrefixRemoved(const QString &text)
+{
+ QString theText = text;
+
+ // Prefixes are taken from $LLVM_SOURCE_DIR/tools/clang/lib/Frontend/TextDiagnostic.cpp,
+ // function TextDiagnostic::printDiagnosticLevel (llvm-3.6.2).
+ static const QStringList categoryPrefixes = {
+ QStringLiteral("note"),
+ QStringLiteral("remark"),
+ QStringLiteral("warning"),
+ QStringLiteral("error"),
+ QStringLiteral("fatal error")
+ };
+
+ for (const QString &prefix : categoryPrefixes) {
+ const QString fullPrefix = prefix + QStringLiteral(": ");
+ if (theText.startsWith(fullPrefix)) {
+ theText.remove(0, fullPrefix.length());
+ return theText;
+ }
+ }
+
+ return text;
+}
+
} // namespace Utils
} // namespace Clang