From c2535eb7f843d7d6adc6497097e8fa537ce3eba4 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 16 Aug 2019 16:15:22 +0200 Subject: [PATCH] qmllint: Take prefix into account when inserting names Change-Id: I2c13e8fc173e5e155d07a1bbf8547df65605ba10 Reviewed-by: Simon Hausmann --- tests/auto/qml/qmllint/data/ImportWithPrefix.qml | 5 +++++ tests/auto/qml/qmllint/tst_qmllint.cpp | 7 +++++++ tools/qmllint/findunqualified.cpp | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qml/qmllint/data/ImportWithPrefix.qml diff --git a/tests/auto/qml/qmllint/data/ImportWithPrefix.qml b/tests/auto/qml/qmllint/data/ImportWithPrefix.qml new file mode 100644 index 0000000000..6d070da21a --- /dev/null +++ b/tests/auto/qml/qmllint/data/ImportWithPrefix.qml @@ -0,0 +1,5 @@ +import "." as MyStuff + +MyStuff.Simple { + property bool something: contains(Qt.point(12, 34)) +} diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index cfcc6bf246..2d225aebd3 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -47,6 +47,7 @@ private Q_SLOTS: void testUnmatchedSignalHandler(); void uiQml(); void methodInScope(); + void importWithPrefix(); private: QString runQmllint(const QString &fileToLint, bool shouldSucceed); @@ -150,6 +151,12 @@ void TestQmllint::methodInScope() QVERIFY(output.isEmpty()); } +void TestQmllint::importWithPrefix() +{ + const QString output = runQmllint("ImportWithPrefix.qml", true); + QVERIFY(output.isEmpty()); +} + void TestQmllint::test() { QFETCH(QString, filename); diff --git a/tools/qmllint/findunqualified.cpp b/tools/qmllint/findunqualified.cpp index 32eda12052..4404ddf49a 100644 --- a/tools/qmllint/findunqualified.cpp +++ b/tools/qmllint/findunqualified.cpp @@ -317,7 +317,7 @@ void FindUnqualifiedIDVisitor::importDirectory(const QString &directory, const Q while (it.hasNext()) { LanguageUtils::FakeMetaObject *fake = localQmlFile2FakeMetaObject(it.next()); m_exportedName2MetaObject.insert( - fake->className(), + prefix + fake->className(), QSharedPointer(fake)); } }