aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2023-11-10 16:47:37 +0100
committerSami Shalayel <sami.shalayel@qt.io>2023-11-16 10:42:58 +0100
commit72c29e18d832af78ff043d09744404cba02efa60 (patch)
tree5dbb21ad6836ed828b70da7d7f4d98af449c6e78 /src/qml/parser
parentfdb1d03ff8dc85e8e4bf2d3f8fcfe25551a90542 (diff)
qmlls: fix completions on qualified identifiers
Typing `someProperty.x` would propose methods and properties that do not exist in someProperty in qmlls. Add the operator sourcelocation inside the BinaryExpression so that qmlls can distinguish if currently working on the left or right hand side of the binary expression. Also fix the resolveExpressionType call to not use the last bit of the qualified identifier: in `console.l`, only resolve up to `console` and ignore the `l` bit that might not have been spelled out completely. Previously, the resolution step would fail because of the `l` and no completion would get generated. Task-number: QTBUG-117445 Change-Id: I5929d7153d5b9f5104efd1b88d24d76e0d7a514a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Diffstat (limited to 'src/qml/parser')
-rw-r--r--src/qml/parser/qqmljs.g3
-rw-r--r--src/qml/parser/qqmljsast_p.h1
2 files changed, 4 insertions, 0 deletions
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g
index 3c32fe2ad0..0b7a38c4a5 100644
--- a/src/qml/parser/qqmljs.g
+++ b/src/qml/parser/qqmljs.g
@@ -465,11 +465,13 @@ AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
{
QVarLengthArray<QStringView, 4> nameIds;
QVarLengthArray<SourceLocation, 4> locations;
+ QVarLengthArray<SourceLocation, 4> dotLocations;
AST::ExpressionNode *it = expr;
while (AST::FieldMemberExpression *m = AST::cast<AST::FieldMemberExpression *>(it)) {
nameIds.append(m->name);
locations.append(m->identifierToken);
+ dotLocations.append(m->dotToken);
it = m->base;
}
@@ -481,6 +483,7 @@ AST::UiQualifiedId *Parser::reparseAsQualifiedId(AST::ExpressionNode *expr)
for (int i = nameIds.size() - 1; i != -1; --i) {
currentId = new (pool) AST::UiQualifiedId(currentId, nameIds[i]);
currentId->identifierToken = locations[i];
+ currentId->dotToken = dotLocations[i];
}
return currentId->finish();
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index 8e1724af4b..73b5c5cd5e 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -354,6 +354,7 @@ public:
UiQualifiedId *next;
QStringView name;
SourceLocation identifierToken;
+ SourceLocation dotToken;
};
class QML_PARSER_EXPORT Type: public Node