Skip to content

Commit

Permalink
"Reverting 25160"
Browse files Browse the repository at this point in the history
  • Loading branch information
janicejl committed Jul 18, 2013
1 parent 624fb4c commit 242d978
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 48 deletions.
62 changes: 19 additions & 43 deletions pkg/docgen/lib/docgen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -344,61 +344,38 @@ Map<String, Map<String, Method>> _getMethods
} else if (mirror.isRegularMethod) {
methods[mirrorName] = method;
} else {
throw new ArgumentError('$mirrorName - no method type match');
throw new StateError('${mirror.qualifiedName} - 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};
}

/**
* Returns a map of [Class] objects constructed from inputted mirrors.
*/
Map<String, Class> _getClasses(Map<String, ClassMirror> mirrorMap,
bool includePrivate) {

var abstract = {};
var classes = {};
var typedefs = {};
var errors = {};

var data = {};
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);
var clazz = new Class(mirrorName, superclass, _getComment(mirror),
interfaces.toList(), _getVariables(mirror.variables, includePrivate),
data[mirrorName] = new Class(mirrorName, superclass, mirror.isAbstract,
mirror.isTypedef, _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 {
'abstract': abstract,
'class': classes,
'typedef': typedefs,
'error': errors
};
return data;
}

/**
Expand Down Expand Up @@ -447,11 +424,6 @@ 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.
*/
Expand Down Expand Up @@ -517,20 +489,24 @@ 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.comment, this.interfaces,
this.variables, this.methods, this.annotations,
String qualifiedName) : super(qualifiedName) {}
Class(this.name, this.superclass, this.isAbstract, this.isTypedef,
this.comment, this.interfaces, this.variables, this.methods,
this.annotations, String qualifiedName) : super(qualifiedName) {}

/// Generates a map describing the [Class] object.
Map toMap() {
var classMap = {};
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);
Expand Down
6 changes: 1 addition & 5 deletions pkg/docgen/test/single_library_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ main() {
includePrivate: true);
expect(library is Library, isTrue);

var classTypes = library.classes.values;
expect(classTypes.every((e) => e is Map), isTrue);

var classes = [];
classTypes.forEach((e) => classes.addAll(e.values));
var classes = library.classes.values;
expect(classes.every((e) => e is Class), isTrue);

var classMethodTypes = [];
Expand Down

0 comments on commit 242d978

Please sign in to comment.