qmllint: Warn about partially resolved properties
Partially resolved property types will result in properties not being found as well and thus we should warn about them in the same manner. Task-number: QTBUG-95740 Change-Id: I24bc2a7dfe03b25145618d5314494a49cb59eba3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
This commit is contained in:
parent
eeaa0e8a64
commit
cc3e0a5684
|
@ -574,12 +574,21 @@ void QQmlJSTypePropagator::propagatePropertyLookup(const QString &propertyName)
|
|||
|
||||
auto baseType = m_typeResolver->containedType(m_state.accumulatorIn);
|
||||
// Warn separately when a property is only not found because of a missing type
|
||||
if (auto property = baseType->property(propertyName);
|
||||
property.isValid() && property.type().isNull()) {
|
||||
if (auto property = baseType->property(propertyName); property.isValid()) {
|
||||
|
||||
QString errorType;
|
||||
if (property.type().isNull())
|
||||
errorType = u"found"_qs;
|
||||
else if (!property.type()->isFullyResolved())
|
||||
errorType = u"fully resolved"_qs;
|
||||
|
||||
Q_ASSERT(!errorType.isEmpty());
|
||||
|
||||
m_logger->logWarning(
|
||||
u"Type \"%1\" of property \"%2\" not found. This is likely due to a missing dependency entry or a type not being exposed declaratively."_qs
|
||||
.arg(property.typeName(), propertyName),
|
||||
u"Type \"%1\" of property \"%2\" not %3. This is likely due to a missing dependency entry or a type not being exposed declaratively."_qs
|
||||
.arg(property.typeName(), propertyName, errorType),
|
||||
Log_Type, getCurrentSourceLocation());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
import QtQuick.tooling 1.2
|
||||
Module {
|
||||
dependencies: []
|
||||
Component {
|
||||
name: "CustomPalette"
|
||||
prototype: "QPalette"
|
||||
}
|
||||
|
||||
Component {
|
||||
name: "SomethingEntirelyStrange"
|
||||
prototype: "QObject"
|
||||
|
@ -14,6 +19,7 @@ Module {
|
|||
}
|
||||
}
|
||||
Property { name: "palette"; type: "QPalette" }
|
||||
Property { name: "palette2"; type: "CustomPalette" }
|
||||
}
|
||||
Component {
|
||||
name: "Frame"
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
import Things 1.0
|
||||
|
||||
SomethingEntirelyStrange {
|
||||
id: self
|
||||
property var a: self.palette2.weDontKnowIt
|
||||
}
|
|
@ -368,6 +368,10 @@ void TestQmllint::dirtyQmlCode_data()
|
|||
<< QStringLiteral("incompleteQmltypes.qml")
|
||||
<< QString("Warning: %1:5:26: Type \"QPalette\" of property \"palette\" not found")
|
||||
<< QString() << false;
|
||||
QTest::newRow("incompleteQmltypes2") << QStringLiteral("incompleteQmltypes2.qml")
|
||||
<< QString("Warning: %1:5:26: Type \"CustomPalette\" of "
|
||||
"property \"palette2\" not fully resolved")
|
||||
<< QString() << false;
|
||||
QTest::newRow("inheritanceCylce")
|
||||
<< QStringLiteral("Cycle1.qml")
|
||||
<< QString("Warning: %1: Cycle2 is part of an inheritance cycle: Cycle2 -> Cycle3 -> Cycle1 -> Cycle2")
|
||||
|
|
Loading…
Reference in New Issue