Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 7d994c1

Browse files
devoncarewcommit-bot@chromium.org
authored andcommitted
Add a migration tool notice for TP2.
Change-Id: I3f882bc47c372e196186d6c9c539cc572d406f43 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167620 Reviewed-by: Samuel Rawlins <srawlins@google.com> Commit-Queue: Devon Carew <devoncarew@google.com>
1 parent 4a6e2ae commit 7d994c1

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

pkg/nnbd_migration/lib/migration_cli.dart

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import 'package:analyzer/file_system/file_system.dart'
1515
import 'package:analyzer/file_system/physical_file_system.dart';
1616
import 'package:analyzer/src/dart/analysis/analysis_context_collection.dart';
1717
import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart';
18+
import 'package:analyzer/src/dart/analysis/experiments.dart';
1819
import 'package:analyzer/src/error/codes.dart';
1920
import 'package:analyzer/src/generated/source.dart';
2021
import 'package:analyzer/src/util/sdk.dart';
@@ -223,9 +224,19 @@ class MigrateCommand extends Command<dynamic> {
223224
static const String cmdName = 'migrate';
224225

225226
static const String cmdDescription =
226-
'Perform a null safety migration on a project or package.'
227-
'\n\nThe migration tool is in preview; see '
228-
'https://dart.dev/go/null-safety-migration for a migration guide.';
227+
'Perform a null safety migration on a project or package.';
228+
229+
static const String migrationGuideLink =
230+
'See https://dart.dev/go/null-safety-migration for a migration guide.';
231+
232+
static const String preFlagFlipCaveat =
233+
'Note: this tool is currently running on an SDK version where null '
234+
'safety is not yet enabled by default. You may encounter issues in the '
235+
'migration process - some aspects of the toolchain assume that they are '
236+
'running on an SDK where null safety has been enabled by default.';
237+
238+
/// Return whether the SDK has null safety on by default.
239+
static bool get nullSafetyOnByDefault => IsEnabledByDefault.non_nullable;
229240

230241
final bool verbose;
231242

@@ -247,7 +258,9 @@ class MigrateCommand extends Command<dynamic> {
247258
}
248259

249260
@override
250-
String get description => cmdDescription;
261+
String get description => nullSafetyOnByDefault
262+
? '$cmdDescription\n\n$migrationGuideLink'
263+
: '$cmdDescription\n\n$preFlagFlipCaveat\n\n$migrationGuideLink';
251264

252265
@override
253266
String get invocation {
@@ -726,10 +739,17 @@ class MigrationCliRunner {
726739
logger.stdout('Migrating ${options.directory}');
727740
logger.stdout('');
728741

742+
if (!MigrateCommand.nullSafetyOnByDefault) {
743+
logger.stdout(MigrateCommand.preFlagFlipCaveat);
744+
logger.stdout('');
745+
}
746+
747+
logger.stdout(MigrateCommand.migrationGuideLink);
748+
logger.stdout('');
749+
729750
if (hasMultipleAnalysisContext) {
730-
logger
731-
.stdout('Note: more than one project found; migrating the top-level '
732-
'project.');
751+
logger.stdout('Note: more than one project found; migrating the '
752+
'top-level project.');
733753
logger.stdout('');
734754
}
735755

0 commit comments

Comments
 (0)