Index: tests/compiler/dart2js/mock_compiler.dart |
diff --git a/tests/compiler/dart2js/mock_compiler.dart b/tests/compiler/dart2js/mock_compiler.dart |
index 8e95867081a25bc7f38e3aee28840184f843ed5a..9129573db63d7384eb5ad4d70de648b81f3c8e8e 100644 |
--- a/tests/compiler/dart2js/mock_compiler.dart |
+++ b/tests/compiler/dart2js/mock_compiler.dart |
@@ -173,6 +173,7 @@ const String DEFAULT_ISOLATE_HELPERLIB = r''' |
class _WorkerBase {}'''; |
class MockCompiler extends Compiler { |
+ api.DiagnosticHandler diagnosticHandler; |
List<WarningMessage> warnings; |
List<WarningMessage> errors; |
final Map<String, SourceFile> sourceFiles; |
@@ -256,6 +257,8 @@ class MockCompiler extends Compiler { |
void reportWarning(Node node, var message) { |
if (message is! Message) message = message.message; |
warnings.add(new WarningMessage(node, message)); |
+ reportDiagnostic(spanFromNode(node), |
+ 'Warning: $message', api.Diagnostic.WARNING); |
} |
void reportError(Node node, var message) { |
@@ -265,6 +268,8 @@ class MockCompiler extends Compiler { |
} |
if (message is! Message) message = message.message; |
errors.add(new WarningMessage(node, message)); |
+ reportDiagnostic(spanFromNode(node), |
+ 'Error: $message', api.Diagnostic.ERROR); |
} |
void reportMessage(SourceSpan span, var message, api.Diagnostic kind) { |
@@ -274,10 +279,17 @@ class MockCompiler extends Compiler { |
} else { |
warnings.add(diagnostic); |
} |
+ reportDiagnostic(span, "$message", kind); |
} |
- void reportDiagnostic(SourceSpan span, String message, var kind) { |
- print(message); |
+ void reportDiagnostic(SourceSpan span, String message, api.Diagnostic kind) { |
+ if (diagnosticHandler != null) { |
+ if (span != null) { |
+ diagnosticHandler(span.uri, span.begin, span.end, message, kind); |
+ } else { |
+ diagnosticHandler(null, null, null, message, kind); |
+ } |
+ } |
} |
bool get compilationFailed => !errors.isEmpty; |
@@ -319,7 +331,7 @@ class MockCompiler extends Compiler { |
parseScript(String text, [LibraryElement library]) { |
if (library == null) library = mainApp; |
- parseUnit(text, this, library); |
+ parseUnit(text, this, library, registerSource); |
} |
void scanBuiltinLibraries() { |