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,16 +8,19 @@
|
||||
#include "clangtoolsutils.h"
|
||||
#include "diagnosticconfigswidget.h"
|
||||
|
||||
#include <texteditor/textdocument.h>
|
||||
#include <utils/utilsicons.h>
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
#include <QAction>
|
||||
|
||||
using namespace TextEditor;
|
||||
|
||||
namespace ClangTools {
|
||||
namespace Internal {
|
||||
|
||||
DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic)
|
||||
: TextEditor::TextMark(diagnostic.location.filePath,
|
||||
DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic, TextDocument *document)
|
||||
: TextMark(document,
|
||||
diagnostic.location.line,
|
||||
{Tr::tr("Clang Tools"), Utils::Id(Constants::DIAGNOSTIC_MARK_ID)})
|
||||
, m_diagnostic(diagnostic)
|
||||
@@ -57,6 +60,10 @@ DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic)
|
||||
});
|
||||
}
|
||||
|
||||
DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic)
|
||||
: DiagnosticMark(diagnostic, TextDocument::textDocumentForFilePath(diagnostic.location.filePath))
|
||||
{}
|
||||
|
||||
void DiagnosticMark::disable()
|
||||
{
|
||||
if (!m_enabled)
|
||||
|
@@ -14,6 +14,7 @@ namespace Internal {
|
||||
class DiagnosticMark : public TextEditor::TextMark
|
||||
{
|
||||
public:
|
||||
DiagnosticMark(const Diagnostic &diagnostic, TextEditor::TextDocument *document);
|
||||
explicit DiagnosticMark(const Diagnostic &diagnostic);
|
||||
|
||||
void disable();
|
||||
|
@@ -268,7 +268,7 @@ void DocumentClangToolRunner::onDone(const AnalyzeOutputData &output)
|
||||
if (isSuppressed(diagnostic))
|
||||
continue;
|
||||
|
||||
auto mark = new DiagnosticMark(diagnostic);
|
||||
auto mark = new DiagnosticMark(diagnostic, doc);
|
||||
mark->toolType = toolType;
|
||||
|
||||
if (doc && Utils::anyOf(diagnostic.explainingSteps, &ExplainingStep::isFixIt)) {
|
||||
|
Reference in New Issue
Block a user