aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-02-18 11:40:31 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-02-24 08:33:21 +0100
commit120eb155ef1f0da51c473b080880169a85e5ceb2 (patch)
treeb8bc85734d68f125d424b1f45f2576d20c885a43 /tools
parentae68d95b8c1c56ae907cbe88122dd79bafd20b72 (diff)
qmllint: Check for existence of property types
For each binding there should be a property and that property should have a type we recognize. Enums can be property types in C++. We support this by adding child scopes for such enums. The child scopes are then referenced by the QQmlJSMetaEnums and derive from int. The test then reveals that we were missing a few properties in QtQuick.tooling. Add those. Change-Id: I1deef94393ee0e17d34c2dc5980ebfbf25417f36 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 08c8e8ac3ba8eb23ae5c158990f5d029ac9988ed)
Diffstat (limited to 'tools')
-rw-r--r--tools/qmllint/findwarnings.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp
index c238f874e2..b23d517d41 100644
--- a/tools/qmllint/findwarnings.cpp
+++ b/tools/qmllint/findwarnings.cpp
@@ -218,8 +218,41 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiScriptBinding *uisb)
}
const QString signal = signalName(name);
- if (signal.isEmpty())
+ if (signal.isEmpty()) {
+ for (const auto &childScope : qmlScope->childScopes()) {
+ if ((childScope->scopeType() == QQmlJSScope::AttachedPropertyScope
+ || childScope->scopeType() == QQmlJSScope::GroupedPropertyScope)
+ && childScope->internalName() == name) {
+ return true;
+ }
+ }
+
+ if (!qmlScope->hasProperty(name.toString())) {
+ m_errors.append({
+ QStringLiteral("Binding assigned to \"%1\", but no property \"%1\" "
+ "exists in the current element.\n").arg(name),
+ QtWarningMsg,
+ uisb->firstSourceLocation()
+ });
+ m_visitFailed = true;
+ return true;
+ }
+
+ const auto property = qmlScope->property(name.toString());
+ if (!property.type()) {
+ m_errors.append({
+ QStringLiteral("No type found for property \"%1\". This may be due "
+ "to a missing import statement or incomplete "
+ "qmltypes files.\n").arg(name),
+ QtWarningMsg,
+ uisb->firstSourceLocation()
+ });
+ m_visitFailed = true;
+
+ }
+
return true;
+ }
if (!qmlScope->hasMethod(signal) && m_warnUnqualified) {