Format named constructor calls in enum value constructors. (#1443)
diff --git a/lib/src/front_end/ast_node_visitor.dart b/lib/src/front_end/ast_node_visitor.dart
index d6e9c1a..e1fe5d3 100644
--- a/lib/src/front_end/ast_node_visitor.dart
+++ b/lib/src/front_end/ast_node_visitor.dart
@@ -445,6 +445,14 @@
}
@override
+ Piece visitConstructorSelector(ConstructorSelector node) {
+ return buildPiece((b) {
+ b.token(node.period);
+ b.visit(node.name);
+ });
+ }
+
+ @override
Piece visitContinueStatement(ContinueStatement node) {
return createBreak(node.continueKeyword, node.label, node.semicolon);
}
diff --git a/lib/src/front_end/piece_factory.dart b/lib/src/front_end/piece_factory.dart
index 472d610..1182412 100644
--- a/lib/src/front_end/piece_factory.dart
+++ b/lib/src/front_end/piece_factory.dart
@@ -310,6 +310,7 @@
b.token(node.name);
if (node.arguments case var arguments?) {
b.visit(arguments.typeArguments);
+ b.visit(arguments.constructorSelector);
b.visit(arguments.argumentList);
}
diff --git a/test/tall/declaration/enum.unit b/test/tall/declaration/enum.unit
index eb7b73a..82efdf1 100644
--- a/test/tall/declaration/enum.unit
+++ b/test/tall/declaration/enum.unit
@@ -94,6 +94,22 @@
anotherNamed: argumentValue,
),
}
+>>> Named constructor in value.
+enum Things {
+ unsplit.name(argument),
+ private._(argument),
+ splitInArgumentList.longerName(argument),
+ generic<int>.name(argument)
+}
+<<<
+enum Things {
+ unsplit.name(argument),
+ private._(argument),
+ splitInArgumentList.longerName(
+ argument,
+ ),
+ generic<int>.name(argument),
+}
>>> Generic enum type.
enum MagicNumbers< T extends num , S> {
one(1), two(2),pi<double,String>(3.14159)