diff options
| author | Sami Shalayel <sami.shalayel@qt.io> | 2024-07-26 15:16:20 +0200 |
|---|---|---|
| committer | Sami Shalayel <sami.shalayel@qt.io> | 2024-07-30 17:06:43 +0200 |
| commit | 85e47ec482072531d59c40555dea4bd5df5e63dc (patch) | |
| tree | ebaacd528e59073789ad388e8cd98ae7a7b1e1b3 | |
| parent | 698110b42fccbb75943f5972cff415d1502f85cd (diff) | |
qmllint: unify missing property warning
Currently, there are two different warning formulations when binding
something to a property that does not exist. Unify them so that they
don't need to be documented twice by replacing
```
Binding assigned to XXX, but no property XXX exists in the current
element.
```
with the warning
```
Property X does not exist
```
Also, from a user perspective it does not make sense to have different
warnings for "assigning an object to a property that does not exist" and
"assigning a script expression to a property that does not exist".
Pick-to: 6.7 6.8
Task-number: QTBUG-118112
Change-Id: Iec2b5717709239d4b8fa45793ee16c6e1cc39a24
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
| -rw-r--r-- | src/qmlcompiler/qqmljsimportvisitor.cpp | 3 | ||||
| -rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 33 |
2 files changed, 12 insertions, 24 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp index 2b4687da77..e52a1c9a1e 100644 --- a/src/qmlcompiler/qqmljsimportvisitor.cpp +++ b/src/qmlcompiler/qqmljsimportvisitor.cpp @@ -951,8 +951,7 @@ void QQmlJSImportVisitor::processPropertyBindings() } } - m_logger->log(QStringLiteral("Binding assigned to \"%1\", but no property \"%1\" " - "exists in the current element.") + m_logger->log(QStringLiteral("Property \"%1\" does not exist.") .arg(name), qmlMissingProperty, location, true, true, fixSuggestion); continue; diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index 2ddd3c7666..8cbec7c3ef 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -665,9 +665,8 @@ void TestQmllint::dirtyQmlCode_data() << Result { { Message { QStringLiteral( "unknown attached property scope WrongAttached.") } } }; QTest::newRow("BadBinding") << QStringLiteral("badBinding.qml") - << Result { { Message { QStringLiteral( - "Binding assigned to \"doesNotExist\", but no property " - "\"doesNotExist\" exists in the current element.") } } }; + << Result{ { Message{ QStringLiteral( + "Property \"doesNotExist\" does not exist.") } } }; QTest::newRow("bad template literal (simple)") << QStringLiteral("badTemplateStringSimple.qml") << Result { { Message { @@ -687,16 +686,12 @@ void TestQmllint::dirtyQmlCode_data() QStringLiteral("Cannot assign literal of type string to int") } } }; QTest::newRow("BadScriptBindingOnGroup") << QStringLiteral("badScriptBinding.group.qml") - << Result { { Message { - QStringLiteral("Binding assigned to \"bogusProperty\", but no " - "property \"bogusProperty\" exists in the current element."), - 3, 10 } } }; + << Result{ { Message{ QStringLiteral("Property \"bogusProperty\" does not exist."), 3, + 10 } } }; QTest::newRow("BadScriptBindingOnAttachedType") << QStringLiteral("badScriptBinding.attached.qml") - << Result { { Message { - QStringLiteral("Binding assigned to \"bogusProperty\", but no " - "property \"bogusProperty\" exists in the current element."), - 5, 12 } } }; + << Result{ { Message{ QStringLiteral("Property \"bogusProperty\" does not exist."), 5, + 12 } } }; QTest::newRow("BadScriptBindingOnAttachedSignalHandler") << QStringLiteral("badScriptBinding.attachedSignalHandler.qml") << Result { { Message { @@ -900,7 +895,7 @@ expression: \${expr} \${expr} \\\${expr} \\\${expr}`)", << QStringLiteral("unresolvedAttachedType.qml") << Result { { Message { QStringLiteral( "unknown attached property scope UnresolvedAttachedType.") } }, - { Message { QStringLiteral("Property \"property\" does not exist") } } }; + { Message { QStringLiteral("Property \"property\" does not exist.") } } }; QTest::newRow("nestedInlineComponents") << QStringLiteral("nestedInlineComponents.qml") << Result { { Message { @@ -950,9 +945,7 @@ expression: \${expr} \${expr} \\\${expr} \\\${expr}`)", "MenuItem is part of an inheritance cycle: MenuItem -> MenuItem") } } }; QTest::newRow("badGeneralizedGroup1") << QStringLiteral("badGeneralizedGroup1.qml") - << Result { { Message { QStringLiteral( - "Binding assigned to \"aaaa\", " - "but no property \"aaaa\" exists in the current element") } } }; + << Result{ { Message{ QStringLiteral("Property \"aaaa\" does not exist.") } } }; QTest::newRow("badGeneralizedGroup2") << QStringLiteral("badGeneralizedGroup2.qml") << Result { { Message { QStringLiteral("unknown grouped property scope aself") } } }; @@ -999,13 +992,9 @@ expression: \${expr} \${expr} \\\${expr} \\\${expr}`)", "no matching signal found for handler \"onWannabeSignal\"") } } }; QTest::newRow("didYouMean(binding)") << QStringLiteral("didYouMeanBinding.qml") - << Result { - { Message { QStringLiteral( - "Binding assigned to \"witdh\", but no property \"witdh\" exists in " - "the current element.") } }, - {}, - { Message { QStringLiteral("width") } } - }; + << Result{ { Message{ QStringLiteral("Property \"witdh\" does not exist.") } }, + {}, + { Message{ QStringLiteral("width") } } }; QTest::newRow("didYouMean(unqualified)") << QStringLiteral("didYouMeanUnqualified.qml") << Result { { Message { QStringLiteral("Unqualified access") } }, |
