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 mirrors_dart2js; | 5 library mirrors_dart2js; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:uri'; | 9 import 'dart:uri'; |
10 | 10 |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 | 667 |
668 class Dart2JsLibraryMirror extends Dart2JsContainerMirror | 668 class Dart2JsLibraryMirror extends Dart2JsContainerMirror |
669 implements LibraryMirror { | 669 implements LibraryMirror { |
670 Map<String, ClassMirror> _classes; | 670 Map<String, ClassMirror> _classes; |
671 | 671 |
672 Dart2JsLibraryMirror(Dart2JsMirrorSystem system, LibraryElement library) | 672 Dart2JsLibraryMirror(Dart2JsMirrorSystem system, LibraryElement library) |
673 : super(system, library); | 673 : super(system, library); |
674 | 674 |
675 LibraryElement get _library => _element; | 675 LibraryElement get _library => _element; |
676 | 676 |
677 Uri get uri => _library.uri; | 677 Uri get uri => _library.canonicalUri; |
678 | 678 |
679 DeclarationMirror get owner => null; | 679 DeclarationMirror get owner => null; |
680 | 680 |
681 bool get isPrivate => false; | 681 bool get isPrivate => false; |
682 | 682 |
683 LibraryMirror library() => this; | 683 LibraryMirror library() => this; |
684 | 684 |
685 /** | 685 /** |
686 * Returns the library name (for libraries with a #library tag) or the script | 686 * Returns the library name (for libraries with a #library tag) or the script |
687 * file name (for scripts without a #library tag). The latter case is used to | 687 * file name (for scripts without a #library tag). The latter case is used to |
688 * provide a 'library name' for scripts, to use for instance in dartdoc. | 688 * provide a 'library name' for scripts, to use for instance in dartdoc. |
689 */ | 689 */ |
690 String get simpleName { | 690 String get simpleName { |
691 if (_library.libraryTag != null) { | 691 if (_library.libraryTag != null) { |
692 // TODO(ahe): Remove StringNode check when old syntax is removed. | 692 // TODO(ahe): Remove StringNode check when old syntax is removed. |
693 StringNode name = _library.libraryTag.name.asStringNode(); | 693 StringNode name = _library.libraryTag.name.asStringNode(); |
694 if (name != null) { | 694 if (name != null) { |
695 return name.dartString.slowToString(); | 695 return name.dartString.slowToString(); |
696 } else { | 696 } else { |
697 return _library.libraryTag.name.toString(); | 697 return _library.libraryTag.name.toString(); |
698 } | 698 } |
699 } else { | 699 } else { |
700 // Use the file name as script name. | 700 // Use the file name as script name. |
701 String path = _library.uri.path; | 701 String path = _library.canonicalUri.path; |
702 return path.substring(path.lastIndexOf('/') + 1); | 702 return path.substring(path.lastIndexOf('/') + 1); |
703 } | 703 } |
704 } | 704 } |
705 | 705 |
706 String get qualifiedName => simpleName; | 706 String get qualifiedName => simpleName; |
707 | 707 |
708 void _ensureClasses() { | 708 void _ensureClasses() { |
709 if (_classes == null) { | 709 if (_classes == null) { |
710 _classes = <String, ClassMirror>{}; | 710 _classes = <String, ClassMirror>{}; |
711 _library.forEachLocalMember((Element e) { | 711 _library.forEachLocalMember((Element e) { |
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1859 return new Future.immediate( | 1859 return new Future.immediate( |
1860 new Dart2JsStringConstantMirror.fromString(mirrors, text)); | 1860 new Dart2JsStringConstantMirror.fromString(mirrors, text)); |
1861 } else if (fieldName == 'trimmedText') { | 1861 } else if (fieldName == 'trimmedText') { |
1862 return new Future.immediate( | 1862 return new Future.immediate( |
1863 new Dart2JsStringConstantMirror.fromString(mirrors, trimmedText)); | 1863 new Dart2JsStringConstantMirror.fromString(mirrors, trimmedText)); |
1864 } | 1864 } |
1865 // TODO(johnniwinther): Which exception/error should be thrown here? | 1865 // TODO(johnniwinther): Which exception/error should be thrown here? |
1866 throw new UnsupportedError('InstanceMirror does not have a reflectee'); | 1866 throw new UnsupportedError('InstanceMirror does not have a reflectee'); |
1867 } | 1867 } |
1868 } | 1868 } |
OLD | NEW |