summaryrefslogtreecommitdiff
path: root/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2011-04-21 12:21:23 +0200
committerChristian Kamm <christian.d.kamm@nokia.com>2011-04-21 12:25:15 +0200
commitd0d0a8c07ee00ae27edd2f6681b1146c1a2d8ae6 (patch)
tree7364f43aa900645131959acaad10560ee226e690 /src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
parente3928941ee22995d42d868c6c4ca1081aeace698 (diff)
downloadqt-creator-d0d0a8c07ee00ae27edd2f6681b1146c1a2d8ae6.tar.gz
QmlJS: Fix indent of object literals.
Reviewed-by: Roberto Raggi
Diffstat (limited to 'src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp')
-rw-r--r--src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp b/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
index 1455625d69..07d44c5923 100644
--- a/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
+++ b/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
@@ -117,6 +117,7 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
break;
case binding_assignment:
+ case objectliteral_assignment:
if (lastToken)
*indentDepth = *savedIndentDepth + 4;
else
@@ -203,6 +204,16 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
*indentDepth = *savedIndentDepth + m_indentSize;
break;
+ case objectliteral_open:
+ if (parentState.type == expression || parentState.type == objectliteral_assignment) {
+ // undo the continuation indent of the expression
+ *indentDepth = parentState.savedIndentDepth;
+ *savedIndentDepth = *indentDepth;
+ }
+ *indentDepth += m_indentSize;
+ break;
+
+
case statement_with_condition:
case statement_with_block:
case if_statement:
@@ -290,7 +301,8 @@ void QtStyleCodeFormatter::adjustIndent(const QList<Token> &tokens, int lexerSta
const int type = state(i).type;
if (type == objectdefinition_open
|| type == jsblock_open
- || type == substatement_open) {
+ || type == substatement_open
+ || type == objectliteral_open) {
*indentDepth = state(i).savedIndentDepth;
break;
}