diff --git a/pkg/nnbd_migration/lib/migration_cli.dart b/pkg/nnbd_migration/lib/migration_cli.dart index ee6254ddb7e..9c75be66bf6 100644 --- a/pkg/nnbd_migration/lib/migration_cli.dart +++ b/pkg/nnbd_migration/lib/migration_cli.dart @@ -521,7 +521,10 @@ class _DartFixListener implements DartFixListenerInterface { @override void addSourceFileEdit( String description, Location location, SourceFileEdit fileEdit) { - throw UnimplementedError('TODO(paulberry)'); + suggestions.add(_DartFixSuggestion(description, location: location)); + for (var sourceEdit in fileEdit.edits) { + sourceChange.addEdit(fileEdit.file, fileEdit.fileStamp, sourceEdit); + } } @override @@ -603,7 +606,10 @@ class _FixCodeProcessor extends Object with FixCodeProcessor { } Future runFirstPhase() async { - // TODO(paulberry): do more things from EditDartFix.runAllTasks + // Process package + await processPackage(context.contextRoot.root); + + // Process each source file. await processResources((ResolvedUnitResult result) async { List errors = result.errors .where((error) => error.severity == Severity.error) diff --git a/pkg/nnbd_migration/test/migration_cli_test.dart b/pkg/nnbd_migration/test/migration_cli_test.dart index 35d199743c0..6e9eaa0cbef 100644 --- a/pkg/nnbd_migration/test/migration_cli_test.dart +++ b/pkg/nnbd_migration/test/migration_cli_test.dart @@ -136,12 +136,11 @@ mixin _MigrationCliTestMethods on _MigrationCliTestBase { } Map simpleProject({bool migrated: false, String sourceText}) { - // TODO(paulberry): pubspec needs to be updated when migrating. return { 'pubspec.yaml': ''' name: test environment: -sdk: '>=2.6.0 <3.0.0' + sdk: '${migrated ? '>=2.9.0 <2.10.0' : '>=2.6.0 <3.0.0'}' ''', 'lib/test.dart': sourceText ?? ''' @@ -224,8 +223,9 @@ int${migrated ? '?' : ''} f() => null; await cli.run(['--no-web-preview', '--apply-changes', projectDir]); // Check that a summary was printed expect(logger.stdoutBuffer.toString(), contains('Applying changes')); - // And that it refers to test.dart + // And that it refers to test.dart and pubspec.yaml expect(logger.stdoutBuffer.toString(), contains('test.dart')); + expect(logger.stdoutBuffer.toString(), contains('pubspec.yaml')); // And that it does not tell the user they can rerun with `--apply-changes` expect(logger.stdoutBuffer.toString(), isNot(contains('--apply-changes'))); // Changes should have been made @@ -279,8 +279,9 @@ int? f() => null await cli.run(['--no-web-preview', projectDir]); // Check that a summary was printed expect(logger.stdoutBuffer.toString(), contains('Summary')); - // And that it refers to test.dart + // And that it refers to test.dart and pubspec.yaml expect(logger.stdoutBuffer.toString(), contains('test.dart')); + expect(logger.stdoutBuffer.toString(), contains('pubspec.yaml')); // And that it tells the user they can rerun with `--apply-changes` expect(logger.stdoutBuffer.toString(), contains('--apply-changes')); // No changes should have been made