diff options
author | Sami Shalayel <sami.shalayel@qt.io> | 2023-06-02 09:41:14 +0200 |
---|---|---|
committer | Sami Shalayel <sami.shalayel@qt.io> | 2023-06-05 15:27:52 +0200 |
commit | 6d58a20fbbb2be7afa5a07963c786335df178103 (patch) | |
tree | 9298d0d49ff2b0d477e805572b903739d1216780 /src/qml/parser/qqmljsast.cpp | |
parent | 4fdaf22a54343f3f1185362db112cc44fd7d34b6 (diff) |
qmlls: find definitions of function parameters
Function parameter definitions in the QQmlJSScope were lacking their
source location, such that asking the definition of a parameter always
returned the location of the first parameter.
Fix it by writing the proper Location in the QQmlJSScope. This requires
adding the location information to BoundName(s).
Also added some tests.
Task-number: QTBUG-111409
Change-Id: Ieb6155f120ca24e899af4b3824cab561788d008b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Diffstat (limited to 'src/qml/parser/qqmljsast.cpp')
-rw-r--r-- | src/qml/parser/qqmljsast.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp index e3ed876473..347a2945f3 100644 --- a/src/qml/parser/qqmljsast.cpp +++ b/src/qml/parser/qqmljsast.cpp @@ -3,6 +3,7 @@ #include <QString> #include <QLocale> +#include "common/qqmljssourcelocation_p.h" #include "qqmljsast_p.h" #include "qqmljsastvisitor_p.h" @@ -1015,13 +1016,9 @@ BoundNames FormalParameterList::formals() const // change the name of the earlier argument to enforce the lookup semantics from the spec formals[duplicateIndex].id += QLatin1String("#") + QString::number(i); } - formals += { - name, - it->element->typeAnnotation, - it->element->isInjectedSignalParameter - ? BoundName::Injected - : BoundName::Declared - }; + formals += { name, it->element->firstSourceLocation(), it->element->typeAnnotation, + it->element->isInjectedSignalParameter ? BoundName::Injected + : BoundName::Declared }; } ++i; } @@ -1423,8 +1420,8 @@ void PatternElement::boundNames(BoundNames *names) else if (PatternPropertyList *p = propertyList()) p->boundNames(names); } else { - names->append({bindingIdentifier.toString(), typeAnnotation, - isInjectedSignalParameter ? BoundName::Injected : BoundName::Declared}); + names->append({ bindingIdentifier.toString(), firstSourceLocation(), typeAnnotation, + isInjectedSignalParameter ? BoundName::Injected : BoundName::Declared }); } } |