diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2025-01-16 18:32:24 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2025-01-17 14:13:55 +0100 |
| commit | 746f38bf56027c29a72bd8a3c3a5f9aad73b9bd3 (patch) | |
| tree | c1f779a136b03784e17a7518c74b22fa511fcbdf /src/qmlcompiler/qqmljsimportvisitor.cpp | |
| parent | c159f4e837d99c8cb4b260e7bbc390cdb83d5e19 (diff) | |
QmlCompiler: Reduce duplication of warnings about missing properties
If a property cannot be found, we don't need to check its type or even
try to compile a binding for it. We also shouldn't claim a property
doesn't exist if we cannot find it. We may have failed to resolve the
type after all.
Pick-to: 6.9 6.8
Task-number: QTBUG-124913
Change-Id: I93ef12e888762ae03f8fa6b1bef2e8d04ba3d4b2
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsimportvisitor.cpp')
| -rw-r--r-- | src/qmlcompiler/qqmljsimportvisitor.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp index 62c08d2bfb..9db0e9af69 100644 --- a/src/qmlcompiler/qqmljsimportvisitor.cpp +++ b/src/qmlcompiler/qqmljsimportvisitor.cpp @@ -222,6 +222,14 @@ void QQmlJSImportVisitor::warnUnresolvedType(const QQmlJSScope::ConstPtr &type) qmlUnresolvedType, type->sourceLocation()); } +void QQmlJSImportVisitor::warnMissingPropertyForBinding( + const QString &property, const QQmlJS::SourceLocation &location, + const std::optional<QQmlJSFixSuggestion> &fixSuggestion) +{ + m_logger->log(QStringLiteral("Could not find property \"%1\".").arg(property), + qmlMissingProperty, location, true, true, fixSuggestion); +} + static bool mayBeUnresolvedGroupedProperty(const QQmlJSScope::ConstPtr &scope) { return scope->scopeType() == QQmlSA::ScopeType::GroupedPropertyScope && !scope->baseType(); @@ -753,8 +761,7 @@ void QQmlJSImportVisitor::processPropertyBindingObjects() QQmlJSMetaProperty property = objectBinding.scope->property(propertyName); if (!property.isValid()) { - m_logger->log(QStringLiteral("Property \"%1\" does not exist").arg(propertyName), - qmlMissingProperty, objectBinding.location); + warnMissingPropertyForBinding(propertyName, objectBinding.location); continue; } const auto handleUnresolvedProperty = [&](const QQmlJSScope::ConstPtr &) { @@ -976,9 +983,7 @@ void QQmlJSImportVisitor::processPropertyBindings() } } - m_logger->log(QStringLiteral("Property \"%1\" does not exist.") - .arg(name), - qmlMissingProperty, location, true, true, fixSuggestion); + warnMissingPropertyForBinding(name, location, fixSuggestion); continue; } |
