Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmldomreformatter.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include "qqmldomcomments_p.h"
6
7#include <QtQml/private/qqmljsast_p.h>
8#include <QtQml/private/qqmljsastvisitor_p.h>
9#include <QtQml/private/qqmljsengine_p.h>
10#include <QtQml/private/qqmljslexer_p.h>
11
12#include <QString>
13
14#include <algorithm>
15#include <limits>
16
18namespace QQmlJS {
19namespace Dom {
20
21using namespace AST;
22
24{
25 if (CommentedElement *c = comments->commentForNode(n)) {
26 c->writePre(lw);
27 postOps[n].append([c, this]() { c->writePost(lw); });
28 }
29 return true;
30}
32{
33 for (auto &op : postOps[n]) {
34 op();
35 }
36 postOps.remove(n);
37}
38
40{
41 int indent = lw.increaseIndent(1);
42 lw.ensureNewline();
43 accept(node);
44 lw.decreaseIndent(1, indent);
45}
46
47bool ScriptFormatter::acceptBlockOrIndented(Node *ast, bool finishWithSpaceOrNewline)
48{
49 if (cast<Block *>(ast)) {
50 out(" ");
51 accept(ast);
52 if (finishWithSpaceOrNewline)
53 out(" ");
54 return true;
55 } else {
56 if (finishWithSpaceOrNewline)
57 postOps[ast].append([this]() { this->newLine(); });
59 return false;
60 }
61}
62
64{
65 out(ast->thisToken);
66 return true;
67}
68
70{
71 out(ast->nullToken);
72 return true;
73}
75{
76 out(ast->trueToken);
77 return true;
78}
80{
81 out(ast->falseToken);
82 return true;
83}
84
86{
87 out(ast->identifierToken);
88 return true;
89}
91{
92 // correctly handle multiline literals
93 if (ast->literalToken.length == 0)
94 return true;
95 QStringView str = loc2Str(ast->literalToken);
96 if (lw.indentNextlines && str.contains(QLatin1Char('\n'))) {
97 out(str.mid(0, 1));
98 lw.indentNextlines = false;
99 out(str.mid(1));
100 lw.indentNextlines = true;
101 } else {
102 out(str);
103 }
104 return true;
105}
107{
108 out(ast->literalToken);
109 return true;
110}
112{
113 out(ast->literalToken);
114 return true;
115}
116
118{
119 out(ast->lbracketToken);
120 int baseIndent = lw.increaseIndent(1);
121 if (ast->elements) {
122 accept(ast->elements);
123 out(ast->commaToken);
124 auto lastElement = lastListElement(ast->elements);
125 if (lastElement->element && cast<ObjectPattern *>(lastElement->element->initializer)) {
126 newLine();
127 }
128 } else {
129 out(ast->commaToken);
130 }
131 lw.decreaseIndent(1, baseIndent);
132 out(ast->rbracketToken);
133 return false;
134}
135
137{
138 out(ast->lbraceToken);
139 ++expressionDepth;
140 if (ast->properties) {
142 newLine();
143 }
144 --expressionDepth;
145 out(ast->rbraceToken);
146 return false;
147}
148
150{
151 for (PatternElementList *it = ast; it; it = it->next) {
152 const bool isObjectInitializer =
153 it->element && cast<ObjectPattern *>(it->element->initializer);
154 if (isObjectInitializer)
155 newLine();
156
157 if (it->elision)
158 accept(it->elision);
159 if (it->elision && it->element)
160 out(", ");
161 if (it->element)
162 accept(it->element);
163 if (it->next) {
164 out(", ");
165 if (isObjectInitializer)
166 newLine();
167 }
168 }
169 return false;
170}
171
173{
174 for (PatternPropertyList *it = ast; it; it = it->next) {
175 accept(it->property);
176 if (it->next) {
177 out(",");
178 newLine();
179 }
180 }
181 return false;
182}
183
184// https://262.ecma-international.org/7.0/#prod-PropertyDefinition
186{
188 || property->type == PatternElement::Method) {
189 // note that MethodDefinitions and FunctionDeclarations have different syntax
190 // https://262.ecma-international.org/7.0/#prod-MethodDefinition
191 // https://262.ecma-international.org/7.0/#prod-FunctionDeclaration
192 // hence visit(FunctionDeclaration*) is not quite appropriate here
193 if (property->type == PatternProperty::Getter)
194 out("get ");
195 else if (property->type == PatternProperty::Setter)
196 out("set ");
197 FunctionExpression *f = AST::cast<FunctionExpression *>(property->initializer);
198 if (f->isGenerator) {
199 out("*");
200 }
201 accept(property->name);
202 out(f->lparenToken);
203 accept(f->formals);
204 out(f->rparenToken);
205 out(f->lbraceToken);
206 const bool scoped = f->lbraceToken.isValid();
207 if (scoped)
208 ++expressionDepth;
209 if (f->body) {
210 if (f->body->next || scoped) {
211 lnAcceptIndented(f->body);
212 lw.newline();
213 } else {
214 auto baseIndent = lw.increaseIndent(1);
215 accept(f->body);
216 lw.decreaseIndent(1, baseIndent);
217 }
218 }
219 if (scoped)
220 --expressionDepth;
221 out(f->rbraceToken);
222 return false;
223 }
224
225 // IdentifierReference[?Yield]
226 accept(property->name);
227 bool useInitializer = false;
228 const bool bindingIdentifierExist = !property->bindingIdentifier.isEmpty();
229 if (property->colonToken.isValid()) {
230 // PropertyName[?Yield] : AssignmentExpression[In, ?Yield]
231 out(": ");
232 useInitializer = true;
233 if (bindingIdentifierExist)
234 out(property->bindingIdentifier);
235 if (property->bindingTarget)
236 accept(property->bindingTarget);
237 }
238
239 if (property->initializer) {
240 // CoverInitializedName[?Yield]
241 if (bindingIdentifierExist) {
242 out(" = ");
243 useInitializer = true;
244 }
245 if (useInitializer)
246 accept(property->initializer);
247 }
248 return false;
249}
250
252{
253 out(ast->lparenToken);
254 int baseIndent = lw.increaseIndent(1);
255 accept(ast->expression);
256 lw.decreaseIndent(1, baseIndent);
257 out(ast->rparenToken);
258 return false;
259}
260
262{
263 out(ast->id.toString());
264 return true;
265}
267{
269 return true;
270}
272{
273 out(QString::number(ast->id));
274 return true;
275}
276
278{
279 // correctly handle multiline literals
280 if (ast->literalToken.length != 0) {
281 QStringView str = loc2Str(ast->literalToken);
282 if (lw.indentNextlines && str.contains(QLatin1Char('\n'))) {
283 out(str.mid(0, 1));
284 lw.indentNextlines = false;
285 out(str.mid(1));
286 lw.indentNextlines = true;
287 } else {
288 out(str);
289 }
290 }
291 accept(ast->expression);
292 return true;
293}
294
296{
297 accept(ast->base);
298 out(ast->lbracketToken);
299 int indent = lw.increaseIndent(1);
300 accept(ast->expression);
301 lw.decreaseIndent(1, indent);
302 out(ast->rbracketToken);
303 return false;
304}
305
307{
308 accept(ast->base);
309 out(ast->dotToken);
310 out(ast->identifierToken);
311 return false;
312}
313
315{
316 out("new "); // ast->newToken
317 accept(ast->base);
318 out(ast->lparenToken);
319 accept(ast->arguments);
320 out(ast->rparenToken);
321 return false;
322}
323
325{
326 out("new "); // ast->newToken
327 accept(ast->expression);
328 return false;
329}
330
332{
333 accept(ast->base);
334 out(ast->lparenToken);
335 accept(ast->arguments);
336 out(ast->rparenToken);
337 return false;
338}
339
341{
342 accept(ast->base);
343 out(ast->incrementToken);
344 return false;
345}
346
348{
349 accept(ast->base);
350 out(ast->decrementToken);
351 return false;
352}
353
355{
356 out(ast->incrementToken);
357 accept(ast->expression);
358 return false;
359}
360
362{
363 out(ast->decrementToken);
364 accept(ast->expression);
365 return false;
366}
367
369{
370 out("delete "); // ast->deleteToken
371 accept(ast->expression);
372 return false;
373}
374
376{
377 out("void "); // ast->voidToken
378 accept(ast->expression);
379 return false;
380}
381
383{
384 out("typeof "); // ast->typeofToken
385 accept(ast->expression);
386 return false;
387}
388
390{
391 out(ast->plusToken);
392 accept(ast->expression);
393 return false;
394}
395
397{
398 out(ast->minusToken);
399 accept(ast->expression);
400 return false;
401}
402
404{
405 out(ast->tildeToken);
406 accept(ast->expression);
407 return false;
408}
409
411{
412 out(ast->notToken);
413 accept(ast->expression);
414 return false;
415}
416
418{
419 accept(ast->left);
420 out(" ");
421 out(ast->operatorToken);
422 out(" ");
423 accept(ast->right);
424 return false;
425}
426
428{
429 accept(ast->expression);
430 out(" ? "); // ast->questionToken
431 accept(ast->ok);
432 out(" : "); // ast->colonToken
433 accept(ast->ko);
434 return false;
435}
436
438{
439 out(ast->lbraceToken);
440 if (ast->statements) {
441 ++expressionDepth;
443 newLine();
444 --expressionDepth;
445 }
446 out(ast->rbraceToken);
447 return false;
448}
449
451{
453 out(" ");
454 accept(ast->declarations);
455 if (addSemicolons())
456 out(";");
457 return false;
458}
459
461{
462 switch (ast->type) {
466 break;
468 out("get ");
469 break;
471 out("set ");
472 break;
474 out("...");
475 break;
476 }
477
478 accept(ast->bindingTarget);
479 if (!ast->destructuringPattern())
480 out(ast->identifierToken);
481 if (ast->initializer) {
483 out(" = ");
484 accept(ast->initializer);
485 }
486 return false;
487}
488
490{
491 out(ast->semicolonToken);
492 return false;
493}
494
496{
497 out(ast->ifToken);
498 out(" ");
499 out(ast->lparenToken);
500 preVisit(ast->expression);
501 ast->expression->accept0(this);
502 out(ast->rparenToken);
503 postVisit(ast->expression);
504 acceptBlockOrIndented(ast->ok, ast->ko);
505 if (ast->ko) {
506 out(ast->elseToken);
507 if (cast<Block *>(ast->ko) || cast<IfStatement *>(ast->ko)) {
508 out(" ");
509 accept(ast->ko);
510 } else {
511 lnAcceptIndented(ast->ko);
512 }
513 }
514 return false;
515}
516
518{
519 out(ast->doToken);
521 out(ast->whileToken);
522 out(" ");
523 out(ast->lparenToken);
524 accept(ast->expression);
525 out(ast->rparenToken);
526 return false;
527}
528
530{
531 out(ast->whileToken);
532 out(" ");
533 out(ast->lparenToken);
534 accept(ast->expression);
535 out(ast->rparenToken);
537 return false;
538}
539
541{
542 out(ast->forToken);
543 out(" ");
544 out(ast->lparenToken);
545 if (ast->initialiser) {
546 accept(ast->initialiser);
547 } else if (ast->declarations) {
548 if (auto pe = ast->declarations->declaration) {
549 out(pe->declarationKindToken);
550 out(" ");
551 }
552 for (VariableDeclarationList *it = ast->declarations; it; it = it->next) {
553 accept(it->declaration);
554 }
555 }
556 out("; "); // ast->firstSemicolonToken
557 accept(ast->condition);
558 out("; "); // ast->secondSemicolonToken
559 accept(ast->expression);
560 out(ast->rparenToken);
562 return false;
563}
564
566{
567 out(ast->forToken);
568 out(" ");
569 out(ast->lparenToken);
570 if (auto pe = AST::cast<PatternElement *>(ast->lhs)) {
571 out(pe->declarationKindToken);
572 out(" ");
573 }
574 accept(ast->lhs);
575 out(" ");
576 out(ast->inOfToken);
577 out(" ");
578 accept(ast->expression);
579 out(ast->rparenToken);
581 return false;
582}
583
585{
586 out(ast->continueToken);
587 if (!ast->label.isNull()) {
588 out(" ");
589 out(ast->identifierToken);
590 }
591 if (addSemicolons())
592 out(";");
593 return false;
594}
595
597{
598 out(ast->breakToken);
599 if (!ast->label.isNull()) {
600 out(" ");
601 out(ast->identifierToken);
602 }
603 if (addSemicolons())
604 out(";");
605 return false;
606}
607
609{
610 out(ast->returnToken);
611 if (ast->expression) {
612 if (ast->returnToken.length != 0)
613 out(" ");
614 accept(ast->expression);
615 }
616 if (ast->returnToken.length > 0 && addSemicolons())
617 out(";");
618 return false;
619}
620
622{
623 out(ast->throwToken);
624 if (ast->expression) {
625 out(" ");
626 accept(ast->expression);
627 }
628 if (addSemicolons())
629 out(";");
630 return false;
631}
632
634{
635 out(ast->withToken);
636 out(" ");
637 out(ast->lparenToken);
638 accept(ast->expression);
639 out(ast->rparenToken);
641 return false;
642}
643
645{
646 out(ast->switchToken);
647 out(" ");
648 out(ast->lparenToken);
649 accept(ast->expression);
650 out(ast->rparenToken);
651 out(" ");
652 accept(ast->block);
653 return false;
654}
655
657{
658 out(ast->lbraceToken);
659 ++expressionDepth;
660 newLine();
661 accept(ast->clauses);
662 if (ast->clauses && ast->defaultClause)
663 newLine();
664 accept(ast->defaultClause);
665 if (ast->moreClauses)
666 newLine();
667 accept(ast->moreClauses);
668 newLine();
669 --expressionDepth;
670 out(ast->rbraceToken);
671 return false;
672}
673
675{
676 out("case "); // ast->caseToken
677 accept(ast->expression);
678 out(ast->colonToken);
679 if (ast->statements)
681 return false;
682}
683
685{
686 out(ast->defaultToken);
687 out(ast->colonToken);
689 return false;
690}
691
693{
694 out(ast->identifierToken);
695 out(": "); // ast->colonToken
696 accept(ast->statement);
697 return false;
698}
699
701{
702 out("try "); // ast->tryToken
703 accept(ast->statement);
704 if (ast->catchExpression) {
705 out(" ");
707 }
708 if (ast->finallyExpression) {
709 out(" ");
711 }
712 return false;
713}
714
716{
717 out(ast->catchToken);
718 out(" ");
719 out(ast->lparenToken);
720 out(ast->identifierToken);
721 out(") "); // ast->rparenToken
722 accept(ast->statement);
723 return false;
724}
725
727{
728 out("finally "); // ast->finallyToken
729 accept(ast->statement);
730 return false;
731}
732
734{
735 return ScriptFormatter::visit(static_cast<FunctionExpression *>(ast));
736}
737
739{
740 if (!ast->isArrowFunction) {
741 if (ast->isGenerator) {
742 out("function* ");
743 } else {
744 out("function ");
745 }
746 if (!ast->name.isNull())
747 out(ast->identifierToken);
748 }
749 out(ast->lparenToken);
750 const bool needParentheses = ast->formals
751 && (ast->formals->next
752 || (ast->formals->element && ast->formals->element->bindingTarget));
753 if (ast->isArrowFunction && needParentheses)
754 out("(");
755 int baseIndent = lw.increaseIndent(1);
756 accept(ast->formals);
757 lw.decreaseIndent(1, baseIndent);
758 if (ast->isArrowFunction && needParentheses)
759 out(")");
760 out(ast->rparenToken);
761 if (ast->isArrowFunction && !ast->formals)
762 out("()");
763 out(" ");
764 if (ast->isArrowFunction)
765 out("=> ");
766 out(ast->lbraceToken);
767 if (ast->lbraceToken.length != 0)
768 ++expressionDepth;
769 if (ast->body) {
770 if (ast->body->next || ast->lbraceToken.length != 0) {
772 newLine();
773 } else {
774 // print a single statement in one line. E.g. x => x * 2
775 baseIndent = lw.increaseIndent(1);
776 accept(ast->body);
777 lw.decreaseIndent(1, baseIndent);
778 }
779 }
780 if (ast->lbraceToken.length != 0)
781 --expressionDepth;
782 out(ast->rbraceToken);
783 return false;
784}
785
787{
788 for (Elision *it = ast; it; it = it->next) {
789 if (it->next)
790 out(", "); // ast->commaToken
791 }
792 return false;
793}
794
796{
797 for (ArgumentList *it = ast; it; it = it->next) {
798 if (it->isSpreadElement)
799 out("...");
800 accept(it->expression);
801 if (it->next) {
802 out(", "); // it->commaToken
803 }
804 }
805 return false;
806}
807
809{
810 ++expressionDepth;
811 for (StatementList *it = ast; it; it = it->next) {
812 // ### work around parser bug: skip empty statements with wrong tokens
813 if (EmptyStatement *emptyStatement = cast<EmptyStatement *>(it->statement)) {
814 if (loc2Str(emptyStatement->semicolonToken) != QLatin1String(";"))
815 continue;
816 }
817
818 accept(it->statement);
819 if (it->next) {
820 // There might be a post-comment attached to the current
821 // statement or a pre-comment attached to the next
822 // statmente or both.
823 // If any of those are present they will take care of
824 // handling the spacing between the statements so we
825 // don't need to push any newline.
826 auto *commentForCurrentStatement = comments->commentForNode(it->statement);
827 auto *commentForNextStatement = comments->commentForNode(it->next->statement);
828
829 if (
830 (commentForCurrentStatement && !commentForCurrentStatement->postComments().empty())
831 || (commentForNextStatement && !commentForNextStatement->preComments().empty())
832 ) continue;
833
834 quint32 lineDelta = it->next->firstSourceLocation().startLine
835 - it->statement->lastSourceLocation().startLine;
836 lineDelta = std::clamp(lineDelta, quint32{ 1 }, quint32{ 2 });
837
838 newLine(lineDelta);
839 }
840 }
841 --expressionDepth;
842 return false;
843}
844
846{
847 for (VariableDeclarationList *it = ast; it; it = it->next) {
848 accept(it->declaration);
849 if (it->next)
850 out(", "); // it->commaToken
851 }
852 return false;
853}
854
856{
857 for (CaseClauses *it = ast; it; it = it->next) {
858 accept(it->clause);
859 if (it->next)
860 newLine();
861 }
862 return false;
863}
864
866{
867 for (FormalParameterList *it = ast; it; it = it->next) {
868 // compare FormalParameterList::finish
869 if (auto id = it->element->bindingIdentifier.toString(); !id.isEmpty())
870 out(id);
871 if (it->element->bindingTarget)
872 accept(it->element->bindingTarget);
873 if (it->next)
874 out(", ");
875 }
876 return false;
877}
878
879// to check
881{
882 out("super");
883 return true;
884}
886{
887 out("[");
888 return true;
889}
891{
892 accept(el->left);
893 out(", ");
894 accept(el->right);
895 return false;
896}
898{
899 if (addSemicolons())
900 postOps[el->expression].append([this]() { out(";"); });
901 return true;
902}
903
904// Return false because we want to omit default function calls in accept0 implementation.
906{
907 preVisit(ast);
908 out(ast->classToken);
909 out(" ");
910 out(ast->name);
911 if (ast->heritage) {
912 out(" extends ");
913 accept(ast->heritage);
914 }
915 out(" {");
916 int baseIndent = lw.increaseIndent();
917 for (ClassElementList *it = ast->elements; it; it = it->next) {
918 lw.newline();
919 if (it->isStatic)
920 out("static ");
921 accept(it->property);
922 lw.newline();
923 }
924 lw.decreaseIndent(1, baseIndent);
925 out("}");
926 postVisit(ast);
927 return false;
928}
929
931{
932 out(ast->importToken);
933 lw.space();
934 if (!ast->moduleSpecifier.isNull()) {
936 }
937 return true;
938}
939
941{
942 if (!ast->identifier.isNull()) {
943 out(ast->identifierToken);
944 lw.space();
945 out("as");
946 lw.space();
947 }
949 return true;
950}
951
953{
954 out(ast->starToken);
955 lw.space();
956 out("as");
957 lw.space();
959 return true;
960}
961
963{
964 for (ImportsList *it = ast; it; it = it->next) {
965 accept(it->importSpecifier);
966 if (it->next) {
967 out(",");
968 lw.space();
969 }
970 }
971 return false;
972}
974{
975 out(ast->leftBraceToken);
976 if (ast->importsList) {
977 lw.space();
978 }
979 return true;
980}
981
983{
984 if (!ast->importedDefaultBinding.isNull()) {
986 if (ast->nameSpaceImport || ast->namedImports) {
987 out(",");
988 lw.space();
989 }
990 }
991 return true;
992}
993
995{
996 out(ast->exportToken);
997 lw.space();
998 if (ast->exportDefault) {
999 out("default");
1000 lw.space();
1001 }
1002 if (ast->exportsAll()) {
1003 out("*");
1004 }
1005 return true;
1006}
1007
1009{
1010 out(ast->leftBraceToken);
1011 if (ast->exportsList) {
1012 lw.space();
1013 }
1014 return true;
1015}
1016
1018{
1019 out(ast->identifier);
1020 if (ast->exportedIdentifierToken.isValid()) {
1021 lw.space();
1022 out("as");
1023 lw.space();
1024 out(ast->exportedIdentifier);
1025 }
1026 return true;
1027}
1028
1030{
1031 for (ExportsList *it = ast; it; it = it->next) {
1032 accept(it->exportSpecifier);
1033 if (it->next) {
1034 out(",");
1035 lw.space();
1036 }
1037 }
1038 return false;
1039}
1040
1042{
1043 lw.space();
1044 out(ast->fromToken);
1045 lw.space();
1047 return true;
1048}
1049
1054
1056{
1057 // add a semicolon at the end of the following expressions
1058 // export * FromClause ;
1059 // export ExportClause FromClause ;
1060 if (ast->fromClause) {
1061 out(";");
1062 }
1063
1064 // add a semicolon at the end of the following expressions
1065 // export ExportClause ;
1066 if (ast->exportClause && !ast->fromClause) {
1067 out(";");
1068 }
1069
1070 // add a semicolon at the end of the following expressions
1071 // export default [lookahead ∉ { function, class }] AssignmentExpression;
1073 // lookahead ∉ { function, class }
1076 out(";");
1077 }
1078 // ArrowFunction in QQmlJS::AST is handled with the help of FunctionDeclaration
1079 // and not as part of AssignmentExpression (as per ECMA
1080 // https://262.ecma-international.org/7.0/#prod-AssignmentExpression)
1083 ->isArrowFunction) {
1084 out(";");
1085 }
1086 }
1087}
1088
1090{
1091 if (ast->exportsList) {
1092 lw.space();
1093 }
1094 out(ast->rightBraceToken);
1095}
1096
1098{
1099 if (ast->importsList) {
1100 lw.space();
1101 }
1102 out(ast->rightBraceToken);
1103}
1104
1109
1111{
1112 out("/* ERROR: Hit recursion limit ScriptFormatter::visiting AST, rewrite failed */");
1113}
1114
1115void reformatAst(OutWriter &lw, const std::shared_ptr<AstComments> &comments,
1116 const std::function<QStringView(SourceLocation)> &loc2Str, AST::Node *n)
1117{
1118 if (n) {
1119 ScriptFormatter formatter(lw, comments, loc2Str, n);
1120 }
1121}
1122
1123} // namespace Dom
1124} // namespace QQmlJS
SourceLocation rbracketToken
PatternElementList * elements
SourceLocation lbracketToken
SourceLocation commaToken
StatementList * statements
SourceLocation rbraceToken
SourceLocation lbraceToken
CaseClauses * moreClauses
SourceLocation lbraceToken
SourceLocation rbraceToken
DefaultClause * defaultClause
ExpressionNode * expression
SourceLocation colonToken
StatementList * statements
SourceLocation identifierToken
SourceLocation lparenToken
SourceLocation catchToken
ClassElementList * elements
SourceLocation rightBraceToken
SourceLocation leftBraceToken
SourceLocation exportedIdentifierToken
SourceLocation falseToken
ExpressionNode * expression
VariableDeclarationList * declarations
ExpressionNode * initialiser
ExpressionNode * condition
SourceLocation fromToken
SourceLocation moduleSpecifierToken
FormalParameterList * formals
SourceLocation rparenToken
SourceLocation lparenToken
ExpressionNode * expression
SourceLocation importedDefaultBindingToken
QStringView importedDefaultBinding
NamedImports * namedImports
NameSpaceImport * nameSpaceImport
SourceLocation importedBindingToken
SourceLocation importedBindingToken
SourceLocation rightBraceToken
SourceLocation leftBraceToken
ExpressionNode * expression
virtual void accept0(BaseVisitor *visitor)=0
ExpressionNode * expression
PatternPropertyList * properties
SourceLocation identifierToken
ExpressionNode * initializer
Pattern * destructuringPattern() const
ExpressionNode * bindingTarget
bool isVariableDeclaration() const
SourceLocation propertyNameToken
SourceLocation literalToken
SourceLocation literalToken
ExpressionNode * expression
ExpressionNode * expression
SourceLocation trueToken
VariableDeclarationList * declarations
ExpressionNode * expression
ExpressionNode * expression
ExpressionNode * expression
Keeps the comment associated with an element.
OutWriter & ensureNewline(int nNewlines=1)
int increaseIndent(int level=1)
int decreaseIndent(int level=1, int expectedIndent=-1)
void lnAcceptIndented(AST::Node *node)
bool visit(AST::ThisExpression *ast) override
bool preVisit(AST::Node *n) override
void endVisit(AST::ComputedPropertyName *) override
bool acceptBlockOrIndented(AST::Node *ast, bool finishWithSpaceOrNewline=false)
void postVisit(AST::Node *n) override
\inmodule QtCore
Definition qstringview.h:78
constexpr QStringView left(qsizetype n) const noexcept
QString toString() const
Returns a deep copy of this string view's data as a QString.
Definition qstring.h:1121
constexpr bool isNull() const noexcept
Returns whether this string view is null - that is, whether {data() == nullptr}.
constexpr QStringView right(qsizetype n) const noexcept
QString mid(qsizetype position, qsizetype n=-1) const &
Definition qstring.cpp:5300
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition qstring.h:1369
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:8084
QString str
[2]
QSet< QString >::iterator it
T lastListElement(T head)
void reformatAst(OutWriter &lw, const std::shared_ptr< AstComments > &comments, const std::function< QStringView(SourceLocation)> &loc2Str, AST::Node *n)
Combined button and popup list for selecting options.
GLfloat GLfloat f
GLfloat n
const GLubyte * c
unsigned int quint32
Definition qtypes.h:50
const char property[13]
Definition qwizard.cpp:101
QTextStream out(stdout)
[7]
QStringView el
\inmodule QtCore \reentrant
Definition qchar.h:18