forked from qt-creator/qt-creator
qml | Fix functions and loops formatting
Bugs fixed in this change: 1. Incorrect function arguments formatting: function(a, b, c) -> function(abc) 2. Incorrect foreach loop formatting: for (var a in b) -> for (a in b) 3. Incorrect for loop formatting: for (var a = 1; a < 100; ++a) -> for(; a < 100; ++a) Change-Id: I8afef6e5f2485a2225931b7ecb7210506e06dc6c Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
committed by
selatnick
parent
8f7cbd6416
commit
70fecd518e
@@ -962,7 +962,15 @@ protected:
|
|||||||
|
|
||||||
bool visit(PatternElement *ast) override
|
bool visit(PatternElement *ast) override
|
||||||
{
|
{
|
||||||
|
if (ast->isForDeclaration) {
|
||||||
|
if (ast->scope == VariableScope::Var) {
|
||||||
|
out("var ");
|
||||||
|
} else if (ast->scope == VariableScope::Let) {
|
||||||
|
out("let ");
|
||||||
|
} else if (ast->scope == VariableScope::Const) {
|
||||||
|
out("const ");
|
||||||
|
}
|
||||||
|
}
|
||||||
out(ast->identifierToken);
|
out(ast->identifierToken);
|
||||||
if (ast->initializer) {
|
if (ast->initializer) {
|
||||||
if (ast->isVariableDeclaration())
|
if (ast->isVariableDeclaration())
|
||||||
@@ -1026,7 +1034,12 @@ protected:
|
|||||||
out(ast->forToken);
|
out(ast->forToken);
|
||||||
out(" ");
|
out(" ");
|
||||||
out(ast->lparenToken);
|
out(ast->lparenToken);
|
||||||
|
if (ast->initialiser) {
|
||||||
accept(ast->initialiser);
|
accept(ast->initialiser);
|
||||||
|
} else if (ast->declarations) {
|
||||||
|
out("var ");
|
||||||
|
accept(ast->declarations);
|
||||||
|
}
|
||||||
out("; ", ast->firstSemicolonToken);
|
out("; ", ast->firstSemicolonToken);
|
||||||
accept(ast->condition);
|
accept(ast->condition);
|
||||||
out("; ", ast->secondSemicolonToken);
|
out("; ", ast->secondSemicolonToken);
|
||||||
@@ -1314,6 +1327,9 @@ protected:
|
|||||||
{
|
{
|
||||||
for (FormalParameterList *it = ast; it; it = it->next) {
|
for (FormalParameterList *it = ast; it; it = it->next) {
|
||||||
out(it->element->bindingIdentifier.toString()); // TODO
|
out(it->element->bindingIdentifier.toString()); // TODO
|
||||||
|
if (it->next) {
|
||||||
|
out(", ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -32,6 +32,12 @@ while (true) {
|
|||||||
for (var x in a) {
|
for (var x in a) {
|
||||||
print(a[x])
|
print(a[x])
|
||||||
}
|
}
|
||||||
|
for (let x in a) {
|
||||||
|
print(a[x])
|
||||||
|
}
|
||||||
|
for (const x in a) {
|
||||||
|
print(a[x])
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
a = x
|
a = x
|
||||||
|
Reference in New Issue
Block a user