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
|
/// Display normal output of the command. This should be used for things like
|
||||||
/// progress messages, success messages, or just normal command output.
|
/// 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
|
/// 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.
|
/// to help diagnose issues with the toolchain or with their setup.
|
||||||
@ -58,11 +58,14 @@ class StdoutLogger extends Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void printStatus(String message, { bool emphasis: false }) {
|
void printStatus(String message, { bool emphasis: false, bool newline: true }) {
|
||||||
_status?.cancel();
|
_status?.cancel();
|
||||||
_status = null;
|
_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
|
@override
|
||||||
@ -102,7 +105,12 @@ class BufferLogger extends Logger {
|
|||||||
void printError(String message, [StackTrace stackTrace]) => _error.writeln(message);
|
void printError(String message, [StackTrace stackTrace]) => _error.writeln(message);
|
||||||
|
|
||||||
@override
|
@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
|
@override
|
||||||
void printTrace(String message) => _trace.writeln(message);
|
void printTrace(String message) => _trace.writeln(message);
|
||||||
@ -130,7 +138,8 @@ class VerboseLogger extends Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@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();
|
_emit();
|
||||||
lastMessage = new _LogMessage(_LogType.status, message);
|
lastMessage = new _LogMessage(_LogType.status, message);
|
||||||
}
|
}
|
||||||
@ -208,11 +217,14 @@ class AnsiTerminal {
|
|||||||
|
|
||||||
static const String _bold = '\u001B[1m';
|
static const String _bold = '\u001B[1m';
|
||||||
static const String _reset = '\u001B[0m';
|
static const String _reset = '\u001B[0m';
|
||||||
|
static const String _clear = '\u001B[2J\u001B[H';
|
||||||
|
|
||||||
bool supportsColor;
|
bool supportsColor;
|
||||||
|
|
||||||
String writeBold(String str) => supportsColor ? '$_bold$str$_reset' : str;
|
String writeBold(String str) => supportsColor ? '$_bold$str$_reset' : str;
|
||||||
|
|
||||||
|
String clearScreen() => supportsColor ? _clear : '\n\n';
|
||||||
|
|
||||||
set singleCharMode(bool value) {
|
set singleCharMode(bool value) {
|
||||||
stdin.lineMode = !value;
|
stdin.lineMode = !value;
|
||||||
}
|
}
|
||||||
|
@ -271,30 +271,8 @@ class AnalyzeCommand extends FlutterCommand {
|
|||||||
return collected;
|
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;
|
bool firstAnalysis = true;
|
||||||
Set<String> analyzedPaths = new Set<String>();
|
Set<String> analyzedPaths = new Set<String>();
|
||||||
Map<String, List<AnalysisError>> analysisErrors = <String, List<AnalysisError>>{};
|
Map<String, List<AnalysisError>> analysisErrors = <String, List<AnalysisError>>{};
|
||||||
@ -302,26 +280,54 @@ class AnalyzeCommand extends FlutterCommand {
|
|||||||
int lastErrorCount = 0;
|
int lastErrorCount = 0;
|
||||||
Status analysisStatus;
|
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) {
|
void _handleAnalysisStatus(AnalysisServer server, bool isAnalyzing) {
|
||||||
if (isAnalyzing) {
|
if (isAnalyzing) {
|
||||||
analysisStatus?.cancel();
|
analysisStatus?.cancel();
|
||||||
|
if (!firstAnalysis)
|
||||||
if (firstAnalysis) {
|
printStatus('\n');
|
||||||
analysisStatus = logger.startProgress('Analyzing ${path.basename(Directory.current.path)}...');
|
analysisStatus = logger.startProgress('Analyzing $analysisTarget...');
|
||||||
} else {
|
|
||||||
analysisStatus = logger.startProgress('\nAnalyzing...');
|
|
||||||
}
|
|
||||||
|
|
||||||
analyzedPaths.clear();
|
analyzedPaths.clear();
|
||||||
analysisTimer = new Stopwatch()..start();
|
analysisTimer = new Stopwatch()..start();
|
||||||
} else {
|
} else {
|
||||||
analysisStatus?.stop(showElapsedTime: true);
|
analysisStatus?.stop(showElapsedTime: true);
|
||||||
analysisTimer.stop();
|
analysisTimer.stop();
|
||||||
|
|
||||||
// Sort and print errors.
|
logger.printStatus(terminal.clearScreen(), newline: false);
|
||||||
List<AnalysisError> errors = <AnalysisError>[];
|
|
||||||
for (List<AnalysisError> fileErrors in analysisErrors.values)
|
// Remove errors for deleted files, sort, and print errors.
|
||||||
errors.addAll(fileErrors);
|
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();
|
errors.sort();
|
||||||
|
|
||||||
@ -341,11 +347,11 @@ class AnalyzeCommand extends FlutterCommand {
|
|||||||
if (firstAnalysis)
|
if (firstAnalysis)
|
||||||
errorsMessage = '$issueCount ${pluralize('issue', issueCount)} found';
|
errorsMessage = '$issueCount ${pluralize('issue', issueCount)} found';
|
||||||
else if (issueDiff > 0)
|
else if (issueDiff > 0)
|
||||||
errorsMessage = '$issueDiff new ${pluralize('issue', issueDiff)}, $issueCount total';
|
errorsMessage = '$issueCount ${pluralize('issue', issueCount)} found ($issueDiff new)';
|
||||||
else if (issueDiff < 0)
|
else if (issueDiff < 0)
|
||||||
errorsMessage = '${-issueDiff} ${pluralize('issue', -issueDiff)} fixed, $issueCount remaining';
|
errorsMessage = '$issueCount ${pluralize('issue', issueCount)} found (${-issueDiff} fixed)';
|
||||||
else if (issueCount != 0)
|
else if (issueCount != 0)
|
||||||
errorsMessage = 'no new issues, $issueCount total';
|
errorsMessage = '$issueCount ${pluralize('issue', issueCount)} found';
|
||||||
else
|
else
|
||||||
errorsMessage = 'no issues found';
|
errorsMessage = 'no issues found';
|
||||||
|
|
||||||
|
@ -536,7 +536,7 @@ class NotifyingLogger extends Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void printStatus(String message, { bool emphasis: false }) {
|
void printStatus(String message, { bool emphasis: false, bool newline: true }) {
|
||||||
_messageController.add(new LogMessage('status', message));
|
_messageController.add(new LogMessage('status', message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -603,7 +603,7 @@ class _AppRunLogger extends Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@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 });
|
domain?._sendAppEvent(app, 'log', <String, dynamic>{ 'log': message });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import 'dart:io';
|
|||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
import 'package:test/src/executable.dart' as executable; // ignore: implementation_imports
|
import 'package:test/src/executable.dart' as executable; // ignore: implementation_imports
|
||||||
|
|
||||||
|
import '../base/logger.dart';
|
||||||
import '../dart/package_map.dart';
|
import '../dart/package_map.dart';
|
||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
import '../runner/flutter_command.dart';
|
import '../runner/flutter_command.dart';
|
||||||
@ -91,7 +92,7 @@ class TestCommand extends FlutterCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testArgs.insert(0, '--');
|
testArgs.insert(0, '--');
|
||||||
if (Platform.environment['TERM'] == 'dumb')
|
if (!terminal.supportsColor)
|
||||||
testArgs.insert(0, '--no-color');
|
testArgs.insert(0, '--no-color');
|
||||||
|
|
||||||
loader.installHook();
|
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
|
/// Display normal output of the command. This should be used for things like
|
||||||
/// progress messages, success messages, or just normal command output.
|
/// 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
|
/// 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.
|
/// to help diagnose issues with the toolchain or with their setup.
|
||||||
|
@ -264,6 +264,17 @@ class FlutterCommandRunner extends CommandRunner {
|
|||||||
.toList();
|
.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() {
|
bool _checkFlutterCopy() {
|
||||||
// If the current directory is contained by a flutter repo, check that it's
|
// If the current directory is contained by a flutter repo, check that it's
|
||||||
// the same flutter that is currently running.
|
// the same flutter that is currently running.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user