aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/qml/qmllint/data/EnumAccess1.qml9
-rw-r--r--tests/auto/qml/qmllint/data/EnumAccess2.qml9
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp2
-rw-r--r--tools/qmllint/checkidentifiers.cpp6
-rw-r--r--tools/qmllint/importedmembersvisitor.cpp12
-rw-r--r--tools/qmllint/importedmembersvisitor.h1
6 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qml/qmllint/data/EnumAccess1.qml b/tests/auto/qml/qmllint/data/EnumAccess1.qml
new file mode 100644
index 0000000000..8392930b65
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/EnumAccess1.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.0
+
+Item {
+ enum Status {
+ On, Off
+ }
+
+ property int status: EnumAccess1.Off
+}
diff --git a/tests/auto/qml/qmllint/data/EnumAccess2.qml b/tests/auto/qml/qmllint/data/EnumAccess2.qml
new file mode 100644
index 0000000000..9aa6e1bac8
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/EnumAccess2.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.0
+
+Item {
+ enum Status {
+ On, Off
+ }
+
+ property int status: EnumAccess1.Status.Off
+}
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index bdb5cf37c0..2c7998b571 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -220,6 +220,8 @@ void TestQmllint::cleanQmlCode_data()
QTest::newRow("unknownBuiltinFont") << QStringLiteral("ButtonLoader.qml");
QTest::newRow("confusingImport") << QStringLiteral("Dialog.qml");
QTest::newRow("qualifiedAttached") << QStringLiteral("Drawer.qml");
+ QTest::newRow("EnumAccess1") << QStringLiteral("EnumAccess1.qml");
+ QTest::newRow("EnumAccess2") << QStringLiteral("EnumAccess2.qml");
}
void TestQmllint::cleanQmlCode()
diff --git a/tools/qmllint/checkidentifiers.cpp b/tools/qmllint/checkidentifiers.cpp
index 32c2fa4d79..e1593182ab 100644
--- a/tools/qmllint/checkidentifiers.cpp
+++ b/tools/qmllint/checkidentifiers.cpp
@@ -173,6 +173,12 @@ bool CheckIdentifiers::checkMemberAccess(const QVector<ScopeTree::FieldMember> &
const auto enums = scope->enums();
for (const auto &enumerator : enums) {
+ if (enumerator.name() == access.m_name) {
+ detectedRestrictiveKind = QLatin1String("enum");
+ detectedRestrictiveName = access.m_name;
+ expectedNext.append(enumerator.keys());
+ break;
+ }
for (const QString &key : enumerator.keys()) {
if (access.m_name == key) {
detectedRestrictiveKind = QLatin1String("enum");
diff --git a/tools/qmllint/importedmembersvisitor.cpp b/tools/qmllint/importedmembersvisitor.cpp
index bf3787d489..7bc58dee24 100644
--- a/tools/qmllint/importedmembersvisitor.cpp
+++ b/tools/qmllint/importedmembersvisitor.cpp
@@ -51,6 +51,9 @@ ScopeTree::Ptr ImportedMembersVisitor::result(const QString &scopeName) const
for (const auto &method : m_rootObject->methods())
result->addMethod(method);
+ for (const auto &enumerator : m_rootObject->enums())
+ result->addEnum(enumerator);
+
return result;
}
@@ -151,6 +154,15 @@ bool ImportedMembersVisitor::visit(UiScriptBinding *scriptBinding)
return true;
}
+bool ImportedMembersVisitor::visit(QQmlJS::AST::UiEnumDeclaration *uied)
+{
+ MetaEnum qmlEnum(uied->name.toString());
+ for (const auto *member = uied->members; member; member = member->next)
+ qmlEnum.addKey(member->member.toString());
+ currentObject()->addEnum(qmlEnum);
+ return true;
+}
+
void ImportedMembersVisitor::throwRecursionDepthError()
{
m_colorOut->write(QStringLiteral("Error"), Error);
diff --git a/tools/qmllint/importedmembersvisitor.h b/tools/qmllint/importedmembersvisitor.h
index 045ba00420..023e58df73 100644
--- a/tools/qmllint/importedmembersvisitor.h
+++ b/tools/qmllint/importedmembersvisitor.h
@@ -59,6 +59,7 @@ private:
bool visit(QQmlJS::AST::UiPublicMember *) override;
bool visit(QQmlJS::AST::UiSourceElement *) override;
bool visit(QQmlJS::AST::UiScriptBinding *) override;
+ bool visit(QQmlJS::AST::UiEnumDeclaration *uied) override;
void throwRecursionDepthError() override;
ScopeTree::Ptr currentObject() const { return m_currentObjects.back(); }