diff options
-rw-r--r-- | tests/auto/qml/qmllint/data/Dialog.qml | 10 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/data/Text.qml | 6 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 1 | ||||
-rw-r--r-- | tools/qmllint/findunqualified.cpp | 9 | ||||
-rw-r--r-- | tools/qmllint/importedmembersvisitor.cpp | 11 |
5 files changed, 28 insertions, 9 deletions
diff --git a/tests/auto/qml/qmllint/data/Dialog.qml b/tests/auto/qml/qmllint/data/Dialog.qml new file mode 100644 index 0000000000..bde8eae18b --- /dev/null +++ b/tests/auto/qml/qmllint/data/Dialog.qml @@ -0,0 +1,10 @@ +import QtQuick 2.12 + +Item { + id: control + property Text header + header: Text { + font.bold: true + padding: 12 + } +} diff --git a/tests/auto/qml/qmllint/data/Text.qml b/tests/auto/qml/qmllint/data/Text.qml new file mode 100644 index 0000000000..130578d1e3 --- /dev/null +++ b/tests/auto/qml/qmllint/data/Text.qml @@ -0,0 +1,6 @@ +import QtQuick 2.12 as T + +T.Text { + id: control + text: "'ello" +} diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index f1930d3caf..3e5237aebe 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -193,6 +193,7 @@ void TestQmllint::cleanQmlCode_data() QTest::newRow("goodTypeAssertion") << QStringLiteral("goodTypeAssertion.qml"); QTest::newRow("AttachedProps") << QStringLiteral("AttachedProps.qml"); QTest::newRow("unknownBuiltinFont") << QStringLiteral("ButtonLoader.qml"); + QTest::newRow("confusingImport") << QStringLiteral("Dialog.qml"); } void TestQmllint::cleanQmlCode() diff --git a/tools/qmllint/findunqualified.cpp b/tools/qmllint/findunqualified.cpp index ae23d6d5f8..5bb9b62529 100644 --- a/tools/qmllint/findunqualified.cpp +++ b/tools/qmllint/findunqualified.cpp @@ -43,6 +43,7 @@ static const QString prefixedName(const QString &prefix, const QString &name) { + Q_ASSERT(!prefix.endsWith('.')); return prefix.isEmpty() ? name : (prefix + QLatin1Char('.') + name); } @@ -88,11 +89,9 @@ void FindUnqualifiedIDVisitor::parseHeaders(QQmlJS::AST::UiHeaderItemList *heade uri = uri->next; } path.chop(1); - QString prefix = QLatin1String(""); - if (import->asToken.isValid()) { - prefix += import->importId + QLatin1Char('.'); - } - importHelper(path, prefix, import->version->majorVersion, + importHelper(path, + import->asToken.isValid() ? import->importId.toString() : QString(), + import->version->majorVersion, import->version->minorVersion); } } diff --git a/tools/qmllint/importedmembersvisitor.cpp b/tools/qmllint/importedmembersvisitor.cpp index 676903d135..c5214f2bb9 100644 --- a/tools/qmllint/importedmembersvisitor.cpp +++ b/tools/qmllint/importedmembersvisitor.cpp @@ -57,10 +57,13 @@ ScopeTree *ImportedMembersVisitor::result(const QString &scopeName) const bool ImportedMembersVisitor::visit(UiObjectDefinition *definition) { ScopeTree::Ptr scope(new ScopeTree(ScopeType::QMLScope)); - auto qualifiedId = definition->qualifiedTypeNameId; - while (qualifiedId && qualifiedId->next) - qualifiedId = qualifiedId->next; - scope->setSuperclassName(qualifiedId->name.toString()); + QString superType; + for (auto segment = definition->qualifiedTypeNameId; segment; segment = segment->next) { + if (!superType.isEmpty()) + superType.append('.'); + superType.append(segment->name.toString()); + } + scope->setSuperclassName(superType); if (!m_rootObject) m_rootObject = scope; m_currentObjects.append(scope); |