summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Raggi <qtc-committer@nokia.com>2009-01-07 10:59:36 +0100
committerRoberto Raggi <qtc-committer@nokia.com>2009-01-07 10:59:36 +0100
commitf4bf0a3a6db41dd7ce6f122053a0d144c01b5bd8 (patch)
treee17ad3b3833726d05d2a784e96d65d19c2364c2f
parent8ec03e6bcd7d7ed7ee1e22c96bcfb46b86cdc3bf (diff)
downloadqt-creator-f4bf0a3a6db41dd7ce6f122053a0d144c01b5bd8.tar.gz
Checkpoint. Pretty printing of switch and case statements.
-rw-r--r--shared/cplusplus/PrettyPrinter.cpp19
-rw-r--r--tests/manual/cplusplus/tests/t1.cpp5
2 files changed, 23 insertions, 1 deletions
diff --git a/shared/cplusplus/PrettyPrinter.cpp b/shared/cplusplus/PrettyPrinter.cpp
index 620cb0bd2a..2acb98b14e 100644
--- a/shared/cplusplus/PrettyPrinter.cpp
+++ b/shared/cplusplus/PrettyPrinter.cpp
@@ -198,7 +198,24 @@ bool PrettyPrinter::visit(CaseStatementAST *ast)
out << "case ";
accept(ast->expression);
out << ':';
- accept(ast->statement);
+ if (! ast->statement) {
+ newline();
+ return false;
+ }
+
+ if (ast->statement->asCompoundStatement()) {
+ out << ' ';
+ accept(ast->statement);
+ } else if (ast->statement->asCaseStatement() || ast->statement->asLabeledStatement()) {
+ newline();
+ accept(ast->statement);
+ } else {
+ indent();
+ newline();
+ accept(ast->statement);
+ deindent();
+ newline();
+ }
return false;
}
diff --git a/tests/manual/cplusplus/tests/t1.cpp b/tests/manual/cplusplus/tests/t1.cpp
index 2a64b29184..5457def79e 100644
--- a/tests/manual/cplusplus/tests/t1.cpp
+++ b/tests/manual/cplusplus/tests/t1.cpp
@@ -35,6 +35,11 @@ class Class {
switch (int k) {
case 'a': case 'b': case '\\':
return 1;
+ case 1|2: { return 3; } break;
+ case x: break;
+ case y:
+ foo();
+ break;
default:
return 2;
}