| 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 /// **docgen** is a tool for creating machine readable representations of Dart | 5 /// **docgen** is a tool for creating machine readable representations of Dart |
| 6 /// code metadata, including: classes, members, comments and annotations. | 6 /// code metadata, including: classes, members, comments and annotations. |
| 7 /// | 7 /// |
| 8 /// docgen is run on a `.dart` file or a directory containing `.dart` files. | 8 /// docgen is run on a `.dart` file or a directory containing `.dart` files. |
| 9 /// | 9 /// |
| 10 /// $ dart docgen.dart [OPTIONS] [FILE/DIR] | 10 /// $ dart docgen.dart [OPTIONS] [FILE/DIR] |
| (...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1348 | 1348 |
| 1349 abstract class OwnedIndexable extends Indexable { | 1349 abstract class OwnedIndexable extends Indexable { |
| 1350 Indexable owner; | 1350 Indexable owner; |
| 1351 | 1351 |
| 1352 /// Returns this object's qualified name, but following the conventions | 1352 /// Returns this object's qualified name, but following the conventions |
| 1353 /// we're using in Dartdoc, which is that library names with dots in them | 1353 /// we're using in Dartdoc, which is that library names with dots in them |
| 1354 /// have them replaced with hyphens. | 1354 /// have them replaced with hyphens. |
| 1355 String get docName => owner.docName + '.' + dart2js_util.nameOf(mirror); | 1355 String get docName => owner.docName + '.' + dart2js_util.nameOf(mirror); |
| 1356 | 1356 |
| 1357 OwnedIndexable(DeclarationMirror mirror, this.owner) : super(mirror); | 1357 OwnedIndexable(DeclarationMirror mirror, this.owner) : super(mirror); |
| 1358 |
| 1359 String get packagePrefix => owner.packagePrefix; |
| 1358 } | 1360 } |
| 1359 | 1361 |
| 1360 /// A class containing contents of a Dart class. | 1362 /// A class containing contents of a Dart class. |
| 1361 class Class extends OwnedIndexable implements Comparable { | 1363 class Class extends OwnedIndexable implements Comparable { |
| 1362 | 1364 |
| 1363 /// List of the names of interfaces that this class implements. | 1365 /// List of the names of interfaces that this class implements. |
| 1364 List<Class> interfaces = []; | 1366 List<Class> interfaces = []; |
| 1365 | 1367 |
| 1366 /// Names of classes that extends or implements this class. | 1368 /// Names of classes that extends or implements this class. |
| 1367 Set<Class> subclasses = new Set<Class>(); | 1369 Set<Class> subclasses = new Set<Class>(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 if (!classMirror.isNameSynthetic && _isVisible) { | 1446 if (!classMirror.isNameSynthetic && _isVisible) { |
| 1445 parentChain().forEach((parentClass) { | 1447 parentChain().forEach((parentClass) { |
| 1446 parentClass.addSubclass(this); | 1448 parentClass.addSubclass(this); |
| 1447 }); | 1449 }); |
| 1448 } | 1450 } |
| 1449 | 1451 |
| 1450 if (this.superclass != null) addInherited(superclass); | 1452 if (this.superclass != null) addInherited(superclass); |
| 1451 interfaces.forEach((interface) => addInherited(interface)); | 1453 interfaces.forEach((interface) => addInherited(interface)); |
| 1452 } | 1454 } |
| 1453 | 1455 |
| 1454 String get packagePrefix => owner.packagePrefix; | |
| 1455 | |
| 1456 String _lookupInClassAndSuperclasses(String name) { | 1456 String _lookupInClassAndSuperclasses(String name) { |
| 1457 var lookupFunc = Indexable.determineLookupFunc(name); | 1457 var lookupFunc = Indexable.determineLookupFunc(name); |
| 1458 var classScope = this; | 1458 var classScope = this; |
| 1459 while (classScope != null) { | 1459 while (classScope != null) { |
| 1460 var classFunc = lookupFunc(classScope.mirror, name); | 1460 var classFunc = lookupFunc(classScope.mirror, name); |
| 1461 if (classFunc != null) { | 1461 if (classFunc != null) { |
| 1462 return packagePrefix + Indexable.getDocgenObject(classFunc, owner).docNa
me; | 1462 return packagePrefix + Indexable.getDocgenObject(classFunc, owner).docNa
me; |
| 1463 } | 1463 } |
| 1464 classScope = classScope.superclass; | 1464 classScope = classScope.superclass; |
| 1465 } | 1465 } |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1690 'name': name, | 1690 'name': name, |
| 1691 'qualifiedName': qualifiedName, | 1691 'qualifiedName': qualifiedName, |
| 1692 'comment': comment, | 1692 'comment': comment, |
| 1693 'final': isFinal.toString(), | 1693 'final': isFinal.toString(), |
| 1694 'static': isStatic.toString(), | 1694 'static': isStatic.toString(), |
| 1695 'constant': isConst.toString(), | 1695 'constant': isConst.toString(), |
| 1696 'type': new List.filled(1, type.toMap()), | 1696 'type': new List.filled(1, type.toMap()), |
| 1697 'annotations': annotations.map((a) => a.toMap()).toList() | 1697 'annotations': annotations.map((a) => a.toMap()).toList() |
| 1698 }; | 1698 }; |
| 1699 | 1699 |
| 1700 String get packagePrefix => owner.packagePrefix; | |
| 1701 | |
| 1702 String get typeName => 'property'; | 1700 String get typeName => 'property'; |
| 1703 | 1701 |
| 1704 get comment { | 1702 get comment { |
| 1705 if (_comment != null) return _comment; | 1703 if (_comment != null) return _comment; |
| 1706 if (owner is Class) { | 1704 if (owner is Class) { |
| 1707 (owner as Class).ensureComments(); | 1705 (owner as Class).ensureComments(); |
| 1708 } | 1706 } |
| 1709 return super.comment; | 1707 return super.comment; |
| 1710 } | 1708 } |
| 1711 | 1709 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1762 Method._(MethodMirror mirror, Indexable owner, this.methodInheritedFrom) | 1760 Method._(MethodMirror mirror, Indexable owner, this.methodInheritedFrom) |
| 1763 : super(mirror, owner) { | 1761 : super(mirror, owner) { |
| 1764 isStatic = mirror.isStatic; | 1762 isStatic = mirror.isStatic; |
| 1765 isAbstract = mirror.isAbstract; | 1763 isAbstract = mirror.isAbstract; |
| 1766 isConst = mirror.isConstConstructor; | 1764 isConst = mirror.isConstConstructor; |
| 1767 returnType = new Type(mirror.returnType, _getOwningLibrary(owner)); | 1765 returnType = new Type(mirror.returnType, _getOwningLibrary(owner)); |
| 1768 parameters = _createParameters(mirror.parameters, owner); | 1766 parameters = _createParameters(mirror.parameters, owner); |
| 1769 annotations = _createAnnotations(mirror, _getOwningLibrary(owner)); | 1767 annotations = _createAnnotations(mirror, _getOwningLibrary(owner)); |
| 1770 } | 1768 } |
| 1771 | 1769 |
| 1772 String get packagePrefix => owner.packagePrefix; | |
| 1773 | |
| 1774 Method get originallyInheritedFrom => methodInheritedFrom == null ? | 1770 Method get originallyInheritedFrom => methodInheritedFrom == null ? |
| 1775 this : methodInheritedFrom.originallyInheritedFrom; | 1771 this : methodInheritedFrom.originallyInheritedFrom; |
| 1776 | 1772 |
| 1777 markdown.Node fixReferenceWithScope(String name) => fixReference(name); | 1773 markdown.Node fixReferenceWithScope(String name) => fixReference(name); |
| 1778 | 1774 |
| 1779 /// Look for the specified name starting with the current member, and | 1775 /// Look for the specified name starting with the current member, and |
| 1780 /// progressively working outward to the current library scope. | 1776 /// progressively working outward to the current library scope. |
| 1781 String findElementInScope(String name) { | 1777 String findElementInScope(String name) { |
| 1782 var lookupFunc = Indexable.determineLookupFunc(name); | 1778 var lookupFunc = Indexable.determineLookupFunc(name); |
| 1783 | 1779 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1993 .map((e) => originalMirror.getField(e.simpleName).reflectee) | 1989 .map((e) => originalMirror.getField(e.simpleName).reflectee) |
| 1994 .where((e) => e != null) | 1990 .where((e) => e != null) |
| 1995 .toList(); | 1991 .toList(); |
| 1996 } | 1992 } |
| 1997 | 1993 |
| 1998 Map toMap() => { | 1994 Map toMap() => { |
| 1999 'name': Indexable.getDocgenObject(mirror, owningLibrary).docName, | 1995 'name': Indexable.getDocgenObject(mirror, owningLibrary).docName, |
| 2000 'parameters': parameters | 1996 'parameters': parameters |
| 2001 }; | 1997 }; |
| 2002 } | 1998 } |
| OLD | NEW |