| 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..4c746d1e88faa4372cbdf3d162db15e2f8e2a9a0 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,24 @@ Future<String> compile(String entrypoint, {String packageRoot,
|
| packageRoot = path.join(path.dirname(entrypoint), 'packages');
|
| }
|
|
|
| - if (provider == null) {
|
| - provider = new SourceFileProvider();
|
| + // Must either pass both of these or neither.
|
| + if ((inputProvider == null) != (diagnosticHandler == null)) {
|
| + throw new ArgumentError("If either inputProvider or diagnosticHandler "
|
| + "is passed, then both must be.");
|
| + }
|
| +
|
| + if (inputProvider == null) {
|
| + var provider = new SourceFileProvider();
|
| + inputProvider = provider.readStringFromUri;
|
| + diagnosticHandler = new FormattingDiagnosticHandler(provider)
|
| + .diagnosticHandler;
|
| }
|
|
|
| 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".');
|
|
|