forked from qt-creator/qt-creator
ClangTools: optimize generating diagnostic text marks
If we already know the document for a TextMark we are saving a potentially expensive lookup. Change-Id: Ib42b9ab5f36492a94846ef819c84c69a5aecf2e4 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -8,18 +8,21 @@
|
|||||||
#include "clangtoolsutils.h"
|
#include "clangtoolsutils.h"
|
||||||
#include "diagnosticconfigswidget.h"
|
#include "diagnosticconfigswidget.h"
|
||||||
|
|
||||||
|
#include <texteditor/textdocument.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
|
||||||
|
using namespace TextEditor;
|
||||||
|
|
||||||
namespace ClangTools {
|
namespace ClangTools {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic)
|
DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic, TextDocument *document)
|
||||||
: TextEditor::TextMark(diagnostic.location.filePath,
|
: TextMark(document,
|
||||||
diagnostic.location.line,
|
diagnostic.location.line,
|
||||||
{Tr::tr("Clang Tools"), Utils::Id(Constants::DIAGNOSTIC_MARK_ID)})
|
{Tr::tr("Clang Tools"), Utils::Id(Constants::DIAGNOSTIC_MARK_ID)})
|
||||||
, m_diagnostic(diagnostic)
|
, m_diagnostic(diagnostic)
|
||||||
{
|
{
|
||||||
setSettingsPage(Constants::SETTINGS_PAGE_ID);
|
setSettingsPage(Constants::SETTINGS_PAGE_ID);
|
||||||
@@ -57,6 +60,10 @@ DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic)
|
||||||
|
: DiagnosticMark(diagnostic, TextDocument::textDocumentForFilePath(diagnostic.location.filePath))
|
||||||
|
{}
|
||||||
|
|
||||||
void DiagnosticMark::disable()
|
void DiagnosticMark::disable()
|
||||||
{
|
{
|
||||||
if (!m_enabled)
|
if (!m_enabled)
|
||||||
|
@@ -14,6 +14,7 @@ namespace Internal {
|
|||||||
class DiagnosticMark : public TextEditor::TextMark
|
class DiagnosticMark : public TextEditor::TextMark
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
DiagnosticMark(const Diagnostic &diagnostic, TextEditor::TextDocument *document);
|
||||||
explicit DiagnosticMark(const Diagnostic &diagnostic);
|
explicit DiagnosticMark(const Diagnostic &diagnostic);
|
||||||
|
|
||||||
void disable();
|
void disable();
|
||||||
|
@@ -268,7 +268,7 @@ void DocumentClangToolRunner::onDone(const AnalyzeOutputData &output)
|
|||||||
if (isSuppressed(diagnostic))
|
if (isSuppressed(diagnostic))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto mark = new DiagnosticMark(diagnostic);
|
auto mark = new DiagnosticMark(diagnostic, doc);
|
||||||
mark->toolType = toolType;
|
mark->toolType = toolType;
|
||||||
|
|
||||||
if (doc && Utils::anyOf(diagnostic.explainingSteps, &ExplainingStep::isFixIt)) {
|
if (doc && Utils::anyOf(diagnostic.explainingSteps, &ExplainingStep::isFixIt)) {
|
||||||
|
Reference in New Issue
Block a user