forked from qt-creator/qt-creator
C++ indenter: Make continuations after ( consistent.
Change-Id: Iae780127065e3fce274db10e173f5c0bde15bd92 Reviewed-on: http://codereview.qt.nokia.com/1229 Reviewed-by: Leandro T. C. Melo <leandro.melo@nokia.com>
This commit is contained in:
@@ -1144,6 +1144,7 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
|
|||||||
|
|
||||||
case arglist_open:
|
case arglist_open:
|
||||||
case condition_paren_open:
|
case condition_paren_open:
|
||||||
|
case member_init_paren_open:
|
||||||
if (!lastToken)
|
if (!lastToken)
|
||||||
*paddingDepth = nextTokenPosition-*indentDepth;
|
*paddingDepth = nextTokenPosition-*indentDepth;
|
||||||
else
|
else
|
||||||
@@ -1179,10 +1180,6 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
|
|||||||
*paddingDepth += 2; // savedIndentDepth is the position of ':'
|
*paddingDepth += 2; // savedIndentDepth is the position of ':'
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case member_init_paren_open:
|
|
||||||
addContinuationIndent(paddingDepth);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case case_cont:
|
case case_cont:
|
||||||
if (m_styleSettings.indentStatementsRelativeToSwitchLabels)
|
if (m_styleSettings.indentStatementsRelativeToSwitchLabels)
|
||||||
*indentDepth += m_tabSettings.m_indentSize;
|
*indentDepth += m_tabSettings.m_indentSize;
|
||||||
|
|||||||
@@ -115,7 +115,8 @@ private Q_SLOTS:
|
|||||||
void functionBodyAndBraces2();
|
void functionBodyAndBraces2();
|
||||||
void functionBodyAndBraces3();
|
void functionBodyAndBraces3();
|
||||||
void functionBodyAndBraces4();
|
void functionBodyAndBraces4();
|
||||||
void constructor();
|
void constructor1();
|
||||||
|
void constructor2();
|
||||||
void caseBody1();
|
void caseBody1();
|
||||||
void caseBody2();
|
void caseBody2();
|
||||||
void caseBody3();
|
void caseBody3();
|
||||||
@@ -1080,7 +1081,7 @@ void tst_CodeFormatter::memberInitializer()
|
|||||||
<< Line(" Foo()")
|
<< Line(" Foo()")
|
||||||
<< Line(" ~ : baR(),")
|
<< Line(" ~ : baR(),")
|
||||||
<< Line(" ~ moodoo(barR + ")
|
<< Line(" ~ moodoo(barR + ")
|
||||||
<< Line(" ~ 42),")
|
<< Line(" ~ 42),")
|
||||||
<< Line(" ~ xyz()")
|
<< Line(" ~ xyz()")
|
||||||
<< Line(" {}")
|
<< Line(" {}")
|
||||||
<< Line("};")
|
<< Line("};")
|
||||||
@@ -1764,7 +1765,7 @@ void tst_CodeFormatter::functionBodyAndBraces4()
|
|||||||
checkIndent(data, codeStyle);
|
checkIndent(data, codeStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_CodeFormatter::constructor()
|
void tst_CodeFormatter::constructor1()
|
||||||
{
|
{
|
||||||
QList<Line> data;
|
QList<Line> data;
|
||||||
data << Line("class Foo {")
|
data << Line("class Foo {")
|
||||||
@@ -1782,6 +1783,42 @@ void tst_CodeFormatter::constructor()
|
|||||||
checkIndent(data, codeStyle);
|
checkIndent(data, codeStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_CodeFormatter::constructor2()
|
||||||
|
{
|
||||||
|
QList<Line> data;
|
||||||
|
data << Line("class Foo {")
|
||||||
|
<< Line(" Foo() : _a(0)")
|
||||||
|
<< Line(" {")
|
||||||
|
<< Line(" _b = 0")
|
||||||
|
<< Line(" }")
|
||||||
|
<< Line(" int _a;")
|
||||||
|
<< Line(" Foo()")
|
||||||
|
<< Line(" ~ : _foo(1),")
|
||||||
|
<< Line(" ~ _bar(2),")
|
||||||
|
<< Line(" ~ _carooooo(")
|
||||||
|
<< Line(" ~ foo() + 12),")
|
||||||
|
<< Line(" ~ _carooooo(foo(),")
|
||||||
|
<< Line(" ~ 12)")
|
||||||
|
<< Line(" {")
|
||||||
|
<< Line(" _b = 0")
|
||||||
|
<< Line(" }")
|
||||||
|
<< Line(" int _b;")
|
||||||
|
<< Line(" Foo()")
|
||||||
|
<< Line(" ~ : _foo(1)")
|
||||||
|
<< Line(" ~ , _bar(2)")
|
||||||
|
<< Line(" ~ , _carooooo(")
|
||||||
|
<< Line(" ~ foo() + 12)")
|
||||||
|
<< Line(" ~ , _carooooo(foo(),")
|
||||||
|
<< Line(" ~ 12)")
|
||||||
|
<< Line(" {")
|
||||||
|
<< Line(" _b = 0")
|
||||||
|
<< Line(" }")
|
||||||
|
<< Line("};")
|
||||||
|
;
|
||||||
|
CppCodeStyleSettings codeStyle;
|
||||||
|
checkIndent(data);
|
||||||
|
}
|
||||||
|
|
||||||
void tst_CodeFormatter::caseBody1()
|
void tst_CodeFormatter::caseBody1()
|
||||||
{
|
{
|
||||||
QList<Line> data;
|
QList<Line> data;
|
||||||
|
|||||||
Reference in New Issue
Block a user