@@ -1181,6 +1181,25 @@ class SourceVisitor extends ThrowingAstVisitor {
1181
1181
});
1182
1182
}
1183
1183
1184
+ visitGenericFunctionType (GenericFunctionType node) {
1185
+ visit (node.returnType, after: space);
1186
+ token (node.functionKeyword);
1187
+ _visitParameterSignature (node.typeParameters, node.parameters);
1188
+ }
1189
+
1190
+ visitGenericTypeAlias (GenericTypeAlias node) {
1191
+ visitNodes (node.metadata, between: newline, after: newline);
1192
+ _simpleStatement (node, () {
1193
+ token (node.typedefKeyword);
1194
+ space ();
1195
+ visit (node.name);
1196
+ space ();
1197
+ token (node.equals);
1198
+ space ();
1199
+ visit (node.functionType);
1200
+ });
1201
+ }
1202
+
1184
1203
visitHideCombinator (HideCombinator node) {
1185
1204
_visitCombinator (node.keyword, node.hiddenNames);
1186
1205
}
@@ -1555,7 +1574,14 @@ class SourceVisitor extends ThrowingAstVisitor {
1555
1574
builder.nestExpression ();
1556
1575
modifier (node.covariantKeyword);
1557
1576
modifier (node.keyword);
1558
- visit (node.type, after: split);
1577
+
1578
+ visit (node.type);
1579
+
1580
+ // In function declarations and the old typedef syntax, you can have a
1581
+ // parameter name without a type. In the new syntax, you can have a type
1582
+ // without a name. Handle both cases.
1583
+ if (node.type != null && node.identifier != null ) split ();
1584
+
1559
1585
visit (node.identifier);
1560
1586
builder.unnest ();
1561
1587
builder.endRule ();
@@ -2016,6 +2042,18 @@ class SourceVisitor extends ThrowingAstVisitor {
2016
2042
builder.startLazyRule (new Rule (Cost .arrow));
2017
2043
}
2018
2044
2045
+ _visitParameterSignature (typeParameters, parameters);
2046
+
2047
+ if (beforeBody != null ) beforeBody ();
2048
+ visit (body);
2049
+
2050
+ if (body is ExpressionFunctionBody ) builder.unnest ();
2051
+ }
2052
+
2053
+ /// Visits the type parameters (if any) and formal parameters of a method
2054
+ /// declaration, function declaration, or generic function type.
2055
+ void _visitParameterSignature (TypeParameterList typeParameters,
2056
+ FormalParameterList parameters) {
2019
2057
// Start the nesting for the parameters here, so they wrap around the
2020
2058
// type parameters too, if any.
2021
2059
builder.nestExpression ();
@@ -2026,11 +2064,6 @@ class SourceVisitor extends ThrowingAstVisitor {
2026
2064
}
2027
2065
2028
2066
builder.unnest ();
2029
-
2030
- if (beforeBody != null ) beforeBody ();
2031
- visit (body);
2032
-
2033
- if (body is ExpressionFunctionBody ) builder.unnest ();
2034
2067
}
2035
2068
2036
2069
/// Visits the body statement of a `for` , `for in` , or `while` loop.
0 commit comments