Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Unified Diff: pkg/docgen/lib/docgen.dart

Issue 19708003: Catergorized classes to abstract, class, typedef, and error/exception (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/docgen/test/single_library_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | pkg/docgen/test/single_library_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698