aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmldom/qqmldomreformatter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmldom/qqmldomreformatter.cpp')
-rw-r--r--src/qmldom/qqmldomreformatter.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/qmldom/qqmldomreformatter.cpp b/src/qmldom/qqmldomreformatter.cpp
index 4232097d17..a5022f95e1 100644
--- a/src/qmldom/qqmldomreformatter.cpp
+++ b/src/qmldom/qqmldomreformatter.cpp
@@ -585,16 +585,27 @@ protected:
return false;
}
+
+ void outputScope(VariableScope scope) {
+ switch (scope) {
+ case VariableScope::Const:
+ out("const ");
+ break;
+ case VariableScope::Let:
+ out("let ");
+ break;
+ case VariableScope::Var:
+ out("var ");
+ break;
+ default:
+ break;
+ }
+ }
+
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 ");
- }
+ outputScope(ast->scope);
}
accept(ast->bindingTarget);
switch (ast->type) {
@@ -678,7 +689,7 @@ protected:
if (ast->initialiser) {
accept(ast->initialiser);
} else if (ast->declarations) {
- out("var ");
+ outputScope(ast->declarations->declaration->scope);
accept(ast->declarations);
}
out("; "); // ast->firstSemicolonToken