@@ -6,6 +6,7 @@ import 'dart:async';
66import 'dart:io' hide File;
77
88import 'package:analyzer/dart/analysis/analysis_context_collection.dart' ;
9+ import 'package:analyzer/dart/analysis/features.dart' ;
910import 'package:analyzer/dart/analysis/results.dart' ;
1011import 'package:analyzer/diagnostic/diagnostic.dart' ;
1112import 'package:analyzer/error/error.dart' ;
@@ -50,9 +51,10 @@ class AnalysisResult {
5051 final Map <String , LineInfo > lineInfo;
5152 final Context pathContext;
5253 final String rootDirectory;
54+ final bool allSourcesAlreadyMigrated;
5355
54- AnalysisResult (
55- this .errors , this .lineInfo, this .pathContext, this .rootDirectory ) {
56+ AnalysisResult (this .errors, this .lineInfo, this .pathContext,
57+ this .rootDirectory , this .allSourcesAlreadyMigrated ) {
5658 errors.sort ((AnalysisError one, AnalysisError two) {
5759 if (one.source != two.source) {
5860 return one.source.fullName.compareTo (two.source.fullName);
@@ -876,6 +878,14 @@ Exception details:
876878 .stdout ('Unresolved URIs found. Did you forget to run "pub get"?' );
877879 logger.stdout ('' );
878880 }
881+ if (analysisResult.allSourcesAlreadyMigrated) {
882+ logger.stdout ('''
883+ All files appear to have null safety already enabled. Did you update the
884+ language version prior to running "dart migrate"? If so, you need to un-do this
885+ (and re-run "pub get") prior to performing the migration.
886+ ''' );
887+ logger.stdout ('' );
888+ }
879889 logger.stdout (
880890 'Please fix the analysis issues (or, force generation of migration '
881891 'suggestions by re-running with '
@@ -1037,7 +1047,11 @@ class _FixCodeProcessor extends Object {
10371047 _progressBar = ProgressBar (_migrationCli.logger, pathsToProcess.length);
10381048
10391049 // Process each source file.
1050+ bool allSourcesAlreadyMigrated = true ;
10401051 await processResources ((ResolvedUnitResult result) async {
1052+ if (! result.unit.featureSet.isEnabled (Feature .non_nullable)) {
1053+ allSourcesAlreadyMigrated = false ;
1054+ }
10411055 _progressBar.tick ();
10421056 List <AnalysisError > errors = result.errors
10431057 .where ((error) => error.severity == Severity .error)
@@ -1061,8 +1075,12 @@ class _FixCodeProcessor extends Object {
10611075 }
10621076 }
10631077
1064- return AnalysisResult (analysisErrors, _migrationCli.lineInfo,
1065- _migrationCli.pathContext, _migrationCli.options.directory);
1078+ return AnalysisResult (
1079+ analysisErrors,
1080+ _migrationCli.lineInfo,
1081+ _migrationCli.pathContext,
1082+ _migrationCli.options.directory,
1083+ allSourcesAlreadyMigrated);
10661084 }
10671085
10681086 Future <MigrationState > runLaterPhases () async {
0 commit comments