Index: pkg/docgen/lib/docgen.dart |
diff --git a/pkg/docgen/lib/docgen.dart b/pkg/docgen/lib/docgen.dart |
index 76ac11eedce14c15e71f61ba1ae422ef3530f807..33a8ac1233515a7301610eddc4ddb44f5813141a 100644 |
--- a/pkg/docgen/lib/docgen.dart |
+++ b/pkg/docgen/lib/docgen.dart |
@@ -344,15 +344,17 @@ Map<String, Map<String, Method>> _getMethods |
} else if (mirror.isRegularMethod) { |
methods[mirrorName] = method; |
} else { |
- throw new StateError('${mirror.qualifiedName} - no method type match'); |
+ throw new ArgumentError('$mirrorName - no method type match'); |
} |
} |
}); |
- return {'setters' : setters, |
- 'getters' : getters, |
- 'constructors' : constructors, |
- 'operators' : operators, |
- 'methods' : methods}; |
+ return { |
+ 'setters': setters, |
+ 'getters': getters, |
+ 'constructors': constructors, |
+ 'operators': operators, |
+ 'methods': methods |
+ }; |
} |
/** |
@@ -360,22 +362,43 @@ Map<String, Map<String, Method>> _getMethods |
*/ |
Map<String, Class> _getClasses(Map<String, ClassMirror> mirrorMap, |
bool includePrivate) { |
- var data = {}; |
+ |
+ var abstract = {}; |
+ var classes = {}; |
+ var typedefs = {}; |
+ var errors = {}; |
+ |
mirrorMap.forEach((String mirrorName, ClassMirror mirror) { |
if (includePrivate || !mirror.isPrivate) { |
- _currentClass = mirror; |
var superclass = (mirror.superclass != null) ? |
mirror.superclass.qualifiedName : ''; |
var interfaces = |
mirror.superinterfaces.map((interface) => interface.qualifiedName); |
- data[mirrorName] = new Class(mirrorName, superclass, mirror.isAbstract, |
- mirror.isTypedef, _getComment(mirror), interfaces.toList(), |
- _getVariables(mirror.variables, includePrivate), |
+ var clazz = new Class(mirrorName, superclass, _getComment(mirror), |
+ interfaces.toList(), _getVariables(mirror.variables, includePrivate), |
_getMethods(mirror.methods, includePrivate), |
_getAnnotations(mirror), mirror.qualifiedName); |
+ _currentClass = mirror; |
+ |
+ if (isError(mirror.qualifiedName)) { |
+ errors[mirrorName] = clazz; |
+ } else if (mirror.isTypedef) { |
+ typedefs[mirrorName] = clazz; |
+ } else if (mirror.isAbstract) { |
+ abstract[mirrorName] = clazz; |
+ } else if (mirror.isClass) { |
+ classes[mirrorName] = clazz; |
+ } else { |
+ throw new ArgumentError('$mirrorName - no class style match. '); |
+ } |
} |
}); |
- return data; |
+ return { |
+ 'abstract': abstract, |
+ 'class': classes, |
+ 'typedef': typedefs, |
+ 'error': errors |
+ }; |
} |
/** |
@@ -424,6 +447,11 @@ Map recurseMap(Map inputMap) { |
return outputMap; |
} |
+bool isError(String qualifiedName) { |
+ return qualifiedName.toLowerCase().contains('error') || |
+ qualifiedName.toLowerCase().contains('exception'); |
+} |
+ |
/** |
* A class representing all programming constructs, like library or class. |
*/ |
@@ -489,15 +517,13 @@ class Class extends Indexable { |
String name; |
String superclass; |
- bool isAbstract; |
- bool isTypedef; |
/// List of the meta annotations on the class. |
List<String> annotations; |
- Class(this.name, this.superclass, this.isAbstract, this.isTypedef, |
- this.comment, this.interfaces, this.variables, this.methods, |
- this.annotations, String qualifiedName) : super(qualifiedName) {} |
+ Class(this.name, this.superclass, this.comment, this.interfaces, |
+ this.variables, this.methods, this.annotations, |
+ String qualifiedName) : super(qualifiedName) {} |
/// Generates a map describing the [Class] object. |
Map toMap() { |
@@ -505,8 +531,6 @@ class Class extends Indexable { |
classMap['name'] = name; |
classMap['comment'] = comment; |
classMap['superclass'] = superclass; |
- classMap['abstract'] = isAbstract.toString(); |
- classMap['typedef'] = isTypedef.toString(); |
classMap['implements'] = new List.from(interfaces); |
classMap['variables'] = recurseMap(variables); |
classMap['methods'] = recurseMap(methods); |