forked from qt-creator/qt-creator
ClangTools: Do not show text marks for suppressed diagnostics
Do not generate marks for automatic runs and hide them for the explicitly invoked analyzes. Change-Id: Ic48e7b13c424c51e7e1759c588c94bbd45e6d1bb Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -194,6 +194,9 @@ void DocumentClangToolRunner::run()
|
||||
const RunSettings &runSettings = projectSettings->useGlobalSettings()
|
||||
? ClangToolsSettings::instance()->runSettings()
|
||||
: projectSettings->runSettings();
|
||||
|
||||
m_suppressed = projectSettings->suppressedDiagnostics();
|
||||
m_lastProjectDirectory = project->projectDirectory();
|
||||
m_projectSettingsUpdate = connect(projectSettings.data(),
|
||||
&ClangToolsProjectSettings::changed,
|
||||
this,
|
||||
@@ -293,6 +296,9 @@ void DocumentClangToolRunner::onSuccess()
|
||||
TextEditor::RefactorMarkers markers;
|
||||
|
||||
for (const Diagnostic &diagnostic : diagnostics) {
|
||||
if (isSuppressed(diagnostic))
|
||||
continue;
|
||||
|
||||
auto mark = new DiagnosticMark(diagnostic);
|
||||
mark->source = m_currentRunner->name();
|
||||
|
||||
@@ -351,6 +357,20 @@ void DocumentClangToolRunner::cancel()
|
||||
}
|
||||
}
|
||||
|
||||
bool DocumentClangToolRunner::isSuppressed(const Diagnostic &diagnostic) const
|
||||
{
|
||||
auto equalsSuppressed = [this, &diagnostic](const SuppressedDiagnostic &suppressed) {
|
||||
if (suppressed.description != diagnostic.description)
|
||||
return false;
|
||||
QString filePath = suppressed.filePath.toString();
|
||||
QFileInfo fi(filePath);
|
||||
if (fi.isRelative())
|
||||
filePath = m_lastProjectDirectory.toString() + QLatin1Char('/') + filePath;
|
||||
return filePath == diagnostic.location.filePath;
|
||||
};
|
||||
return Utils::anyOf(m_suppressed, equalsSuppressed);
|
||||
}
|
||||
|
||||
const CppTools::ClangDiagnosticConfig DocumentClangToolRunner::getDiagnosticConfig(ProjectExplorer::Project *project)
|
||||
{
|
||||
const auto projectSettings = ClangToolsProjectSettings::getSettings(project);
|
||||
|
||||
Reference in New Issue
Block a user