Skip to content

Commit 758e5ea

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Use '=' for default values of named parameters.
R=brianwilkerson@google.com Change-Id: I694c9e411fc125ae7b716d0f8b9e78c5cac57e34 Reviewed-on: https://dart-review.googlesource.com/68180 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
1 parent f625490 commit 758e5ea

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

pkg/analysis_server/test/services/correction/fix_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3852,7 +3852,7 @@ abstract class A {
38523852
String m3(int p1, double p2, Map<int, List<String>> p3);
38533853
String m4(p1, p2);
38543854
String m5(p1, [int p2 = 2, int p3, p4 = 4]);
3855-
String m6(p1, {int p2: 2, int p3, p4: 4});
3855+
String m6(p1, {int p2 = 2, int p3, p4: 4});
38563856
}
38573857
38583858
class B extends A {
@@ -3865,7 +3865,7 @@ abstract class A {
38653865
String m3(int p1, double p2, Map<int, List<String>> p3);
38663866
String m4(p1, p2);
38673867
String m5(p1, [int p2 = 2, int p3, p4 = 4]);
3868-
String m6(p1, {int p2: 2, int p3, p4: 4});
3868+
String m6(p1, {int p2 = 2, int p3, p4: 4});
38693869
}
38703870
38713871
class B extends A {
@@ -3895,7 +3895,7 @@ class B extends A {
38953895
}
38963896
38973897
@override
3898-
String m6(p1, {int p2: 2, int p3, p4: 4}) {
3898+
String m6(p1, {int p2 = 2, int p3, p4 = 4}) {
38993899
// TODO: implement m6
39003900
}
39013901
}

pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -573,11 +573,7 @@ class DartEditBuilderImpl extends EditBuilderImpl implements DartEditBuilder {
573573
// default value
574574
String defaultCode = parameter.defaultValueCode;
575575
if (defaultCode != null) {
576-
if (sawPositional) {
577-
write(' = ');
578-
} else {
579-
write(': ');
580-
}
576+
write(' = ');
581577
write(defaultCode);
582578
}
583579
}

pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ class A {}
15141514

15151515
test_writeParameters_named() async {
15161516
String path = provider.convertPath('/test.dart');
1517-
String content = 'f(int i, {String s}) {}';
1517+
String content = 'f(int a, {bool b = false, String c}) {}';
15181518
addSource(path, content);
15191519

15201520
CompilationUnit unit = (await driver.getResult(path))?.unit;
@@ -1530,12 +1530,13 @@ class A {}
15301530
});
15311531
});
15321532
SourceEdit edit = getEdit(builder);
1533-
expect(edit.replacement, equalsIgnoringWhitespace('(int i, {String s})'));
1533+
expect(edit.replacement,
1534+
equalsIgnoringWhitespace('(int a, {bool b = false, String c})'));
15341535
}
15351536

15361537
test_writeParameters_positional() async {
15371538
String path = provider.convertPath('/test.dart');
1538-
String content = 'f(int i, [String s]) {}';
1539+
String content = 'f(int a, [bool b = false, String c]) {}';
15391540
addSource(path, content);
15401541
CompilationUnit unit = (await driver.getResult(path))?.unit;
15411542
FunctionDeclaration f = unit.declarations[0];
@@ -1550,7 +1551,8 @@ class A {}
15501551
});
15511552
});
15521553
SourceEdit edit = getEdit(builder);
1553-
expect(edit.replacement, equalsIgnoringWhitespace('(int i, [String s])'));
1554+
expect(edit.replacement,
1555+
equalsIgnoringWhitespace('(int a, [bool b = false, String c])'));
15541556
}
15551557

15561558
test_writeParameters_required() async {

0 commit comments

Comments
 (0)