OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library dart2js.library_loader; | 5 library dart2js.library_loader; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'dart2jslib.dart' show | 9 import 'dart2jslib.dart' show |
10 Compiler, | 10 Compiler, |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 compiler.reportError(unit, MessageKind.MISSING_PART_OF_TAG); | 492 compiler.reportError(unit, MessageKind.MISSING_PART_OF_TAG); |
493 } | 493 } |
494 }); | 494 }); |
495 }); | 495 }); |
496 }); | 496 }); |
497 } | 497 } |
498 | 498 |
499 /** | 499 /** |
500 * Handle an import/export tag by loading the referenced library and | 500 * Handle an import/export tag by loading the referenced library and |
501 * registering its dependency in [handler] for the computation of the import/ | 501 * registering its dependency in [handler] for the computation of the import/ |
502 * export scope. | 502 * export scope. If the tag does not contain a valid URI, then its dependency |
| 503 * is not registered in [handler]. |
503 */ | 504 */ |
504 Future registerLibraryFromTag(LibraryDependencyHandler handler, | 505 Future<Null> registerLibraryFromTag(LibraryDependencyHandler handler, |
505 LibraryElement library, | 506 LibraryElement library, |
506 LibraryDependency tag) { | 507 LibraryDependency tag) { |
507 Uri base = library.canonicalUri; | 508 Uri base = library.canonicalUri; |
508 Uri resolvedUri = base.resolve(tag.uri.dartString.slowToString()); | 509 String tagUriString = tag.uri.dartString.slowToString(); |
| 510 Uri resolvedUri; |
| 511 try { |
| 512 resolvedUri = base.resolve(tagUriString); |
| 513 } on FormatException { |
| 514 compiler.reportError( |
| 515 tag.uri, MessageKind.INVALID_URI, {'uri': tagUriString}); |
| 516 // 'reportError' does not stop necessarily stop compilation |
| 517 return new Future.value(); |
| 518 } |
509 return createLibrary(handler, library, resolvedUri, tag.uri) | 519 return createLibrary(handler, library, resolvedUri, tag.uri) |
510 .then((LibraryElement loadedLibrary) { | 520 .then((LibraryElement loadedLibrary) { |
511 if (loadedLibrary == null) return; | 521 if (loadedLibrary == null) return; |
512 compiler.withCurrentElement(library, () { | 522 compiler.withCurrentElement(library, () { |
513 handler.registerDependency(library, tag, loadedLibrary); | 523 handler.registerDependency(library, tag, loadedLibrary); |
514 }); | 524 }); |
515 }); | 525 }); |
516 } | 526 } |
517 | 527 |
518 /** | 528 /** |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1186 } | 1196 } |
1187 suffixes.add(const Link<Uri>().prepend(canonicalUri)); | 1197 suffixes.add(const Link<Uri>().prepend(canonicalUri)); |
1188 } | 1198 } |
1189 suffixChainMap[library] = suffixes; | 1199 suffixChainMap[library] = suffixes; |
1190 return; | 1200 return; |
1191 } | 1201 } |
1192 | 1202 |
1193 computeSuffixes(rootLibrary, const Link<Uri>()); | 1203 computeSuffixes(rootLibrary, const Link<Uri>()); |
1194 } | 1204 } |
1195 } | 1205 } |
OLD | NEW |