summaryrefslogtreecommitdiff
path: root/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2011-09-07 12:06:46 +0200
committerChristian Kamm <christian.d.kamm@nokia.com>2011-09-08 13:55:08 +0200
commit62a71b75a0d2eaf9c68df5d6b12d70c75a7b8856 (patch)
tree2ad2ebaaa4dce23a3df9b7f568e6d7284575133c /src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
parent84364b7884433069b43b9811ca9d21b26b1a096a (diff)
downloadqt-creator-62a71b75a0d2eaf9c68df5d6b12d70c75a7b8856.tar.gz
QmlJS indenter: Fix indentation for property initializers.
property int foo: { used to start an object literal but is a block statement now. Change-Id: I9ffbce4927b444314f1a43aba65ca3d9d234e47c Reviewed-on: http://codereview.qt-project.org/4339 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
Diffstat (limited to 'src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp')
-rw-r--r--src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp b/src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
index 17d7f7fdca..a85a25685e 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 || parentState.type == property_initializer)
+ if (parentState.type == binding_assignment)
*savedIndentDepth = state(1).savedIndentDepth;
if (firstToken)
@@ -117,7 +117,6 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
break;
case binding_assignment:
- case property_initializer:
case objectliteral_assignment:
if (lastToken)
*indentDepth = *savedIndentDepth + 4;
@@ -134,7 +133,6 @@ 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;
}
@@ -155,8 +153,7 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
break;
case bracket_open:
- if (parentState.type == expression && (state(1).type == binding_assignment
- || state(1).type == property_initializer)) {
+ if (parentState.type == expression && state(1).type == binding_assignment) {
*savedIndentDepth = state(2).savedIndentDepth;
*indentDepth = *savedIndentDepth + m_indentSize;
} else if (!lastToken) {
@@ -201,16 +198,15 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
}
// fallthrough
case substatement_open:
- // special case for foo: {
- if (parentState.type == binding_assignment && state(1).type == binding_or_objectdefinition)
+ // special case for "foo: {" and "property int foo: {"
+ if (parentState.type == binding_assignment)
*savedIndentDepth = state(1).savedIndentDepth;
*indentDepth = *savedIndentDepth + m_indentSize;
break;
case objectliteral_open:
if (parentState.type == expression
- || parentState.type == objectliteral_assignment
- || parentState.type == property_initializer) {
+ || parentState.type == objectliteral_assignment) {
// undo the continuation indent of the expression
*indentDepth = parentState.savedIndentDepth;
*savedIndentDepth = *indentDepth;
@@ -293,7 +289,6 @@ 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;
}