| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart2js.mirrors; | 5 part of dart2js.mirrors; |
| 6 | 6 |
| 7 | 7 |
| 8 class Dart2JsLibraryMirror | 8 class Dart2JsLibraryMirror |
| 9 extends Dart2JsElementMirror | 9 extends Dart2JsElementMirror |
| 10 with ObjectMirrorMixin, ContainerMixin | 10 with ObjectMirrorMixin, ContainerMixin |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 bool get isPrivate => false; | 27 bool get isPrivate => false; |
| 28 | 28 |
| 29 LibraryMirror library() => this; | 29 LibraryMirror library() => this; |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * Returns the library name (for libraries with a library tag) or the script | 32 * Returns the library name (for libraries with a library tag) or the script |
| 33 * file name (for scripts without a library tag). The latter case is used to | 33 * file name (for scripts without a library tag). The latter case is used to |
| 34 * provide a 'library name' for scripts, to use for instance in dartdoc. | 34 * provide a 'library name' for scripts, to use for instance in dartdoc. |
| 35 */ | 35 */ |
| 36 String get _simpleNameString { | 36 String get _simpleNameString => _element.getLibraryOrScriptName(); |
| 37 if (_element.libraryTag != null) { | |
| 38 return _element.libraryTag.name.toString(); | |
| 39 } else { | |
| 40 // Use the file name as script name. | |
| 41 String path = _element.canonicalUri.path; | |
| 42 return path.substring(path.lastIndexOf('/') + 1); | |
| 43 } | |
| 44 } | |
| 45 | 37 |
| 46 Symbol get qualifiedName => simpleName; | 38 Symbol get qualifiedName => simpleName; |
| 47 | 39 |
| 48 void _forEachElement(f(Element element)) => _element.forEachLocalMember(f); | 40 void _forEachElement(f(Element element)) => _element.forEachLocalMember(f); |
| 49 | 41 |
| 50 Iterable<Dart2JsDeclarationMirror> _getDeclarationMirrors(Element element) { | 42 Iterable<Dart2JsDeclarationMirror> _getDeclarationMirrors(Element element) { |
| 51 if (element.isClass || element.isTypedef) { | 43 if (element.isClass || element.isTypedef) { |
| 52 return [mirrorSystem._getTypeDeclarationMirror(element)]; | 44 return [mirrorSystem._getTypeDeclarationMirror(element)]; |
| 53 } else { | 45 } else { |
| 54 return super._getDeclarationMirrors(element); | 46 return super._getDeclarationMirrors(element); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 int get offset => _span.begin; | 232 int get offset => _span.begin; |
| 241 | 233 |
| 242 int get length => _span.end - _span.begin; | 234 int get length => _span.end - _span.begin; |
| 243 | 235 |
| 244 String get text => _script.text.substring(_span.begin, _span.end); | 236 String get text => _script.text.substring(_span.begin, _span.end); |
| 245 | 237 |
| 246 Uri get sourceUri => _script.resourceUri; | 238 Uri get sourceUri => _script.resourceUri; |
| 247 | 239 |
| 248 String get sourceText => _script.text; | 240 String get sourceText => _script.text; |
| 249 } | 241 } |
| OLD | NEW |