Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(730)

Unified Diff: pkg/docgen/lib/src/models/parameter.dart

Issue 242363004: pkg/docgen: moved model classes into minilibs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: cl nits Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/docgen/lib/src/models/parameter.dart
diff --git a/pkg/docgen/lib/src/models/parameter.dart b/pkg/docgen/lib/src/models/parameter.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2f8798c6af7d96f3ba1522219ee16244ac49fbcb
--- /dev/null
+++ b/pkg/docgen/lib/src/models/parameter.dart
@@ -0,0 +1,49 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library docgen.models.parameter;
+
+import '../exports/mirrors_util.dart' as dart2js_util;
+import '../exports/source_mirrors.dart';
+
+import 'annotation.dart';
+import 'doc_gen_type.dart';
+import 'library.dart';
+import 'mirror_based.dart';
+import 'model_helpers.dart';
+
+/// Docgen wrapper around the dart2js mirror for a Dart
+/// method/function parameter.
+class Parameter extends MirrorBased {
+ final ParameterMirror mirror;
+ final String name;
+ final bool isOptional;
+ final bool isNamed;
+ final bool hasDefaultValue;
+ final DocGenType type;
+ final String defaultValue;
+ /// List of the meta annotations on the parameter.
+ final List<Annotation> annotations;
+
+ Parameter(ParameterMirror mirror, Library owningLibrary)
+ : this.mirror = mirror,
+ name = dart2js_util.nameOf(mirror),
+ isOptional = mirror.isOptional,
+ isNamed = mirror.isNamed,
+ hasDefaultValue = mirror.hasDefaultValue,
+ defaultValue = getDefaultValue(mirror),
+ type = new DocGenType(mirror.type, owningLibrary),
+ annotations = createAnnotations(mirror, owningLibrary);
+
+ /// Generates a map describing the [Parameter] object.
+ Map toMap() => {
+ 'name': name,
+ 'optional': isOptional,
+ 'named': isNamed,
+ 'default': hasDefaultValue,
+ 'type': new List.filled(1, type.toMap()),
+ 'value': defaultValue,
+ 'annotations': annotations.map((a) => a.toMap()).toList()
+ };
+}

Powered by Google App Engine
This is Rietveld 408576698