OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library mirrors; |
| 6 |
| 7 import 'dart:mirrors'; |
| 8 import 'dart:mirrors' as api show SourceLocation; |
| 9 export 'dart:mirrors'; |
| 10 |
| 11 abstract class DeclarationSourceMirror implements DeclarationMirror { |
| 12 /// Returns `true` if the name of this declaration is generated by the |
| 13 /// provider of the mirror system. |
| 14 bool get isNameSynthetic; |
| 15 |
| 16 /** |
| 17 * Looks up [name] in the scope of this declaration. |
| 18 * |
| 19 * [name] may be either a single identifier, like 'foo', or of the |
| 20 * a prefixed identifier, like 'foo.bar', where 'foo' must be a prefix. |
| 21 * For methods and constructors, the scope includes the parameters. For |
| 22 * classes and typedefs, the scope includes the type variables. |
| 23 * For classes and class members, the scope includes inherited members. |
| 24 * |
| 25 * See also: |
| 26 * |
| 27 * * [Lexical Scope](https://www.dartlang.org/docs/dart-up-and-running/content
s/ch02.html#ch02-lexical-scope) |
| 28 * in Dart Up and Running. |
| 29 * * [Lexical Scoping](http://www.dartlang.org/docs/spec/latest/dart-language-
specification.html#h.jb82efuudrc5) |
| 30 * in the Dart Specification. |
| 31 */ |
| 32 DeclarationMirror lookupInScope(String name); |
| 33 } |
| 34 |
| 35 /** |
| 36 * Specialized [InstanceMirror] used for reflection on constant lists. |
| 37 */ |
| 38 abstract class ListInstanceMirror implements InstanceMirror { |
| 39 /** |
| 40 * Returns an instance mirror of the value at [index] or throws a [RangeError] |
| 41 * if the [index] is out of bounds. |
| 42 */ |
| 43 InstanceMirror getElement(int index); |
| 44 |
| 45 /** |
| 46 * The number of elements in the list. |
| 47 */ |
| 48 int get length; |
| 49 } |
| 50 |
| 51 /** |
| 52 * Specialized [InstanceMirror] used for reflection on constant maps. |
| 53 */ |
| 54 abstract class MapInstanceMirror implements InstanceMirror { |
| 55 /** |
| 56 * Returns a collection containing all the keys in the map. |
| 57 */ |
| 58 Iterable<String> get keys; |
| 59 |
| 60 /** |
| 61 * Returns an instance mirror of the value for the given key or |
| 62 * null if key is not in the map. |
| 63 */ |
| 64 InstanceMirror getValue(String key); |
| 65 |
| 66 /** |
| 67 * The number of {key, value} pairs in the map. |
| 68 */ |
| 69 int get length; |
| 70 } |
| 71 |
| 72 /** |
| 73 * Specialized [InstanceMirror] used for reflection on type constants. |
| 74 */ |
| 75 abstract class TypeInstanceMirror implements InstanceMirror { |
| 76 /** |
| 77 * Returns the type mirror for the type represented by the reflected type |
| 78 * constant. |
| 79 */ |
| 80 TypeMirror get representedType; |
| 81 } |
| 82 |
| 83 /** |
| 84 * Specialized [InstanceMirror] used for reflection on comments as metadata. |
| 85 */ |
| 86 abstract class CommentInstanceMirror implements InstanceMirror { |
| 87 /** |
| 88 * The comment text as written in the source text. |
| 89 */ |
| 90 String get text; |
| 91 |
| 92 /** |
| 93 * The comment text without the start, end, and padding text. |
| 94 * |
| 95 * For example, if [text] is [: /** Comment text. */ :] then the [trimmedText] |
| 96 * is [: Comment text. :]. |
| 97 */ |
| 98 String get trimmedText; |
| 99 |
| 100 /** |
| 101 * Is [:true:] if this comment is a documentation comment. |
| 102 * |
| 103 * That is, that the comment is either enclosed in [: /** ... */ :] or starts |
| 104 * with [: /// :]. |
| 105 */ |
| 106 bool get isDocComment; |
| 107 } |
| 108 |
| 109 /** |
| 110 * A library. |
| 111 */ |
| 112 abstract class LibrarySourceMirror |
| 113 implements DeclarationSourceMirror, LibraryMirror { |
| 114 /** |
| 115 * Returns a list of the imports and exports in this library; |
| 116 */ |
| 117 List<LibraryDependencyMirror> get libraryDependencies; |
| 118 } |
| 119 |
| 120 /// A mirror on an import or export declaration. |
| 121 abstract class LibraryDependencyMirror { |
| 122 /// Is `true` if this dependency is an import. |
| 123 bool get isImport; |
| 124 |
| 125 /// Is `true` if this dependency is an export. |
| 126 bool get isExport; |
| 127 |
| 128 /// Returns the library mirror of the library that imports or exports the |
| 129 /// [targetLibrary]. |
| 130 LibraryMirror get sourceLibrary; |
| 131 |
| 132 /// Returns the library mirror of the library that is imported or exported. |
| 133 LibraryMirror get targetLibrary; |
| 134 |
| 135 /// Returns the prefix if this is a prefixed import and `null` otherwise. |
| 136 String get prefix; |
| 137 |
| 138 /// Returns the list of show/hide combinators on the import/export |
| 139 /// declaration. |
| 140 List<CombinatorMirror> get combinators; |
| 141 |
| 142 /// Returns the source location for this import/export declaration. |
| 143 SourceLocation get location; |
| 144 } |
| 145 |
| 146 /// A mirror on a show/hide combinator declared on a library dependency. |
| 147 abstract class CombinatorMirror { |
| 148 /// The list of identifiers on the combinator. |
| 149 List<String> get identifiers; |
| 150 |
| 151 /// Is `true` if this is a 'show' combinator. |
| 152 bool get isShow; |
| 153 |
| 154 /// Is `true` if this is a 'hide' combinator. |
| 155 bool get isHide; |
| 156 } |
| 157 |
| 158 /** |
| 159 * Common interface for classes, interfaces, typedefs and type variables. |
| 160 */ |
| 161 abstract class TypeSourceMirror implements DeclarationSourceMirror, TypeMirror { |
| 162 /// Returns `true` is this is a mirror on the void type. |
| 163 bool get isVoid; |
| 164 |
| 165 /// Returns `true` is this is a mirror on the dynamic type. |
| 166 bool get isDynamic; |
| 167 |
| 168 /// Create a type mirror on the instantiation of the declaration of this type |
| 169 /// with [typeArguments] as type arguments. |
| 170 TypeMirror createInstantiation(List<TypeMirror> typeArguments); |
| 171 } |
| 172 |
| 173 /** |
| 174 * A class or interface type. |
| 175 */ |
| 176 abstract class ClassSourceMirror implements TypeSourceMirror, ClassMirror { |
| 177 /** |
| 178 * Is [:true:] if this class is declared abstract. |
| 179 */ |
| 180 bool get isAbstract; |
| 181 } |
| 182 |
| 183 /** |
| 184 * A formal parameter. |
| 185 */ |
| 186 abstract class ParameterSourceMirror implements ParameterMirror { |
| 187 /** |
| 188 * Returns [:true:] iff this parameter is an initializing formal of a |
| 189 * constructor. That is, if it is of the form [:this.x:] where [:x:] is a |
| 190 * field. |
| 191 */ |
| 192 bool get isInitializingFormal; |
| 193 |
| 194 /** |
| 195 * Returns the initialized field, if this parameter is an initializing formal. |
| 196 */ |
| 197 VariableMirror get initializedField; |
| 198 } |
| 199 |
| 200 /** |
| 201 * A [SourceLocation] describes the span of an entity in Dart source code. |
| 202 * A [SourceLocation] with a non-zero [length] should be the minimum span that |
| 203 * encloses the declaration of the mirrored entity. |
| 204 */ |
| 205 abstract class SourceLocation implements api.SourceLocation { |
| 206 /** |
| 207 * The 1-based line number for this source location. |
| 208 * |
| 209 * A value of 0 means that the line number is unknown. |
| 210 */ |
| 211 int get line; |
| 212 |
| 213 /** |
| 214 * The 1-based column number for this source location. |
| 215 * |
| 216 * A value of 0 means that the column number is unknown. |
| 217 */ |
| 218 int get column; |
| 219 |
| 220 /** |
| 221 * The 0-based character offset into the [sourceText] where this source |
| 222 * location begins. |
| 223 * |
| 224 * A value of -1 means that the offset is unknown. |
| 225 */ |
| 226 int get offset; |
| 227 |
| 228 /** |
| 229 * The number of characters in this source location. |
| 230 * |
| 231 * A value of 0 means that the [offset] is approximate. |
| 232 */ |
| 233 int get length; |
| 234 |
| 235 /** |
| 236 * The text of the location span. |
| 237 */ |
| 238 String get text; |
| 239 |
| 240 /** |
| 241 * Returns the URI where the source originated. |
| 242 */ |
| 243 Uri get sourceUri; |
| 244 |
| 245 /** |
| 246 * Returns the text of this source. |
| 247 */ |
| 248 String get sourceText; |
| 249 } |
OLD | NEW |