| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library docgen.models.parameter; |
| 6 |
| 7 import '../exports/mirrors_util.dart' as dart2js_util; |
| 8 import '../exports/source_mirrors.dart'; |
| 9 |
| 10 import 'annotation.dart'; |
| 11 import 'doc_gen_type.dart'; |
| 12 import 'library.dart'; |
| 13 import 'mirror_based.dart'; |
| 14 import 'model_helpers.dart'; |
| 15 |
| 16 /// Docgen wrapper around the dart2js mirror for a Dart |
| 17 /// method/function parameter. |
| 18 class Parameter extends MirrorBased { |
| 19 final ParameterMirror mirror; |
| 20 final String name; |
| 21 final bool isOptional; |
| 22 final bool isNamed; |
| 23 final bool hasDefaultValue; |
| 24 final DocGenType type; |
| 25 final String defaultValue; |
| 26 /// List of the meta annotations on the parameter. |
| 27 final List<Annotation> annotations; |
| 28 |
| 29 Parameter(ParameterMirror mirror, Library owningLibrary) |
| 30 : this.mirror = mirror, |
| 31 name = dart2js_util.nameOf(mirror), |
| 32 isOptional = mirror.isOptional, |
| 33 isNamed = mirror.isNamed, |
| 34 hasDefaultValue = mirror.hasDefaultValue, |
| 35 defaultValue = getDefaultValue(mirror), |
| 36 type = new DocGenType(mirror.type, owningLibrary), |
| 37 annotations = createAnnotations(mirror, owningLibrary); |
| 38 |
| 39 /// Generates a map describing the [Parameter] object. |
| 40 Map toMap() => { |
| 41 'name': name, |
| 42 'optional': isOptional, |
| 43 'named': isNamed, |
| 44 'default': hasDefaultValue, |
| 45 'type': new List.filled(1, type.toMap()), |
| 46 'value': defaultValue, |
| 47 'annotations': annotations.map((a) => a.toMap()).toList() |
| 48 }; |
| 49 } |
| OLD | NEW |