@@ -344,38 +344,61 @@ Map<String, Map<String, Method>> _getMethods
344
344
} else if (mirror.isRegularMethod) {
345
345
methods[mirrorName] = method;
346
346
} else {
347
- throw new StateError ('${ mirror . qualifiedName } - no method type match' );
347
+ throw new ArgumentError ('$mirrorName - no method type match' );
348
348
}
349
349
}
350
350
});
351
- return {'setters' : setters,
352
- 'getters' : getters,
353
- 'constructors' : constructors,
354
- 'operators' : operators,
355
- 'methods' : methods};
351
+ return {
352
+ 'setters' : setters,
353
+ 'getters' : getters,
354
+ 'constructors' : constructors,
355
+ 'operators' : operators,
356
+ 'methods' : methods
357
+ };
356
358
}
357
359
358
360
/**
359
361
* Returns a map of [Class] objects constructed from inputted mirrors.
360
362
*/
361
363
Map <String , Class > _getClasses (Map <String , ClassMirror > mirrorMap,
362
364
bool includePrivate) {
363
- var data = {};
365
+
366
+ var abstract = {};
367
+ var classes = {};
368
+ var typedefs = {};
369
+ var errors = {};
370
+
364
371
mirrorMap.forEach ((String mirrorName, ClassMirror mirror) {
365
372
if (includePrivate || ! mirror.isPrivate) {
366
- _currentClass = mirror;
367
373
var superclass = (mirror.superclass != null ) ?
368
374
mirror.superclass.qualifiedName : '' ;
369
375
var interfaces =
370
376
mirror.superinterfaces.map ((interface ) => interface .qualifiedName);
371
- data[mirrorName] = new Class (mirrorName, superclass, mirror.isAbstract,
372
- mirror.isTypedef, _getComment (mirror), interfaces.toList (),
373
- _getVariables (mirror.variables, includePrivate),
377
+ var clazz = new Class (mirrorName, superclass, _getComment (mirror),
378
+ interfaces.toList (), _getVariables (mirror.variables, includePrivate),
374
379
_getMethods (mirror.methods, includePrivate),
375
380
_getAnnotations (mirror), mirror.qualifiedName);
381
+ _currentClass = mirror;
382
+
383
+ if (isError (mirror.qualifiedName)) {
384
+ errors[mirrorName] = clazz;
385
+ } else if (mirror.isTypedef) {
386
+ typedefs[mirrorName] = clazz;
387
+ } else if (mirror.isAbstract) {
388
+ abstract [mirrorName] = clazz;
389
+ } else if (mirror.isClass) {
390
+ classes[mirrorName] = clazz;
391
+ } else {
392
+ throw new ArgumentError ('$mirrorName - no class style match. ' );
393
+ }
376
394
}
377
395
});
378
- return data;
396
+ return {
397
+ 'abstract' : abstract ,
398
+ 'class' : classes,
399
+ 'typedef' : typedefs,
400
+ 'error' : errors
401
+ };
379
402
}
380
403
381
404
/**
@@ -424,6 +447,11 @@ Map recurseMap(Map inputMap) {
424
447
return outputMap;
425
448
}
426
449
450
+ bool isError (String qualifiedName) {
451
+ return qualifiedName.toLowerCase ().contains ('error' ) ||
452
+ qualifiedName.toLowerCase ().contains ('exception' );
453
+ }
454
+
427
455
/**
428
456
* A class representing all programming constructs, like library or class.
429
457
*/
@@ -489,24 +517,20 @@ class Class extends Indexable {
489
517
490
518
String name;
491
519
String superclass;
492
- bool isAbstract;
493
- bool isTypedef;
494
520
495
521
/// List of the meta annotations on the class.
496
522
List <String > annotations;
497
523
498
- Class (this .name, this .superclass, this .isAbstract , this .isTypedef ,
499
- this .comment , this .interfaces , this .variables, this .methods ,
500
- this .annotations, String qualifiedName) : super (qualifiedName) {}
524
+ Class (this .name, this .superclass, this .comment , this .interfaces ,
525
+ this .variables , this .methods , this .annotations ,
526
+ String qualifiedName) : super (qualifiedName) {}
501
527
502
528
/// Generates a map describing the [Class] object.
503
529
Map toMap () {
504
530
var classMap = {};
505
531
classMap['name' ] = name;
506
532
classMap['comment' ] = comment;
507
533
classMap['superclass' ] = superclass;
508
- classMap['abstract' ] = isAbstract.toString ();
509
- classMap['typedef' ] = isTypedef.toString ();
510
534
classMap['implements' ] = new List .from (interfaces);
511
535
classMap['variables' ] = recurseMap (variables);
512
536
classMap['methods' ] = recurseMap (methods);
0 commit comments