Index: pkg/compiler/lib/src/apiimpl.dart |
diff --git a/pkg/compiler/lib/src/apiimpl.dart b/pkg/compiler/lib/src/apiimpl.dart |
index 9e04e16a7f08205a6a7f99914e69cb481b8956cc..bfadc5b9ec3e351c94e15edc4d40f33e27856ba0 100644 |
--- a/pkg/compiler/lib/src/apiimpl.dart |
+++ b/pkg/compiler/lib/src/apiimpl.dart |
@@ -9,28 +9,22 @@ import 'dart:convert'; |
import 'package:package_config/packages.dart'; |
import 'package:package_config/packages_file.dart' as pkgs; |
-import 'package:package_config/src/packages_impl.dart' show |
- MapPackages, |
- NonFilePackagesDirectoryPackages; |
-import 'package:package_config/src/util.dart' show |
- checkValidPackageUri; |
+import 'package:package_config/src/packages_impl.dart' |
+ show MapPackages, NonFilePackagesDirectoryPackages; |
+import 'package:package_config/src/util.dart' show checkValidPackageUri; |
import '../compiler_new.dart' as api; |
import 'common.dart'; |
-import 'common/tasks.dart' show |
- GenericTask; |
+import 'common/tasks.dart' show GenericTask; |
import 'compiler.dart'; |
-import 'diagnostics/messages.dart' show |
- Message; |
+import 'diagnostics/messages.dart' show Message; |
import 'elements/elements.dart' as elements; |
import 'environment.dart'; |
import 'io/source_file.dart'; |
-import 'options.dart' show |
- CompilerOptions; |
+import 'options.dart' show CompilerOptions; |
import 'platform_configuration.dart' as platform_configuration; |
import 'script.dart'; |
- |
/// Implements the [Compiler] using a [api.CompilerInput] for supplying the |
/// sources. |
class CompilerImpl extends Compiler { |
@@ -50,21 +44,21 @@ class CompilerImpl extends Compiler { |
Uri get libraryRoot => options.platformConfigUri.resolve("."); |
- CompilerImpl(this.provider, api.CompilerOutput outputProvider, |
- this.handler, CompilerOptions options) |
- : super(options: options, outputProvider: outputProvider, |
- environment: new _Environment(options.environment)) { |
+ CompilerImpl(this.provider, api.CompilerOutput outputProvider, this.handler, |
+ CompilerOptions options) |
+ : super( |
+ options: options, |
+ outputProvider: outputProvider, |
+ environment: new _Environment(options.environment)) { |
_Environment env = environment; |
env.compiler = this; |
tasks.addAll([ |
- userHandlerTask = new GenericTask('Diagnostic handler', this), |
- userProviderTask = new GenericTask('Input provider', this), |
- userPackagesDiscoveryTask = |
- new GenericTask('Package discovery', this), |
+ userHandlerTask = new GenericTask('Diagnostic handler', this), |
+ userProviderTask = new GenericTask('Input provider', this), |
+ userPackagesDiscoveryTask = new GenericTask('Package discovery', this), |
]); |
} |
- |
void log(message) { |
callUserHandler( |
null, null, null, null, message, api.Diagnostic.VERBOSE_INFO); |
@@ -72,7 +66,7 @@ class CompilerImpl extends Compiler { |
/// See [Compiler.translateResolvedUri]. |
Uri translateResolvedUri(elements.LibraryElement importingLibrary, |
- Uri resolvedUri, Spannable spannable) { |
+ Uri resolvedUri, Spannable spannable) { |
if (resolvedUri.scheme == 'dart') { |
return translateDartUri(importingLibrary, resolvedUri, spannable); |
} |
@@ -85,8 +79,8 @@ class CompilerImpl extends Compiler { |
Future<Script> readScript(Uri readableUri, [Spannable node]) { |
if (!readableUri.isAbsolute) { |
if (node == null) node = NO_LOCATION_SPANNABLE; |
- reporter.internalError(node, |
- 'Relative uri $readableUri provided to readScript(Uri).'); |
+ reporter.internalError( |
+ node, 'Relative uri $readableUri provided to readScript(Uri).'); |
} |
// We need to store the current element since we are reporting read errors |
@@ -101,9 +95,7 @@ class CompilerImpl extends Compiler { |
{'uri': readableUri, 'exception': exception}); |
} else { |
reporter.withCurrentElement(element, () { |
- reporter.reportErrorMessage( |
- node, |
- MessageKind.READ_SCRIPT_ERROR, |
+ reporter.reportErrorMessage(node, MessageKind.READ_SCRIPT_ERROR, |
{'uri': readableUri, 'exception': exception}); |
}); |
} |
@@ -114,8 +106,7 @@ class CompilerImpl extends Compiler { |
if (resourceUri.scheme == 'dart-ext') { |
if (!options.allowNativeExtensions) { |
reporter.withCurrentElement(element, () { |
- reporter.reportErrorMessage( |
- node, MessageKind.DART_EXT_NOT_SUPPORTED); |
+ reporter.reportErrorMessage(node, MessageKind.DART_EXT_NOT_SUPPORTED); |
}); |
} |
return _synthesizeScript(readableUri); |
@@ -132,7 +123,7 @@ class CompilerImpl extends Compiler { |
sourceFile = new StringSourceFile.fromUri(resourceUri, data); |
} else { |
String message = "Expected a 'String' or a 'List<int>' from the input " |
- "provider, but got: ${Error.safeToString(data)}."; |
+ "provider, but got: ${Error.safeToString(data)}."; |
reportReadError(message); |
} |
// We use [readableUri] as the URI for the script since need to preserve |
@@ -168,19 +159,16 @@ class CompilerImpl extends Compiler { |
/// Internal libraries (whose name starts with '_') can be only resolved if |
/// [importingLibrary] is a platform or patch library. |
Uri translateDartUri(elements.LibraryElement importingLibrary, |
- Uri resolvedUri, Spannable spannable) { |
- |
+ Uri resolvedUri, Spannable spannable) { |
Uri location = lookupLibraryUri(resolvedUri.path); |
if (location == null) { |
- reporter.reportErrorMessage( |
- spannable, |
- MessageKind.LIBRARY_NOT_FOUND, |
+ reporter.reportErrorMessage(spannable, MessageKind.LIBRARY_NOT_FOUND, |
{'resolvedUri': resolvedUri}); |
return null; |
} |
- if (resolvedUri.path.startsWith('_') ) { |
+ if (resolvedUri.path.startsWith('_')) { |
bool allowInternalLibraryAccess = importingLibrary != null && |
(importingLibrary.isPlatformLibrary || |
importingLibrary.isPatch || |
@@ -190,14 +178,12 @@ class CompilerImpl extends Compiler { |
if (!allowInternalLibraryAccess) { |
if (importingLibrary != null) { |
reporter.reportErrorMessage( |
- spannable, |
- MessageKind.INTERNAL_LIBRARY_FROM, |
- {'resolvedUri': resolvedUri, |
- 'importingUri': importingLibrary.canonicalUri}); |
+ spannable, MessageKind.INTERNAL_LIBRARY_FROM, { |
+ 'resolvedUri': resolvedUri, |
+ 'importingUri': importingLibrary.canonicalUri |
+ }); |
} else { |
- reporter.reportErrorMessage( |
- spannable, |
- MessageKind.INTERNAL_LIBRARY, |
+ reporter.reportErrorMessage(spannable, MessageKind.INTERNAL_LIBRARY, |
{'resolvedUri': resolvedUri}); |
registerDisallowedLibraryUse(resolvedUri); |
} |
@@ -206,16 +192,13 @@ class CompilerImpl extends Compiler { |
} |
if (location.scheme == "unsupported") { |
- reporter.reportErrorMessage( |
- spannable, |
- MessageKind.LIBRARY_NOT_SUPPORTED, |
+ reporter.reportErrorMessage(spannable, MessageKind.LIBRARY_NOT_SUPPORTED, |
{'resolvedUri': resolvedUri}); |
registerDisallowedLibraryUse(resolvedUri); |
return null; |
} |
- if (resolvedUri.path == 'html' || |
- resolvedUri.path == 'io') { |
+ if (resolvedUri.path == 'html' || resolvedUri.path == 'io') { |
// TODO(ahe): Get rid of mockableLibraryUsed when test.dart |
// supports this use case better. |
mockableLibraryUsed = true; |
@@ -227,24 +210,18 @@ class CompilerImpl extends Compiler { |
try { |
checkValidPackageUri(uri); |
} on ArgumentError catch (e) { |
- reporter.reportErrorMessage( |
- node, |
- MessageKind.INVALID_PACKAGE_URI, |
+ reporter.reportErrorMessage(node, MessageKind.INVALID_PACKAGE_URI, |
{'uri': uri, 'exception': e.message}); |
return null; |
} |
- return packages.resolve(uri, |
- notFound: (Uri notFound) { |
- reporter.reportErrorMessage( |
- node, |
- MessageKind.LIBRARY_NOT_FOUND, |
- {'resolvedUri': uri}); |
- return null; |
- }); |
+ return packages.resolve(uri, notFound: (Uri notFound) { |
+ reporter.reportErrorMessage( |
+ node, MessageKind.LIBRARY_NOT_FOUND, {'resolvedUri': uri}); |
+ return null; |
+ }); |
} |
- Future<elements.LibraryElement> analyzeUri( |
- Uri uri, |
+ Future<elements.LibraryElement> analyzeUri(Uri uri, |
{bool skipLibraryWithPartOfTag: true}) { |
List<Future> setupFutures = new List<Future>(); |
if (sdkLibraries == null) { |
@@ -254,8 +231,8 @@ class CompilerImpl extends Compiler { |
setupFutures.add(setupPackages(uri)); |
} |
return Future.wait(setupFutures).then((_) { |
- return super.analyzeUri(uri, |
- skipLibraryWithPartOfTag: skipLibraryWithPartOfTag); |
+ return super |
+ .analyzeUri(uri, skipLibraryWithPartOfTag: skipLibraryWithPartOfTag); |
}); |
} |
@@ -271,12 +248,11 @@ class CompilerImpl extends Compiler { |
} |
// The input provider may put a trailing 0 byte when it reads a source |
// file, which confuses the package config parser. |
- if (configContents.length > 0 && |
- configContents.last == 0) { |
+ if (configContents.length > 0 && configContents.last == 0) { |
configContents = configContents.sublist(0, configContents.length - 1); |
} |
- packages = new MapPackages( |
- pkgs.parse(configContents, options.packageConfig)); |
+ packages = |
+ new MapPackages(pkgs.parse(configContents, options.packageConfig)); |
}).catchError((error) { |
reporter.reportErrorMessage( |
NO_LOCATION_SPANNABLE, |
@@ -298,7 +274,8 @@ class CompilerImpl extends Compiler { |
Future<Null> setupSdk() { |
if (sdkLibraries == null) { |
- return platform_configuration.load(options.platformConfigUri, provider) |
+ return platform_configuration |
+ .load(options.platformConfigUri, provider) |
.then((Map<String, Uri> mapping) { |
sdkLibraries = mapping; |
}); |
@@ -338,16 +315,15 @@ class CompilerImpl extends Compiler { |
} |
void reportDiagnostic(DiagnosticMessage message, |
- List<DiagnosticMessage> infos, |
- api.Diagnostic kind) { |
+ List<DiagnosticMessage> infos, api.Diagnostic kind) { |
_reportDiagnosticMessage(message, kind); |
for (DiagnosticMessage info in infos) { |
_reportDiagnosticMessage(info, api.Diagnostic.INFO); |
} |
} |
- void _reportDiagnosticMessage(DiagnosticMessage diagnosticMessage, |
- api.Diagnostic kind) { |
+ void _reportDiagnosticMessage( |
+ DiagnosticMessage diagnosticMessage, api.Diagnostic kind) { |
// [:span.uri:] might be [:null:] in case of a [Script] with no [uri]. For |
// instance in the [Types] constructor in typechecker.dart. |
SourceSpan span = diagnosticMessage.sourceSpan; |
@@ -364,7 +340,7 @@ class CompilerImpl extends Compiler { |
mockableLibraryUsed && options.allowMockCompilation; |
void callUserHandler(Message message, Uri uri, int begin, int end, |
- String text, api.Diagnostic kind) { |
+ String text, api.Diagnostic kind) { |
userHandlerTask.measure(() { |
handler.report(message, uri, begin, end, text, kind); |
}); |
@@ -375,13 +351,13 @@ class CompilerImpl extends Compiler { |
} |
Future<Packages> callUserPackagesDiscovery(Uri uri) { |
- return userPackagesDiscoveryTask.measure( |
- () => options.packagesDiscoveryProvider(uri)); |
+ return userPackagesDiscoveryTask |
+ .measure(() => options.packagesDiscoveryProvider(uri)); |
} |
Uri lookupLibraryUri(String libraryName) { |
- assert(invariant(NO_LOCATION_SPANNABLE, |
- sdkLibraries != null, message: "setupSdk() has not been run")); |
+ assert(invariant(NO_LOCATION_SPANNABLE, sdkLibraries != null, |
+ message: "setupSdk() has not been run")); |
return sdkLibraries[libraryName]; |
} |
@@ -401,8 +377,8 @@ class _Environment implements Environment { |
_Environment(this.definitions); |
String valueOf(String name) { |
- assert(invariant(NO_LOCATION_SPANNABLE, |
- compiler.sdkLibraries != null, message: "setupSdk() has not been run")); |
+ assert(invariant(NO_LOCATION_SPANNABLE, compiler.sdkLibraries != null, |
+ message: "setupSdk() has not been run")); |
var result = definitions[name]; |
if (result != null || definitions.containsKey(name)) return result; |