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

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

Issue 242363004: pkg/docgen: moved model classes into minilibs (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 library docgen.models.variable;
2
3 import '../exports/source_mirrors.dart';
4
5 import '../library_helpers.dart';
6
7 import 'class.dart';
8 import 'doc_gen_type.dart';
9 import 'dummy_mirror.dart';
10 import 'indexable.dart';
11 import 'owned_indexable.dart';
12
13
14 /// A class containing properties of a Dart variable.
15 class Variable extends OwnedIndexable {
16
17 bool isFinal;
18 bool isStatic;
19 bool isConst;
20 DocGenType type;
21 String _variableName;
22
23 factory Variable(String variableName, VariableMirror mirror,
24 Indexable owner) {
25 var variable = getDocgenObject(mirror);
26 if (variable is DummyMirror) {
27 return new Variable._(variableName, mirror, owner);
28 }
29 return variable;
30 }
31
32 Variable._(this._variableName, VariableMirror mirror, Indexable owner) :
33 super(mirror, owner) {
34 isFinal = mirror.isFinal;
35 isStatic = mirror.isStatic;
36 isConst = mirror.isConst;
37 type = new DocGenType(mirror.type, owner.owningLibrary);
38 }
39
40 String get name => _variableName;
41
42 /// Generates a map describing the [Variable] object.
43 Map toMap() => {
44 'name': name,
45 'qualifiedName': qualifiedName,
46 'comment': comment,
47 'final': isFinal,
48 'static': isStatic,
49 'constant': isConst,
50 'type': new List.filled(1, type.toMap()),
51 'annotations': annotations.map((a) => a.toMap()).toList()
52 };
53
54 String get typeName => 'property';
55
56 get comment {
57 if (commentField != null) return commentField;
58 if (owner is Class) {
59 (owner as Class).ensureComments();
60 }
61 return super.comment;
62 }
63
64 String findElementInScope(String name) {
65 var lookupFunc = determineLookupFunc(name);
66 var result = lookupFunc(mirror, name);
67 if (result != null) {
68 result = getDocgenObject(result);
69 if (result is DummyMirror) return packagePrefix + result.docName;
70 return result.packagePrefix + result.docName;
71 }
72
73 if (owner != null) {
74 var result = owner.findElementInScope(name);
75 if (result != null) {
76 return result;
77 }
78 }
79 return super.findElementInScope(name);
80 }
81
82 bool isValidMirror(DeclarationMirror mirror) => mirror is VariableMirror;
83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698