| Index: pkg/docgen/lib/src/model_helpers.dart
|
| diff --git a/pkg/docgen/lib/src/model_helpers.dart b/pkg/docgen/lib/src/model_helpers.dart
|
| index 678fa19394cd84fbddc2dfeff3954eadee302452..1820b1d97770346d340df4e9ea5ac62b98b1f5eb 100644
|
| --- a/pkg/docgen/lib/src/model_helpers.dart
|
| +++ b/pkg/docgen/lib/src/model_helpers.dart
|
| @@ -17,6 +17,41 @@ import 'library_helpers.dart' show includePrivateMembers;
|
| import 'models.dart';
|
| import 'package_helpers.dart';
|
|
|
| +String getDefaultValue(ParameterMirror mirror) {
|
| + if (!mirror.hasDefaultValue) return null;
|
| + return getDefaultValueFromConstMirror(mirror.defaultValue);
|
| +}
|
| +
|
| +String getDefaultValueFromConstMirror(
|
| + dart2js_mirrors.Dart2JsConstantMirror valueMirror) {
|
| +
|
| + if (valueMirror is dart2js_mirrors.Dart2JsStringConstantMirror) {
|
| + return '"${valueMirror.reflectee}"';
|
| + }
|
| +
|
| + if (valueMirror is dart2js_mirrors.Dart2JsListConstantMirror) {
|
| + var buffer = new StringBuffer('[');
|
| +
|
| + var values = new Iterable.generate(valueMirror.length,
|
| + (i) => valueMirror.getElement(i))
|
| + .map((e) => getDefaultValueFromConstMirror(e));
|
| +
|
| + buffer.writeAll(values, ', ');
|
| +
|
| + buffer.write(']');
|
| + return buffer.toString();
|
| + }
|
| +
|
| + if (valueMirror is dart2js_mirrors.Dart2JsMapConstantMirror) {
|
| + // TODO(kevmoo) Handle non-empty case
|
| + if (valueMirror.length == 0) return '{}';
|
| + }
|
| +
|
| + // TODO(kevmoo) Handle consts of non-core types
|
| +
|
| + return '${valueMirror}';
|
| +}
|
| +
|
| /// Returns a list of meta annotations assocated with a mirror.
|
| List<Annotation> createAnnotations(DeclarationMirror mirror,
|
| Library owningLibrary) {
|
|
|