aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2024-04-15 17:40:14 +0200
committerSami Shalayel <sami.shalayel@qt.io>2024-04-17 21:43:12 +0200
commit1bcb8587ab6b7068d1af8897804820853e7bc9d0 (patch)
treec718245ee58d1190c445f2333b4ba3027b4fc36d /tests
parent5337821aaf6b82cf3c1c5c2f8b320357fe2d5738 (diff)
qmlls: assume bound identifiers in completions
Add a new option flag to QmlTypeResolver to allow resolving id's while assuming that Components are bounds (even if they are currently not bound). This allows qmlls to provide completions even if the user forgot to set the pragma, instead of not suggesting anything at all after "someIdThatIsOnlyVisibleWhenComponentsAreBound.". Pick-to: 6.7 Fixes: QTBUG-124459 Change-Id: I658c2f5d678f94f99a94a9e06aaf6d19db9b1147 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qmlls/utils/data/completions/boundComponents.qml21
-rw-r--r--tests/auto/qmlls/utils/tst_qmlls_utils.cpp10
2 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/qmlls/utils/data/completions/boundComponents.qml b/tests/auto/qmlls/utils/data/completions/boundComponents.qml
new file mode 100644
index 0000000000..343e7a3c7b
--- /dev/null
+++ b/tests/auto/qmlls/utils/data/completions/boundComponents.qml
@@ -0,0 +1,21 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+import QtQuick
+
+Item {
+ id: rootId
+ property int inRoot
+
+ DelegateModel {
+ delegate: Item {
+ id: childId
+
+ property int myInt: rootId.inRoot
+ property int inChild
+
+ }
+ }
+
+ property int myInt: childId.inChild
+}
diff --git a/tests/auto/qmlls/utils/tst_qmlls_utils.cpp b/tests/auto/qmlls/utils/tst_qmlls_utils.cpp
index 92b80e7fdd..c8808e2d7c 100644
--- a/tests/auto/qmlls/utils/tst_qmlls_utils.cpp
+++ b/tests/auto/qmlls/utils/tst_qmlls_utils.cpp
@@ -3776,6 +3776,16 @@ void tst_qmlls_utils::completions_data()
<< ExpectedCompletions({})
<< QStringList{ u"QtQuick"_s, attachedTypeName, u"Rectangle"_s, forStatementCompletion,
u"x"_s };
+
+ QTest::newRow("assumeBoundComponentsIdFromParent")
+ << testFile("completions/boundComponents.qml") << 14 << 33
+ << ExpectedCompletions{ { u"rootId"_s, CompletionItemKind::Value } }
+ << QStringList{ u"inRoot"_s };
+
+ QTest::newRow("assumeBoundComponentsPropertyFromParent")
+ << testFile("completions/boundComponents.qml") << 14 << 40
+ << ExpectedCompletions{ { u"inRoot"_s, CompletionItemKind::Property } }
+ << QStringList{ u"root"_s };
}
void tst_qmlls_utils::completions()