diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2010-12-01 10:19:53 +0100 |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2010-12-01 10:22:41 +0100 |
commit | c5c4bacda9c54b600a5ae7bd6d9701a401f37bad (patch) | |
tree | d4c58cbf06b8ca302520062c23dd2f7432491584 /src/plugins/cpptools/cppcodeformatter.cpp | |
parent | bb654838cfcccdc67270404f3b1a570a2c74054f (diff) | |
download | qt-creator-c5c4bacda9c54b600a5ae7bd6d9701a401f37bad.tar.gz |
C++ indenter: Fix labels.
Reviewed-by: Roberto Raggi
Diffstat (limited to 'src/plugins/cpptools/cppcodeformatter.cpp')
-rw-r--r-- | src/plugins/cpptools/cppcodeformatter.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp index f46f469e53..c744d292a4 100644 --- a/src/plugins/cpptools/cppcodeformatter.cpp +++ b/src/plugins/cpptools/cppcodeformatter.cpp @@ -382,6 +382,12 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block) default: leave(); continue; } break; + case label: + switch (kind) { + case T_COLON: leave(); break; + default: leave(); continue; // shouldn't happen + } break; + case multiline_comment_start: case multiline_comment_cont: if (kind != T_COMMENT && kind != T_DOXY_COMMENT) { @@ -710,6 +716,10 @@ bool CodeFormatter::tryDeclaration() enter(qt_like_macro); return true; } + if (m_tokens.size() > 1 && m_tokens.at(1).kind() == T_COLON) { + enter(label); + return true; + } } // fallthrough case T_CHAR: @@ -1428,6 +1438,16 @@ void QtStyleCodeFormatter::adjustIndent(const QList<CPlusPlus::Token> &tokens, i *indentDepth = 0; } break; + case T_IDENTIFIER: + if (topState.type == substatement + || topState.type == substatement_open + || topState.type == case_cont + || topState.type == block_open + || topState.type == defun_open) { + if (tokens.size() > 1 && tokens.at(1).kind() == T_COLON) // label? + *indentDepth = 0; + } + break; } } |