OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library mirrors; | 5 library mirrors; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:uri'; | 8 import 'dart:uri'; |
9 | 9 |
10 // TODO(rnystrom): Use "package:" URL (#4968). | 10 // TODO(rnystrom): Use "package:" URL (#4968). |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 */ | 133 */ |
134 bool get isPrivate; | 134 bool get isPrivate; |
135 | 135 |
136 /** | 136 /** |
137 * Is this declaration top-level? | 137 * Is this declaration top-level? |
138 * | 138 * |
139 * This is defined to be equivalent to: | 139 * This is defined to be equivalent to: |
140 * [:mirror.owner != null && mirror.owner is LibraryMirror:] | 140 * [:mirror.owner != null && mirror.owner is LibraryMirror:] |
141 */ | 141 */ |
142 bool get isTopLevel; | 142 bool get isTopLevel; |
| 143 |
| 144 /** |
| 145 * A list of the metadata associated with this declaration. |
| 146 */ |
| 147 List<InstanceMirror> get metadata; |
| 148 } |
| 149 |
| 150 abstract class ObjectMirror implements Mirror { |
| 151 /** |
| 152 * Invokes a getter and returns a mirror on the result. The getter |
| 153 * can be the implicit getter for a field or a user-defined getter |
| 154 * method. |
| 155 */ |
| 156 Future<InstanceMirror> getField(String fieldName); |
143 } | 157 } |
144 | 158 |
145 /** | 159 /** |
| 160 * An [InstanceMirror] reflects an instance of a Dart language object. |
| 161 */ |
| 162 abstract class InstanceMirror implements ObjectMirror { |
| 163 /** |
| 164 * A mirror on the type of the reflectee. |
| 165 */ |
| 166 ClassMirror get type; |
| 167 |
| 168 /** |
| 169 * Does [reflectee] contain the instance reflected by this mirror? |
| 170 * This will always be true in the local case (reflecting instances |
| 171 * in the same isolate), but only true in the remote case if this |
| 172 * mirror reflects a simple value. |
| 173 * |
| 174 * A value is simple if one of the following holds: |
| 175 * - the value is null |
| 176 * - the value is of type [num] |
| 177 * - the value is of type [bool] |
| 178 * - the value is of type [String] |
| 179 */ |
| 180 bool get hasReflectee; |
| 181 |
| 182 /** |
| 183 * If the [InstanceMirror] reflects an instance it is meaningful to |
| 184 * have a local reference to, we provide access to the actual |
| 185 * instance here. |
| 186 * |
| 187 * If you access [reflectee] when [hasReflectee] is false, an |
| 188 * exception is thrown. |
| 189 */ |
| 190 get reflectee; |
| 191 } |
| 192 |
| 193 /** |
| 194 * Specialized [InstanceMirror] used for reflection on constant lists. |
| 195 */ |
| 196 abstract class ListInstanceMirror |
| 197 implements InstanceMirror, Sequence<Future<InstanceMirror>> { |
| 198 |
| 199 } |
| 200 |
| 201 /** |
| 202 * Specialized [InstanceMirror] used for reflection on constant maps. |
| 203 */ |
| 204 abstract class MapInstanceMirror implements InstanceMirror { |
| 205 /** |
| 206 * Returns a collection containing all the keys in the map. |
| 207 */ |
| 208 Collection<String> get keys; |
| 209 |
| 210 /** |
| 211 * Returns a future on the instance mirror of the value for the given key or |
| 212 * null if key is not in the map. |
| 213 */ |
| 214 Future<InstanceMirror> operator[](String key); |
| 215 |
| 216 /** |
| 217 * The number of {key, value} pairs in the map. |
| 218 */ |
| 219 int get length; |
| 220 } |
| 221 |
| 222 /** |
| 223 * Specialized [InstanceMirror] used for reflection on type constants. |
| 224 */ |
| 225 abstract class TypeInstanceMirror implements InstanceMirror { |
| 226 /** |
| 227 * Returns the type mirror for the type represented by the reflected type |
| 228 * constant. |
| 229 */ |
| 230 TypeMirror get representedType; |
| 231 } |
| 232 |
| 233 /** |
146 * Common interface for classes and libraries. | 234 * Common interface for classes and libraries. |
147 */ | 235 */ |
148 abstract class ContainerMirror implements Mirror { | 236 abstract class ContainerMirror implements Mirror { |
149 | 237 |
150 /** | 238 /** |
151 * An immutable map from from names to mirrors for all members in this | 239 * An immutable map from from names to mirrors for all members in this |
152 * container. | 240 * container. |
153 */ | 241 */ |
154 Map<String, MemberMirror> get members; | 242 Map<String, MemberMirror> get members; |
155 } | 243 } |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 /** | 701 /** |
614 * Returns the URI where the source originated. | 702 * Returns the URI where the source originated. |
615 */ | 703 */ |
616 Uri get sourceUri; | 704 Uri get sourceUri; |
617 | 705 |
618 /** | 706 /** |
619 * Returns the text of this source. | 707 * Returns the text of this source. |
620 */ | 708 */ |
621 String get sourceText; | 709 String get sourceText; |
622 } | 710 } |
| 711 |
| 712 /** |
| 713 * Class used for encoding dartdoc comments as metadata annotations. |
| 714 */ |
| 715 class DartdocComment { |
| 716 final String text; |
| 717 |
| 718 const DartdocComment(this.text); |
| 719 } |
OLD | NEW |