aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljsimportvisitor.cpp
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2021-12-07 18:48:08 +0100
committerMaximilian Goldstein <max.goldstein@qt.io>2021-12-10 17:11:05 +0100
commit52c09a27efafe5566203d86f5e8689f0056a06c7 (patch)
tree28eb23166ec956bba5627c62501415611def8cc2 /src/qmlcompiler/qqmljsimportvisitor.cpp
parentd4d56b519d455a3f8f234a0853d82dbbf2c05ebe (diff)
qmllint: Use fix suggestions in a more structured way
Fix suggestions are now attached to the warnings they are caused by and are also accessible via JSON. This allows us to use the qmllint library for more of tst_qmllint, greatly improving performance. Change-Id: Idd0398028bff1272a75dc1193d2c15a25d335dbf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsimportvisitor.cpp')
-rw-r--r--src/qmlcompiler/qqmljsimportvisitor.cpp33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp
index d2fee8c234..2e651bbda4 100644
--- a/src/qmlcompiler/qqmljsimportvisitor.cpp
+++ b/src/qmlcompiler/qqmljsimportvisitor.cpp
@@ -834,9 +834,7 @@ void QQmlJSImportVisitor::checkSignals()
const QQmlJSScope::ConstPtr signalScope = it.key();
if (!signalScope->hasMethod(signal)) {
- m_logger->logWarning(QStringLiteral("no matching signal found for handler \"%1\"")
- .arg(pair.first),
- Log_UnqualifiedAccess, location);
+ std::optional<FixSuggestion> fix;
// There is a small chance of suggesting this fix for things that are not actually
// QtQml/Connections elements, but rather some other thing that is also called
@@ -848,22 +846,21 @@ void QQmlJSImportVisitor::checkSignals()
const qsizetype newLength = m_logger->code().indexOf(u'\n', location.end())
- location.offset;
- const FixSuggestion suggestion {
- Log_UnqualifiedAccess,
- {
- FixSuggestion::Fix {
- QStringLiteral("Implicitly defining %1 as signal handler in "
- "Connections is deprecated. Create a function "
- "instead").arg(pair.first),
- QQmlJS::SourceLocation(location.offset, newLength,
- location.startLine, location.startColumn),
- QStringLiteral("function %1(%2) { ... }")
- .arg(pair.first, pair.second.join(u", "))
- }
- }
- };
- m_logger->suggestFix(suggestion);
+ fix = FixSuggestion { { FixSuggestion::Fix {
+ QStringLiteral("Implicitly defining %1 as signal handler in "
+ "Connections is deprecated. Create a function "
+ "instead")
+ .arg(pair.first),
+ QQmlJS::SourceLocation(location.offset, newLength, location.startLine,
+ location.startColumn),
+ QStringLiteral("function %1(%2) { ... }")
+ .arg(pair.first, pair.second.join(u", ")) } } };
}
+
+ m_logger->logWarning(QStringLiteral("no matching signal found for handler \"%1\"")
+ .arg(pair.first),
+ Log_UnqualifiedAccess, location, true, true, fix);
+
continue;
}