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

Unified Diff: sdk/lib/_internal/pub/lib/src/dart.dart

Issue 25540004: Use our own DiagnosticHandler for dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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
Index: sdk/lib/_internal/pub/lib/src/dart.dart
diff --git a/sdk/lib/_internal/pub/lib/src/dart.dart b/sdk/lib/_internal/pub/lib/src/dart.dart
index b934112bb38a8e8cef9bcb689a094fac63616f64..5c164635e7ce1d47cd4582dfaf3327e7622b8264 100644
--- a/sdk/lib/_internal/pub/lib/src/dart.dart
+++ b/sdk/lib/_internal/pub/lib/src/dart.dart
@@ -25,11 +25,14 @@ import 'utils.dart';
/// true).
///
/// By default, the package root is assumed to be adjacent to [entrypoint], but
-/// if [packageRoot] is passed that will be used instead. If [provider] is
-/// omitted, uses a default [SourceFileProvider] that loads directly from the
-/// filesystem.
+/// if [packageRoot] is passed that will be used instead.
+///
+/// If [inputProvider] and [diagnosticHandler] are omitted, uses a default
+/// [compiler.CompilerInputProvider] that loads directly from the filesystem.
+/// If either is provided, both must be.
Future<String> compile(String entrypoint, {String packageRoot,
- bool toDart: false, SourceFileProvider provider}) {
+ bool toDart: false, compiler.CompilerInputProvider inputProvider,
+ compiler.DiagnosticHandler diagnosticHandler}) {
return new Future.sync(() {
var options = <String>['--categories=Client,Server', '--minify'];
if (toDart) options.add('--output-type=dart');
@@ -37,17 +40,22 @@ Future<String> compile(String entrypoint, {String packageRoot,
packageRoot = path.join(path.dirname(entrypoint), 'packages');
}
- if (provider == null) {
- provider = new SourceFileProvider();
+ if (inputProvider == null && diagnosticHandler == null) {
+ var provider = new SourceFileProvider();
+ inputProvider = provider.readStringFromUri;
+ diagnosticHandler = new FormattingDiagnosticHandler(provider)
+ .diagnosticHandler;
+ } else {
+ // Must either pass both of these or neither.
+ assert(inputProvider != null);
+ assert(diagnosticHandler != null);
nweiz 2013/10/03 21:39:14 Throw an ArgumentError here.
Bob Nystrom 2013/10/03 21:48:57 Done.
}
return compiler.compile(
path.toUri(entrypoint),
path.toUri(appendSlash(_libPath)),
path.toUri(appendSlash(packageRoot)),
- provider.readStringFromUri,
- new FormattingDiagnosticHandler(provider).diagnosticHandler,
- options);
+ inputProvider, diagnosticHandler, options);
}).then((result) {
if (result != null) return result;
throw new ApplicationException('Failed to compile "$entrypoint".');

Powered by Google App Engine
This is Rietveld 408576698