| 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 57ff0c67387c3ee180f65cba8bfe05806d2a09a0..ecbd8803191473ccc177c3bb7f5e759350f43c3f 100644
|
| --- a/pkg/analysis_server/test/services/correction/fix_test.dart
|
| +++ b/pkg/analysis_server/test/services/correction/fix_test.dart
|
| @@ -477,6 +477,48 @@ main() {
|
| ''');
|
| }
|
|
|
| + test_addMissingRequiredArg_multiple_2() async {
|
| + _addMetaPackageSource();
|
| +
|
| + await resolveTestUnit('''
|
| +import 'package:meta/meta.dart';
|
| +
|
| +test({@required int a, @required int bcd}) {}
|
| +main() {
|
| + test();
|
| +}
|
| +''');
|
| +
|
| + // For now we expect one error per missing arg (dartbug.com/28830).
|
| + List<AnalysisError> errors = await _computeErrors();
|
| + expect(errors, hasLength(2));
|
| +
|
| + List<AnalysisError> filteredErrors = errors
|
| + .where((e) => e.message == "The parameter 'a' is required.")
|
| + .toList();
|
| + expect(filteredErrors, hasLength(1));
|
| +
|
| + List<Fix> fixes = await _computeFixes(filteredErrors.first);
|
| +
|
| + List<Fix> filteredFixes = fixes
|
| + .where((fix) => fix.change.message == "Add required argument 'a'")
|
| + .toList();
|
| + expect(filteredFixes, hasLength(1));
|
| + change = filteredFixes.first.change;
|
| + resultCode = SourceEdit.applySequence(testCode, change.edits[0].edits);
|
| + // verify
|
| + expect(
|
| + resultCode,
|
| + '''
|
| +import 'package:meta/meta.dart';
|
| +
|
| +test({@required int a, @required int bcd}) {}
|
| +main() {
|
| + test(a: null);
|
| +}
|
| +''');
|
| + }
|
| +
|
| test_addMissingRequiredArg_single() async {
|
| _addMetaPackageSource();
|
|
|
| @@ -523,6 +565,29 @@ main() {
|
| ''');
|
| }
|
|
|
| + test_addMissingRequiredArg_single_with_details() async {
|
| + _addMetaPackageSource();
|
| +
|
| + await resolveTestUnit('''
|
| +import 'package:meta/meta.dart';
|
| +
|
| +test({@Required("Really who doesn't need an abc?") int abc}) {}
|
| +main() {
|
| + test();
|
| +}
|
| +''');
|
| + await assertHasFix(
|
| + DartFixKind.ADD_MISSING_REQUIRED_ARGUMENT,
|
| + '''
|
| +import 'package:meta/meta.dart';
|
| +
|
| +test({@Required("Really who doesn't need an abc?") int abc}) {}
|
| +main() {
|
| + test(abc: null);
|
| +}
|
| +''');
|
| + }
|
| +
|
| test_addSync_asyncFor() async {
|
| await resolveTestUnit('''
|
| import 'dart:async';
|
| @@ -5434,7 +5499,10 @@ main() {
|
| }
|
|
|
| void _addMetaPackageSource() {
|
| - addPackageSource('meta', 'meta.dart', r'''
|
| + addPackageSource(
|
| + 'meta',
|
| + 'meta.dart',
|
| + r'''
|
| library meta;
|
|
|
| const Required required = const Required();
|
|
|