summaryrefslogtreecommitdiff
path: root/src/libs/qmljs/qmljscodeformatter.cpp
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2012-03-01 08:35:21 +0100
committerFawzi Mohamed <fawzi.mohamed@nokia.com>2012-03-06 17:26:46 +0100
commitab64c1aef355deb4031d78ba57aefbf8b5f064d0 (patch)
treea83857bfc9ddfe37c1d0d6a94a043e1a67377cda /src/libs/qmljs/qmljscodeformatter.cpp
parent970500141490b1ea6f4137f359e5e7ae758a4162 (diff)
downloadqt-creator-ab64c1aef355deb4031d78ba57aefbf8b5f064d0.tar.gz
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>
Diffstat (limited to 'src/libs/qmljs/qmljscodeformatter.cpp')
-rw-r--r--src/libs/qmljs/qmljscodeformatter.cpp23
1 files changed, 3 insertions, 20 deletions
diff --git a/src/libs/qmljs/qmljscodeformatter.cpp b/src/libs/qmljs/qmljscodeformatter.cpp
index 1ef3c80c08..7c64c9058a 100644
--- a/src/libs/qmljs/qmljscodeformatter.cpp
+++ b/src/libs/qmljs/qmljscodeformatter.cpp
@@ -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: