diff --git a/interfaces/iproblem.h b/interfaces/iproblem.h --- a/interfaces/iproblem.h +++ b/interfaces/iproblem.h @@ -90,6 +90,12 @@ /// Returns a string containing the source of the problem virtual QString sourceString() const = 0; + /// Sets the custom plugin name, which will be returned by sourceString() + /// method instead default generic value. + /// + /// The method call only makes sense when the problem source is IProblem::Plugin. + virtual void setPluginName(const QString& name) = 0; + /// Returns the location of the problem (path, line, column) virtual KDevelop::DocumentRange finalLocation() const = 0; diff --git a/language/duchain/problem.h b/language/duchain/problem.h --- a/language/duchain/problem.h +++ b/language/duchain/problem.h @@ -146,6 +146,7 @@ * Returns a string version of the problem source */ QString sourceString() const override; + void setPluginName(const QString& name) override; TopDUContext* topContext() const override; KDevelop::IndexedString url() const override; diff --git a/language/duchain/problem.cpp b/language/duchain/problem.cpp --- a/language/duchain/problem.cpp +++ b/language/duchain/problem.cpp @@ -234,6 +234,10 @@ } } +void Problem::setPluginName(const QString& name) +{ +} + QString Problem::toString() const { return i18nc(": in :[]: (found by )", diff --git a/shell/problem.h b/shell/problem.h --- a/shell/problem.h +++ b/shell/problem.h @@ -63,7 +63,9 @@ Source source() const override; void setSource(Source source) override; + QString sourceString() const override; + void setPluginName(const QString& name) override; DocumentRange finalLocation() const override; void setFinalLocation(const DocumentRange& location) override; diff --git a/shell/problem.cpp b/shell/problem.cpp --- a/shell/problem.cpp +++ b/shell/problem.cpp @@ -25,14 +25,16 @@ struct DetectedProblemPrivate { DetectedProblemPrivate() - : m_severity(KDevelop::IProblem::Error) + : m_pluginName(i18n("Plugin")) + , m_severity(KDevelop::IProblem::Error) , m_source(KDevelop::IProblem::Unknown) , m_finalLocationMode(KDevelop::IProblem::Range) { } QString m_description; QString m_explanation; + QString m_pluginName; KDevelop::IProblem::Severity m_severity; KDevelop::IProblem::Source m_source; KDevelop::DocumentRange m_range; @@ -77,12 +79,17 @@ case DUChainBuilder: s = i18n("DuchainBuilder"); break; case SemanticAnalysis: s = i18n("Semantic analysis"); break; case ToDo: s = i18n("Todo"); break; - case Plugin: s = i18n("Plugin"); break; + case Plugin: s = d->m_pluginName; break; } return s; } +void DetectedProblem::setPluginName(const QString& name) +{ + d->m_pluginName = name; +} + DocumentRange DetectedProblem::finalLocation() const { return d->m_range; diff --git a/shell/tests/test_detectedproblem.cpp b/shell/tests/test_detectedproblem.cpp --- a/shell/tests/test_detectedproblem.cpp +++ b/shell/tests/test_detectedproblem.cpp @@ -88,6 +88,8 @@ QCOMPARE(sources[i].sourceString, m_problem->sourceString()); } + m_problem->setPluginName(QStringLiteral("TestPlugin")); + QCOMPARE(m_problem->sourceString(), QStringLiteral("TestPlugin")); } struct Severity