diff options
author | Fawzi Mohamed <fawzi.mohamed@qt.io> | 2022-08-11 14:42:03 +0200 |
---|---|---|
committer | Fawzi Mohamed <fawzi.mohamed@qt.io> | 2022-08-30 11:11:14 +0200 |
commit | 071255fd130abc40798eeda4b4657ee6a111261b (patch) | |
tree | dc1bd43f7c726ff715830854add8b17fb25c9da6 /tests | |
parent | c0ec3c15612d787c8cdeadf3603a5fb9e3058065 (diff) |
qmlls: fix import as resolution
Import as resolution (i.e. finding a type that was imported with an import as)
was broken in two ways: the shortcut looking for types did look only to types
imported without as, and the normal lookup for symbols declared the ImportScope
as visited (to avoid loops) too early in one case and would skip it.
This was visible in qmlls completions of Controls.
Change-Id: Ifc1e777973ddc251bd0685290e8d28bfb025f269
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 8e6dcc04fc1073b043eba6792472c2d7cd3d5993)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qmldom/domdata/domitem/test1.qml | 3 | ||||
-rw-r--r-- | tests/auto/qmldom/domitem/tst_qmldomitem.h | 5 | ||||
-rw-r--r-- | tests/auto/qmlls/completions/data/completions/Yyy.qml | 5 | ||||
-rw-r--r-- | tests/auto/qmlls/completions/tst_qmllscompletions.cpp | 21 |
4 files changed, 26 insertions, 8 deletions
diff --git a/tests/auto/qmldom/domdata/domitem/test1.qml b/tests/auto/qmldom/domdata/domitem/test1.qml index 36c1284978..4a28129ee9 100644 --- a/tests/auto/qmldom/domdata/domitem/test1.qml +++ b/tests/auto/qmldom/domdata/domitem/test1.qml @@ -1,4 +1,5 @@ -import QtQuick 2.15 +import QtQuick +import QtQuick as QQ Window { visible: true diff --git a/tests/auto/qmldom/domitem/tst_qmldomitem.h b/tests/auto/qmldom/domitem/tst_qmldomitem.h index fab95c4e1e..0286672f54 100644 --- a/tests/auto/qmldom/domitem/tst_qmldomitem.h +++ b/tests/auto/qmldom/domitem/tst_qmldomitem.h @@ -517,10 +517,15 @@ private slots: obj1.lookup(u"Rectangle"_s, LookupType::Type, LookupOption::Normal); QList<DomItem> rect2 = obj1.lookup(u"Rectangle"_s, LookupType::Symbol, LookupOption::Normal); + QList<DomItem> rectAs = + obj1.lookup(u"QQ.Rectangle"_s, LookupType::Symbol, LookupOption::Normal); + QVERIFY(rect.length() == 1); QVERIFY(rect2.length() == 1); + QVERIFY(rectAs.length() == 1); QCOMPARE(rect.first().internalKind(), DomType::Export); QCOMPARE(rect.first(), rect2.first()); + QCOMPARE(rect.first(), rectAs.first()); DomItem rect3 = rect.first().proceedToScope(); QCOMPARE(rect3.internalKind(), DomType::QmlObject); QList<DomItem> rects; diff --git a/tests/auto/qmlls/completions/data/completions/Yyy.qml b/tests/auto/qmlls/completions/data/completions/Yyy.qml index b07fb9822e..dc1125c6ad 100644 --- a/tests/auto/qmlls/completions/data/completions/Yyy.qml +++ b/tests/auto/qmlls/completions/data/completions/Yyy.qml @@ -1,4 +1,5 @@ import QtQuick 2.0 +import QtQuick as QQ Zzz { id: root @@ -13,4 +14,8 @@ Zzz { function lala() {} property Rectangle foo: Rectangle{ height: 200 } + + QQ.Rectangle { + color:"red" + } } diff --git a/tests/auto/qmlls/completions/tst_qmllscompletions.cpp b/tests/auto/qmlls/completions/tst_qmllscompletions.cpp index e10b400887..03746589dc 100644 --- a/tests/auto/qmlls/completions/tst_qmllscompletions.cpp +++ b/tests/auto/qmlls/completions/tst_qmllscompletions.cpp @@ -128,7 +128,7 @@ void tst_QmllsCompletions::completions_data() QByteArray uri = testFileUrl("completions/Yyy.qml").toString().toUtf8(); - QTest::newRow("objEmptyLine") << uri << 7 << 0 + QTest::newRow("objEmptyLine") << uri << 8 << 0 << ExpectedCompletions({ { u"Rectangle"_s, CompletionItemKind::Class }, { u"property"_s, CompletionItemKind::Keyword }, @@ -137,7 +137,7 @@ void tst_QmllsCompletions::completions_data() }) << QStringList({ u"QtQuick"_s, u"vector4d"_s }); - QTest::newRow("inBindingLabel") << uri << 4 << 9 + QTest::newRow("inBindingLabel") << uri << 5 << 9 << ExpectedCompletions({ { u"Rectangle"_s, CompletionItemKind::Class }, { u"property"_s, CompletionItemKind::Keyword }, @@ -145,7 +145,7 @@ void tst_QmllsCompletions::completions_data() }) << QStringList({ u"QtQuick"_s, u"vector4d"_s }); - QTest::newRow("afterBinding") << uri << 4 << 10 + QTest::newRow("afterBinding") << uri << 5 << 10 << ExpectedCompletions({ { u"Rectangle"_s, CompletionItemKind::Field }, { u"width"_s, CompletionItemKind::Field }, @@ -154,7 +154,7 @@ void tst_QmllsCompletions::completions_data() << QStringList({ u"QtQuick"_s, u"property"_s }); // suppress? - QTest::newRow("afterId") << uri << 3 << 7 + QTest::newRow("afterId") << uri << 4 << 7 << ExpectedCompletions({ { u"import"_s, CompletionItemKind::Keyword }, }) @@ -197,7 +197,7 @@ void tst_QmllsCompletions::completions_data() // }) // << QStringList({ u"as"_s, u"Rectangle"_s, u"import"_s, u"vector4d"_s, u"width"_s }); - QTest::newRow("inScript") << uri << 5 << 14 + QTest::newRow("inScript") << uri << 6 << 14 << ExpectedCompletions({ { u"Rectangle"_s, CompletionItemKind::Field }, { u"vector4d"_s, CompletionItemKind::Field }, @@ -206,19 +206,26 @@ void tst_QmllsCompletions::completions_data() }) << QStringList({ u"import"_s }); - QTest::newRow("expandBase1") << uri << 8 << 23 + QTest::newRow("expandBase1") << uri << 9 << 23 << ExpectedCompletions({ { u"width"_s, CompletionItemKind::Field }, { u"foo"_s, CompletionItemKind::Field }, }) << QStringList({ u"import"_s, u"Rectangle"_s }); - QTest::newRow("expandBase2") << uri << 9 << 29 + QTest::newRow("expandBase2") << uri << 10 << 29 << ExpectedCompletions({ { u"width"_s, CompletionItemKind::Field }, { u"color"_s, CompletionItemKind::Field }, }) << QStringList({ u"foo"_s, u"import"_s, u"Rectangle"_s }); + + QTest::newRow("asCompletions") + << uri << 17 << 8 + << ExpectedCompletions({ + { u"Rectangle"_s, CompletionItemKind::Field }, + }) + << QStringList({ u"foo"_s, u"import"_s, u"lala()"_s, u"width"_s }); } void tst_QmllsCompletions::checkCompletions(QByteArray uri, int lineNr, int character, |