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

Unified Diff: pkg/compiler/lib/src/old_to_new_api.dart

Issue 2690063002: Refactor CompilerOutput (Closed)
Patch Set: Updated cf. comments Created 3 years, 10 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 | « pkg/compiler/lib/src/null_compiler_output.dart ('k') | pkg/compiler/lib/src/serialization/task.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/old_to_new_api.dart
diff --git a/pkg/compiler/lib/src/old_to_new_api.dart b/pkg/compiler/lib/src/old_to_new_api.dart
index d79b5f9b5ea8905f75e2e9a49e0e179d9149cc15..939683d34fc6470df63d7ad2407b84f1255551ab 100644
--- a/pkg/compiler/lib/src/old_to_new_api.dart
+++ b/pkg/compiler/lib/src/old_to_new_api.dart
@@ -40,14 +40,38 @@ class LegacyCompilerDiagnostics implements CompilerDiagnostics {
/// Implementation of [CompilerOutput] using an optional
/// [CompilerOutputProvider].
+// TODO(johnniwinther): Change Pub to use the new interface and remove this.
class LegacyCompilerOutput implements CompilerOutput {
final CompilerOutputProvider _outputProvider;
LegacyCompilerOutput([this._outputProvider]);
@override
- EventSink<String> createEventSink(String name, String extension) {
- if (_outputProvider != null) return _outputProvider(name, extension);
- return NullSink.outputProvider(name, extension);
+ OutputSink createOutputSink(String name, String extension, OutputType type) {
+ if (_outputProvider != null) {
+ switch (type) {
+ case OutputType.info:
+ if (extension == '') {
+ // Needed to make Pub generate the same output name.
+ extension = 'deferred_map';
+ }
+ break;
+ default:
+ }
+ return new LegacyOutputSink(_outputProvider(name, extension));
+ }
+ return NullSink.outputProvider(name, extension, type);
}
}
+
+class LegacyOutputSink implements OutputSink {
+ final EventSink<String> sink;
+
+ LegacyOutputSink(this.sink);
+
+ @override
+ void add(String event) => sink.add(event);
+
+ @override
+ void close() => sink.close();
+}
« no previous file with comments | « pkg/compiler/lib/src/null_compiler_output.dart ('k') | pkg/compiler/lib/src/serialization/task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698