| OLD | NEW |
| (Empty) | |
| 1 library docgen.models.parameter; |
| 2 |
| 3 import '../exports/mirrors_util.dart' as dart2js_util; |
| 4 import '../exports/source_mirrors.dart'; |
| 5 |
| 6 import 'annotation.dart'; |
| 7 import 'doc_gen_type.dart'; |
| 8 import 'library.dart'; |
| 9 import 'mirror_based.dart'; |
| 10 import 'model_helpers.dart'; |
| 11 |
| 12 /// Docgen wrapper around the dart2js mirror for a Dart |
| 13 /// method/function parameter. |
| 14 class Parameter extends MirrorBased { |
| 15 final ParameterMirror mirror; |
| 16 final String name; |
| 17 final bool isOptional; |
| 18 final bool isNamed; |
| 19 final bool hasDefaultValue; |
| 20 final DocGenType type; |
| 21 final String defaultValue; |
| 22 /// List of the meta annotations on the parameter. |
| 23 final List<Annotation> annotations; |
| 24 |
| 25 Parameter(ParameterMirror mirror, Library owningLibrary) |
| 26 : this.mirror = mirror, |
| 27 name = dart2js_util.nameOf(mirror), |
| 28 isOptional = mirror.isOptional, |
| 29 isNamed = mirror.isNamed, |
| 30 hasDefaultValue = mirror.hasDefaultValue, |
| 31 defaultValue = getDefaultValue(mirror), |
| 32 type = new DocGenType(mirror.type, owningLibrary), |
| 33 annotations = createAnnotations(mirror, owningLibrary); |
| 34 |
| 35 /// Generates a map describing the [Parameter] object. |
| 36 Map toMap() => { |
| 37 'name': name, |
| 38 'optional': isOptional, |
| 39 'named': isNamed, |
| 40 'default': hasDefaultValue, |
| 41 'type': new List.filled(1, type.toMap()), |
| 42 'value': defaultValue, |
| 43 'annotations': annotations.map((a) => a.toMap()).toList() |
| 44 }; |
| 45 } |
| OLD | NEW |