Skip to content
Snippets Groups Projects
Commit 0df59335 authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS indenter: Fix wrong indentation after list<> typed properties.


Task-number: QTCREATORBUG-7726
Change-Id: If709a9a71cfed69e2f14af92c114f79d11d03145
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent b17e944d
No related branches found
No related tags found
No related merge requests found
...@@ -198,18 +198,18 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block) ...@@ -198,18 +198,18 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
switch (kind) { switch (kind) {
case Colon: enter(binding_assignment); break; // oops, was a binding case Colon: enter(binding_assignment); break; // oops, was a binding
case Var: case Var:
case Identifier: enter(property_type); break; case Identifier: enter(property_name); break;
case List: enter(property_list_open); break; case List: enter(property_list_open); break;
default: leave(true); continue; default: leave(true); continue;
} break; } break;
case property_type: case property_name:
turnInto(property_maybe_initializer); turnInto(property_maybe_initializer);
break; break;
case property_list_open: case property_list_open:
if (m_currentLine.midRef(m_currentToken.begin(), m_currentToken.length) == QLatin1String(">")) if (m_currentLine.midRef(m_currentToken.begin(), m_currentToken.length) == QLatin1String(">"))
turnInto(property_maybe_initializer); turnInto(property_name);
break; break;
case property_maybe_initializer: case property_maybe_initializer:
...@@ -939,7 +939,7 @@ CodeFormatter::TokenKind CodeFormatter::extendedTokenKind(const QmlJS::Token &to ...@@ -939,7 +939,7 @@ CodeFormatter::TokenKind CodeFormatter::extendedTokenKind(const QmlJS::Token &to
if (text == "on") if (text == "on")
return On; return On;
if (text == "list") if (text == "list")
return On; return List;
} else if (kind == Keyword) { } else if (kind == Keyword) {
const QChar char1 = text.at(0); const QChar char1 = text.at(0);
const QChar char2 = text.at(1); const QChar char2 = text.at(1);
......
...@@ -110,9 +110,9 @@ public: // must be public to make Q_GADGET introspection work ...@@ -110,9 +110,9 @@ public: // must be public to make Q_GADGET introspection work
property_start, // after 'property' property_start, // after 'property'
default_property_start, // after 'default' default_property_start, // after 'default'
property_type, // after first identifier
property_list_open, // after 'list' as a type property_list_open, // after 'list' as a type
property_maybe_initializer, // after property_name, // after the type
property_maybe_initializer, // after the identifier
signal_start, // after 'signal' signal_start, // after 'signal'
signal_maybe_arglist, // after identifier signal_maybe_arglist, // after identifier
......
...@@ -108,6 +108,7 @@ private Q_SLOTS: ...@@ -108,6 +108,7 @@ private Q_SLOTS:
void multilineString(); void multilineString();
void bug1(); void bug1();
void bug2(); void bug2();
void bug3();
}; };
enum { DontCheck = -2, DontIndent = -1 }; enum { DontCheck = -2, DontIndent = -1 };
...@@ -1557,6 +1558,21 @@ void tst_QMLCodeFormatter::bug2() ...@@ -1557,6 +1558,21 @@ void tst_QMLCodeFormatter::bug2()
checkIndent(data); checkIndent(data);
} }
void tst_QMLCodeFormatter::bug3()
{
QList<Line> data;
data << Line("Item {")
<< Line(" property list<Item> foo")
<< Line(" function f() {")
<< Line(" if (1 > 0) {")
<< Line(" foo = 1")
<< Line(" }")
<< Line(" }")
<< Line("}")
;
checkIndent(data);
}
QTEST_APPLESS_MAIN(tst_QMLCodeFormatter) QTEST_APPLESS_MAIN(tst_QMLCodeFormatter)
#include "tst_qmlcodeformatter.moc" #include "tst_qmlcodeformatter.moc"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment