summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppcodeformatter.cpp
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2010-07-05 09:59:42 +0200
committerChristian Kamm <christian.d.kamm@nokia.com>2010-07-05 13:49:12 +0200
commit3100fc0b7edc7670ac9a95a2715b80a6d4a3be21 (patch)
tree1afeb93ccaebcd4adfdaf8fc6bd9a10d0d42ac37 /src/plugins/cpptools/cppcodeformatter.cpp
parent76ebb4647930bf17b394c5610e26930a0af491d9 (diff)
downloadqt-creator-3100fc0b7edc7670ac9a95a2715b80a6d4a3be21.tar.gz
C++ indenter: Add support for other brace styles.
Diffstat (limited to 'src/plugins/cpptools/cppcodeformatter.cpp')
-rw-r--r--src/plugins/cpptools/cppcodeformatter.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp
index 8ab36724ff..1bfb0a574a 100644
--- a/src/plugins/cpptools/cppcodeformatter.cpp
+++ b/src/plugins/cpptools/cppcodeformatter.cpp
@@ -794,6 +794,7 @@ void CodeFormatter::dump()
QtStyleCodeFormatter::QtStyleCodeFormatter()
: m_indentSize(4)
+ , m_style(QtStyle)
{
}
@@ -805,6 +806,14 @@ void QtStyleCodeFormatter::setIndentSize(int size)
}
}
+void QtStyleCodeFormatter::setCompoundStyle(CompoundStyle style)
+{
+ if (style != m_style) {
+ m_style = style;
+ invalidateCache();
+ }
+}
+
void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedIndentDepth) const
{
const State &parentState = state();
@@ -878,6 +887,8 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
break;
case substatement_open:
+ if (m_style == WhitesmithsStyle)
+ break;
if (parentState.type != switch_statement)
*indentDepth += m_indentSize;
break;
@@ -908,6 +919,9 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
// undo the continuation indent of the parent
*indentDepth = parentState.savedIndentDepth;
*savedIndentDepth = *indentDepth;
+ // these styles want to indent braces
+ if (m_style == GnuStyle || m_style == WhitesmithsStyle)
+ *savedIndentDepth += m_indentSize;
break;
case maybe_else: {