qmllint: Update JSON format to include hints into fix suggestions
Hints are no longer their own fix suggestion but instead are part of an
existing one. This breaks compatibility with the existing format but as
the output is not documented and is versioned this should be ok.
This change will enable having multiple fix suggestions per warning in a
future change.
Change-Id: Iedf275507554a2d70399757396e278999874cd53
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 243883ed78
)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
d708b56ae2
commit
58895fe565
|
@ -471,31 +471,18 @@ static void addJsonWarning(QJsonArray &warnings, const QQmlJS::DiagnosticMessage
|
|||
QJsonObject jsonFix {
|
||||
{ "message"_L1, suggestion->fixDescription() },
|
||||
{ "replacement"_L1, suggestion->replacement() },
|
||||
{ "isHint"_L1, !suggestion->isAutoApplicable() },
|
||||
{ "isAutoApplicable"_L1, suggestion->isAutoApplicable() },
|
||||
{ "hint"_L1, suggestion->hint() },
|
||||
};
|
||||
convertLocation(suggestion->location(), &jsonFix);
|
||||
const QString filename = suggestion->filename();
|
||||
if (!filename.isEmpty())
|
||||
jsonFix.insert("fileName"_L1, filename);
|
||||
suggestions << jsonFix;
|
||||
|
||||
const QString hint = suggestion->hint();
|
||||
if (!hint.isEmpty()) {
|
||||
// We need to keep compatibility with the JSON format.
|
||||
// Therefore the overly verbose encoding of the hint.
|
||||
QJsonObject jsonHint {
|
||||
{ "message"_L1, hint },
|
||||
{ "replacement"_L1, QString() },
|
||||
{ "isHint"_L1, true }
|
||||
};
|
||||
convertLocation(QQmlJS::SourceLocation(), &jsonHint);
|
||||
suggestions << jsonHint;
|
||||
}
|
||||
}
|
||||
jsonMessage[u"suggestions"] = suggestions;
|
||||
|
||||
warnings << jsonMessage;
|
||||
|
||||
}
|
||||
|
||||
void QQmlJSLinter::processMessages(QJsonArray &warnings)
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
constexpr int JSON_LOGGING_FORMAT_REVISION = 3;
|
||||
constexpr int JSON_LOGGING_FORMAT_REVISION = 4;
|
||||
|
||||
bool argumentsFromCommandLineAndFile(QStringList& allArguments, const QStringList &arguments)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue