forked from qt-creator/qt-creator
qml | Add support for enums formatting
Change-Id: Id7e435a7c556c7fc469b9055ca772a7850e16676 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
selatnick
parent
69cd74f25d
commit
ab87bdf4ea
@@ -534,6 +534,37 @@ protected:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool visit(UiEnumDeclaration *ast) override
|
||||||
|
{
|
||||||
|
out(ast->enumToken);
|
||||||
|
out(" ");
|
||||||
|
out(ast->name.toString());
|
||||||
|
out(" ");
|
||||||
|
out("{"); // TODO: out(ast->lbraceToken);
|
||||||
|
newLine();
|
||||||
|
|
||||||
|
accept(ast->members);
|
||||||
|
|
||||||
|
out(ast->rbraceToken);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool visit(UiEnumMemberList *list) override
|
||||||
|
{
|
||||||
|
for (UiEnumMemberList *it = list; it; it = it->next) {
|
||||||
|
out(it->memberToken);
|
||||||
|
if (it->valueToken.isValid()) {
|
||||||
|
out(" = ");
|
||||||
|
out(it->valueToken);
|
||||||
|
}
|
||||||
|
if (it->next) {
|
||||||
|
out(",");
|
||||||
|
}
|
||||||
|
newLine();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool visit(UiImport *ast) override
|
bool visit(UiImport *ast) override
|
||||||
{
|
{
|
||||||
out("import ", ast->importToken);
|
out("import ", ast->importToken);
|
||||||
|
14
tests/auto/qml/reformatter/enum.qml
Normal file
14
tests/auto/qml/reformatter/enum.qml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import QtQuick 2.0
|
||||||
|
|
||||||
|
Item {
|
||||||
|
enum Test {
|
||||||
|
A,
|
||||||
|
B
|
||||||
|
}
|
||||||
|
|
||||||
|
enum TestWithValues {
|
||||||
|
A = 11.1,
|
||||||
|
B,
|
||||||
|
C = 3
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user