diff options
Diffstat (limited to 'src/libs/qmljs')
-rw-r--r-- | src/libs/qmljs/qmljscodeformatter.cpp | 19 | ||||
-rw-r--r-- | src/libs/qmljs/qmljscodeformatter.h | 3 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/libs/qmljs/qmljscodeformatter.cpp b/src/libs/qmljs/qmljscodeformatter.cpp index edd596c5ca..f3811e50a9 100644 --- a/src/libs/qmljs/qmljscodeformatter.cpp +++ b/src/libs/qmljs/qmljscodeformatter.cpp @@ -165,6 +165,21 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block) default: enter(expression); continue; } break; + // property inits don't take statements + case property_initializer: + switch (kind) { + case Semicolon: leave(true); break; + case LeftBrace: enter(objectliteral_open); break; + case On: + case As: + case List: + case Import: + case Signal: + case Property: + case Identifier: enter(expression_or_objectdefinition); break; + default: enter(expression); continue; + } break; + case objectdefinition_open: switch (kind) { case RightBrace: leave(true); break; @@ -206,7 +221,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block) case property_maybe_initializer: switch (kind) { - case Colon: enter(binding_assignment); break; + case Colon: enter(property_initializer); break; default: leave(true); continue; } break; @@ -298,7 +313,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block) case Colon: enter(objectliteral_assignment); break; case RightBracket: case RightParenthesis: leave(); continue; // error recovery - case RightBrace: leave(); break; + case RightBrace: leave(true); break; } break; // pretty much like expression, but ends with , or } diff --git a/src/libs/qmljs/qmljscodeformatter.h b/src/libs/qmljs/qmljscodeformatter.h index a3752ff672..44b5c19686 100644 --- a/src/libs/qmljs/qmljscodeformatter.h +++ b/src/libs/qmljs/qmljscodeformatter.h @@ -126,7 +126,8 @@ public: // must be public to make Q_GADGET introspection work binding_or_objectdefinition, // after an identifier - binding_assignment, // after : + binding_assignment, // after : in a binding + property_initializer, // after : in a property objectdefinition_open, // after { expression, |