Index: pkg/analysis_server/test/services/correction/fix_test.dart |
diff --git a/pkg/analysis_server/test/services/correction/fix_test.dart b/pkg/analysis_server/test/services/correction/fix_test.dart |
index f128f88fc1462b86c22ad632f9bbe9d25551e547..53b0d4a27b3441ad6ec587a641a4c74fe014488d 100644 |
--- a/pkg/analysis_server/test/services/correction/fix_test.dart |
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart |
@@ -466,6 +466,179 @@ main() { |
target: '/test.dart'); |
} |
+ test_addMissingRequiredArg_cons_single_closure() async { |
+ _addMetaPackageSource(); |
+ |
+ addSource( |
+ '/libA.dart', |
+ r''' |
+library libA; |
+import 'package:meta/meta.dart'; |
+ |
+typedef void VoidCallback(); |
+ |
+class A { |
+ A({@required VoidCallback onPressed}) {} |
+} |
+'''); |
+ |
+ await resolveTestUnit(''' |
+import 'libA.dart'; |
+ |
+main() { |
+ A a = new A(); |
+} |
+'''); |
+ await assertHasFix( |
+ DartFixKind.ADD_MISSING_REQUIRED_ARGUMENT, |
+ ''' |
+import 'libA.dart'; |
+ |
+main() { |
+ A a = new A(onPressed: () {}); |
+} |
+''', |
+ target: '/test.dart'); |
+ } |
+ |
+ test_addMissingRequiredArg_cons_single_closure_2() async { |
+ _addMetaPackageSource(); |
+ |
+ addSource( |
+ '/libA.dart', |
+ r''' |
+library libA; |
+import 'package:meta/meta.dart'; |
+ |
+typedef void Callback(e); |
+ |
+class A { |
+ A({@required Callback callback}) {} |
+} |
+'''); |
+ |
+ await resolveTestUnit(''' |
+import 'libA.dart'; |
+ |
+main() { |
+ A a = new A(); |
+} |
+'''); |
+ await assertHasFix( |
+ DartFixKind.ADD_MISSING_REQUIRED_ARGUMENT, |
+ ''' |
+import 'libA.dart'; |
+ |
+main() { |
+ A a = new A(callback: (e) {}); |
+} |
+''', |
+ target: '/test.dart'); |
+ } |
+ |
+ test_addMissingRequiredArg_cons_single_closure_3() async { |
+ _addMetaPackageSource(); |
+ |
+ addSource( |
+ '/libA.dart', |
+ r''' |
+library libA; |
+import 'package:meta/meta.dart'; |
+ |
+typedef void Callback(a,b,c); |
+ |
+class A { |
+ A({@required Callback callback}) {} |
+} |
+'''); |
+ |
+ await resolveTestUnit(''' |
+import 'libA.dart'; |
+ |
+main() { |
+ A a = new A(); |
+} |
+'''); |
+ await assertHasFix( |
+ DartFixKind.ADD_MISSING_REQUIRED_ARGUMENT, |
+ ''' |
+import 'libA.dart'; |
+ |
+main() { |
+ A a = new A(callback: (a, b, c) {}); |
+} |
+''', |
+ target: '/test.dart'); |
+ } |
+ |
+ test_addMissingRequiredArg_cons_single_closure_4() async { |
+ _addMetaPackageSource(); |
+ |
+ addSource( |
+ '/libA.dart', |
+ r''' |
+library libA; |
+import 'package:meta/meta.dart'; |
+ |
+typedef int Callback(a,b,c); |
+ |
+class A { |
+ A({@required Callback callback}) {} |
+} |
+'''); |
+ |
+ await resolveTestUnit(''' |
+import 'libA.dart'; |
+ |
+main() { |
+ A a = new A(); |
+} |
+'''); |
+ await assertHasFix( |
+ DartFixKind.ADD_MISSING_REQUIRED_ARGUMENT, |
+ ''' |
+import 'libA.dart'; |
+ |
+main() { |
+ A a = new A(callback: (a, b, c) {}); |
+} |
+''', |
+ target: '/test.dart'); |
+ } |
+ |
+ test_addMissingRequiredArg_cons_single_list() async { |
+ _addMetaPackageSource(); |
+ |
+ addSource( |
+ '/libA.dart', |
+ r''' |
+library libA; |
+import 'package:meta/meta.dart'; |
+ |
+class A { |
+ A({@required List<String> names}) {} |
+} |
+'''); |
+ |
+ await resolveTestUnit(''' |
+import 'libA.dart'; |
+ |
+main() { |
+ A a = new A(); |
+} |
+'''); |
+ await assertHasFix( |
+ DartFixKind.ADD_MISSING_REQUIRED_ARGUMENT, |
+ ''' |
+import 'libA.dart'; |
+ |
+main() { |
+ A a = new A(names: <String>[]); |
+} |
+''', |
+ target: '/test.dart'); |
+ } |
+ |
test_addMissingRequiredArg_multiple() async { |
_addMetaPackageSource(); |