forked from qt-creator/qt-creator
Clang: Add tooltip action to remove specific warnings/checks
...from the diagnostic configuration. If no custom diagnostic configuration is set in Projects Mode > Clang, one is created and set for the current project. Otherwise the current custom diagnostic set in the project settings is modified. Change-Id: I5c48280c90f0e807e7333122d504dda302a8b0a9 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -373,5 +373,51 @@ QString currentCppEditorDocumentFilePath()
|
||||
return filePath;
|
||||
}
|
||||
|
||||
DiagnosticTextInfo::DiagnosticTextInfo(const QString &text)
|
||||
: m_text(text)
|
||||
, m_squareBracketStartIndex(text.lastIndexOf('['))
|
||||
{}
|
||||
|
||||
QString DiagnosticTextInfo::textWithoutOption() const
|
||||
{
|
||||
if (m_squareBracketStartIndex == -1)
|
||||
return m_text;
|
||||
|
||||
return m_text.mid(0, m_squareBracketStartIndex - 1);
|
||||
}
|
||||
|
||||
QString DiagnosticTextInfo::option() const
|
||||
{
|
||||
if (m_squareBracketStartIndex == -1)
|
||||
return QString();
|
||||
|
||||
const int index = m_squareBracketStartIndex + 1;
|
||||
return m_text.mid(index, m_text.count() - index - 1);
|
||||
}
|
||||
|
||||
QString DiagnosticTextInfo::category() const
|
||||
{
|
||||
if (m_squareBracketStartIndex == -1)
|
||||
return QString();
|
||||
|
||||
const int index = m_squareBracketStartIndex + 1;
|
||||
if (isClazyOption(m_text.mid(index)))
|
||||
return QCoreApplication::translate("ClangDiagnosticWidget", "Clazy Issue");
|
||||
else
|
||||
return QCoreApplication::translate("ClangDiagnosticWidget", "Clang-Tidy Issue");
|
||||
}
|
||||
|
||||
bool DiagnosticTextInfo::isClazyOption(const QString &option)
|
||||
{
|
||||
return option.startsWith("-Wclazy");
|
||||
}
|
||||
|
||||
QString DiagnosticTextInfo::clazyCheckName(const QString &option)
|
||||
{
|
||||
if (option.startsWith("-Wclazy"))
|
||||
return option.mid(8); // Chop "-Wclazy-"
|
||||
return option;
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
} // namespace Clang
|
||||
|
||||
Reference in New Issue
Block a user