Analyzer was confused when you deleted files (#4528)
Also, make it clear the screen between results so it's more obvious what's going on when you have new results (especially when you have fixed everything).
This commit is contained in:
parent
1d5d7f4ad3
commit
c9bcf1074e
@ -23,7 +23,7 @@ abstract class Logger {
|
||||
|
||||
/// Display normal output of the command. This should be used for things like
|
||||
/// progress messages, success messages, or just normal command output.
|
||||
void printStatus(String message, { bool emphasis: false });
|
||||
void printStatus(String message, { bool emphasis: false, bool newline: true });
|
||||
|
||||
/// Use this for verbose tracing output. Users can turn this output on in order
|
||||
/// to help diagnose issues with the toolchain or with their setup.
|
||||
@ -58,11 +58,14 @@ class StdoutLogger extends Logger {
|
||||
}
|
||||
|
||||
@override
|
||||
void printStatus(String message, { bool emphasis: false }) {
|
||||
void printStatus(String message, { bool emphasis: false, bool newline: true }) {
|
||||
_status?.cancel();
|
||||
_status = null;
|
||||
|
||||
print(emphasis ? terminal.writeBold(message) : message);
|
||||
if (newline)
|
||||
stdout.writeln(emphasis ? terminal.writeBold(message) : message);
|
||||
else
|
||||
stdout.write(emphasis ? terminal.writeBold(message) : message);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -102,7 +105,12 @@ class BufferLogger extends Logger {
|
||||
void printError(String message, [StackTrace stackTrace]) => _error.writeln(message);
|
||||
|
||||
@override
|
||||
void printStatus(String message, { bool emphasis: false }) => _status.writeln(message);
|
||||
void printStatus(String message, { bool emphasis: false, bool newline: true }) {
|
||||
if (newline)
|
||||
_status.writeln(message);
|
||||
else
|
||||
_status.write(message);
|
||||
}
|
||||
|
||||
@override
|
||||
void printTrace(String message) => _trace.writeln(message);
|
||||
@ -130,7 +138,8 @@ class VerboseLogger extends Logger {
|
||||
}
|
||||
|
||||
@override
|
||||
void printStatus(String message, { bool emphasis: false }) {
|
||||
void printStatus(String message, { bool emphasis: false, bool newline: true }) {
|
||||
// TODO(ianh): We ignore newline and emphasis here.
|
||||
_emit();
|
||||
lastMessage = new _LogMessage(_LogType.status, message);
|
||||
}
|
||||
@ -208,11 +217,14 @@ class AnsiTerminal {
|
||||
|
||||
static const String _bold = '\u001B[1m';
|
||||
static const String _reset = '\u001B[0m';
|
||||
static const String _clear = '\u001B[2J\u001B[H';
|
||||
|
||||
bool supportsColor;
|
||||
|
||||
String writeBold(String str) => supportsColor ? '$_bold$str$_reset' : str;
|
||||
|
||||
String clearScreen() => supportsColor ? _clear : '\n\n';
|
||||
|
||||
set singleCharMode(bool value) {
|
||||
stdin.lineMode = !value;
|
||||
}
|
||||
|
@ -271,30 +271,8 @@ class AnalyzeCommand extends FlutterCommand {
|
||||
return collected;
|
||||
}
|
||||
|
||||
Future<int> _analyzeWatch() async {
|
||||
List<String> directories;
|
||||
|
||||
if (argResults['flutter-repo']) {
|
||||
directories = runner.getRepoPackages().map((Directory dir) => dir.path).toList();
|
||||
printStatus('Analyzing Flutter repository (${directories.length} projects).');
|
||||
for (String projectPath in directories)
|
||||
printTrace(' ${path.relative(projectPath)}');
|
||||
printStatus('');
|
||||
} else {
|
||||
directories = <String>[Directory.current.path];
|
||||
}
|
||||
|
||||
AnalysisServer server = new AnalysisServer(dartSdkPath, directories);
|
||||
server.onAnalyzing.listen((bool isAnalyzing) => _handleAnalysisStatus(server, isAnalyzing));
|
||||
server.onErrors.listen(_handleAnalysisErrors);
|
||||
|
||||
await server.start();
|
||||
|
||||
int exitCode = await server.onExit;
|
||||
printStatus('Analysis server exited with code $exitCode.');
|
||||
return 0;
|
||||
}
|
||||
|
||||
String analysisTarget;
|
||||
bool firstAnalysis = true;
|
||||
Set<String> analyzedPaths = new Set<String>();
|
||||
Map<String, List<AnalysisError>> analysisErrors = <String, List<AnalysisError>>{};
|
||||
@ -302,26 +280,54 @@ class AnalyzeCommand extends FlutterCommand {
|
||||
int lastErrorCount = 0;
|
||||
Status analysisStatus;
|
||||
|
||||
Future<int> _analyzeWatch() async {
|
||||
List<String> directories;
|
||||
|
||||
if (argResults['flutter-repo']) {
|
||||
directories = runner.getRepoAnalysisEntryPoints().map((Directory dir) => dir.path).toList();
|
||||
analysisTarget = 'Flutter repository';
|
||||
printTrace('Analyzing Flutter repository:');
|
||||
for (String projectPath in directories)
|
||||
printTrace(' ${path.relative(projectPath)}');
|
||||
} else {
|
||||
directories = <String>[Directory.current.path];
|
||||
analysisTarget = Directory.current.path;
|
||||
}
|
||||
|
||||
AnalysisServer server = new AnalysisServer(dartSdkPath, directories);
|
||||
server.onAnalyzing.listen((bool isAnalyzing) => _handleAnalysisStatus(server, isAnalyzing));
|
||||
server.onErrors.listen(_handleAnalysisErrors);
|
||||
|
||||
await server.start();
|
||||
final int exitCode = await server.onExit;
|
||||
|
||||
printStatus('Analysis server exited with code $exitCode.');
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _handleAnalysisStatus(AnalysisServer server, bool isAnalyzing) {
|
||||
if (isAnalyzing) {
|
||||
analysisStatus?.cancel();
|
||||
|
||||
if (firstAnalysis) {
|
||||
analysisStatus = logger.startProgress('Analyzing ${path.basename(Directory.current.path)}...');
|
||||
} else {
|
||||
analysisStatus = logger.startProgress('\nAnalyzing...');
|
||||
}
|
||||
|
||||
if (!firstAnalysis)
|
||||
printStatus('\n');
|
||||
analysisStatus = logger.startProgress('Analyzing $analysisTarget...');
|
||||
analyzedPaths.clear();
|
||||
analysisTimer = new Stopwatch()..start();
|
||||
} else {
|
||||
analysisStatus?.stop(showElapsedTime: true);
|
||||
analysisTimer.stop();
|
||||
|
||||
// Sort and print errors.
|
||||
List<AnalysisError> errors = <AnalysisError>[];
|
||||
for (List<AnalysisError> fileErrors in analysisErrors.values)
|
||||
errors.addAll(fileErrors);
|
||||
logger.printStatus(terminal.clearScreen(), newline: false);
|
||||
|
||||
// Remove errors for deleted files, sort, and print errors.
|
||||
final List<AnalysisError> errors = <AnalysisError>[];
|
||||
for (String path in analysisErrors.keys.toList()) {
|
||||
if (FileSystemEntity.isFileSync(path)) {
|
||||
errors.addAll(analysisErrors[path]);
|
||||
} else {
|
||||
analysisErrors.remove(path);
|
||||
}
|
||||
}
|
||||
|
||||
errors.sort();
|
||||
|
||||
@ -341,11 +347,11 @@ class AnalyzeCommand extends FlutterCommand {
|
||||
if (firstAnalysis)
|
||||
errorsMessage = '$issueCount ${pluralize('issue', issueCount)} found';
|
||||
else if (issueDiff > 0)
|
||||
errorsMessage = '$issueDiff new ${pluralize('issue', issueDiff)}, $issueCount total';
|
||||
errorsMessage = '$issueCount ${pluralize('issue', issueCount)} found ($issueDiff new)';
|
||||
else if (issueDiff < 0)
|
||||
errorsMessage = '${-issueDiff} ${pluralize('issue', -issueDiff)} fixed, $issueCount remaining';
|
||||
errorsMessage = '$issueCount ${pluralize('issue', issueCount)} found (${-issueDiff} fixed)';
|
||||
else if (issueCount != 0)
|
||||
errorsMessage = 'no new issues, $issueCount total';
|
||||
errorsMessage = '$issueCount ${pluralize('issue', issueCount)} found';
|
||||
else
|
||||
errorsMessage = 'no issues found';
|
||||
|
||||
|
@ -536,7 +536,7 @@ class NotifyingLogger extends Logger {
|
||||
}
|
||||
|
||||
@override
|
||||
void printStatus(String message, { bool emphasis: false }) {
|
||||
void printStatus(String message, { bool emphasis: false, bool newline: true }) {
|
||||
_messageController.add(new LogMessage('status', message));
|
||||
}
|
||||
|
||||
@ -603,7 +603,7 @@ class _AppRunLogger extends Logger {
|
||||
}
|
||||
|
||||
@override
|
||||
void printStatus(String message, { bool emphasis: false }) {
|
||||
void printStatus(String message, { bool emphasis: false, bool newline: true }) {
|
||||
domain?._sendAppEvent(app, 'log', <String, dynamic>{ 'log': message });
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import 'dart:io';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:test/src/executable.dart' as executable; // ignore: implementation_imports
|
||||
|
||||
import '../base/logger.dart';
|
||||
import '../dart/package_map.dart';
|
||||
import '../globals.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
@ -91,7 +92,7 @@ class TestCommand extends FlutterCommand {
|
||||
}
|
||||
|
||||
testArgs.insert(0, '--');
|
||||
if (Platform.environment['TERM'] == 'dumb')
|
||||
if (!terminal.supportsColor)
|
||||
testArgs.insert(0, '--no-color');
|
||||
|
||||
loader.installHook();
|
||||
|
@ -25,7 +25,9 @@ void printError(String message, [StackTrace stackTrace]) => logger.printError(me
|
||||
|
||||
/// Display normal output of the command. This should be used for things like
|
||||
/// progress messages, success messages, or just normal command output.
|
||||
void printStatus(String message, { bool emphasis: false }) => logger.printStatus(message, emphasis: emphasis);
|
||||
void printStatus(String message, { bool emphasis: false, bool newline: true }) {
|
||||
logger.printStatus(message, emphasis: emphasis, newline: newline);
|
||||
}
|
||||
|
||||
/// Use this for verbose tracing output. Users can turn this output on in order
|
||||
/// to help diagnose issues with the toolchain or with their setup.
|
||||
|
@ -264,6 +264,17 @@ class FlutterCommandRunner extends CommandRunner {
|
||||
.toList();
|
||||
}
|
||||
|
||||
/// Get the entry-points we want to analyze in the Flutter repo.
|
||||
List<Directory> getRepoAnalysisEntryPoints() {
|
||||
String rootPath = path.absolute(Cache.flutterRoot);
|
||||
return <Directory>[
|
||||
// not bin, and not the root
|
||||
new Directory(path.join(rootPath, 'dev')),
|
||||
new Directory(path.join(rootPath, 'examples')),
|
||||
new Directory(path.join(rootPath, 'packages')),
|
||||
];
|
||||
}
|
||||
|
||||
bool _checkFlutterCopy() {
|
||||
// If the current directory is contained by a flutter repo, check that it's
|
||||
// the same flutter that is currently running.
|
||||
|
Loading…
x
Reference in New Issue
Block a user