aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2023-08-08 17:36:12 +0200
committerSami Shalayel <sami.shalayel@qt.io>2023-08-17 13:55:33 +0200
commit055859f93f6f0090a456c813f5b4931b25172aea (patch)
treec4475470f698ca3d65ab520fb0372ea5c1023a3a /src/qml/parser
parentcb8c2cdc5dfee2ba7da045e30ee6623724156b15 (diff)
qmlls: highlight names inside of inline component definitions
Instead of highlighting the base type of the inline component, highlight the name of the inline component, e.g. highlight 'C' in ``` component C: Item {} ``` instead of 'Item'. This requires changing QQmlLSUtils::findTypeDefinitionOf's signature to return a QQmlLSUtilsLocation instead of a DomItem. QQmlLSUtils::findDefinitionOf already returns a QQmlLSUtilsLocation. Also, the QQmlJS::UiInlineComponent parser class did not know about its identifier token. Add it, so the corresponding DomItem knows where its identifier lies. Fix the tests that finds definitions of inline components by removing the QEXPECT_FAIL and adjusting the column numbers. Also simplify the test by removing the "name" that is not related to the actual test. Fix other failing tests by setting their QEXPECT_FAIL at the right place (they fail earlier because of this change, when looking for the type definition of int for example). Change-Id: I00b2f73c2357b7e7fb74619bbc7b948e67619420 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/parser')
-rw-r--r--src/qml/parser/qqmljs.g1
-rw-r--r--src/qml/parser/qqmljsast_p.h1
2 files changed, 2 insertions, 0 deletions
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g
index 9a10015cbc..902e8290b4 100644
--- a/src/qml/parser/qqmljs.g
+++ b/src/qml/parser/qqmljs.g
@@ -1494,6 +1494,7 @@ UiObjectMember: T_COMPONENT T_IDENTIFIER T_COLON UiObjectDefinition;
}
auto inlineComponent = new (pool) AST::UiInlineComponent(stringRef(2), sym(4).UiObjectDefinition);
inlineComponent->componentToken = loc(1);
+ inlineComponent->identifierToken = loc(2);
sym(1).Node = inlineComponent;
} break;
./
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index 5f718c4c62..494fca9e28 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -3538,6 +3538,7 @@ public:
QStringView name;
UiObjectDefinition* component;
SourceLocation componentToken;
+ SourceLocation identifierToken;
};
class QML_PARSER_EXPORT UiSourceElement: public UiObjectMember