DiagnosticMark: Replace source field with ClangToolType

Replace also the AnalyzeOutputData::toolName field with
ClangToolType toolType. Stop relying on comparing translatable
strings inside DocumentClangToolRunner::onDone().

Change-Id: I1b69619fe9283622ed478973ee3a5e9cf8f4c309
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Jarek Kobus
2023-01-12 02:12:33 +01:00
parent e7781e2a99
commit 6415eef6af
4 changed files with 9 additions and 9 deletions

View File

@@ -163,7 +163,7 @@ TaskItem clangToolTask(const AnalyzeInputData &input,
if (!outputHandler) if (!outputHandler)
return; return;
const ClangToolStorage *data = storage.activeStorage(); const ClangToolStorage *data = storage.activeStorage();
outputHandler({true, input.unit.file, data->outputFilePath, data->name}); outputHandler({true, input.unit.file, data->outputFilePath, input.tool});
}; };
const auto onProcessError = [=](const QtcProcess &process) { const auto onProcessError = [=](const QtcProcess &process) {
if (!outputHandler) if (!outputHandler)
@@ -180,7 +180,7 @@ TaskItem clangToolTask(const AnalyzeInputData &input,
message = Tr::tr("%1 finished with exit code: %2.").arg(data->name).arg(process.exitCode()); message = Tr::tr("%1 finished with exit code: %2.").arg(data->name).arg(process.exitCode());
else else
message = Tr::tr("%1 crashed.").arg(data->name); message = Tr::tr("%1 crashed.").arg(data->name);
outputHandler({false, input.unit.file, data->outputFilePath, data->name, message, details}); outputHandler({false, input.unit.file, data->outputFilePath, input.tool, message, details});
}; };
const Group group { const Group group {

View File

@@ -39,7 +39,7 @@ struct AnalyzeOutputData
bool success = true; bool success = true;
QString fileToAnalyze; QString fileToAnalyze;
QString outputFilePath; QString outputFilePath;
QString toolName; CppEditor::ClangToolType toolType;
QString errorMessage = {}; QString errorMessage = {};
QString errorDetails = {}; QString errorDetails = {};
}; };

View File

@@ -5,12 +5,12 @@
#include "clangtoolsdiagnostic.h" #include "clangtoolsdiagnostic.h"
#include <cppeditor/clangdiagnosticconfig.h>
#include <texteditor/textmark.h> #include <texteditor/textmark.h>
namespace ClangTools { namespace ClangTools {
namespace Internal { namespace Internal {
class DiagnosticMark : public TextEditor::TextMark class DiagnosticMark : public TextEditor::TextMark
{ {
Q_DECLARE_TR_FUNCTIONS(ClangTools::Internal::DiagnosticMark) Q_DECLARE_TR_FUNCTIONS(ClangTools::Internal::DiagnosticMark)
@@ -22,7 +22,7 @@ public:
Diagnostic diagnostic() const; Diagnostic diagnostic() const;
QString source; std::optional<CppEditor::ClangToolType> toolType;
private: private:
const Diagnostic m_diagnostic; const Diagnostic m_diagnostic;

View File

@@ -245,10 +245,10 @@ void DocumentClangToolRunner::onDone(const AnalyzeOutputData &output)
} }
} }
const QString toolName = output.toolName; const CppEditor::ClangToolType toolType = output.toolType;
// remove outdated marks of the current runner // remove outdated marks of the current runner
auto [toDelete, newMarks] = Utils::partition(m_marks, [toolName](DiagnosticMark *mark) { const auto [toDelete, newMarks] = Utils::partition(m_marks, [toolType](DiagnosticMark *mark) {
return mark->source == toolName; // TODO: comparison on translatable string return mark->toolType == toolType;
}); });
m_marks = newMarks; m_marks = newMarks;
qDeleteAll(toDelete); qDeleteAll(toDelete);
@@ -262,7 +262,7 @@ void DocumentClangToolRunner::onDone(const AnalyzeOutputData &output)
continue; continue;
auto mark = new DiagnosticMark(diagnostic); auto mark = new DiagnosticMark(diagnostic);
mark->source = toolName; mark->toolType = toolType;
if (doc && Utils::anyOf(diagnostic.explainingSteps, &ExplainingStep::isFixIt)) { if (doc && Utils::anyOf(diagnostic.explainingSteps, &ExplainingStep::isFixIt)) {
TextEditor::RefactorMarker marker; TextEditor::RefactorMarker marker;