Chromium Code Reviews| 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 'common.dart'; | 9 import 'common.dart'; |
| 10 import 'common/names.dart' show | 10 import 'common/names.dart' show |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 LibraryElement importingLibrary, | 645 LibraryElement importingLibrary, |
| 646 Uri resolvedUri, | 646 Uri resolvedUri, |
| 647 {Spannable node, | 647 {Spannable node, |
| 648 bool skipFileWithPartOfTag: false}) { | 648 bool skipFileWithPartOfTag: false}) { |
| 649 Uri readableUri = | 649 Uri readableUri = |
| 650 uriTranslator.translate(importingLibrary, resolvedUri, node); | 650 uriTranslator.translate(importingLibrary, resolvedUri, node); |
| 651 LibraryElement library = libraryCanonicalUriMap[resolvedUri]; | 651 LibraryElement library = libraryCanonicalUriMap[resolvedUri]; |
| 652 if (library != null) { | 652 if (library != null) { |
| 653 return new Future.value(library); | 653 return new Future.value(library); |
| 654 } | 654 } |
| 655 library = deserializer.readLibrary(resolvedUri); | 655 return deserializer.readLibrary(resolvedUri).then((LibraryElement library) { |
|
Siggi Cherem (dart-lang)
2016/04/08 16:55:32
or use `await`?
Johnni Winther
2016/04/11 08:54:04
Aren't we still avoiding the using of async/await
Siggi Cherem (dart-lang)
2016/04/11 17:48:07
are they still blocked on that? I thought it was g
Johnni Winther
2016/04/12 08:05:47
I'll check with sgjesse and let you know.
| |
| 656 if (library != null) { | 656 if (library != null) { |
| 657 return loadDeserializedLibrary(handler, library); | 657 return loadDeserializedLibrary(handler, library); |
| 658 } | 658 } |
| 659 return reporter.withCurrentElement(importingLibrary, () { | 659 return reporter.withCurrentElement(importingLibrary, () { |
| 660 return _readScript(node, readableUri, resolvedUri).then((Script script) { | 660 return _readScript(node, readableUri, resolvedUri) |
| 661 if (script == null) return null; | 661 .then((Script script) { |
| 662 LibraryElement element = | 662 if (script == null) return null; |
| 663 createLibrarySync(handler, script, resolvedUri); | 663 LibraryElement element = |
| 664 CompilationUnitElementX compilationUnit = element.entryCompilationUnit; | 664 createLibrarySync(handler, script, resolvedUri); |
| 665 if (compilationUnit.partTag != null) { | 665 CompilationUnitElementX compilationUnit = |
| 666 if (skipFileWithPartOfTag) { | 666 element.entryCompilationUnit; |
| 667 // TODO(johnniwinther): Avoid calling [listener.onLibraryCreated] | 667 if (compilationUnit.partTag != null) { |
| 668 // for this library. | 668 if (skipFileWithPartOfTag) { |
| 669 libraryCanonicalUriMap.remove(resolvedUri); | 669 // TODO(johnniwinther): Avoid calling [listener.onLibraryCreated] |
| 670 return null; | 670 // for this library. |
| 671 libraryCanonicalUriMap.remove(resolvedUri); | |
| 672 return null; | |
| 673 } | |
| 674 if (importingLibrary == null) { | |
| 675 DiagnosticMessage error = reporter.withCurrentElement( | |
| 676 compilationUnit, | |
| 677 () => reporter.createMessage( | |
| 678 compilationUnit.partTag, MessageKind.MAIN_HAS_PART_OF)); | |
| 679 reporter.reportError(error); | |
| 680 } else { | |
| 681 DiagnosticMessage error = reporter.withCurrentElement( | |
| 682 compilationUnit, | |
| 683 () => reporter.createMessage( | |
| 684 compilationUnit.partTag, MessageKind.IMPORT_PART_OF)); | |
| 685 DiagnosticMessage info = reporter.withCurrentElement( | |
| 686 importingLibrary, | |
| 687 () => reporter.createMessage( | |
| 688 node, | |
| 689 MessageKind.IMPORT_PART_OF_HERE)); | |
| 690 reporter.reportError(error, [info]); | |
| 691 } | |
| 671 } | 692 } |
| 672 if (importingLibrary == null) { | 693 return processLibraryTags(handler, element).then((_) { |
| 673 DiagnosticMessage error = reporter.withCurrentElement( | 694 reporter.withCurrentElement(element, () { |
| 674 compilationUnit, | 695 handler.registerLibraryExports(element); |
| 675 () => reporter.createMessage( | 696 }); |
| 676 compilationUnit.partTag, MessageKind.MAIN_HAS_PART_OF)); | 697 return element; |
| 677 reporter.reportError(error); | |
| 678 } else { | |
| 679 DiagnosticMessage error = reporter.withCurrentElement( | |
| 680 compilationUnit, | |
| 681 () => reporter.createMessage( | |
| 682 compilationUnit.partTag, MessageKind.IMPORT_PART_OF)); | |
| 683 DiagnosticMessage info = reporter.withCurrentElement( | |
| 684 importingLibrary, | |
| 685 () => reporter.createMessage( | |
| 686 node, | |
| 687 MessageKind.IMPORT_PART_OF_HERE)); | |
| 688 reporter.reportError(error, [info]); | |
| 689 } | |
| 690 } | |
| 691 return processLibraryTags(handler, element).then((_) { | |
| 692 reporter.withCurrentElement(element, () { | |
| 693 handler.registerLibraryExports(element); | |
| 694 }); | 698 }); |
| 695 return element; | |
| 696 }); | 699 }); |
| 697 }); | 700 }); |
| 698 }); | 701 }); |
| 699 } | 702 } |
| 700 | 703 |
| 701 LibraryElement createLibrarySync(LibraryDependencyHandler handler, | 704 LibraryElement createLibrarySync(LibraryDependencyHandler handler, |
| 702 Script script, Uri resolvedUri) { | 705 Script script, Uri resolvedUri) { |
| 703 LibraryElement element = new LibraryElementX(script, resolvedUri); | 706 LibraryElement element = new LibraryElementX(script, resolvedUri); |
| 704 return reporter.withCurrentElement(element, () { | 707 return reporter.withCurrentElement(element, () { |
| 705 if (handler != null) { | 708 if (handler != null) { |
| (...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1517 /// Called after a request to load a library. The [results] will include all | 1520 /// Called after a request to load a library. The [results] will include all |
| 1518 /// transitive libraries loaded as a result of the initial request. | 1521 /// transitive libraries loaded as a result of the initial request. |
| 1519 Future onLibrariesLoaded(LoadedLibraries results); | 1522 Future onLibrariesLoaded(LoadedLibraries results); |
| 1520 | 1523 |
| 1521 /// Called whenever a library element is created. | 1524 /// Called whenever a library element is created. |
| 1522 void onLibraryCreated(LibraryElement library); | 1525 void onLibraryCreated(LibraryElement library); |
| 1523 | 1526 |
| 1524 /// Called whenever a library is scanned from a script file. | 1527 /// Called whenever a library is scanned from a script file. |
| 1525 Future onLibraryScanned(LibraryElement library, LibraryLoader loader); | 1528 Future onLibraryScanned(LibraryElement library, LibraryLoader loader); |
| 1526 } | 1529 } |
| OLD | NEW |