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

Unified Diff: sdk/lib/_internal/compiler/implementation/library_loader.dart

Issue 21544003: Handle missing imports/exports/parts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add example to warning. Created 7 years, 4 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/compiler/implementation/library_loader.dart
diff --git a/sdk/lib/_internal/compiler/implementation/library_loader.dart b/sdk/lib/_internal/compiler/implementation/library_loader.dart
index 8f4f224a52dd305fdc4e27fcc83a5e3da7295ebb..d01be710b71dfba7153a766058029ee98a4a29e5 100644
--- a/sdk/lib/_internal/compiler/implementation/library_loader.dart
+++ b/sdk/lib/_internal/compiler/implementation/library_loader.dart
@@ -362,7 +362,9 @@ class LibraryLoaderTask extends LibraryLoader {
void scanPart(Part part, Uri resolvedUri, LibraryElement library) {
if (!resolvedUri.isAbsolute) throw new ArgumentError(resolvedUri);
Uri readableUri = compiler.translateResolvedUri(library, resolvedUri, part);
+ if (readableUri == null) return;
Script sourceScript = compiler.readScript(readableUri, part);
+ if (sourceScript == null) return;
CompilationUnitElement unit =
new CompilationUnitElementX(sourceScript, library);
compiler.withCurrentElement(unit, () {
@@ -385,6 +387,7 @@ class LibraryLoaderTask extends LibraryLoader {
Uri resolvedUri = base.resolve(tag.uri.dartString.slowToString());
LibraryElement loadedLibrary =
createLibrary(handler, library, resolvedUri, tag.uri, resolvedUri);
+ if (loadedLibrary == null) return;
handler.registerDependency(library, tag, loadedLibrary);
if (!loadedLibrary.hasLibraryName()) {
@@ -409,26 +412,26 @@ class LibraryLoaderTask extends LibraryLoader {
LibraryElement createLibrary(LibraryDependencyHandler handler,
LibraryElement importingLibrary,
Uri resolvedUri, Node node, Uri canonicalUri) {
- bool newLibrary = false;
+ // TODO(johnniwinther): Create erroneous library elements for missing
+ // libraries.
Uri readableUri =
compiler.translateResolvedUri(importingLibrary, resolvedUri, node);
if (readableUri == null) return null;
- LibraryElement createLibrary() {
- newLibrary = true;
- Script script = compiler.readScript(readableUri, node);
- LibraryElement element = new LibraryElementX(script, canonicalUri);
- handler.registerNewLibrary(element);
- native.maybeEnableNative(compiler, element);
- return element;
- }
LibraryElement library;
- if (canonicalUri == null) {
- library = createLibrary();
- } else {
- library = compiler.libraries.putIfAbsent(canonicalUri.toString(),
- createLibrary);
+ if (canonicalUri != null) {
+ library = compiler.libraries[canonicalUri.toString()];
}
- if (newLibrary) {
+ if (library == null) {
+ Script script = compiler.readScript(readableUri, node);
+ if (script == null) return null;
+
+ library = new LibraryElementX(script, canonicalUri);
+ handler.registerNewLibrary(library);
+ native.maybeEnableNative(compiler, library);
+ if (canonicalUri != null) {
+ compiler.libraries[canonicalUri.toString()] = library;
+ }
+
compiler.withCurrentElement(library, () {
compiler.scanner.scanLibrary(library);
processLibraryTags(handler, library);

Powered by Google App Engine
This is Rietveld 408576698