qmllint: Consider attached properties
We cannot figure out who attached properties to what, therefore we consider any uppercase property we cannot locate as a potential attached property. Change-Id: I60508b9e4e038a51b87c56edf0796ac492aa3fa0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
01b865411d
commit
d31bb553b5
|
@ -0,0 +1,6 @@
|
||||||
|
import QtQml 2.0
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
id: self
|
||||||
|
property var foo: self.Component.completed
|
||||||
|
}
|
|
@ -191,6 +191,7 @@ void TestQmllint::cleanQmlCode_data()
|
||||||
QTest::newRow("goodAlias") << QStringLiteral("goodAlias.qml");
|
QTest::newRow("goodAlias") << QStringLiteral("goodAlias.qml");
|
||||||
QTest::newRow("goodParent") << QStringLiteral("goodParent.qml");
|
QTest::newRow("goodParent") << QStringLiteral("goodParent.qml");
|
||||||
QTest::newRow("goodTypeAssertion") << QStringLiteral("goodTypeAssertion.qml");
|
QTest::newRow("goodTypeAssertion") << QStringLiteral("goodTypeAssertion.qml");
|
||||||
|
QTest::newRow("AttachedProps") << QStringLiteral("AttachedProps.qml");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQmllint::cleanQmlCode()
|
void TestQmllint::cleanQmlCode()
|
||||||
|
|
|
@ -230,6 +230,16 @@ bool ScopeTree::checkMemberAccess(
|
||||||
type = types.value(type->superclassName());
|
type = types.value(type->superclassName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (access->m_name.front().isUpper() && scope->scopeType() == ScopeType::QMLScope) {
|
||||||
|
// may be an attached type
|
||||||
|
const auto it = types.find(access->m_name);
|
||||||
|
if (it != types.end() && !(*it)->attachedTypeName().isEmpty()) {
|
||||||
|
const auto attached = types.find((*it)->attachedTypeName());
|
||||||
|
if (attached != types.end())
|
||||||
|
return checkMemberAccess(code, access.get(), attached->get(), types, colorOut);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
colorOut.write("Warning: ", Warning);
|
colorOut.write("Warning: ", Warning);
|
||||||
colorOut.write(QString::fromLatin1(
|
colorOut.write(QString::fromLatin1(
|
||||||
"Property \"%1\" not found on type \"%2\" at %3:%4\n")
|
"Property \"%1\" not found on type \"%2\" at %3:%4\n")
|
||||||
|
|
Loading…
Reference in New Issue