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

Side by Side Diff: pkg/docgen/lib/src/models/parameter.dart

Issue 1364553002: remove docgen source and targets from build (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: remove scripts Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « pkg/docgen/lib/src/models/owned_indexable.dart ('k') | pkg/docgen/lib/src/models/typedef.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 'closure.dart';
12 import 'doc_gen_type.dart';
13 import 'library.dart';
14 import 'mirror_based.dart';
15 import 'model_helpers.dart';
16
17 /// Docgen wrapper around the dart2js mirror for a Dart
18 /// method/function parameter.
19 class Parameter extends MirrorBased {
20 final ParameterMirror mirror;
21 final String name;
22 final bool isOptional;
23 final bool isNamed;
24 final bool hasDefaultValue;
25 final DocGenType type;
26 final String defaultValue;
27 /// List of the meta annotations on the parameter.
28 final List<Annotation> annotations;
29 final Library owningLibrary;
30 // Only non-null if this parameter is a function declaration.
31 Closure functionDeclaration;
32
33 Parameter(ParameterMirror mirror, Library owningLibrary)
34 : this.mirror = mirror,
35 name = dart2js_util.nameOf(mirror),
36 isOptional = mirror.isOptional,
37 isNamed = mirror.isNamed,
38 hasDefaultValue = mirror.hasDefaultValue,
39 defaultValue = getDefaultValue(mirror),
40 type = new DocGenType(mirror.type, owningLibrary),
41 annotations = createAnnotations(mirror, owningLibrary),
42 owningLibrary = owningLibrary {
43 if (mirror.type is FunctionTypeMirror) {
44 functionDeclaration =
45 new Closure(mirror.type as FunctionTypeMirror, owningLibrary);
46 }
47 }
48
49 /// Generates a map describing the [Parameter] object.
50 Map toMap() {
51 var map = {
52 'name': name,
53 'optional': isOptional,
54 'named': isNamed,
55 'default': hasDefaultValue,
56 'type': new List.filled(1, type.toMap()),
57 'value': defaultValue,
58 'annotations': annotations.map((a) => a.toMap()).toList()
59 };
60 if (functionDeclaration != null) {
61 map['functionDeclaration'] = functionDeclaration.toMap();
62 }
63 return map;
64 }
65 }
OLDNEW
« no previous file with comments | « pkg/docgen/lib/src/models/owned_indexable.dart ('k') | pkg/docgen/lib/src/models/typedef.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698