forked from qt-creator/qt-creator
C++ indenter: Add support for other brace styles.
This commit is contained in:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user