Fix analyze --watch command iterator (#96264)

This commit is contained in:
Jenn Magder
2022-01-07 17:15:08 -08:00
committed by GitHub
parent 7ab50d64af
commit db5c71f448
2 changed files with 86 additions and 15 deletions

View File

@@ -110,27 +110,29 @@ class AnalyzeContinuously extends AnalyzeBase {
logger.printStatus(terminal.clearScreen(), newline: false);
// Remove errors for deleted files, sort, and print errors.
final List<AnalysisError> errors = <AnalysisError>[];
final List<AnalysisError> sortedErrors = <AnalysisError>[];
final List<String> pathsToRemove = <String>[];
analysisErrors.forEach((String path, List<AnalysisError> errors) {
if (fileSystem.isFileSync(path)) {
errors.addAll(errors);
sortedErrors.addAll(errors);
} else {
analysisErrors.remove(path);
pathsToRemove.add(path);
}
});
analysisErrors.removeWhere((String path, _) => pathsToRemove.contains(path));
errors.sort();
sortedErrors.sort();
for (final AnalysisError error in errors) {
for (final AnalysisError error in sortedErrors) {
logger.printStatus(error.toString());
if (error.code != null) {
logger.printTrace('error code: ${error.code}');
}
}
dumpErrors(errors.map<String>((AnalysisError error) => error.toLegacyString()));
dumpErrors(sortedErrors.map<String>((AnalysisError error) => error.toLegacyString()));
final int issueCount = errors.length;
final int issueCount = sortedErrors.length;
final int issueDiff = issueCount - lastErrorCount;
lastErrorCount = issueCount;
final String seconds = (analysisTimer.elapsedMilliseconds / 1000.0).toStringAsFixed(2);