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

Side by Side Diff: pkg/compiler/lib/src/old_to_new_api.dart

Issue 2690063002: Refactor CompilerOutput (Closed)
Patch Set: Cleanup. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Implementation of the new compiler API in '../compiler_new.dart' through the 5 /// Implementation of the new compiler API in '../compiler_new.dart' through the
6 /// old compiler API in '../compiler.dart'. 6 /// old compiler API in '../compiler.dart'.
7 7
8 library compiler.api.legacy; 8 library compiler.api.legacy;
9 9
10 import 'dart:async' show EventSink, Future; 10 import 'dart:async' show EventSink, Future;
(...skipping 22 matching lines...) Expand all
33 33
34 @override 34 @override
35 void report( 35 void report(
36 var code, Uri uri, int begin, int end, String message, Diagnostic kind) { 36 var code, Uri uri, int begin, int end, String message, Diagnostic kind) {
37 _handler(uri, begin, end, message, kind); 37 _handler(uri, begin, end, message, kind);
38 } 38 }
39 } 39 }
40 40
41 /// Implementation of [CompilerOutput] using an optional 41 /// Implementation of [CompilerOutput] using an optional
42 /// [CompilerOutputProvider]. 42 /// [CompilerOutputProvider].
43 // TODO(johnniwinther): Change Pub to use the new interface and remove this.
43 class LegacyCompilerOutput implements CompilerOutput { 44 class LegacyCompilerOutput implements CompilerOutput {
44 final CompilerOutputProvider _outputProvider; 45 final CompilerOutputProvider _outputProvider;
45 46
46 LegacyCompilerOutput([this._outputProvider]); 47 LegacyCompilerOutput([this._outputProvider]);
47 48
48 @override 49 @override
49 EventSink<String> createEventSink(String name, String extension) { 50 OutputSink createOutputSink(String name, String extension, OutputType type) {
50 if (_outputProvider != null) return _outputProvider(name, extension); 51 if (_outputProvider != null) {
51 return NullSink.outputProvider(name, extension); 52 switch (type) {
53 case OutputType.info:
54 if (extension == '') {
55 extension = 'deferred_map';
Siggi Cherem (dart-lang) 2017/02/14 23:14:17 seems odd to inject that here, can you comment why
Johnni Winther 2017/02/20 09:18:11 Pub uses '$name.$extension' as output name, so thi
56 }
57 break;
58 default:
59 }
60 return new LegacyOutputSink(_outputProvider(name, extension));
61 }
62 return NullSink.outputProvider(name, extension, type);
52 } 63 }
53 } 64 }
65
66 class LegacyOutputSink implements OutputSink {
67 final EventSink<String> sink;
68
69 LegacyOutputSink(this.sink);
70
71 @override
72 void add(String event) => sink.add(event);
73
74 @override
75 void close() => sink.close();
76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698