forked from qt-creator/qt-creator
qmljs: reformat inline components
Fixes: QTCREATORBUG-25381 Change-Id: I472105cd6436d4d0ae7369880c332b8f4a2321ad Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
@@ -218,6 +218,12 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
|
|||||||
default: leave(true); continue;
|
default: leave(true); continue;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case component_start:
|
||||||
|
switch (kind) {
|
||||||
|
case Identifier: turnInto(StateType::component_name); break;
|
||||||
|
default: leave(true); continue;
|
||||||
|
} break;
|
||||||
|
|
||||||
case property_name:
|
case property_name:
|
||||||
turnInto(property_maybe_initializer);
|
turnInto(property_maybe_initializer);
|
||||||
break;
|
break;
|
||||||
@@ -957,6 +963,8 @@ CodeFormatter::TokenKind CodeFormatter::extendedTokenKind(const QmlJS::Token &to
|
|||||||
return Property;
|
return Property;
|
||||||
if (text == QLatin1String("readonly"))
|
if (text == QLatin1String("readonly"))
|
||||||
return Readonly;
|
return Readonly;
|
||||||
|
if (text == QLatin1String("component"))
|
||||||
|
return Component;
|
||||||
if (text == QLatin1String("required"))
|
if (text == QLatin1String("required"))
|
||||||
return Required;
|
return Required;
|
||||||
if (text == QLatin1String("on"))
|
if (text == QLatin1String("on"))
|
||||||
|
@@ -109,6 +109,8 @@ public: // must be public to make Q_GADGET introspection work
|
|||||||
property_list_open, // after 'list' as a type
|
property_list_open, // after 'list' as a type
|
||||||
property_name, // after the type
|
property_name, // after the type
|
||||||
property_maybe_initializer, // after the identifier
|
property_maybe_initializer, // after the identifier
|
||||||
|
component_start, // after component
|
||||||
|
component_name, // after component Name
|
||||||
|
|
||||||
enum_start, // after 'enum'
|
enum_start, // after 'enum'
|
||||||
|
|
||||||
@@ -239,6 +241,7 @@ protected:
|
|||||||
List,
|
List,
|
||||||
Property,
|
Property,
|
||||||
Required,
|
Required,
|
||||||
|
Component,
|
||||||
Readonly,
|
Readonly,
|
||||||
|
|
||||||
Question,
|
Question,
|
||||||
|
@@ -598,6 +598,15 @@ protected:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool visit(UiInlineComponent *ast) override
|
||||||
|
{
|
||||||
|
out(ast->componentToken);
|
||||||
|
out(" ");
|
||||||
|
out(ast->name.toString());
|
||||||
|
out(": ");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool visit(UiObjectDefinition *ast) override
|
bool visit(UiObjectDefinition *ast) override
|
||||||
{
|
{
|
||||||
accept(ast->qualifiedTypeNameId);
|
accept(ast->qualifiedTypeNameId);
|
||||||
|
8
tests/auto/qml/reformatter/inline.qml
Normal file
8
tests/auto/qml/reformatter/inline.qml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import QtQuick 2.15
|
||||||
|
|
||||||
|
Item {
|
||||||
|
component CustomText: Text {
|
||||||
|
color: "red"
|
||||||
|
text: "Test Text"
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user