Capture all aspects of messages from compiler (flutter/engine#4118)

* Capture all aspects of messages from compiler

* Make static
This commit is contained in:
Alexander Aprelev 2017-09-15 16:04:58 -07:00 committed by GitHub
parent 3af1533e03
commit a87bbccccd

View File

@ -122,7 +122,18 @@ class _FrontendCompiler implements CompilerInterface {
..strongMode = false
..target = new FlutterTarget(new TargetFlags())
..onError = (CompilationMessage message) {
_outputStream.writeln("$message");
final StringBuffer outputMessage = new StringBuffer()
..write(_severityName(message.severity))
..write(': ');
if (message.span != null) {
outputMessage.writeln(message.span.message(message.message));
} else {
outputMessage.writeln(message.message);
}
if (message.tip != null) {
outputMessage.writeln(message.tip);
}
_outputStream.write(outputMessage);
};
Program program;
if (options['incremental']) {
@ -187,6 +198,21 @@ class _FrontendCompiler implements CompilerInterface {
path = '$path/';
return Uri.base.resolve(path);
}
static String _severityName(Severity severity) {
switch (severity) {
case Severity.error:
return "Error";
case Severity.internalProblem:
return "Internal problem";
case Severity.nit:
return "Nit";
case Severity.warning:
return "Warning";
default:
return severity.toString();
}
}
}
/// Entry point for this module, that creates `_FrontendCompiler` instance and