forked from qt-creator/qt-creator
ClangCodeModel: prevent text mark annotations in non project files
Since non project files get opened in project specific clients now, the check whether we should add annotations needs to make sure that the marks file is part of the client project. Change-Id: I2790d0f7feb39162686efd06bb3542684d289b95 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "client.h"
|
||||
|
||||
#include <coreplugin/editormanager/documentmodel.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <texteditor/fontsettings.h>
|
||||
#include <texteditor/textdocument.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
@@ -74,7 +75,7 @@ private:
|
||||
DiagnosticManager::DiagnosticManager(Client *client)
|
||||
: m_client(client)
|
||||
{
|
||||
m_textMarkCreator = [this](const FilePath &filePath, const Diagnostic &diagnostic) {
|
||||
m_textMarkCreator = [this](const FilePath &filePath, const Diagnostic &diagnostic, bool /*isProjectFile*/) {
|
||||
return createTextMark(filePath, diagnostic);
|
||||
};
|
||||
}
|
||||
@@ -125,9 +126,11 @@ void DiagnosticManager::showDiagnostics(const DocumentUri &uri, int version)
|
||||
QList<QTextEdit::ExtraSelection> extraSelections;
|
||||
const VersionedDiagnostics &versionedDiagnostics = m_diagnostics.value(uri);
|
||||
if (versionedDiagnostics.version.value_or(version) == version) {
|
||||
const bool isProjectFile = m_client->project()
|
||||
&& m_client->project()->isKnownFile(filePath);
|
||||
for (const Diagnostic &diagnostic : versionedDiagnostics.diagnostics) {
|
||||
extraSelections << toDiagnosticsSelections(diagnostic, doc->document());
|
||||
m_marks[filePath].append(m_textMarkCreator(filePath, diagnostic));
|
||||
m_marks[filePath].append(m_textMarkCreator(filePath, diagnostic, isProjectFile));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user