@@ -266,9 +266,9 @@ String _getComment(DeclarationMirror mirror) {
266
266
}
267
267
}
268
268
});
269
- commentText = commentText == null ? '' :
270
- markdown. markdownToHtml (commentText. trim (), linkResolver : linkResolver)
271
- . replaceAll ( ' \n ' , ' ' );
269
+
270
+ commentText = commentText == null ? '' :
271
+ markdown. markdownToHtml (commentText. trim (), linkResolver : linkResolver );
272
272
return commentText;
273
273
}
274
274
@@ -300,9 +300,9 @@ Map<String, Variable> _getVariables(Map<String, VariableMirror> mirrorMap,
300
300
mirrorMap.forEach ((String mirrorName, VariableMirror mirror) {
301
301
if (includePrivate || ! mirror.isPrivate) {
302
302
_currentMember = mirror;
303
- data[mirrorName] = new Variable (mirrorName, mirror.qualifiedName,
304
- mirror.isFinal, mirror. isStatic, mirror.type.qualifiedName,
305
- _getComment (mirror), _getAnnotations (mirror));
303
+ data[mirrorName] = new Variable (mirrorName, mirror.isFinal,
304
+ mirror.isStatic, mirror.type.qualifiedName, _getComment (mirror),
305
+ _getAnnotations (mirror));
306
306
}
307
307
});
308
308
return data;
@@ -311,21 +311,42 @@ Map<String, Variable> _getVariables(Map<String, VariableMirror> mirrorMap,
311
311
/**
312
312
* Returns a map of [Method] objects constructed from inputted mirrors.
313
313
*/
314
- Map <String , Method > _getMethods (Map <String , MethodMirror > mirrorMap,
315
- bool includePrivate) {
316
- var data = {};
314
+ Map <String , Map <String , Method >> _getMethods
315
+ (Map <String , MethodMirror > mirrorMap, bool includePrivate) {
316
+
317
+ var setters = {};
318
+ var getters = {};
319
+ var constructors = {};
320
+ var operators = {};
321
+ var methods = {};
322
+
317
323
mirrorMap.forEach ((String mirrorName, MethodMirror mirror) {
318
324
if (includePrivate || ! mirror.isPrivate) {
325
+ var method = new Method (mirrorName, mirror.isStatic,
326
+ mirror.returnType.qualifiedName, _getComment (mirror),
327
+ _getParameters (mirror.parameters), _getAnnotations (mirror));
319
328
_currentMember = mirror;
320
- data[mirrorName] = new Method (mirrorName, mirror.qualifiedName,
321
- mirror.isSetter, mirror.isGetter, mirror.isConstructor,
322
- mirror.isOperator, mirror.isStatic, mirror.returnType.qualifiedName,
323
- _getComment (mirror), _getParameters (mirror.parameters),
324
- _getAnnotations (mirror));
329
+ if (mirror.isSetter) {
330
+ setters[mirrorName] = method;
331
+ } else if (mirror.isGetter) {
332
+ getters[mirrorName] = method;
333
+ } else if (mirror.isConstructor) {
334
+ constructors[mirrorName] = method;
335
+ } else if (mirror.isOperator) {
336
+ operators[mirrorName] = method;
337
+ } else if (mirror.isRegularMethod) {
338
+ methods[mirrorName] = method;
339
+ } else {
340
+ throw new StateError ('${mirror .qualifiedName } - no method type match' );
341
+ }
325
342
}
326
343
});
327
- return data;
328
- }
344
+ return {'setters' : setters,
345
+ 'getters' : getters,
346
+ 'constructors' : constructors,
347
+ 'operators' : operators,
348
+ 'methods' : methods};
349
+ }
329
350
330
351
/**
331
352
* Returns a map of [Class] objects constructed from inputted mirrors.
@@ -340,9 +361,8 @@ Map<String, Class> _getClasses(Map<String, ClassMirror> mirrorMap,
340
361
mirror.superclass.qualifiedName : '' ;
341
362
var interfaces =
342
363
mirror.superinterfaces.map ((interface ) => interface .qualifiedName);
343
- data[mirrorName] = new Class (mirrorName, mirror.qualifiedName,
344
- superclass, mirror.isAbstract, mirror.isTypedef,
345
- _getComment (mirror), interfaces.toList (),
364
+ data[mirrorName] = new Class (mirrorName, superclass, mirror.isAbstract,
365
+ mirror.isTypedef, _getComment (mirror), interfaces.toList (),
346
366
_getVariables (mirror.variables, includePrivate),
347
367
_getMethods (mirror.methods, includePrivate),
348
368
_getAnnotations (mirror));
@@ -358,10 +378,10 @@ Map<String, Parameter> _getParameters(List<ParameterMirror> mirrorList) {
358
378
var data = {};
359
379
mirrorList.forEach ((ParameterMirror mirror) {
360
380
_currentMember = mirror;
361
- data[mirror.simpleName] = new Parameter (mirror.simpleName,
362
- mirror.qualifiedName , mirror.isOptional , mirror.isNamed,
363
- mirror.hasDefaultValue , mirror.type.qualifiedName,
364
- mirror.defaultValue, _getAnnotations (mirror));
381
+ data[mirror.simpleName] = new Parameter (mirror.simpleName,
382
+ mirror.isOptional , mirror.isNamed , mirror.hasDefaultValue,
383
+ mirror.type.qualifiedName , mirror.defaultValue,
384
+ _getAnnotations (mirror));
365
385
});
366
386
return data;
367
387
}
@@ -388,7 +408,11 @@ void _writeToFile(String text, String filename) {
388
408
Map recurseMap (Map inputMap) {
389
409
var outputMap = {};
390
410
inputMap.forEach ((key, value) {
391
- outputMap[key] = value.toMap ();
411
+ if (value is Map ) {
412
+ outputMap[key] = recurseMap (value);
413
+ } else {
414
+ outputMap[key] = value.toMap ();
415
+ }
392
416
});
393
417
return outputMap;
394
418
}
@@ -405,8 +429,8 @@ class Library {
405
429
Map <String , Variable > variables;
406
430
407
431
/// Top-level functions in the library.
408
- Map <String , Method > functions;
409
-
432
+ Map <String , Map < String , Method > > functions;
433
+
410
434
/// Classes defined within the library
411
435
Map <String , Class > classes;
412
436
@@ -443,26 +467,24 @@ class Class {
443
467
Map <String , Variable > variables;
444
468
445
469
/// Methods in the class.
446
- Map <String , Method > methods;
447
-
470
+ Map <String , Map < String , Method > > methods;
471
+
448
472
String name;
449
- String qualifiedName;
450
473
String superclass;
451
474
bool isAbstract;
452
475
bool isTypedef;
453
476
454
477
/// List of the meta annotations on the class.
455
478
List <String > annotations;
456
-
457
- Class (this .name, this .qualifiedName , this .superclass , this .isAbstract,
458
- this .isTypedef , this .comment , this .interfaces , this .variables,
459
- this .methods, this . annotations);
479
+
480
+ Class (this .name, this .superclass , this .isAbstract , this .isTypedef,
481
+ this .comment , this .interfaces , this .variables , this .methods,
482
+ this .annotations);
460
483
461
484
/// Generates a map describing the [Class] object.
462
485
Map toMap () {
463
486
var classMap = {};
464
487
classMap['name' ] = name;
465
- classMap['qualifiedname' ] = qualifiedName;
466
488
classMap['comment' ] = comment;
467
489
classMap['superclass' ] = superclass;
468
490
classMap['abstract' ] = isAbstract.toString ();
@@ -484,22 +506,20 @@ class Variable {
484
506
String comment;
485
507
486
508
String name;
487
- String qualifiedName;
488
509
bool isFinal;
489
510
bool isStatic;
490
511
String type;
491
512
492
513
/// List of the meta annotations on the variable.
493
514
List <String > annotations;
494
-
495
- Variable (this .name, this .qualifiedName , this .isFinal , this .isStatic,
496
- this .type, this .comment, this . annotations);
497
-
515
+
516
+ Variable (this .name, this .isFinal , this .isStatic , this .type, this .comment,
517
+ this .annotations);
518
+
498
519
/// Generates a map describing the [Variable] object.
499
520
Map toMap () {
500
521
var variableMap = {};
501
522
variableMap['name' ] = name;
502
- variableMap['qualifiedname' ] = qualifiedName;
503
523
variableMap['comment' ] = comment;
504
524
variableMap['final' ] = isFinal.toString ();
505
525
variableMap['static' ] = isStatic.toString ();
@@ -521,29 +541,20 @@ class Method {
521
541
Map <String , Parameter > parameters;
522
542
523
543
String name;
524
- String qualifiedName;
525
- bool isSetter;
526
- bool isGetter;
527
- bool isConstructor;
528
- bool isOperator;
529
544
bool isStatic;
530
545
String returnType;
531
546
532
547
/// List of the meta annotations on the method.
533
548
List <String > annotations;
534
-
535
- Method (this .name, this .qualifiedName, this .isSetter, this .isGetter,
536
- this .isConstructor, this .isOperator, this .isStatic, this .returnType,
537
- this .comment, this .parameters, this .annotations);
538
-
549
+
550
+ Method (this .name, this .isStatic, this .returnType, this .comment,
551
+ this .parameters, this .annotations);
552
+
539
553
/// Generates a map describing the [Method] object.
540
554
Map toMap () {
541
555
var methodMap = {};
542
556
methodMap['name' ] = name;
543
- methodMap['qualifiedname' ] = qualifiedName;
544
557
methodMap['comment' ] = comment;
545
- methodMap['type' ] = isSetter ? 'setter' : isGetter ? 'getter' :
546
- isOperator ? 'operator' : isConstructor ? 'constructor' : 'method' ;
547
558
methodMap['static' ] = isStatic.toString ();
548
559
methodMap['return' ] = returnType;
549
560
methodMap['parameters' ] = recurseMap (parameters);
@@ -558,7 +569,6 @@ class Method {
558
569
class Parameter {
559
570
560
571
String name;
561
- String qualifiedName;
562
572
bool isOptional;
563
573
bool isNamed;
564
574
bool hasDefaultValue;
@@ -567,15 +577,14 @@ class Parameter {
567
577
568
578
/// List of the meta annotations on the parameter.
569
579
List <String > annotations;
570
-
571
- Parameter (this .name, this .qualifiedName , this .isOptional , this .isNamed,
572
- this .hasDefaultValue, this . type, this .defaultValue, this .annotations);
573
-
580
+
581
+ Parameter (this .name, this .isOptional , this .isNamed , this .hasDefaultValue,
582
+ this .type, this .defaultValue, this .annotations);
583
+
574
584
/// Generates a map describing the [Parameter] object.
575
585
Map toMap () {
576
586
var parameterMap = {};
577
587
parameterMap['name' ] = name;
578
- parameterMap['qualifiedname' ] = qualifiedName;
579
588
parameterMap['optional' ] = isOptional.toString ();
580
589
parameterMap['named' ] = isNamed.toString ();
581
590
parameterMap['default' ] = hasDefaultValue.toString ();
0 commit comments