diff options
Diffstat (limited to 'src/qmlcompiler')
-rw-r--r-- | src/qmlcompiler/qqmljslinter.cpp | 17 | ||||
-rw-r--r-- | src/qmlcompiler/qqmljslogger.cpp | 14 |
2 files changed, 10 insertions, 21 deletions
diff --git a/src/qmlcompiler/qqmljslinter.cpp b/src/qmlcompiler/qqmljslinter.cpp index 3031d82bf7..c177968220 100644 --- a/src/qmlcompiler/qqmljslinter.cpp +++ b/src/qmlcompiler/qqmljslinter.cpp @@ -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) diff --git a/src/qmlcompiler/qqmljslogger.cpp b/src/qmlcompiler/qqmljslogger.cpp index 8410032f48..6d42e4f545 100644 --- a/src/qmlcompiler/qqmljslogger.cpp +++ b/src/qmlcompiler/qqmljslogger.cpp @@ -477,13 +477,15 @@ void QQmlJSLogger::printFix(const QQmlJSFixSuggestion &fixItem) int tabCount = issueLocationWithContext.beforeText().count(u'\t'); // Do not draw location indicator for multiline replacement strings - if (replacementString.contains(u'\n')) - return; + if (!replacementString.contains(u'\n')) { + m_output.write(u" "_s.repeated( + issueLocationWithContext.beforeText().size() - tabCount) + + u"\t"_s.repeated(tabCount) + + u"^"_s.repeated(replacement.size()) + u'\n'); + } - m_output.write(u" "_s.repeated( - issueLocationWithContext.beforeText().size() - tabCount) - + u"\t"_s.repeated(tabCount) - + u"^"_s.repeated(replacement.size()) + u'\n'); + if (!fixItem.hint().isEmpty()) + m_output.write(" "_L1 + fixItem.hint()); } QQmlJSFixSuggestion::QQmlJSFixSuggestion(const QString &fixDescription, |