summaryrefslogtreecommitdiff
path: root/shared/cplusplus/PrettyPrinter.cpp
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 /shared/cplusplus/PrettyPrinter.cpp
parent8ec03e6bcd7d7ed7ee1e22c96bcfb46b86cdc3bf (diff)
downloadqt-creator-f4bf0a3a6db41dd7ce6f122053a0d144c01b5bd8.tar.gz
Checkpoint. Pretty printing of switch and case statements.
Diffstat (limited to 'shared/cplusplus/PrettyPrinter.cpp')
-rw-r--r--shared/cplusplus/PrettyPrinter.cpp19
1 files changed, 18 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;
}