@@ -15,6 +15,7 @@ import 'package:analyzer/file_system/file_system.dart'
1515import 'package:analyzer/file_system/physical_file_system.dart' ;
1616import 'package:analyzer/src/dart/analysis/analysis_context_collection.dart' ;
1717import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart' ;
18+ import 'package:analyzer/src/dart/analysis/experiments.dart' ;
1819import 'package:analyzer/src/error/codes.dart' ;
1920import 'package:analyzer/src/generated/source.dart' ;
2021import '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\n The 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