From 758e5ea5025a30bada47d029898206a3f7e79286 Mon Sep 17 00:00:00 2001 From: Konstantin Shcheglov Date: Thu, 2 Aug 2018 19:34:52 +0000 Subject: [PATCH] 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 Commit-Queue: Konstantin Shcheglov --- .../test/services/correction/fix_test.dart | 6 +++--- .../utilities/change_builder/change_builder_dart.dart | 6 +----- .../change_builder/change_builder_dart_test.dart | 10 ++++++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/pkg/analysis_server/test/services/correction/fix_test.dart b/pkg/analysis_server/test/services/correction/fix_test.dart index 9845594ff129..da017ea00160 100644 --- a/pkg/analysis_server/test/services/correction/fix_test.dart +++ b/pkg/analysis_server/test/services/correction/fix_test.dart @@ -3852,7 +3852,7 @@ abstract class A { String m3(int p1, double p2, Map> p3); String m4(p1, p2); String m5(p1, [int p2 = 2, int p3, p4 = 4]); - String m6(p1, {int p2: 2, int p3, p4: 4}); + String m6(p1, {int p2 = 2, int p3, p4: 4}); } class B extends A { @@ -3865,7 +3865,7 @@ abstract class A { String m3(int p1, double p2, Map> p3); String m4(p1, p2); String m5(p1, [int p2 = 2, int p3, p4 = 4]); - String m6(p1, {int p2: 2, int p3, p4: 4}); + String m6(p1, {int p2 = 2, int p3, p4: 4}); } class B extends A { @@ -3895,7 +3895,7 @@ class B extends A { } @override - String m6(p1, {int p2: 2, int p3, p4: 4}) { + String m6(p1, {int p2 = 2, int p3, p4 = 4}) { // TODO: implement m6 } } diff --git a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart index 09e34b0fb776..05d094dc6ce2 100644 --- a/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart +++ b/pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart @@ -573,11 +573,7 @@ class DartEditBuilderImpl extends EditBuilderImpl implements DartEditBuilder { // default value String defaultCode = parameter.defaultValueCode; if (defaultCode != null) { - if (sawPositional) { - write(' = '); - } else { - write(': '); - } + write(' = '); write(defaultCode); } } diff --git a/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart b/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart index 9223ae448b9c..500aa98347ac 100644 --- a/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart +++ b/pkg/analyzer_plugin/test/src/utilities/change_builder/change_builder_dart_test.dart @@ -1514,7 +1514,7 @@ class A {} test_writeParameters_named() async { String path = provider.convertPath('/test.dart'); - String content = 'f(int i, {String s}) {}'; + String content = 'f(int a, {bool b = false, String c}) {}'; addSource(path, content); CompilationUnit unit = (await driver.getResult(path))?.unit; @@ -1530,12 +1530,13 @@ class A {} }); }); SourceEdit edit = getEdit(builder); - expect(edit.replacement, equalsIgnoringWhitespace('(int i, {String s})')); + expect(edit.replacement, + equalsIgnoringWhitespace('(int a, {bool b = false, String c})')); } test_writeParameters_positional() async { String path = provider.convertPath('/test.dart'); - String content = 'f(int i, [String s]) {}'; + String content = 'f(int a, [bool b = false, String c]) {}'; addSource(path, content); CompilationUnit unit = (await driver.getResult(path))?.unit; FunctionDeclaration f = unit.declarations[0]; @@ -1550,7 +1551,8 @@ class A {} }); }); SourceEdit edit = getEdit(builder); - expect(edit.replacement, equalsIgnoringWhitespace('(int i, [String s])')); + expect(edit.replacement, + equalsIgnoringWhitespace('(int a, [bool b = false, String c])')); } test_writeParameters_required() async {