Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1060)

Unified Diff: tests/compiler/dart2js/output_collector.dart

Issue 1235563003: Add interfaces for a new compiler API. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Rebased Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/compiler/dart2js/mock_compiler.dart ('k') | tests/compiler/dart2js/sourcemaps/sourcemap_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/output_collector.dart
diff --git a/tests/compiler/dart2js/output_collector.dart b/tests/compiler/dart2js/output_collector.dart
index d2d3af4fc04f6e598432653ae654d929121863d3..7eb7486eb582872e4936475f76cab5615d5af678 100644
--- a/tests/compiler/dart2js/output_collector.dart
+++ b/tests/compiler/dart2js/output_collector.dart
@@ -7,6 +7,7 @@
library output_collector;
import 'dart:async';
+import 'package:compiler/compiler_new.dart';
class BufferedEventSink implements EventSink<String> {
StringBuffer sb = new StringBuffer();
@@ -49,13 +50,11 @@ class CloningEventSink implements EventSink<String> {
}
}
-class OutputCollector {
+class OutputCollector implements CompilerOutput {
Map<String, Map<String, BufferedEventSink>> outputMap = {};
EventSink<String> call(String name, String extension) {
- Map<String, BufferedEventSink> sinkMap =
- outputMap.putIfAbsent(extension, () => {});
- return sinkMap.putIfAbsent(name, () => new BufferedEventSink());
+ return createEventSink(name, extension);
}
String getOutput(String name, String extension) {
@@ -64,4 +63,24 @@ class OutputCollector {
BufferedEventSink sink = sinkMap[name];
return sink != null ? sink.text : null;
}
+
+ /// `true` if any output has been collected.
+ bool get hasOutput => !outputMap.isEmpty;
+
+ /// `true` if any output other than main output has been collected.
+ bool get hasExtraOutput {
+ for (String extension in outputMap.keys) {
+ for (String name in outputMap[extension].keys) {
+ if (name != '') return true;
+ }
+ }
+ return false;
+ }
+
+ @override
+ EventSink<String> createEventSink(String name, String extension) {
+ Map<String, BufferedEventSink> sinkMap =
+ outputMap.putIfAbsent(extension, () => {});
+ return sinkMap.putIfAbsent(name, () => new BufferedEventSink());
+ }
}
« no previous file with comments | « tests/compiler/dart2js/mock_compiler.dart ('k') | tests/compiler/dart2js/sourcemaps/sourcemap_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698