aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2023-09-27 09:07:33 +0200
committerSami Shalayel <sami.shalayel@qt.io>2023-10-12 17:38:31 +0200
commit4d5ef7be53e3394ce26f5046c91362d0b7c4f31a (patch)
tree1ad12c6322c3f92c16170bf5584c8e9a19441096 /src/qml/parser
parent21e5f0ea63ec7a20d40ba125d0bd479675bf5766 (diff)
qmlls: do not autocomplete property definition name
Make QQmlLSUtils::itemsFromTextLocation smarter: it differentiates now between property definitions and bindings. Example: For this property ``` property var somePropertyDef: Item { property var propertyDef: 42; } ``` The ranges of the filelocations are as follows: somePropertyDef FileLocations range: |------------------------------------------------------------------| propertyDef FileLocations range: |-----------------------------| binding FileLocations range: |----------------| The previous behavior of QQmlLSUtils::itemsFromTextLocation could not distinguish between a binding being alone or a binding being in a property definition, and would return the binding. The new implementation recognizes when a binding is inside a property definition, and returns this propertydefinition if the current text position is before the ':'-token. It even can choose the right property definition when there are nested ones, like in the example above with somePropertyDef and propertyDef. This means that qmlls can now differentiate between being inside a property definition name and the binding of the property definition. This allows to suppress completions inside of property definition names. Completion inside the binding of a property definition are still handled by the code for normal bindings. Fixes: QTBUG-117440 Change-Id: If0592ccadd8b1e3e9efbf4952c8044c40854202b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/parser')
-rw-r--r--src/qml/parser/qqmljs.g2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g
index 849ec67c45..7b31bfa416 100644
--- a/src/qml/parser/qqmljs.g
+++ b/src/qml/parser/qqmljs.g
@@ -1382,6 +1382,7 @@ UiObjectMemberWithArray: UiPropertyAttributes T_IDENTIFIER T_LT UiPropertyType T
node->typeToken = loc(4);
node->identifierToken = loc(6);
node->semicolonToken = loc(7); // insert a fake ';' before ':'
+ node->colonToken = loc(7);
AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(6));
propertyName->identifierToken = loc(6);
@@ -1411,6 +1412,7 @@ UiObjectMemberExpressionStatementLookahead: UiPropertyAttributes UiPropertyType
node->typeToken = loc(2);
node->identifierToken = loc(3);
node->semicolonToken = loc(4); // insert a fake ';' before ':'
+ node->colonToken = loc(4);
AST::UiQualifiedId *propertyName = new (pool) AST::UiQualifiedId(stringRef(3));
propertyName->identifierToken = loc(3);