QmlJS indenter: Fix ternary multiline indent.

Task-number: QTCREATORBUG-6208
Change-Id: I7e5267291bc01226b5339cb4abdbb15856c58477
Reviewed-by: Leandro T. C. Melo <leandro.melo@nokia.com>
This commit is contained in:
Christian Kamm
2011-10-14 12:52:42 +02:00
parent 29dff7221d
commit ea24106373
4 changed files with 37 additions and 18 deletions

View File

@@ -258,6 +258,14 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
default: enter(expression); continue;
} break;
case ternary_op:
if (kind == Colon) {
enter(ternary_op_after_colon);
enter(expression_continuation);
break;
}
// fallthrough
case ternary_op_after_colon:
case expression:
if (tryInsideExpression())
break;
@@ -332,18 +340,6 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
default: leave(); continue;
} break;
case ternary_op:
if (tryInsideExpression())
break;
switch (kind) {
case RightParenthesis:
case RightBracket:
case RightBrace:
case Comma:
case Semicolon: leave(); continue;
case Colon: enter(expression); break; // entering expression makes maybe_continuation work
} break;
case jsblock_open:
case substatement_open:
if (tryStatement())
@@ -494,7 +490,8 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
// some states might be continued on the next line
if (topState == expression
|| topState == expression_or_objectdefinition
|| topState == objectliteral_assignment) {
|| topState == objectliteral_assignment
|| topState == ternary_op_after_colon) {
enter(expression_maybe_continuation);
}
// multi-line comment start?

View File

@@ -145,6 +145,7 @@ public: // must be public to make Q_GADGET introspection work
bracket_element_maybe_objectdefinition, // after an identifier in bracket_element_start
ternary_op, // The ? : operator
ternary_op_after_colon, // after the : in a ternary
jsblock_open,