QmlJS indenter: Improve indentation of function expressions.

As discussed with Tor Arne and Fawzi in
http://codereview.qt-project.org/#change,18080

Change-Id: Ia0482d2ed3ddd61fa002e2c76b948301af52a795
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
Christian Kamm
2012-03-01 08:35:21 +01:00
committed by Fawzi Mohamed
parent 9705001414
commit ab64c1aef3
3 changed files with 35 additions and 27 deletions

View File

@@ -1124,27 +1124,10 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
}
break;
case function_start: {
// in these states, align to the 'function' keyword
const int parentType = parentState.type;
if (parentType == objectdefinition_open
|| parentType == paren_open
|| parentType == bracket_open) {
*indentDepth = tokenPosition;
*savedIndentDepth = *indentDepth;
break;
}
// otherwise find the enclosing expression end state and align to that
for (int i = 1; state(i).type != topmost_intro; ++i) {
const int type = state(i).type;
if (isExpressionEndState(type)) {
*indentDepth = state(i - 1).savedIndentDepth;
break;
}
}
case function_start:
// align to the beginning of the line
*savedIndentDepth = *indentDepth = column(tokenAt(0).begin());
break;
}
case do_statement_while_paren_open:
case statement_with_condition_paren_open: