diff options
author | Sami Shalayel <sami.shalayel@qt.io> | 2023-09-06 17:07:21 +0200 |
---|---|---|
committer | Sami Shalayel <sami.shalayel@qt.io> | 2023-09-11 12:28:32 +0000 |
commit | 640ff3d8125264e25bd1826529b9a57cdddf2205 (patch) | |
tree | 6a0b34771816325b743b851254ff67bc77651a98 /src/qml/parser | |
parent | 38c941bc55ee3356c5fe7c446f7698c76e22a3fb (diff) |
FormalParameterList: prepare for qmlformat
Remove useless arg#0 bindingIdentifier from FormalParameterList. They
are used nowhere, are not tested and are not even set correctly:
FormalParameterList::finish() sets next to nullptr before its forloop
that goes from this to this->next (that was freshly set to nullptr three
lines above)...
Instead of setting bindingIdentifier to arg#0 when its empty and testing
for arg#, just test for bindingIdentifier being empty. That saves some
trouble in qmlformat because you dont have to care about the position
that the current method parameter has.
Apropos position of the current parameter: qmlformat needs some context
when doing its reformatting test, to avoid reparsing code in completely
wrong contexts. Add missing preCode and postCode to MethodParameter to
provide an artificial context for qmlformat, so it knows that it is
working on a MethodParameter, and also teach qmlformat how to
get the FormalParameter out of the artificial context, by extracting it
from the FormalParameterList.
Pick-to: 6.6 6.5
Change-Id: I2bc82f65d95c3cd09ad846c60dd7561ac03efad3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Diffstat (limited to 'src/qml/parser')
-rw-r--r-- | src/qml/parser/qqmljsast.cpp | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp index 347a2945f3..76448f6853 100644 --- a/src/qml/parser/qqmljsast.cpp +++ b/src/qml/parser/qqmljsast.cpp @@ -1046,17 +1046,10 @@ void FormalParameterList::accept0(BaseVisitor *visitor) } } -FormalParameterList *FormalParameterList::finish(QQmlJS::MemoryPool *pool) +FormalParameterList *FormalParameterList::finish(QQmlJS::MemoryPool *) { FormalParameterList *front = next; next = nullptr; - - int i = 0; - for (const FormalParameterList *it = this; it; it = it->next) { - if (it->element && it->element->bindingIdentifier.isEmpty()) - it->element->bindingIdentifier = pool->newString(QLatin1String("arg#") + QString::number(i)); - ++i; - } return front; } |