summaryrefslogtreecommitdiff
path: root/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2011-04-21 12:56:37 +0200
committerChristian Kamm <christian.d.kamm@nokia.com>2011-04-21 12:56:59 +0200
commit8d4d88f072453926e427beb0ec481c3166e6d34e (patch)
tree258a4a4474464d90817b7a269374017c40c9227e /src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
parentb0da6a1e6c642a61e250bddc624f345f3601a3ed (diff)
downloadqt-creator-8d4d88f072453926e427beb0ec481c3166e6d34e.tar.gz
QmlJS: Fix object literal indent in property initializers.
Diffstat (limited to 'src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp')
-rw-r--r--src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp b/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
index 07d44c5923..4c87f1daca 100644
--- a/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
+++ b/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
@@ -101,7 +101,7 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
switch (newState) {
case objectdefinition_open: {
// special case for things like "gradient: Gradient {"
- if (parentState.type == binding_assignment)
+ if (parentState.type == binding_assignment || parentState.type == property_initializer)
*savedIndentDepth = state(1).savedIndentDepth;
if (firstToken)
@@ -117,6 +117,7 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
break;
case binding_assignment:
+ case property_initializer:
case objectliteral_assignment:
if (lastToken)
*indentDepth = *savedIndentDepth + 4;
@@ -133,6 +134,7 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
// ternary already adjusts indents nicely
if (parentState.type != expression_or_objectdefinition
&& parentState.type != binding_assignment
+ && parentState.type != property_initializer
&& parentState.type != ternary_op) {
*indentDepth += 2 * m_indentSize;
}
@@ -153,7 +155,8 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
break;
case bracket_open:
- if (parentState.type == expression && state(1).type == binding_assignment) {
+ if (parentState.type == expression && (state(1).type == binding_assignment
+ || state(1).type == property_initializer)) {
*savedIndentDepth = state(2).savedIndentDepth;
*indentDepth = *savedIndentDepth + m_indentSize;
} else if (!lastToken) {
@@ -205,7 +208,9 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
break;
case objectliteral_open:
- if (parentState.type == expression || parentState.type == objectliteral_assignment) {
+ if (parentState.type == expression
+ || parentState.type == objectliteral_assignment
+ || parentState.type == property_initializer) {
// undo the continuation indent of the expression
*indentDepth = parentState.savedIndentDepth;
*savedIndentDepth = *indentDepth;
@@ -288,6 +293,7 @@ void QtStyleCodeFormatter::adjustIndent(const QList<Token> &tokens, int lexerSta
case LeftBrace:
if (topState.type == substatement
|| topState.type == binding_assignment
+ || topState.type == property_initializer
|| topState.type == case_cont) {
*indentDepth = topState.savedIndentDepth;
}