| 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 /** | 5 /** |
| 6 * **docgen** is a tool for creating machine readable representations of Dart | 6 * **docgen** is a tool for creating machine readable representations of Dart |
| 7 * code metadata, including: classes, members, comments and annotations. | 7 * code metadata, including: classes, members, comments and annotations. |
| 8 * | 8 * |
| 9 * docgen is run on a `.dart` file or a directory containing `.dart` files. | 9 * docgen is run on a `.dart` file or a directory containing `.dart` files. |
| 10 * | 10 * |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 }); | 462 }); |
| 463 return data; | 463 return data; |
| 464 } | 464 } |
| 465 | 465 |
| 466 /** | 466 /** |
| 467 * Returns a map of [Method] objects constructed from [mirrorMap]. | 467 * Returns a map of [Method] objects constructed from [mirrorMap]. |
| 468 */ | 468 */ |
| 469 MethodGroup _methods(Map<String, MethodMirror> mirrorMap) { | 469 MethodGroup _methods(Map<String, MethodMirror> mirrorMap) { |
| 470 var group = new MethodGroup(); | 470 var group = new MethodGroup(); |
| 471 mirrorMap.forEach((String mirrorName, MethodMirror mirror) { | 471 mirrorMap.forEach((String mirrorName, MethodMirror mirror) { |
| 472 if (_includePrivate || !_isHidden(mirror)) { | 472 if (_includePrivate || !mirror.isPrivate) { |
| 473 group.addMethod(mirror); | 473 group.addMethod(mirror); |
| 474 } | 474 } |
| 475 }); | 475 }); |
| 476 return group; | 476 return group; |
| 477 } | 477 } |
| 478 | 478 |
| 479 /** | 479 /** |
| 480 * Returns the [Class] for the given [mirror] has already been created, and if | 480 * Returns the [Class] for the given [mirror] has already been created, and if |
| 481 * it does not exist, creates it. | 481 * it does not exist, creates it. |
| 482 */ | 482 */ |
| 483 Class _class(ClassMirror mirror) { | 483 Class _class(ClassMirror mirror) { |
| 484 var clazz = entityMap[mirror.qualifiedName]; | 484 var clazz = entityMap[mirror.qualifiedName]; |
| 485 if (clazz == null) { | 485 if (clazz == null) { |
| 486 var superclass = mirror.superclass != null ? | 486 var superclass = mirror.superclass != null ? |
| 487 _class(mirror.superclass) : null; | 487 _class(mirror.superclass) : null; |
| 488 var interfaces = | 488 var interfaces = |
| 489 mirror.superinterfaces.map((interface) => _class(interface)); | 489 mirror.superinterfaces.map((interface) => _class(interface)); |
| 490 clazz = new Class(mirror.simpleName, superclass, _commentToHtml(mirror), | 490 clazz = new Class(mirror.simpleName, superclass, _commentToHtml(mirror), |
| 491 interfaces.toList(), _variables(mirror.variables), | 491 interfaces.toList(), _variables(mirror.variables), |
| 492 _methods(mirror.methods), _annotations(mirror), _generics(mirror), | 492 _methods(mirror.methods), _annotations(mirror), _generics(mirror), |
| 493 mirror.qualifiedName, _isHidden(mirror), mirror.owner.qualifiedName, | 493 mirror.qualifiedName, _isHidden(mirror), mirror.owner.qualifiedName, |
| 494 mirror.isAbstract); | 494 mirror.isAbstract); |
| 495 if (superclass != null) | 495 if (superclass != null) clazz.addInherited(superclass); |
| 496 clazz.addInherited(superclass); | 496 interfaces.forEach((interface) => clazz.addInherited(interface)); |
| 497 interfaces.forEach((interface) { | |
| 498 clazz.addInherited(interface); | |
| 499 }); | |
| 500 entityMap[mirror.qualifiedName] = clazz; | 497 entityMap[mirror.qualifiedName] = clazz; |
| 501 } | 498 } |
| 502 return clazz; | 499 return clazz; |
| 503 } | 500 } |
| 504 | 501 |
| 505 /** | 502 /** |
| 506 * Returns a map of [Class] objects constructed from [mirrorMap]. | 503 * Returns a map of [Class] objects constructed from [mirrorMap]. |
| 507 */ | 504 */ |
| 508 ClassGroup _classes(Map<String, ClassMirror> mirrorMap) { | 505 ClassGroup _classes(Map<String, ClassMirror> mirrorMap) { |
| 509 var group = new ClassGroup(); | 506 var group = new ClassGroup(); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 return parent; | 701 return parent; |
| 705 } | 702 } |
| 706 | 703 |
| 707 /** | 704 /** |
| 708 * Add all inherited variables and methods from the provided superclass. | 705 * Add all inherited variables and methods from the provided superclass. |
| 709 * If [_includePrivate] is true, it also adds the variables and methods from | 706 * If [_includePrivate] is true, it also adds the variables and methods from |
| 710 * the superclass. | 707 * the superclass. |
| 711 */ | 708 */ |
| 712 void addInherited(Class superclass) { | 709 void addInherited(Class superclass) { |
| 713 inheritedVariables.addAll(superclass.inheritedVariables); | 710 inheritedVariables.addAll(superclass.inheritedVariables); |
| 714 if (_isVisible(superclass)) { | 711 inheritedVariables.addAll(superclass.variables); |
| 715 inheritedVariables.addAll(superclass.variables); | |
| 716 } | |
| 717 inheritedMethods.addInherited(superclass); | 712 inheritedMethods.addInherited(superclass); |
| 718 } | 713 } |
| 719 | 714 |
| 720 /** | 715 /** |
| 721 * Add the subclass to the class. | 716 * Add the subclass to the class. |
| 722 * | 717 * |
| 723 * If [this] is private, it will add the subclass to the list of subclasses in | 718 * If [this] is private, it will add the subclass to the list of subclasses in |
| 724 * the superclasses. | 719 * the superclasses. |
| 725 */ | 720 */ |
| 726 void addSubclass(Class subclass) { | 721 void addSubclass(Class subclass) { |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 operators[mirror.simpleName] = method; | 1013 operators[mirror.simpleName] = method; |
| 1019 } else if (mirror.isRegularMethod) { | 1014 } else if (mirror.isRegularMethod) { |
| 1020 regularMethods[mirror.simpleName] = method; | 1015 regularMethods[mirror.simpleName] = method; |
| 1021 } else { | 1016 } else { |
| 1022 throw new ArgumentError('${mirror.simpleName} - no method type match'); | 1017 throw new ArgumentError('${mirror.simpleName} - no method type match'); |
| 1023 } | 1018 } |
| 1024 } | 1019 } |
| 1025 | 1020 |
| 1026 void addInherited(Class parent) { | 1021 void addInherited(Class parent) { |
| 1027 setters.addAll(parent.inheritedMethods.setters); | 1022 setters.addAll(parent.inheritedMethods.setters); |
| 1023 setters.addAll(parent.methods.setters); |
| 1028 getters.addAll(parent.inheritedMethods.getters); | 1024 getters.addAll(parent.inheritedMethods.getters); |
| 1025 getters.addAll(parent.methods.getters); |
| 1029 operators.addAll(parent.inheritedMethods.operators); | 1026 operators.addAll(parent.inheritedMethods.operators); |
| 1027 operators.addAll(parent.methods.operators); |
| 1030 regularMethods.addAll(parent.inheritedMethods.regularMethods); | 1028 regularMethods.addAll(parent.inheritedMethods.regularMethods); |
| 1031 if (_isVisible(parent)) { | 1029 regularMethods.addAll(parent.methods.regularMethods); |
| 1032 setters.addAll(parent.methods.setters); | |
| 1033 getters.addAll(parent.methods.getters); | |
| 1034 operators.addAll(parent.methods.operators); | |
| 1035 regularMethods.addAll(parent.methods.regularMethods); | |
| 1036 } | |
| 1037 } | 1030 } |
| 1038 | 1031 |
| 1039 Map toMap() => { | 1032 Map toMap() => { |
| 1040 'setters': recurseMap(setters), | 1033 'setters': recurseMap(setters), |
| 1041 'getters': recurseMap(getters), | 1034 'getters': recurseMap(getters), |
| 1042 'constructors': recurseMap(constructors), | 1035 'constructors': recurseMap(constructors), |
| 1043 'operators': recurseMap(operators), | 1036 'operators': recurseMap(operators), |
| 1044 'methods': recurseMap(regularMethods) | 1037 'methods': recurseMap(regularMethods) |
| 1045 }; | 1038 }; |
| 1046 | 1039 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 String qualifiedName; | 1149 String qualifiedName; |
| 1157 List<String> parameters; | 1150 List<String> parameters; |
| 1158 | 1151 |
| 1159 Annotation(this.qualifiedName, this.parameters); | 1152 Annotation(this.qualifiedName, this.parameters); |
| 1160 | 1153 |
| 1161 Map toMap() => { | 1154 Map toMap() => { |
| 1162 'name': qualifiedName, | 1155 'name': qualifiedName, |
| 1163 'parameters': parameters | 1156 'parameters': parameters |
| 1164 }; | 1157 }; |
| 1165 } | 1158 } |
| OLD | NEW |