mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 11:58:13 +00:00
Migrator: Do not overflow progress bar, or print warnings before ticks
Fixes https://github.com/dart-lang/sdk/issues/43752 Change-Id: I538b283b1cabe2b2212ada30317c14e76e182a06 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170562 Reviewed-by: Paul Berry <paulberry@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
parent
e8c8e51139
commit
d01694d8aa
|
@ -4,6 +4,7 @@
|
|||
|
||||
import 'dart:async';
|
||||
import 'dart:convert' show jsonDecode;
|
||||
import 'dart:math';
|
||||
import 'dart:io' hide File;
|
||||
|
||||
import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
|
||||
|
@ -1124,14 +1125,14 @@ class _FixCodeProcessor extends Object {
|
|||
}
|
||||
|
||||
Future<AnalysisResult> runFirstPhase() async {
|
||||
// All tasks should be registered; [numPhases] should be finalized.
|
||||
_progressBar = _ProgressBar(_migrationCli.logger, pathsToProcess.length);
|
||||
|
||||
// Process package
|
||||
_task.processPackage(context.contextRoot.root);
|
||||
|
||||
var analysisErrors = <AnalysisError>[];
|
||||
|
||||
// All tasks should be registered; [numPhases] should be finalized.
|
||||
_progressBar = _ProgressBar(_migrationCli.logger, pathsToProcess.length);
|
||||
|
||||
// Process each source file.
|
||||
await processResources((ResolvedUnitResult result) async {
|
||||
_progressBar.tick();
|
||||
|
@ -1269,7 +1270,8 @@ class _ProgressBar {
|
|||
return;
|
||||
}
|
||||
_tickCount++;
|
||||
var fractionComplete = _tickCount * _innerWidth ~/ _totalTickCount - 1;
|
||||
var fractionComplete =
|
||||
max(0, _tickCount * _innerWidth ~/ _totalTickCount - 1);
|
||||
var remaining = _innerWidth - fractionComplete - 1;
|
||||
_logger.write('\r[' + // Bring cursor back to the start of the line.
|
||||
'-' * fractionComplete + // Print complete work.
|
||||
|
|
Loading…
Reference in a new issue