| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 library docgen.models.owned_indexable; |
| 6 |
| 7 import '../exports/mirrors_util.dart' as dart2js_util; |
| 8 import '../exports/source_mirrors.dart'; |
| 9 |
| 10 import '../library_helpers.dart'; |
| 11 import '../mdn.dart'; |
| 12 import '../package_helpers.dart'; |
| 13 |
| 14 import 'annotation.dart'; |
| 15 import 'indexable.dart'; |
| 16 import 'model_helpers.dart'; |
| 17 |
| 18 abstract class OwnedIndexable<TMirror extends DeclarationMirror> |
| 19 extends Indexable<TMirror> { |
| 20 /// List of the meta annotations on this item. |
| 21 final List<Annotation> annotations; |
| 22 |
| 23 /// The object one scope-level above which this item is defined. |
| 24 /// |
| 25 /// Ex: The owner for a top level class, would be its enclosing library. |
| 26 /// The owner of a local variable in a method would be the enclosing method. |
| 27 final Indexable owner; |
| 28 |
| 29 /// Returns this object's qualified name, but following the conventions |
| 30 /// we're using in Dartdoc, which is that library names with dots in them |
| 31 /// have them replaced with hyphens. |
| 32 String get docName => owner.docName + '.' + dart2js_util.nameOf(mirror); |
| 33 |
| 34 OwnedIndexable(DeclarationMirror mirror, Indexable owner) |
| 35 : annotations = createAnnotations(mirror, owner.owningLibrary), |
| 36 this.owner = owner, |
| 37 super(mirror); |
| 38 |
| 39 /// Generates MDN comments from database.json. |
| 40 String getMdnComment() { |
| 41 var domAnnotation = this.annotations.firstWhere( |
| 42 (e) => e.mirror.qualifiedName == #metadata.DomName, |
| 43 orElse: () => null); |
| 44 if (domAnnotation == null) return ''; |
| 45 var domName = domAnnotation.parameters.single; |
| 46 |
| 47 return mdnComment(rootDirectory, logger, domName); |
| 48 } |
| 49 |
| 50 String get packagePrefix => owner.packagePrefix; |
| 51 } |
| OLD | NEW |