@@ -425,37 +425,36 @@ class MigrationCli {
425425 List <String > previewUrls;
426426 NonNullableFix nonNullableFix;
427427
428- await _withProgress (
429- '${ansi .emphasized ('Generating migration suggestions' )}' , () async {
430- _fixCodeProcessor = _FixCodeProcessor (context, this );
431- _dartFixListener = DartFixListener (
432- DriverProviderImpl (resourceProvider, context), _exceptionReported);
433- nonNullableFix = createNonNullableFix (
434- _dartFixListener, resourceProvider, _fixCodeProcessor.getLineInfo,
435- included: [options.directory],
436- preferredPort: options.previewPort,
437- summaryPath: options.summary);
438- nonNullableFix.rerunFunction = _rerunFunction;
439- _fixCodeProcessor.registerCodeTask (nonNullableFix);
440- _fixCodeProcessor.nonNullableFixTask = nonNullableFix;
428+ logger.stdout (ansi.emphasized ('Analyzing project...' ));
429+ _fixCodeProcessor = _FixCodeProcessor (context, this );
430+ _dartFixListener = DartFixListener (
431+ DriverProviderImpl (resourceProvider, context), _exceptionReported);
432+ nonNullableFix = createNonNullableFix (
433+ _dartFixListener, resourceProvider, _fixCodeProcessor.getLineInfo,
434+ included: [options.directory],
435+ preferredPort: options.previewPort,
436+ summaryPath: options.summary);
437+ nonNullableFix.rerunFunction = _rerunFunction;
438+ _fixCodeProcessor.registerCodeTask (nonNullableFix);
439+ _fixCodeProcessor.nonNullableFixTask = nonNullableFix;
441440
442- try {
443- // TODO(devoncarew): The progress written by the fix processor conflicts
444- // with the progress written by the ansi logger above.
445- await _fixCodeProcessor.runFirstPhase ();
446- _fixCodeProcessor._progressBar.clear ();
447- _checkForErrors ();
448- } on ExperimentStatusException catch (e) {
449- logger.stdout (e.toString ());
450- final sdkPathVar = _environmentVariables['SDK_PATH' ];
451- if (sdkPathVar != null ) {
452- logger.stdout ('$sdkPathEnvironmentVariableSet : $sdkPathVar ' );
453- }
454- exitCode = 1 ;
441+ try {
442+ await _fixCodeProcessor.runFirstPhase (singlePhaseProgress: true );
443+ _checkForErrors ();
444+ } on ExperimentStatusException catch (e) {
445+ logger.stdout (e.toString ());
446+ final sdkPathVar = _environmentVariables['SDK_PATH' ];
447+ if (sdkPathVar != null ) {
448+ logger.stdout ('$sdkPathEnvironmentVariableSet : $sdkPathVar ' );
455449 }
456- if (exitCode != null ) return ;
457- previewUrls = await _fixCodeProcessor.runLaterPhases ();
458- });
450+ exitCode = 1 ;
451+ }
452+ if (exitCode != null ) return ;
453+
454+ logger.stdout ('' );
455+ logger.stdout (ansi.emphasized ('Generating migration suggestions...' ));
456+ previewUrls = await _fixCodeProcessor.runLaterPhases (resetProgress: true );
457+
459458 if (exitCode != null ) return ;
460459
461460 if (options.applyChanges) {
@@ -491,6 +490,7 @@ Use this interactive web view to review, improve, or apply the results.
491490
492491 logger.stdout ('When finished with the preview, hit ctrl-c '
493492 'to terminate this process.' );
493+ logger.stdout ('' );
494494
495495 // Block until sigint (ctrl-c).
496496 await blockUntilSignalInterrupt ();
@@ -685,6 +685,8 @@ Exception details:
685685 error.errorCode == CompileTimeErrorCode .URI_DOES_NOT_EXIST ;
686686
687687 Future <void > _rerunFunction () async {
688+ logger.stdout (ansi.emphasized ('Recalculating migration suggestions...' ));
689+
688690 _dartFixListener.reset ();
689691 _fixCodeProcessor.prepareToRerun ();
690692 await _fixCodeProcessor.runFirstPhase ();
@@ -715,16 +717,6 @@ Exception details:
715717 return edits;
716718 }
717719
718- Future <void > _withProgress (String message, FutureOr <void > callback ()) async {
719- var progress = logger.progress (message);
720- try {
721- await callback ();
722- progress.finish (showTiming: true );
723- } finally {
724- progress.cancel ();
725- }
726- }
727-
728720 static ArgParser createParser ({bool hide = true }) {
729721 var parser = ArgParser ();
730722 parser.addFlag (CommandLineOptions .helpFlag,
@@ -904,9 +896,10 @@ class _FixCodeProcessor extends Object {
904896 _task = task;
905897 }
906898
907- Future <void > runFirstPhase () async {
899+ Future <void > runFirstPhase ({ bool singlePhaseProgress = false } ) async {
908900 // All tasks should be registered; [numPhases] should be finalized.
909- _progressBar = _ProgressBar (pathsToProcess.length * _task.numPhases);
901+ _progressBar = _ProgressBar (
902+ pathsToProcess.length * (singlePhaseProgress ? 1 : _task.numPhases));
910903
911904 // Process package
912905 _task.processPackage (context.contextRoot.root);
@@ -928,7 +921,12 @@ class _FixCodeProcessor extends Object {
928921 });
929922 }
930923
931- Future <List <String >> runLaterPhases () async {
924+ Future <List <String >> runLaterPhases ({bool resetProgress = false }) async {
925+ if (resetProgress) {
926+ _progressBar =
927+ _ProgressBar (pathsToProcess.length * (_task.numPhases - 1 ));
928+ }
929+
932930 for (var phase = 1 ; phase < _task.numPhases; phase++ ) {
933931 await processResources ((ResolvedUnitResult result) async {
934932 _progressBar.tick ();
0 commit comments