Skip to content

Commit 7adb2db

Browse files
authored
Format "super." parameters. (#1097)
Fix #1091.
1 parent c8ed552 commit 7adb2db

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* Format named arguments anywhere (#1072).
44
* Format enhanced enums (#1075).
5+
* Format "super." parameters (#1091).
56

67
# 2.2.1
78

lib/src/source_visitor.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2584,6 +2584,21 @@ class SourceVisitor extends ThrowingAstVisitor {
25842584
token(node.superKeyword);
25852585
}
25862586

2587+
@override
2588+
void visitSuperFormalParameter(SuperFormalParameter node) {
2589+
visitParameterMetadata(node.metadata, () {
2590+
_beginFormalParameter(node);
2591+
token(node.keyword, after: space);
2592+
visit(node.type, after: split);
2593+
token(node.superKeyword);
2594+
token(node.period);
2595+
visit(node.identifier);
2596+
visit(node.parameters);
2597+
token(node.question);
2598+
_endFormalParameter(node);
2599+
});
2600+
}
2601+
25872602
@override
25882603
void visitSwitchCase(SwitchCase node) {
25892604
_visitLabels(node.labels);

test/whitespace/constructors.unit

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,26 @@ class Foo {
6868
<<<
6969
class Foo {
7070
Foo(this.bar(), baz);
71+
}
72+
>>> "super." parameters
73+
class Foo {
74+
Foo(super . a, int super . b , int super . bar());
75+
Foo.optional([ super . a, int super . b = 123 , int super . bar() ]);
76+
Foo.named({ required super . a, int super . b : 123 , required int super . bar() });
77+
Foo.other( final int super.x, super.bar() ? );
78+
}
79+
<<<
80+
class Foo {
81+
Foo(super.a, int super.b,
82+
int super.bar());
83+
Foo.optional(
84+
[super.a,
85+
int super.b = 123,
86+
int super.bar()]);
87+
Foo.named(
88+
{required super.a,
89+
int super.b: 123,
90+
required int super.bar()});
91+
Foo.other(
92+
final int super.x, super.bar()?);
7193
}

test/whitespace/metadata.unit

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,15 @@ class Foo {
209209
class Foo {
210210
Foo(@bar this.field);
211211
}
212+
>>> metadata on "super." parameter
213+
class Foo {
214+
Foo(@bar super.field, [ @foo() @baz super.another ]);
215+
}
216+
<<<
217+
class Foo {
218+
Foo(@bar super.field,
219+
[@foo() @baz super.another]);
220+
}
212221
>>> metadata on function-typed formal parameter
213222
withReturnType(@foo @bar int fn(@foo param)) {}
214223
withoutReturnType(@foo @bar fn(@foo param)) {}

0 commit comments

Comments
 (0)