forked from qt-creator/qt-creator
QmlJS: Add support for annotations in qmljsreformatter
This fixes that the annotations are removed. The indentation still has issues. Change-Id: I6752767e00e0fafe8eb567066db3b9952f0d0a4f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -590,14 +590,35 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool visit(UiObjectDefinition *ast) override
|
||||
bool visit(UiAnnotation *ast) override
|
||||
{
|
||||
out("@");
|
||||
accept(ast->qualifiedTypeNameId);
|
||||
out(" ");
|
||||
accept(ast->initializer);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool visit(UiAnnotationList *ast) override
|
||||
{
|
||||
for (UiAnnotationList *it = ast; it; it = it->next) {
|
||||
accept(it->annotation);
|
||||
newLine();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool visit(UiObjectDefinition *ast) override
|
||||
{
|
||||
accept(ast->annotations);
|
||||
|
||||
accept(ast->qualifiedTypeNameId);
|
||||
out(" ");
|
||||
accept(ast->initializer);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool visit(UiObjectInitializer *ast) override
|
||||
{
|
||||
out(ast->lbraceToken);
|
||||
@@ -687,9 +708,12 @@ protected:
|
||||
|
||||
bool visit(UiScriptBinding *ast) override
|
||||
{
|
||||
accept(ast->annotations);
|
||||
|
||||
accept(ast->qualifiedId);
|
||||
out(": ", ast->colonToken);
|
||||
accept(ast->statement);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1290,6 +1314,7 @@ protected:
|
||||
{
|
||||
for (UiObjectMemberList *it = ast; it; it = it->next) {
|
||||
accept(it->member);
|
||||
|
||||
if (it->next)
|
||||
newLine();
|
||||
}
|
||||
|
||||
22
tests/auto/qml/reformatter/annotations.qml
Normal file
22
tests/auto/qml/reformatter/annotations.qml
Normal file
@@ -0,0 +1,22 @@
|
||||
import QtQuick
|
||||
|
||||
@Annotation {}
|
||||
Item {
|
||||
// properties
|
||||
property int foo
|
||||
property alias bar: x
|
||||
@Annotation2 {
|
||||
someproperty: 10
|
||||
}
|
||||
id: someId
|
||||
|
||||
@Annotation3 {
|
||||
someproperty: 10
|
||||
}
|
||||
Rectangle {
|
||||
// properties
|
||||
property int foo
|
||||
property alias bar: x
|
||||
id: someId2
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user