| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.element; | 8 library engine.element; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| 11 | 11 |
| 12 import 'package:analyzer/src/generated/utilities_general.dart'; | 12 import 'package:analyzer/src/generated/utilities_general.dart'; |
| 13 | 13 |
| 14 import 'ast.dart'; | 14 import 'ast.dart'; |
| 15 import 'constant.dart' show EvaluationResultImpl; | 15 import 'constant.dart' show EvaluationResultImpl; |
| 16 import 'engine.dart' show AnalysisContext, AnalysisEngine, AnalysisException; | 16 import 'engine.dart' show AnalysisContext, AnalysisEngine, AnalysisException; |
| 17 import 'html.dart' show XmlAttributeNode, XmlTagNode; | 17 import 'html.dart' show XmlAttributeNode, XmlTagNode; |
| 18 import 'java_core.dart'; | 18 import 'java_core.dart'; |
| 19 import 'java_engine.dart'; | 19 import 'java_engine.dart'; |
| 20 import 'resolver.dart'; | 20 import 'resolver.dart'; |
| 21 import 'scanner.dart' show Keyword; | 21 import 'scanner.dart' show Keyword; |
| 22 import 'sdk.dart' show DartSdk; | 22 import 'sdk.dart' show DartSdk; |
| 23 import 'source.dart'; | 23 import 'source.dart'; |
| 24 import 'utilities_collection.dart'; | 24 import 'utilities_collection.dart'; |
| 25 import 'utilities_dart.dart'; | 25 import 'utilities_dart.dart'; |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * For AST nodes that could be in both the getter and setter contexts ([IndexExp
ression]s and | 28 * For AST nodes that could be in both the getter and setter contexts |
| 29 * [SimpleIdentifier]s), the additional resolved elements are stored in the AST
node, in an | 29 * ([IndexExpression]s and [SimpleIdentifier]s), the additional resolved |
| 30 * [AuxiliaryElements]. Since resolved elements are either statically resolved o
r resolved | 30 * elements are stored in the AST node, in an [AuxiliaryElements]. Because |
| 31 * using propagated type information, this class is a wrapper for a pair of | 31 * resolved elements are either statically resolved or resolved using propagated |
| 32 * [ExecutableElement]s, not just a single [ExecutableElement]. | 32 * type information, this class is a wrapper for a pair of [ExecutableElement]s, |
| 33 * not just a single [ExecutableElement]. |
| 33 */ | 34 */ |
| 34 class AuxiliaryElements { | 35 class AuxiliaryElements { |
| 35 /** | 36 /** |
| 36 * The element based on propagated type information, or `null` if the AST stru
cture has not | 37 * The element based on propagated type information, or `null` if the AST |
| 37 * been resolved or if this identifier could not be resolved. | 38 * structure has not been resolved or if the node could not be resolved. |
| 38 */ | 39 */ |
| 39 final ExecutableElement propagatedElement; | 40 final ExecutableElement propagatedElement; |
| 40 | 41 |
| 41 /** | 42 /** |
| 42 * The element associated with this identifier based on static type informatio
n, or `null` | 43 * The element based on static type information, or `null` if the AST |
| 43 * if the AST structure has not been resolved or if this identifier could not
be resolved. | 44 * structure has not been resolved or if the node could not be resolved. |
| 44 */ | 45 */ |
| 45 final ExecutableElement staticElement; | 46 final ExecutableElement staticElement; |
| 46 | 47 |
| 47 /** | 48 /** |
| 48 * Create the [AuxiliaryElements] with a static and propagated [ExecutableElem
ent]. | 49 * Initialize a newly created pair to have both the [staticElement] and the |
| 49 * | 50 * [propagatedElement]. |
| 50 * @param staticElement the static element | |
| 51 * @param propagatedElement the propagated element | |
| 52 */ | 51 */ |
| 53 AuxiliaryElements(this.staticElement, this.propagatedElement); | 52 AuxiliaryElements(this.staticElement, this.propagatedElement); |
| 54 } | 53 } |
| 55 | 54 |
| 56 /** | 55 /** |
| 57 * The unique instance of the class `BottomTypeImpl` implements the type `bottom
`. | 56 * A [Type] that represents the type 'bottom'. |
| 58 */ | 57 */ |
| 59 class BottomTypeImpl extends TypeImpl { | 58 class BottomTypeImpl extends TypeImpl { |
| 60 /** | 59 /** |
| 61 * The unique instance of this class. | 60 * The unique instance of this class. |
| 62 */ | 61 */ |
| 63 static BottomTypeImpl _INSTANCE = new BottomTypeImpl(); | 62 static BottomTypeImpl _INSTANCE = new BottomTypeImpl._(); |
| 64 | 63 |
| 65 /** | 64 /** |
| 66 * Return the unique instance of this class. | 65 * Return the unique instance of this class. |
| 67 * | |
| 68 * @return the unique instance of this class | |
| 69 */ | 66 */ |
| 70 static BottomTypeImpl get instance => _INSTANCE; | 67 static BottomTypeImpl get instance => _INSTANCE; |
| 71 | 68 |
| 72 /** | 69 /** |
| 73 * Prevent the creation of instances of this class. | 70 * Prevent the creation of instances of this class. |
| 74 */ | 71 */ |
| 75 BottomTypeImpl() : super(null, "<bottom>"); | 72 BottomTypeImpl._() : super(null, "<bottom>"); |
| 76 | 73 |
| 77 @override | 74 @override |
| 78 int get hashCode => 0; | 75 int get hashCode => 0; |
| 79 | 76 |
| 80 @override | 77 @override |
| 81 bool get isBottom => true; | 78 bool get isBottom => true; |
| 82 | 79 |
| 83 @override | 80 @override |
| 84 bool operator ==(Object object) => identical(object, this); | 81 bool operator ==(Object object) => identical(object, this); |
| 85 | 82 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 100 | 97 |
| 101 @override | 98 @override |
| 102 bool isSupertypeOf(DartType type) => false; | 99 bool isSupertypeOf(DartType type) => false; |
| 103 | 100 |
| 104 @override | 101 @override |
| 105 BottomTypeImpl substitute2( | 102 BottomTypeImpl substitute2( |
| 106 List<DartType> argumentTypes, List<DartType> parameterTypes) => this; | 103 List<DartType> argumentTypes, List<DartType> parameterTypes) => this; |
| 107 } | 104 } |
| 108 | 105 |
| 109 /** | 106 /** |
| 110 * The interface `ClassElement` defines the behavior of elements that represent
a class. | 107 * An element that represents a class. |
| 111 */ | 108 */ |
| 112 abstract class ClassElement implements Element { | 109 abstract class ClassElement implements Element { |
| 113 /** | 110 /** |
| 114 * Return an array containing all of the accessors (getters and setters) decla
red in this class. | 111 * Return a list containing all of the accessors (getters and setters) |
| 115 * | 112 * declared in this class. |
| 116 * @return the accessors declared in this class | |
| 117 */ | 113 */ |
| 118 List<PropertyAccessorElement> get accessors; | 114 List<PropertyAccessorElement> get accessors; |
| 119 | 115 |
| 120 /** | 116 /** |
| 121 * Return an array containing all the supertypes defined for this class and it
s supertypes. This | 117 * Return a list containing all the supertypes defined for this class and its |
| 122 * includes superclasses, mixins and interfaces. | 118 * supertypes. This includes superclasses, mixins and interfaces. |
| 123 * | |
| 124 * @return all the supertypes of this class, including mixins | |
| 125 */ | 119 */ |
| 126 List<InterfaceType> get allSupertypes; | 120 List<InterfaceType> get allSupertypes; |
| 127 | 121 |
| 128 /** | 122 /** |
| 129 * Return an array containing all of the constructors declared in this class. | 123 * Return a list containing all of the constructors declared in this class. |
| 130 * | |
| 131 * @return the constructors declared in this class | |
| 132 */ | 124 */ |
| 133 List<ConstructorElement> get constructors; | 125 List<ConstructorElement> get constructors; |
| 134 | 126 |
| 135 /** | 127 /** |
| 136 * Return an array containing all of the fields declared in this class. | 128 * Return a list containing all of the fields declared in this class. |
| 137 * | |
| 138 * @return the fields declared in this class | |
| 139 */ | 129 */ |
| 140 List<FieldElement> get fields; | 130 List<FieldElement> get fields; |
| 141 | 131 |
| 142 /** | 132 /** |
| 143 * Return `true` if this class or its superclass declares a non-final instance
field. | 133 * Return `true` if this class or its superclass declares a non-final instance |
| 144 * | 134 * field. |
| 145 * @return `true` if this class or its superclass declares a non-final instanc
e field | |
| 146 */ | 135 */ |
| 147 bool get hasNonFinalField; | 136 bool get hasNonFinalField; |
| 148 | 137 |
| 149 /** | 138 /** |
| 150 * Return `true` if this class has reference to super (so, for example, cannot
be used as a | 139 * Return `true` if this class has reference to super (so, for example, cannot |
| 151 * mixin). | 140 * be used as a mixin). |
| 152 * | |
| 153 * @return `true` if this class has reference to super | |
| 154 */ | 141 */ |
| 155 bool get hasReferenceToSuper; | 142 bool get hasReferenceToSuper; |
| 156 | 143 |
| 157 /** | 144 /** |
| 158 * Return `true` if this class declares a static member. | 145 * Return `true` if this class declares a static member. |
| 159 * | |
| 160 * @return `true` if this class declares a static member | |
| 161 */ | 146 */ |
| 162 bool get hasStaticMember; | 147 bool get hasStaticMember; |
| 163 | 148 |
| 164 /** | 149 /** |
| 165 * Return an array containing all of the interfaces that are implemented by th
is class. | 150 * Return a list containing all of the interfaces that are implemented by this |
| 151 * class. |
| 166 * | 152 * |
| 167 * <b>Note:</b> Because the element model represents the state of the code, it
is possible for it | 153 * <b>Note:</b> Because the element model represents the state of the code, it |
| 168 * to be semantically invalid. In particular, it is not safe to assume that th
e inheritance | 154 * is possible for it to be semantically invalid. In particular, it is not |
| 169 * structure of a class does not contain a cycle. Clients that traverse the in
heritance structure | 155 * safe to assume that the inheritance structure of a class does not contain a |
| 170 * must explicitly guard against infinite loops. | 156 * cycle. Clients that traverse the inheritance structure must explicitly |
| 171 * | 157 * guard against infinite loops. |
| 172 * @return the interfaces that are implemented by this class | |
| 173 */ | 158 */ |
| 174 List<InterfaceType> get interfaces; | 159 List<InterfaceType> get interfaces; |
| 175 | 160 |
| 176 /** | 161 /** |
| 177 * Return `true` if this class is abstract. A class is abstract if it has an e
xplicit | 162 * Return `true` if this class is abstract. A class is abstract if it has an |
| 178 * `abstract` modifier. Note, that this definition of <i>abstract</i> is diffe
rent from | 163 * explicit `abstract` modifier. Note, that this definition of <i>abstract</i> |
| 179 * <i>has unimplemented members</i>. | 164 * is different from <i>has unimplemented members</i>. |
| 180 * | |
| 181 * @return `true` if this class is abstract | |
| 182 */ | 165 */ |
| 183 bool get isAbstract; | 166 bool get isAbstract; |
| 184 | 167 |
| 185 /** | 168 /** |
| 186 * Return `true` if this class is defined by an enum declaration. | 169 * Return `true` if this class is defined by an enum declaration. |
| 187 * | |
| 188 * @return `true` if this class is defined by an enum declaration | |
| 189 */ | 170 */ |
| 190 bool get isEnum; | 171 bool get isEnum; |
| 191 | 172 |
| 192 /** | 173 /** |
| 193 * Return `true` if this class [isProxy], or if it inherits the proxy annotati
on | 174 * Return `true` if this class [isProxy], or if it inherits the proxy |
| 194 * from a supertype. | 175 * annotation from a supertype. |
| 195 * | |
| 196 * @return `true` if this class defines or inherits a proxy | |
| 197 */ | 176 */ |
| 198 bool get isOrInheritsProxy; | 177 bool get isOrInheritsProxy; |
| 199 | 178 |
| 200 /** | 179 /** |
| 201 * Return `true` if this element has an annotation of the form '@proxy'. | 180 * Return `true` if this element has an annotation of the form '@proxy'. |
| 202 * | |
| 203 * @return `true` if this element defines a proxy | |
| 204 */ | 181 */ |
| 205 bool get isProxy; | 182 bool get isProxy; |
| 206 | 183 |
| 207 /** | 184 /** |
| 208 * Return `true` if this class is defined by a typedef construct. | 185 * Return `true` if this class is defined by a typedef construct. |
| 209 * | |
| 210 * @return `true` if this class is defined by a typedef construct | |
| 211 */ | 186 */ |
| 212 bool get isTypedef; | 187 bool get isTypedef; |
| 213 | 188 |
| 214 /** | 189 /** |
| 215 * Return `true` if this class can validly be used as a mixin when defining an
other class. | 190 * Return `true` if this class can validly be used as a mixin when defining |
| 216 * The behavior of this method is defined by the Dart Language Specification i
n section 9: | 191 * another class. The behavior of this method is defined by the Dart Language |
| 217 * <blockquote>It is a compile-time error if a declared or derived mixin refer
s to super. It is a | 192 * Specification in section 9: |
| 218 * compile-time error if a declared or derived mixin explicitly declares a con
structor. It is a | 193 * <blockquote> |
| 219 * compile-time error if a mixin is derived from a class whose superclass is n
ot | 194 * It is a compile-time error if a declared or derived mixin refers to super. |
| 220 * Object.</blockquote> | 195 * It is a compile-time error if a declared or derived mixin explicitly |
| 221 * | 196 * declares a constructor. It is a compile-time error if a mixin is derived |
| 222 * @return `true` if this class can validly be used as a mixin | 197 * from a class whose superclass is not Object. |
| 198 * </blockquote> |
| 223 */ | 199 */ |
| 224 bool get isValidMixin; | 200 bool get isValidMixin; |
| 225 | 201 |
| 226 /** | 202 /** |
| 227 * Return an array containing all of the methods declared in this class. | 203 * Return a list containing all of the methods declared in this class. |
| 228 * | |
| 229 * @return the methods declared in this class | |
| 230 */ | 204 */ |
| 231 List<MethodElement> get methods; | 205 List<MethodElement> get methods; |
| 232 | 206 |
| 233 /** | 207 /** |
| 234 * Return an array containing all of the mixins that are applied to the class
being extended in | 208 * Return a list containing all of the mixins that are applied to the class |
| 235 * order to derive the superclass of this class. | 209 * being extended in order to derive the superclass of this class. |
| 236 * | 210 * |
| 237 * <b>Note:</b> Because the element model represents the state of the code, it
is possible for it | 211 * <b>Note:</b> Because the element model represents the state of the code, it |
| 238 * to be semantically invalid. In particular, it is not safe to assume that th
e inheritance | 212 * is possible for it to be semantically invalid. In particular, it is not |
| 239 * structure of a class does not contain a cycle. Clients that traverse the in
heritance structure | 213 * safe to assume that the inheritance structure of a class does not contain a |
| 240 * must explicitly guard against infinite loops. | 214 * cycle. Clients that traverse the inheritance structure must explicitly |
| 241 * | 215 * guard against infinite loops. |
| 242 * @return the mixins that are applied to derive the superclass of this class | |
| 243 */ | 216 */ |
| 244 List<InterfaceType> get mixins; | 217 List<InterfaceType> get mixins; |
| 245 | 218 |
| 246 /** | 219 /** |
| 247 * Return the resolved [ClassDeclaration] node that declares this [ClassElemen
t]. | 220 * Return the resolved [ClassDeclaration] node that declares this |
| 221 * [ClassElement]. |
| 248 * | 222 * |
| 249 * This method is expensive, because resolved AST might be evicted from cache,
so parsing and | 223 * This method is expensive, because resolved AST might be evicted from cache, |
| 250 * resolving will be performed. | 224 * so parsing and resolving will be performed. |
| 251 * | |
| 252 * @return the resolved [ClassDeclaration], not `null`. | |
| 253 */ | 225 */ |
| 254 @override | 226 @override |
| 255 ClassDeclaration get node; | 227 ClassDeclaration get node; |
| 256 | 228 |
| 257 /** | 229 /** |
| 258 * Return the superclass of this class, or `null` if the class represents the
class | 230 * Return the superclass of this class, or `null` if the class represents the |
| 259 * 'Object'. All other classes will have a non-`null` superclass. If the super
class was not | 231 * class 'Object'. All other classes will have a non-`null` superclass. If the |
| 260 * explicitly declared then the implicit superclass 'Object' will be returned. | 232 * superclass was not explicitly declared then the implicit superclass |
| 233 * 'Object' will be returned. |
| 261 * | 234 * |
| 262 * <b>Note:</b> Because the element model represents the state of the code, it
is possible for it | 235 * <b>Note:</b> Because the element model represents the state of the code, it |
| 263 * to be semantically invalid. In particular, it is not safe to assume that th
e inheritance | 236 * is possible for it to be semantically invalid. In particular, it is not |
| 264 * structure of a class does not contain a cycle. Clients that traverse the in
heritance structure | 237 * safe to assume that the inheritance structure of a class does not contain a |
| 265 * must explicitly guard against infinite loops. | 238 * cycle. Clients that traverse the inheritance structure must explicitly |
| 266 * | 239 * guard against infinite loops. |
| 267 * @return the superclass of this class | |
| 268 */ | 240 */ |
| 269 InterfaceType get supertype; | 241 InterfaceType get supertype; |
| 270 | 242 |
| 271 /** | 243 /** |
| 272 * Return the type defined by the class. | 244 * Return the type defined by the class. |
| 273 * | |
| 274 * @return the type defined by the class | |
| 275 */ | 245 */ |
| 276 InterfaceType get type; | 246 InterfaceType get type; |
| 277 | 247 |
| 278 /** | 248 /** |
| 279 * Return an array containing all of the type parameters declared for this cla
ss. | 249 * Return a list containing all of the type parameters declared for this |
| 280 * | 250 * class. |
| 281 * @return the type parameters declared for this class | |
| 282 */ | 251 */ |
| 283 List<TypeParameterElement> get typeParameters; | 252 List<TypeParameterElement> get typeParameters; |
| 284 | 253 |
| 285 /** | 254 /** |
| 286 * Return the unnamed constructor declared in this class, or `null` if this cl
ass does not | 255 * Return the unnamed constructor declared in this class, or `null` if this |
| 287 * declare an unnamed constructor but does declare named constructors. The ret
urned constructor | 256 * class does not declare an unnamed constructor but does declare named |
| 288 * will be synthetic if this class does not declare any constructors, in which
case it will | 257 * constructors. The returned constructor will be synthetic if this class does |
| 289 * represent the default constructor for the class. | 258 * not declare any constructors, in which case it will represent the default |
| 290 * | 259 * constructor for the class. |
| 291 * @return the unnamed constructor defined in this class | |
| 292 */ | 260 */ |
| 293 ConstructorElement get unnamedConstructor; | 261 ConstructorElement get unnamedConstructor; |
| 294 | 262 |
| 295 /** | 263 /** |
| 296 * Return the field (synthetic or explicit) defined in this class that has the
given name, or | 264 * Return the field (synthetic or explicit) defined in this class that has the |
| 297 * `null` if this class does not define a field with the given name. | 265 * given [name], or `null` if this class does not define a field with the |
| 298 * | 266 * given name. |
| 299 * @param fieldName the name of the field to be returned | |
| 300 * @return the field with the given name that is defined in this class | |
| 301 */ | 267 */ |
| 302 FieldElement getField(String fieldName); | 268 FieldElement getField(String name); |
| 303 | 269 |
| 304 /** | 270 /** |
| 305 * Return the element representing the getter with the given name that is decl
ared in this class, | 271 * Return the element representing the getter with the given [name] that is |
| 306 * or `null` if this class does not declare a getter with the given name. | 272 * declared in this class, or `null` if this class does not declare a getter |
| 307 * | 273 * with the given name. |
| 308 * @param getterName the name of the getter to be returned | |
| 309 * @return the getter declared in this class with the given name | |
| 310 */ | 274 */ |
| 311 PropertyAccessorElement getGetter(String getterName); | 275 PropertyAccessorElement getGetter(String name); |
| 312 | 276 |
| 313 /** | 277 /** |
| 314 * Return the element representing the method with the given name that is decl
ared in this class, | 278 * Return the element representing the method with the given [name] that is |
| 315 * or `null` if this class does not declare a method with the given name. | 279 * declared in this class, or `null` if this class does not declare a method |
| 316 * | 280 * with the given name. |
| 317 * @param methodName the name of the method to be returned | |
| 318 * @return the method declared in this class with the given name | |
| 319 */ | 281 */ |
| 320 MethodElement getMethod(String methodName); | 282 MethodElement getMethod(String name); |
| 321 | 283 |
| 322 /** | 284 /** |
| 323 * Return the named constructor declared in this class with the given name, or
`null` if | 285 * Return the named constructor declared in this class with the given [name], |
| 324 * this class does not declare a named constructor with the given name. | 286 * or `null` if this class does not declare a named constructor with the given |
| 325 * | 287 * name. |
| 326 * @param name the name of the constructor to be returned | |
| 327 * @return the element representing the specified constructor | |
| 328 */ | 288 */ |
| 329 ConstructorElement getNamedConstructor(String name); | 289 ConstructorElement getNamedConstructor(String name); |
| 330 | 290 |
| 331 /** | 291 /** |
| 332 * Return the element representing the setter with the given name that is decl
ared in this class, | 292 * Return the element representing the setter with the given [name] that is |
| 333 * or `null` if this class does not declare a setter with the given name. | 293 * declared in this class, or `null` if this class does not declare a setter |
| 334 * | 294 * with the given name. |
| 335 * @param setterName the name of the getter to be returned | |
| 336 * @return the setter declared in this class with the given name | |
| 337 */ | 295 */ |
| 338 PropertyAccessorElement getSetter(String setterName); | 296 PropertyAccessorElement getSetter(String name); |
| 339 | 297 |
| 340 /** | 298 /** |
| 341 * Determine whether the given [constructor], which exists in the superclass | 299 * Determine whether the given [constructor], which exists in the superclass |
| 342 * of this class, is accessible to constructors in this class. | 300 * of this class, is accessible to constructors in this class. |
| 343 */ | 301 */ |
| 344 bool isSuperConstructorAccessible(ConstructorElement constructor); | 302 bool isSuperConstructorAccessible(ConstructorElement constructor); |
| 345 | 303 |
| 346 /** | 304 /** |
| 347 * Return the element representing the method that results from looking up the
given method in | 305 * Return the element representing the method that results from looking up the |
| 348 * this class with respect to the given library, ignoring abstract methods, or
`null` if the | 306 * given [methodName] in this class with respect to the given [library], |
| 349 * look up fails. The behavior of this method is defined by the Dart Language
Specification in | 307 * ignoring abstract methods, or `null` if the look up fails. The behavior of |
| 350 * section 12.15.1: <blockquote> The result of looking up method <i>m</i> in c
lass <i>C</i> with | 308 * this method is defined by the Dart Language Specification in section |
| 351 * respect to library <i>L</i> is: | 309 * 16.15.1: |
| 352 * * If <i>C</i> declares an instance method named <i>m</i> that is accessible
to <i>L</i>, then | 310 * <blockquote> |
| 353 * that method is the result of the lookup. Otherwise, if <i>C</i> has a super
class <i>S</i>, then | 311 * The result of looking up method <i>m</i> in class <i>C</i> with respect to |
| 354 * the result of the lookup is the result of looking up method <i>m</i> in <i>
S</i> with respect | 312 * library <i>L</i> is: If <i>C</i> declares an instance method named <i>m</i> |
| 355 * to <i>L</i>. Otherwise, we say that the lookup has failed. | 313 * that is accessible to <i>L</i>, then that method is the result of the |
| 314 * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result |
| 315 * of the lookup is the result of looking up method <i>m</i> in <i>S</i> with |
| 316 * respect to <i>L</i>. Otherwise, we say that the lookup has failed. |
| 356 * </blockquote> | 317 * </blockquote> |
| 357 * | |
| 358 * @param methodName the name of the method being looked up | |
| 359 * @param library the library with respect to which the lookup is being perfor
med | |
| 360 * @return the result of looking up the given method in this class with respec
t to the given | |
| 361 * library | |
| 362 */ | 318 */ |
| 363 MethodElement lookUpConcreteMethod(String methodName, LibraryElement library); | 319 MethodElement lookUpConcreteMethod(String methodName, LibraryElement library); |
| 364 | 320 |
| 365 /** | 321 /** |
| 366 * Return the element representing the getter that results from looking up the
given getter in | 322 * Return the element representing the getter that results from looking up the |
| 367 * this class with respect to the given library, or `null` if the look up fail
s. The | 323 * given [getterName] in this class with respect to the given [library], or |
| 368 * behavior of this method is defined by the Dart Language Specification in se
ction 12.15.1: | 324 * `null` if the look up fails. The behavior of this method is defined by the |
| 369 * <blockquote>The result of looking up getter (respectively setter) <i>m</i>
in class <i>C</i> | 325 * Dart Language Specification in section 16.15.2: |
| 370 * with respect to library <i>L</i> is: | 326 * <blockquote> |
| 371 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is | 327 * The result of looking up getter (respectively setter) <i>m</i> in class |
| 372 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. | 328 * <i>C</i> with respect to library <i>L</i> is: If <i>C</i> declares an |
| 373 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result | 329 * instance getter (respectively setter) named <i>m</i> that is accessible to |
| 374 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. | 330 * <i>L</i>, then that getter (respectively setter) is the result of the |
| 375 * Otherwise, we say that the lookup has failed. | 331 * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result |
| 332 * of the lookup is the result of looking up getter (respectively setter) |
| 333 * <i>m</i> in <i>S</i> with respect to <i>L</i>. Otherwise, we say that the |
| 334 * lookup has failed. |
| 376 * </blockquote> | 335 * </blockquote> |
| 377 * | |
| 378 * @param getterName the name of the getter being looked up | |
| 379 * @param library the library with respect to which the lookup is being perfor
med | |
| 380 * @return the result of looking up the given getter in this class with respec
t to the given | |
| 381 * library | |
| 382 */ | 336 */ |
| 383 PropertyAccessorElement lookUpGetter( | 337 PropertyAccessorElement lookUpGetter( |
| 384 String getterName, LibraryElement library); | 338 String getterName, LibraryElement library); |
| 385 | 339 |
| 386 /** | 340 /** |
| 387 * Return the element representing the getter that results from looking up the
given getter in the | 341 * Return the element representing the getter that results from looking up the |
| 388 * superclass of this class with respect to the given library, ignoring abstra
ct getters, or | 342 * given [getterName] in the superclass of this class with respect to the |
| 389 * `null` if the look up fails. The behavior of this method is defined by the
Dart Language | 343 * given [library], ignoring abstract getters, or `null` if the look up fails. |
| 390 * Specification in section 12.15.1: <blockquote>The result of looking up gett
er (respectively | 344 * The behavior of this method is defined by the Dart Language Specification |
| 391 * setter) <i>m</i> in class <i>C</i> with respect to library <i>L</i> is: | 345 * in section 16.15.2: |
| 392 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is | 346 * <blockquote> |
| 393 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. | 347 * The result of looking up getter (respectively setter) <i>m</i> in class |
| 394 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result | 348 * <i>C</i> with respect to library <i>L</i> is: If <i>C</i> declares an |
| 395 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. | 349 * instance getter (respectively setter) named <i>m</i> that is accessible to |
| 396 * Otherwise, we say that the lookup has failed. | 350 * <i>L</i>, then that getter (respectively setter) is the result of the |
| 351 * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result |
| 352 * of the lookup is the result of looking up getter (respectively setter) |
| 353 * <i>m</i> in <i>S</i> with respect to <i>L</i>. Otherwise, we say that the |
| 354 * lookup has failed. |
| 397 * </blockquote> | 355 * </blockquote> |
| 398 * | |
| 399 * @param getterName the name of the getter being looked up | |
| 400 * @param library the library with respect to which the lookup is being perfor
med | |
| 401 * @return the result of looking up the given getter in this class with respec
t to the given | |
| 402 * library | |
| 403 */ | 356 */ |
| 404 PropertyAccessorElement lookUpInheritedConcreteGetter( | 357 PropertyAccessorElement lookUpInheritedConcreteGetter( |
| 405 String getterName, LibraryElement library); | 358 String getterName, LibraryElement library); |
| 406 | 359 |
| 407 /** | 360 /** |
| 408 * Return the element representing the method that results from looking up the
given method in the | 361 * Return the element representing the method that results from looking up the |
| 409 * superclass of this class with respect to the given library, ignoring abstra
ct methods, or | 362 * given [methodName] in the superclass of this class with respect to the |
| 410 * `null` if the look up fails. The behavior of this method is defined by the
Dart Language | 363 * given [library], ignoring abstract methods, or `null` if the look up fails. |
| 411 * Specification in section 12.15.1: <blockquote> The result of looking up met
hod <i>m</i> in | 364 * The behavior of this method is defined by the Dart Language Specification |
| 412 * class <i>C</i> with respect to library <i>L</i> is: | 365 * in section 16.15.1: |
| 413 * * If <i>C</i> declares an instance method named <i>m</i> that is accessible
to <i>L</i>, then | 366 * <blockquote> |
| 414 * that method is the result of the lookup. Otherwise, if <i>C</i> has a super
class <i>S</i>, then | 367 * The result of looking up method <i>m</i> in class <i>C</i> with respect to |
| 415 * the result of the lookup is the result of looking up method <i>m</i> in <i>
S</i> with respect | 368 * library <i>L</i> is: If <i>C</i> declares an instance method named |
| 416 * to <i>L</i>. Otherwise, we say that the lookup has failed. | 369 * <i>m</i> that is accessible to <i>L</i>, then that method is the result of |
| 370 * the lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the |
| 371 * result of the lookup is the result of looking up method <i>m</i> in |
| 372 * <i>S</i> with respect to <i>L</i>. Otherwise, we say that the lookup has |
| 373 * failed. |
| 417 * </blockquote> | 374 * </blockquote> |
| 418 * | |
| 419 * @param methodName the name of the method being looked up | |
| 420 * @param library the library with respect to which the lookup is being perfor
med | |
| 421 * @return the result of looking up the given method in the superclass of this
class with respect | |
| 422 * to the given library | |
| 423 */ | 375 */ |
| 424 MethodElement lookUpInheritedConcreteMethod( | 376 MethodElement lookUpInheritedConcreteMethod( |
| 425 String methodName, LibraryElement library); | 377 String methodName, LibraryElement library); |
| 426 | 378 |
| 427 /** | 379 /** |
| 428 * Return the element representing the setter that results from looking up the
given setter in the | 380 * Return the element representing the setter that results from looking up the |
| 429 * superclass of this class with respect to the given library, ignoring abstra
ct setters, or | 381 * given [setterName] in the superclass of this class with respect to the |
| 430 * `null` if the look up fails. The behavior of this method is defined by the
Dart Language | 382 * given [library], ignoring abstract setters, or `null` if the look up fails. |
| 431 * Specification in section 12.16: <blockquote> The result of looking up gette
r (respectively | 383 * The behavior of this method is defined by the Dart Language Specification |
| 432 * setter) <i>m</i> in class <i>C</i> with respect to library <i>L</i> is: | 384 * in section 16.15.2: |
| 433 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is | 385 * <blockquote> |
| 434 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. | 386 * The result of looking up getter (respectively setter) <i>m</i> in class |
| 435 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result | 387 * <i>C</i> with respect to library <i>L</i> is: If <i>C</i> declares an |
| 436 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. | 388 * instance getter (respectively setter) named <i>m</i> that is accessible to |
| 437 * Otherwise, we say that the lookup has failed. | 389 * <i>L</i>, then that getter (respectively setter) is the result of the |
| 390 * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result |
| 391 * of the lookup is the result of looking up getter (respectively setter) |
| 392 * <i>m</i> in <i>S</i> with respect to <i>L</i>. Otherwise, we say that the |
| 393 * lookup has failed. |
| 438 * </blockquote> | 394 * </blockquote> |
| 439 * | |
| 440 * @param setterName the name of the setter being looked up | |
| 441 * @param library the library with respect to which the lookup is being perfor
med | |
| 442 * @return the result of looking up the given setter in this class with respec
t to the given | |
| 443 * library | |
| 444 */ | 395 */ |
| 445 PropertyAccessorElement lookUpInheritedConcreteSetter( | 396 PropertyAccessorElement lookUpInheritedConcreteSetter( |
| 446 String setterName, LibraryElement library); | 397 String setterName, LibraryElement library); |
| 447 | 398 |
| 448 /** | 399 /** |
| 449 * Return the element representing the method that results from looking up the
given method in the | 400 * Return the element representing the method that results from looking up the |
| 450 * superclass of this class with respect to the given library, or `null` if th
e look up | 401 * given [methodName] in the superclass of this class with respect to the |
| 451 * fails. The behavior of this method is defined by the Dart Language Specific
ation in section | 402 * given [library], or `null` if the look up fails. The behavior of this |
| 452 * 12.15.1: <blockquote> The result of looking up method <i>m</i> in class <i>
C</i> with respect | 403 * method is defined by the Dart Language Specification in section 16.15.1: |
| 453 * to library <i>L</i> is: | 404 * <blockquote> |
| 454 * * If <i>C</i> declares an instance method named <i>m</i> that is accessible
to <i>L</i>, then | 405 * The result of looking up method <i>m</i> in class <i>C</i> with respect to |
| 455 * that method is the result of the lookup. Otherwise, if <i>C</i> has a super
class <i>S</i>, then | 406 * library <i>L</i> is: If <i>C</i> declares an instance method named |
| 456 * the result of the lookup is the result of looking up method <i>m</i> in <i>
S</i> with respect | 407 * <i>m</i> that is accessible to <i>L</i>, then that method is the result of |
| 457 * to <i>L</i>. Otherwise, we say that the lookup has failed. | 408 * the lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the |
| 409 * result of the lookup is the result of looking up method <i>m</i> in |
| 410 * <i>S</i> with respect to <i>L</i>. Otherwise, we say that the lookup has |
| 411 * failed. |
| 458 * </blockquote> | 412 * </blockquote> |
| 459 * | |
| 460 * @param methodName the name of the method being looked up | |
| 461 * @param library the library with respect to which the lookup is being perfor
med | |
| 462 * @return the result of looking up the given method in the superclass of this
class with respect | |
| 463 * to the given library | |
| 464 */ | 413 */ |
| 465 MethodElement lookUpInheritedMethod( | 414 MethodElement lookUpInheritedMethod( |
| 466 String methodName, LibraryElement library); | 415 String methodName, LibraryElement library); |
| 467 | 416 |
| 468 /** | 417 /** |
| 469 * Return the element representing the method that results from looking up the
given method in | 418 * Return the element representing the method that results from looking up the |
| 470 * this class with respect to the given library, or `null` if the look up fail
s. The | 419 * given [methodName] in this class with respect to the given [library], or |
| 471 * behavior of this method is defined by the Dart Language Specification in se
ction 12.15.1: | 420 * `null` if the look up fails. The behavior of this method is defined by the |
| 472 * <blockquote> The result of looking up method <i>m</i> in class <i>C</i> wit
h respect to library | 421 * Dart Language Specification in section 16.15.1: |
| 473 * <i>L</i> is: | 422 * <blockquote> |
| 474 * * If <i>C</i> declares an instance method named <i>m</i> that is accessible
to <i>L</i>, then | 423 * The result of looking up method <i>m</i> in class <i>C</i> with respect to |
| 475 * that method is the result of the lookup. Otherwise, if <i>C</i> has a super
class <i>S</i>, then | 424 * library <i>L</i> is: If <i>C</i> declares an instance method named |
| 476 * the result of the lookup is the result of looking up method <i>m</i> in <i>
S</i> with respect | 425 * <i>m</i> that is accessible to <i>L</i>, then that method is the result of |
| 477 * to <i>L</i>. Otherwise, we say that the lookup has failed. | 426 * the lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the |
| 427 * result of the lookup is the result of looking up method <i>m</i> in |
| 428 * <i>S</i> with respect to <i>L</i>. Otherwise, we say that the lookup has |
| 429 * failed. |
| 478 * </blockquote> | 430 * </blockquote> |
| 479 * | |
| 480 * @param methodName the name of the method being looked up | |
| 481 * @param library the library with respect to which the lookup is being perfor
med | |
| 482 * @return the result of looking up the given method in this class with respec
t to the given | |
| 483 * library | |
| 484 */ | 431 */ |
| 485 MethodElement lookUpMethod(String methodName, LibraryElement library); | 432 MethodElement lookUpMethod(String methodName, LibraryElement library); |
| 486 | 433 |
| 487 /** | 434 /** |
| 488 * Return the element representing the setter that results from looking up the
given setter in | 435 * Return the element representing the setter that results from looking up the |
| 489 * this class with respect to the given library, or `null` if the look up fail
s. The | 436 * given [setterName] in this class with respect to the given [library], or |
| 490 * behavior of this method is defined by the Dart Language Specification in se
ction 12.16: | 437 * `null` if the look up fails. The behavior of this method is defined by the |
| 491 * <blockquote> The result of looking up getter (respectively setter) <i>m</i>
in class <i>C</i> | 438 * Dart Language Specification in section 16.15.2: |
| 492 * with respect to library <i>L</i> is: | 439 * <blockquote> |
| 493 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is | 440 * The result of looking up getter (respectively setter) <i>m</i> in class |
| 494 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. | 441 * <i>C</i> with respect to library <i>L</i> is: If <i>C</i> declares an |
| 495 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result | 442 * instance getter (respectively setter) named <i>m</i> that is accessible to |
| 496 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. | 443 * <i>L</i>, then that getter (respectively setter) is the result of the |
| 497 * Otherwise, we say that the lookup has failed. | 444 * lookup. Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result |
| 445 * of the lookup is the result of looking up getter (respectively setter) |
| 446 * <i>m</i> in <i>S</i> with respect to <i>L</i>. Otherwise, we say that the |
| 447 * lookup has failed. |
| 498 * </blockquote> | 448 * </blockquote> |
| 499 * | |
| 500 * @param setterName the name of the setter being looked up | |
| 501 * @param library the library with respect to which the lookup is being perfor
med | |
| 502 * @return the result of looking up the given setter in this class with respec
t to the given | |
| 503 * library | |
| 504 */ | 449 */ |
| 505 PropertyAccessorElement lookUpSetter( | 450 PropertyAccessorElement lookUpSetter( |
| 506 String setterName, LibraryElement library); | 451 String setterName, LibraryElement library); |
| 507 } | 452 } |
| 508 | 453 |
| 509 /** | 454 /** |
| 510 * Instances of the class `ClassElementImpl` implement a `ClassElement`. | 455 * A concrete implementation of a [ClassElement]. |
| 511 */ | 456 */ |
| 512 class ClassElementImpl extends ElementImpl implements ClassElement { | 457 class ClassElementImpl extends ElementImpl implements ClassElement { |
| 513 /** | 458 /** |
| 514 * An empty list of class elements. | 459 * An empty list of class elements. |
| 515 */ | 460 */ |
| 516 static const List<ClassElement> EMPTY_ARRAY = const <ClassElement>[]; | 461 static const List<ClassElement> EMPTY_ARRAY = const <ClassElement>[]; |
| 517 | 462 |
| 518 /** | 463 /** |
| 519 * An array containing all of the accessors (getters and setters) contained in
this class. | 464 * A list containing all of the accessors (getters and setters) contained in |
| 465 * this class. |
| 520 */ | 466 */ |
| 521 List<PropertyAccessorElement> _accessors = | 467 List<PropertyAccessorElement> _accessors = |
| 522 PropertyAccessorElementImpl.EMPTY_ARRAY; | 468 PropertyAccessorElementImpl.EMPTY_ARRAY; |
| 523 | 469 |
| 524 /** | 470 /** |
| 525 * An array containing all of the constructors contained in this class. | 471 * A list containing all of the constructors contained in this class. |
| 526 */ | 472 */ |
| 527 List<ConstructorElement> _constructors = ConstructorElementImpl.EMPTY_ARRAY; | 473 List<ConstructorElement> _constructors = ConstructorElementImpl.EMPTY_ARRAY; |
| 528 | 474 |
| 529 /** | 475 /** |
| 530 * An array containing all of the fields contained in this class. | 476 * A list containing all of the fields contained in this class. |
| 531 */ | 477 */ |
| 532 List<FieldElement> _fields = FieldElementImpl.EMPTY_ARRAY; | 478 List<FieldElement> _fields = FieldElementImpl.EMPTY_ARRAY; |
| 533 | 479 |
| 534 /** | 480 /** |
| 535 * An array containing all of the mixins that are applied to the class being e
xtended in order to | 481 * A list containing all of the mixins that are applied to the class being |
| 536 * derive the superclass of this class. | 482 * extended in order to derive the superclass of this class. |
| 537 */ | 483 */ |
| 538 List<InterfaceType> mixins = InterfaceType.EMPTY_ARRAY; | 484 List<InterfaceType> mixins = InterfaceType.EMPTY_ARRAY; |
| 539 | 485 |
| 540 /** | 486 /** |
| 541 * An array containing all of the interfaces that are implemented by this clas
s. | 487 * A list containing all of the interfaces that are implemented by this class. |
| 542 */ | 488 */ |
| 543 List<InterfaceType> interfaces = InterfaceType.EMPTY_ARRAY; | 489 List<InterfaceType> interfaces = InterfaceType.EMPTY_ARRAY; |
| 544 | 490 |
| 545 /** | 491 /** |
| 546 * An array containing all of the methods contained in this class. | 492 * A list containing all of the methods contained in this class. |
| 547 */ | 493 */ |
| 548 List<MethodElement> _methods = MethodElementImpl.EMPTY_ARRAY; | 494 List<MethodElement> _methods = MethodElementImpl.EMPTY_ARRAY; |
| 549 | 495 |
| 550 /** | 496 /** |
| 551 * The superclass of the class, or `null` if the class does not have an explic
it superclass. | 497 * The superclass of the class, or `null` if the class does not have an |
| 498 * explicit superclass. |
| 552 */ | 499 */ |
| 553 InterfaceType supertype; | 500 InterfaceType supertype; |
| 554 | 501 |
| 555 /** | 502 /** |
| 556 * The type defined by the class. | 503 * The type defined by the class. |
| 557 */ | 504 */ |
| 558 InterfaceType type; | 505 InterfaceType type; |
| 559 | 506 |
| 560 /** | 507 /** |
| 561 * An array containing all of the type parameters defined for this class. | 508 * A list containing all of the type parameters defined for this class. |
| 562 */ | 509 */ |
| 563 List<TypeParameterElement> _typeParameters = | 510 List<TypeParameterElement> _typeParameters = |
| 564 TypeParameterElementImpl.EMPTY_ARRAY; | 511 TypeParameterElementImpl.EMPTY_ARRAY; |
| 565 | 512 |
| 566 /** | 513 /** |
| 567 * Initialize a newly created class element to have the given name. | 514 * Initialize a newly created class element to have the given [name] at the |
| 568 * | 515 * given [offset] in the file that contains the declaration of this element. |
| 569 * @param name the name of this element | |
| 570 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
| 571 * declaration of this element | |
| 572 */ | 516 */ |
| 573 ClassElementImpl(String name, int nameOffset) : super(name, nameOffset); | 517 ClassElementImpl(String name, int offset) : super(name, offset); |
| 574 | 518 |
| 575 /** | 519 /** |
| 576 * Initialize a newly created class element to have the given name. | 520 * Initialize a newly created class element to have the given [name]. |
| 577 * | |
| 578 * @param name the name of this element | |
| 579 */ | 521 */ |
| 580 ClassElementImpl.forNode(Identifier name) : super.forNode(name); | 522 ClassElementImpl.forNode(Identifier name) : super.forNode(name); |
| 581 | 523 |
| 582 /** | 524 /** |
| 583 * Set whether this class is abstract to correspond to the given value. | 525 * Set whether this class is abstract. |
| 584 * | |
| 585 * @param isAbstract `true` if the class is abstract | |
| 586 */ | 526 */ |
| 587 void set abstract(bool isAbstract) { | 527 void set abstract(bool isAbstract) { |
| 588 setModifier(Modifier.ABSTRACT, isAbstract); | 528 setModifier(Modifier.ABSTRACT, isAbstract); |
| 589 } | 529 } |
| 590 | 530 |
| 591 @override | 531 @override |
| 592 List<PropertyAccessorElement> get accessors => _accessors; | 532 List<PropertyAccessorElement> get accessors => _accessors; |
| 593 | 533 |
| 594 /** | 534 /** |
| 595 * Set the accessors contained in this class to the given accessors. | 535 * Set the accessors contained in this class to the given [accessors]. |
| 596 * | |
| 597 * @param accessors the accessors contained in this class | |
| 598 */ | 536 */ |
| 599 void set accessors(List<PropertyAccessorElement> accessors) { | 537 void set accessors(List<PropertyAccessorElement> accessors) { |
| 600 for (PropertyAccessorElement accessor in accessors) { | 538 for (PropertyAccessorElement accessor in accessors) { |
| 601 (accessor as PropertyAccessorElementImpl).enclosingElement = this; | 539 (accessor as PropertyAccessorElementImpl).enclosingElement = this; |
| 602 } | 540 } |
| 603 this._accessors = accessors; | 541 this._accessors = accessors; |
| 604 } | 542 } |
| 605 | 543 |
| 606 @override | 544 @override |
| 607 List<InterfaceType> get allSupertypes { | 545 List<InterfaceType> get allSupertypes { |
| 608 List<InterfaceType> list = new List<InterfaceType>(); | 546 List<InterfaceType> list = new List<InterfaceType>(); |
| 609 _collectAllSupertypes(list); | 547 _collectAllSupertypes(list); |
| 610 return list; | 548 return list; |
| 611 } | 549 } |
| 612 | 550 |
| 613 @override | 551 @override |
| 614 List<ConstructorElement> get constructors => _constructors; | 552 List<ConstructorElement> get constructors => _constructors; |
| 615 | 553 |
| 616 /** | 554 /** |
| 617 * Set the constructors contained in this class to the given constructors. | 555 * Set the constructors contained in this class to the given [constructors]. |
| 618 * | |
| 619 * @param constructors the constructors contained in this class | |
| 620 */ | 556 */ |
| 621 void set constructors(List<ConstructorElement> constructors) { | 557 void set constructors(List<ConstructorElement> constructors) { |
| 622 for (ConstructorElement constructor in constructors) { | 558 for (ConstructorElement constructor in constructors) { |
| 623 (constructor as ConstructorElementImpl).enclosingElement = this; | 559 (constructor as ConstructorElementImpl).enclosingElement = this; |
| 624 } | 560 } |
| 625 this._constructors = constructors; | 561 this._constructors = constructors; |
| 626 } | 562 } |
| 627 | 563 |
| 628 /** | 564 /** |
| 629 * Set whether this class is defined by an enum declaration to correspond to t
he given value. | 565 * Set whether this class is defined by an enum declaration. |
| 630 * | |
| 631 * @param isEnum `true` if the class is defined by an enum declaration | |
| 632 */ | 566 */ |
| 633 void set enum2(bool isEnum) { | 567 void set enum2(bool isEnum) { |
| 634 setModifier(Modifier.ENUM, isEnum); | 568 setModifier(Modifier.ENUM, isEnum); |
| 635 } | 569 } |
| 636 | 570 |
| 637 @override | 571 @override |
| 638 List<FieldElement> get fields => _fields; | 572 List<FieldElement> get fields => _fields; |
| 639 | 573 |
| 640 /** | 574 /** |
| 641 * Set the fields contained in this class to the given fields. | 575 * Set the fields contained in this class to the given [fields]. |
| 642 * | |
| 643 * @param fields the fields contained in this class | |
| 644 */ | 576 */ |
| 645 void set fields(List<FieldElement> fields) { | 577 void set fields(List<FieldElement> fields) { |
| 646 for (FieldElement field in fields) { | 578 for (FieldElement field in fields) { |
| 647 (field as FieldElementImpl).enclosingElement = this; | 579 (field as FieldElementImpl).enclosingElement = this; |
| 648 } | 580 } |
| 649 this._fields = fields; | 581 this._fields = fields; |
| 650 } | 582 } |
| 651 | 583 |
| 652 @override | 584 @override |
| 653 bool get hasNonFinalField { | 585 bool get hasNonFinalField { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 682 } | 614 } |
| 683 } | 615 } |
| 684 // not found | 616 // not found |
| 685 return false; | 617 return false; |
| 686 } | 618 } |
| 687 | 619 |
| 688 @override | 620 @override |
| 689 bool get hasReferenceToSuper => hasModifier(Modifier.REFERENCES_SUPER); | 621 bool get hasReferenceToSuper => hasModifier(Modifier.REFERENCES_SUPER); |
| 690 | 622 |
| 691 /** | 623 /** |
| 692 * Set whether this class references 'super' to the given value. | 624 * Set whether this class references 'super'. |
| 693 * | |
| 694 * @param isReferencedSuper `true` references 'super' | |
| 695 */ | 625 */ |
| 696 void set hasReferenceToSuper(bool isReferencedSuper) { | 626 void set hasReferenceToSuper(bool isReferencedSuper) { |
| 697 setModifier(Modifier.REFERENCES_SUPER, isReferencedSuper); | 627 setModifier(Modifier.REFERENCES_SUPER, isReferencedSuper); |
| 698 } | 628 } |
| 699 | 629 |
| 700 @override | 630 @override |
| 701 bool get hasStaticMember { | 631 bool get hasStaticMember { |
| 702 for (MethodElement method in _methods) { | 632 for (MethodElement method in _methods) { |
| 703 if (method.isStatic) { | 633 if (method.isStatic) { |
| 704 return true; | 634 return true; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 @override | 668 @override |
| 739 bool get isValidMixin => hasModifier(Modifier.MIXIN); | 669 bool get isValidMixin => hasModifier(Modifier.MIXIN); |
| 740 | 670 |
| 741 @override | 671 @override |
| 742 ElementKind get kind => ElementKind.CLASS; | 672 ElementKind get kind => ElementKind.CLASS; |
| 743 | 673 |
| 744 @override | 674 @override |
| 745 List<MethodElement> get methods => _methods; | 675 List<MethodElement> get methods => _methods; |
| 746 | 676 |
| 747 /** | 677 /** |
| 748 * Set the methods contained in this class to the given methods. | 678 * Set the methods contained in this class to the given [methods]. |
| 749 * | |
| 750 * @param methods the methods contained in this class | |
| 751 */ | 679 */ |
| 752 void set methods(List<MethodElement> methods) { | 680 void set methods(List<MethodElement> methods) { |
| 753 for (MethodElement method in methods) { | 681 for (MethodElement method in methods) { |
| 754 (method as MethodElementImpl).enclosingElement = this; | 682 (method as MethodElementImpl).enclosingElement = this; |
| 755 } | 683 } |
| 756 this._methods = methods; | 684 this._methods = methods; |
| 757 } | 685 } |
| 758 | 686 |
| 759 bool get mixinErrorsReported => hasModifier(Modifier.MIXIN_ERRORS_REPORTED); | 687 bool get mixinErrorsReported => hasModifier(Modifier.MIXIN_ERRORS_REPORTED); |
| 760 | 688 |
| 761 /** | 689 /** |
| 762 * Set whether an error has reported explaining why this class is an | 690 * Set whether an error has reported explaining why this class is an |
| 763 * invalid mixin application. | 691 * invalid mixin application. |
| 764 */ | 692 */ |
| 765 void set mixinErrorsReported(bool value) { | 693 void set mixinErrorsReported(bool value) { |
| 766 setModifier(Modifier.MIXIN_ERRORS_REPORTED, value); | 694 setModifier(Modifier.MIXIN_ERRORS_REPORTED, value); |
| 767 } | 695 } |
| 768 | 696 |
| 769 @override | 697 @override |
| 770 ClassDeclaration get node => | 698 ClassDeclaration get node => |
| 771 getNodeMatching((node) => node is ClassDeclaration); | 699 getNodeMatching((node) => node is ClassDeclaration); |
| 772 | 700 |
| 773 /** | 701 /** |
| 774 * Set whether this class is defined by a typedef construct to correspond to t
he given value. | 702 * Set whether this class is defined by a typedef construct. |
| 775 * | |
| 776 * @param isTypedef `true` if the class is defined by a typedef construct | |
| 777 */ | 703 */ |
| 778 void set typedef(bool isTypedef) { | 704 void set typedef(bool isTypedef) { |
| 779 setModifier(Modifier.TYPEDEF, isTypedef); | 705 setModifier(Modifier.TYPEDEF, isTypedef); |
| 780 } | 706 } |
| 781 | 707 |
| 782 @override | 708 @override |
| 783 List<TypeParameterElement> get typeParameters => _typeParameters; | 709 List<TypeParameterElement> get typeParameters => _typeParameters; |
| 784 | 710 |
| 785 /** | 711 /** |
| 786 * Set the type parameters defined for this class to the given type parameters
. | 712 * Set the type parameters defined for this class to the given |
| 787 * | 713 * [typeParameters]. |
| 788 * @param typeParameters the type parameters defined for this class | |
| 789 */ | 714 */ |
| 790 void set typeParameters(List<TypeParameterElement> typeParameters) { | 715 void set typeParameters(List<TypeParameterElement> typeParameters) { |
| 791 for (TypeParameterElement typeParameter in typeParameters) { | 716 for (TypeParameterElement typeParameter in typeParameters) { |
| 792 (typeParameter as TypeParameterElementImpl).enclosingElement = this; | 717 (typeParameter as TypeParameterElementImpl).enclosingElement = this; |
| 793 } | 718 } |
| 794 this._typeParameters = typeParameters; | 719 this._typeParameters = typeParameters; |
| 795 } | 720 } |
| 796 | 721 |
| 797 @override | 722 @override |
| 798 ConstructorElement get unnamedConstructor { | 723 ConstructorElement get unnamedConstructor { |
| 799 for (ConstructorElement element in constructors) { | 724 for (ConstructorElement element in constructors) { |
| 800 String name = element.displayName; | 725 String name = element.displayName; |
| 801 if (name == null || name.isEmpty) { | 726 if (name == null || name.isEmpty) { |
| 802 return element; | 727 return element; |
| 803 } | 728 } |
| 804 } | 729 } |
| 805 return null; | 730 return null; |
| 806 } | 731 } |
| 807 | 732 |
| 808 /** | 733 /** |
| 809 * Set whether this class is a valid mixin to correspond to the given value. | 734 * Set whether this class is a valid mixin. |
| 810 * | |
| 811 * @param isValidMixin `true` if this class can be used as a mixin | |
| 812 */ | 735 */ |
| 813 void set validMixin(bool isValidMixin) { | 736 void set validMixin(bool isValidMixin) { |
| 814 setModifier(Modifier.MIXIN, isValidMixin); | 737 setModifier(Modifier.MIXIN, isValidMixin); |
| 815 } | 738 } |
| 816 | 739 |
| 817 @override | 740 @override |
| 818 accept(ElementVisitor visitor) => visitor.visitClassElement(this); | 741 accept(ElementVisitor visitor) => visitor.visitClassElement(this); |
| 819 | 742 |
| 820 @override | 743 @override |
| 821 void appendTo(StringBuffer buffer) { | 744 void appendTo(StringBuffer buffer) { |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 for (int i = 0; i < supertypes.length; i++) { | 1114 for (int i = 0; i < supertypes.length; i++) { |
| 1192 if (_safeIsOrInheritsProxy(supertypes[i].element, visitedClassElts)) { | 1115 if (_safeIsOrInheritsProxy(supertypes[i].element, visitedClassElts)) { |
| 1193 return true; | 1116 return true; |
| 1194 } | 1117 } |
| 1195 } | 1118 } |
| 1196 return false; | 1119 return false; |
| 1197 } | 1120 } |
| 1198 } | 1121 } |
| 1199 | 1122 |
| 1200 /** | 1123 /** |
| 1201 * The interface `ClassMemberElement` defines the behavior of elements that are
contained | 1124 * An element that is contained within a [ClassElement]. |
| 1202 * within a [ClassElement]. | |
| 1203 */ | 1125 */ |
| 1204 abstract class ClassMemberElement implements Element { | 1126 abstract class ClassMemberElement implements Element { |
| 1205 /** | 1127 /** |
| 1206 * Return the type in which this member is defined. | 1128 * Return the type in which this member is defined. |
| 1207 * | |
| 1208 * @return the type in which this member is defined | |
| 1209 */ | 1129 */ |
| 1210 @override | 1130 @override |
| 1211 ClassElement get enclosingElement; | 1131 ClassElement get enclosingElement; |
| 1212 | 1132 |
| 1213 /** | 1133 /** |
| 1214 * Return `true` if this element is a static element. A static element is an e
lement that is | 1134 * Return `true` if this element is a static element. A static element is an |
| 1215 * not associated with a particular instance, but rather with an entire librar
y or class. | 1135 * element that is not associated with a particular instance, but rather with |
| 1216 * | 1136 * an entire library or class. |
| 1217 * @return `true` if this executable element is a static element | |
| 1218 */ | 1137 */ |
| 1219 bool get isStatic; | 1138 bool get isStatic; |
| 1220 } | 1139 } |
| 1221 | 1140 |
| 1222 /** | 1141 /** |
| 1223 * The interface `CompilationUnitElement` defines the behavior of elements repre
senting a | 1142 * An element representing a compilation unit. |
| 1224 * compilation unit. | |
| 1225 */ | 1143 */ |
| 1226 abstract class CompilationUnitElement implements Element, UriReferencedElement { | 1144 abstract class CompilationUnitElement implements Element, UriReferencedElement { |
| 1227 /** | 1145 /** |
| 1228 * Return an array containing all of the top-level accessors (getters and sett
ers) contained in | 1146 * Return a list containing all of the top-level accessors (getters and |
| 1229 * this compilation unit. | 1147 * setters) contained in this compilation unit. |
| 1230 * | |
| 1231 * @return the top-level accessors contained in this compilation unit | |
| 1232 */ | 1148 */ |
| 1233 List<PropertyAccessorElement> get accessors; | 1149 List<PropertyAccessorElement> get accessors; |
| 1234 | 1150 |
| 1235 /** | 1151 /** |
| 1236 * Return the library in which this compilation unit is defined. | 1152 * Return the library in which this compilation unit is defined. |
| 1237 * | |
| 1238 * @return the library in which this compilation unit is defined | |
| 1239 */ | 1153 */ |
| 1240 @override | 1154 @override |
| 1241 LibraryElement get enclosingElement; | 1155 LibraryElement get enclosingElement; |
| 1242 | 1156 |
| 1243 /** | 1157 /** |
| 1244 * Return an array containing all of the enums contained in this compilation u
nit. | 1158 * Return a list containing all of the enums contained in this compilation |
| 1245 * | 1159 * unit. |
| 1246 * @return an array containing all of the enums contained in this compilation
unit | |
| 1247 */ | 1160 */ |
| 1248 List<ClassElement> get enums; | 1161 List<ClassElement> get enums; |
| 1249 | 1162 |
| 1250 /** | 1163 /** |
| 1251 * Return an array containing all of the top-level functions contained in this
compilation unit. | 1164 * Return a list containing all of the top-level functions contained in this |
| 1252 * | 1165 * compilation unit. |
| 1253 * @return the top-level functions contained in this compilation unit | |
| 1254 */ | 1166 */ |
| 1255 List<FunctionElement> get functions; | 1167 List<FunctionElement> get functions; |
| 1256 | 1168 |
| 1257 /** | 1169 /** |
| 1258 * Return an array containing all of the function type aliases contained in th
is compilation unit. | 1170 * Return a list containing all of the function type aliases contained in this |
| 1259 * | 1171 * compilation unit. |
| 1260 * @return the function type aliases contained in this compilation unit | |
| 1261 */ | 1172 */ |
| 1262 List<FunctionTypeAliasElement> get functionTypeAliases; | 1173 List<FunctionTypeAliasElement> get functionTypeAliases; |
| 1263 | 1174 |
| 1264 /** | 1175 /** |
| 1265 * Return `true` if this compilation unit defines a top-level function named | 1176 * Return `true` if this compilation unit defines a top-level function named |
| 1266 * `loadLibrary`. | 1177 * `loadLibrary`. |
| 1267 * | |
| 1268 * @return `true` if this compilation unit defines a top-level function named | |
| 1269 * `loadLibrary` | |
| 1270 */ | 1178 */ |
| 1271 bool get hasLoadLibraryFunction; | 1179 bool get hasLoadLibraryFunction; |
| 1272 | 1180 |
| 1273 /** | 1181 /** |
| 1274 * Return the resolved [CompilationUnit] node that declares this element. | 1182 * Return the resolved [CompilationUnit] node that declares this element. |
| 1275 * | 1183 * |
| 1276 * This method is expensive, because resolved AST might be evicted from cache,
so parsing and | 1184 * This method is expensive, because resolved AST might be evicted from cache, |
| 1277 * resolving will be performed. | 1185 * so parsing and resolving will be performed. |
| 1278 * | |
| 1279 * @return the resolved [CompilationUnit], not `null`. | |
| 1280 */ | 1186 */ |
| 1281 @override | 1187 @override |
| 1282 CompilationUnit get node; | 1188 CompilationUnit get node; |
| 1283 | 1189 |
| 1284 /** | 1190 /** |
| 1285 * Return an array containing all of the top-level variables contained in this
compilation unit. | 1191 * Return a list containing all of the top-level variables contained in this |
| 1286 * | 1192 * compilation unit. |
| 1287 * @return the top-level variables contained in this compilation unit | |
| 1288 */ | 1193 */ |
| 1289 List<TopLevelVariableElement> get topLevelVariables; | 1194 List<TopLevelVariableElement> get topLevelVariables; |
| 1290 | 1195 |
| 1291 /** | 1196 /** |
| 1292 * Return an array containing all of the classes contained in this compilation
unit. | 1197 * Return a list containing all of the classes contained in this compilation |
| 1293 * | 1198 * unit. |
| 1294 * @return the classes contained in this compilation unit | |
| 1295 */ | 1199 */ |
| 1296 List<ClassElement> get types; | 1200 List<ClassElement> get types; |
| 1297 | 1201 |
| 1298 /** | 1202 /** |
| 1299 * Return the enum defined in this compilation unit that has the given name, o
r `null` if | 1203 * Return the enum defined in this compilation unit that has the given [name], |
| 1300 * this compilation unit does not define an enum with the given name. | 1204 * or `null` if this compilation unit does not define an enum with the given |
| 1301 * | 1205 * name. |
| 1302 * @param enumName the name of the enum to be returned | |
| 1303 * @return the enum with the given name that is defined in this compilation un
it | |
| 1304 */ | 1206 */ |
| 1305 ClassElement getEnum(String enumName); | 1207 ClassElement getEnum(String name); |
| 1306 | 1208 |
| 1307 /** | 1209 /** |
| 1308 * Return the class defined in this compilation unit that has the given name,
or `null` if | 1210 * Return the class defined in this compilation unit that has the given |
| 1309 * this compilation unit does not define a class with the given name. | 1211 * [name], or `null` if this compilation unit does not define a class with the |
| 1310 * | 1212 * given name. |
| 1311 * @param className the name of the class to be returned | |
| 1312 * @return the class with the given name that is defined in this compilation u
nit | |
| 1313 */ | 1213 */ |
| 1314 ClassElement getType(String className); | 1214 ClassElement getType(String name); |
| 1315 } | 1215 } |
| 1316 | 1216 |
| 1317 /** | 1217 /** |
| 1318 * Instances of the class `CompilationUnitElementImpl` implement a | 1218 * A concrete implementation of a [CompilationUnitElement]. |
| 1319 * [CompilationUnitElement]. | |
| 1320 */ | 1219 */ |
| 1321 class CompilationUnitElementImpl extends UriReferencedElementImpl | 1220 class CompilationUnitElementImpl extends UriReferencedElementImpl |
| 1322 implements CompilationUnitElement { | 1221 implements CompilationUnitElement { |
| 1323 /** | 1222 /** |
| 1324 * An empty list of compilation unit elements. | 1223 * An empty list of compilation unit elements. |
| 1325 */ | 1224 */ |
| 1326 static const List<CompilationUnitElement> EMPTY_ARRAY = | 1225 static const List<CompilationUnitElement> EMPTY_ARRAY = |
| 1327 const <CompilationUnitElement>[]; | 1226 const <CompilationUnitElement>[]; |
| 1328 | 1227 |
| 1329 /** | 1228 /** |
| 1330 * The source that corresponds to this compilation unit. | 1229 * The source that corresponds to this compilation unit. |
| 1331 */ | 1230 */ |
| 1332 Source source; | 1231 Source source; |
| 1333 | 1232 |
| 1334 /** | 1233 /** |
| 1335 * An array containing all of the top-level accessors (getters and setters) co
ntained in this | 1234 * A list containing all of the top-level accessors (getters and setters) |
| 1336 * compilation unit. | 1235 * contained in this compilation unit. |
| 1337 */ | 1236 */ |
| 1338 List<PropertyAccessorElement> _accessors = | 1237 List<PropertyAccessorElement> _accessors = |
| 1339 PropertyAccessorElementImpl.EMPTY_ARRAY; | 1238 PropertyAccessorElementImpl.EMPTY_ARRAY; |
| 1340 | 1239 |
| 1341 /** | 1240 /** |
| 1342 * An array containing all of the enums contained in this compilation unit. | 1241 * A list containing all of the enums contained in this compilation unit. |
| 1343 */ | 1242 */ |
| 1344 List<ClassElement> _enums = ClassElementImpl.EMPTY_ARRAY; | 1243 List<ClassElement> _enums = ClassElementImpl.EMPTY_ARRAY; |
| 1345 | 1244 |
| 1346 /** | 1245 /** |
| 1347 * An array containing all of the top-level functions contained in this compil
ation unit. | 1246 * A list containing all of the top-level functions contained in this |
| 1247 * compilation unit. |
| 1348 */ | 1248 */ |
| 1349 List<FunctionElement> _functions = FunctionElementImpl.EMPTY_ARRAY; | 1249 List<FunctionElement> _functions = FunctionElementImpl.EMPTY_ARRAY; |
| 1350 | 1250 |
| 1351 /** | 1251 /** |
| 1352 * An array containing all of the function type aliases contained in this comp
ilation unit. | 1252 * A list containing all of the function type aliases contained in this |
| 1253 * compilation unit. |
| 1353 */ | 1254 */ |
| 1354 List<FunctionTypeAliasElement> _typeAliases = | 1255 List<FunctionTypeAliasElement> _typeAliases = |
| 1355 FunctionTypeAliasElementImpl.EMPTY_ARRAY; | 1256 FunctionTypeAliasElementImpl.EMPTY_ARRAY; |
| 1356 | 1257 |
| 1357 /** | 1258 /** |
| 1358 * An array containing all of the types contained in this compilation unit. | 1259 * A list containing all of the types contained in this compilation unit. |
| 1359 */ | 1260 */ |
| 1360 List<ClassElement> _types = ClassElementImpl.EMPTY_ARRAY; | 1261 List<ClassElement> _types = ClassElementImpl.EMPTY_ARRAY; |
| 1361 | 1262 |
| 1362 /** | 1263 /** |
| 1363 * An array containing all of the variables contained in this compilation unit
. | 1264 * A list containing all of the variables contained in this compilation unit. |
| 1364 */ | 1265 */ |
| 1365 List<TopLevelVariableElement> _variables = | 1266 List<TopLevelVariableElement> _variables = |
| 1366 TopLevelVariableElementImpl.EMPTY_ARRAY; | 1267 TopLevelVariableElementImpl.EMPTY_ARRAY; |
| 1367 | 1268 |
| 1368 /** | 1269 /** |
| 1369 * Initialize a newly created compilation unit element to have the given name. | 1270 * Initialize a newly created compilation unit element to have the given |
| 1370 * | 1271 * [name]. |
| 1371 * @param name the name of this element | |
| 1372 */ | 1272 */ |
| 1373 CompilationUnitElementImpl(String name) : super(name, -1); | 1273 CompilationUnitElementImpl(String name) : super(name, -1); |
| 1374 | 1274 |
| 1375 @override | 1275 @override |
| 1376 List<PropertyAccessorElement> get accessors => _accessors; | 1276 List<PropertyAccessorElement> get accessors => _accessors; |
| 1377 | 1277 |
| 1378 /** | 1278 /** |
| 1379 * Set the top-level accessors (getters and setters) contained in this compila
tion unit to the | 1279 * Set the top-level accessors (getters and setters) contained in this |
| 1380 * given accessors. | 1280 * compilation unit to the given [accessors]. |
| 1381 * | |
| 1382 * @param the top-level accessors (getters and setters) contained in this comp
ilation unit | |
| 1383 */ | 1281 */ |
| 1384 void set accessors(List<PropertyAccessorElement> accessors) { | 1282 void set accessors(List<PropertyAccessorElement> accessors) { |
| 1385 for (PropertyAccessorElement accessor in accessors) { | 1283 for (PropertyAccessorElement accessor in accessors) { |
| 1386 (accessor as PropertyAccessorElementImpl).enclosingElement = this; | 1284 (accessor as PropertyAccessorElementImpl).enclosingElement = this; |
| 1387 } | 1285 } |
| 1388 this._accessors = accessors; | 1286 this._accessors = accessors; |
| 1389 } | 1287 } |
| 1390 | 1288 |
| 1391 @override | 1289 @override |
| 1392 LibraryElement get enclosingElement => | 1290 LibraryElement get enclosingElement => |
| 1393 super.enclosingElement as LibraryElement; | 1291 super.enclosingElement as LibraryElement; |
| 1394 | 1292 |
| 1395 @override | 1293 @override |
| 1396 List<ClassElement> get enums => _enums; | 1294 List<ClassElement> get enums => _enums; |
| 1397 | 1295 |
| 1398 /** | 1296 /** |
| 1399 * Set the enums contained in this compilation unit to the given enums. | 1297 * Set the enums contained in this compilation unit to the given [enums]. |
| 1400 * | |
| 1401 * @param enums enums contained in this compilation unit | |
| 1402 */ | 1298 */ |
| 1403 void set enums(List<ClassElement> enums) { | 1299 void set enums(List<ClassElement> enums) { |
| 1404 for (ClassElement enumDeclaration in enums) { | 1300 for (ClassElement enumDeclaration in enums) { |
| 1405 (enumDeclaration as ClassElementImpl).enclosingElement = this; | 1301 (enumDeclaration as ClassElementImpl).enclosingElement = this; |
| 1406 } | 1302 } |
| 1407 this._enums = enums; | 1303 this._enums = enums; |
| 1408 } | 1304 } |
| 1409 | 1305 |
| 1410 @override | 1306 @override |
| 1411 List<FunctionElement> get functions => _functions; | 1307 List<FunctionElement> get functions => _functions; |
| 1412 | 1308 |
| 1413 /** | 1309 /** |
| 1414 * Set the top-level functions contained in this compilation unit to the given
functions. | 1310 * Set the top-level functions contained in this compilation unit to the given |
| 1415 * | 1311 * [functions]. |
| 1416 * @param functions the top-level functions contained in this compilation unit | |
| 1417 */ | 1312 */ |
| 1418 void set functions(List<FunctionElement> functions) { | 1313 void set functions(List<FunctionElement> functions) { |
| 1419 for (FunctionElement function in functions) { | 1314 for (FunctionElement function in functions) { |
| 1420 (function as FunctionElementImpl).enclosingElement = this; | 1315 (function as FunctionElementImpl).enclosingElement = this; |
| 1421 } | 1316 } |
| 1422 this._functions = functions; | 1317 this._functions = functions; |
| 1423 } | 1318 } |
| 1424 | 1319 |
| 1425 @override | 1320 @override |
| 1426 List<FunctionTypeAliasElement> get functionTypeAliases => _typeAliases; | 1321 List<FunctionTypeAliasElement> get functionTypeAliases => _typeAliases; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1444 @override | 1339 @override |
| 1445 ElementKind get kind => ElementKind.COMPILATION_UNIT; | 1340 ElementKind get kind => ElementKind.COMPILATION_UNIT; |
| 1446 | 1341 |
| 1447 @override | 1342 @override |
| 1448 CompilationUnit get node => unit; | 1343 CompilationUnit get node => unit; |
| 1449 | 1344 |
| 1450 @override | 1345 @override |
| 1451 List<TopLevelVariableElement> get topLevelVariables => _variables; | 1346 List<TopLevelVariableElement> get topLevelVariables => _variables; |
| 1452 | 1347 |
| 1453 /** | 1348 /** |
| 1454 * Set the top-level variables contained in this compilation unit to the given
variables. | 1349 * Set the top-level variables contained in this compilation unit to the given |
| 1455 * | 1350 * [variables]. |
| 1456 * @param variables the top-level variables contained in this compilation unit | |
| 1457 */ | 1351 */ |
| 1458 void set topLevelVariables(List<TopLevelVariableElement> variables) { | 1352 void set topLevelVariables(List<TopLevelVariableElement> variables) { |
| 1459 for (TopLevelVariableElement field in variables) { | 1353 for (TopLevelVariableElement field in variables) { |
| 1460 (field as TopLevelVariableElementImpl).enclosingElement = this; | 1354 (field as TopLevelVariableElementImpl).enclosingElement = this; |
| 1461 } | 1355 } |
| 1462 this._variables = variables; | 1356 this._variables = variables; |
| 1463 } | 1357 } |
| 1464 | 1358 |
| 1465 /** | 1359 /** |
| 1466 * Set the function type aliases contained in this compilation unit to the giv
en type aliases. | 1360 * Set the function type aliases contained in this compilation unit to the |
| 1467 * | 1361 * given [typeAliases]. |
| 1468 * @param typeAliases the function type aliases contained in this compilation
unit | |
| 1469 */ | 1362 */ |
| 1470 void set typeAliases(List<FunctionTypeAliasElement> typeAliases) { | 1363 void set typeAliases(List<FunctionTypeAliasElement> typeAliases) { |
| 1471 for (FunctionTypeAliasElement typeAlias in typeAliases) { | 1364 for (FunctionTypeAliasElement typeAlias in typeAliases) { |
| 1472 (typeAlias as FunctionTypeAliasElementImpl).enclosingElement = this; | 1365 (typeAlias as FunctionTypeAliasElementImpl).enclosingElement = this; |
| 1473 } | 1366 } |
| 1474 this._typeAliases = typeAliases; | 1367 this._typeAliases = typeAliases; |
| 1475 } | 1368 } |
| 1476 | 1369 |
| 1477 @override | 1370 @override |
| 1478 List<ClassElement> get types => _types; | 1371 List<ClassElement> get types => _types; |
| 1479 | 1372 |
| 1480 /** | 1373 /** |
| 1481 * Set the types contained in this compilation unit to the given types. | 1374 * Set the types contained in this compilation unit to the given [types]. |
| 1482 * | |
| 1483 * @param types types contained in this compilation unit | |
| 1484 */ | 1375 */ |
| 1485 void set types(List<ClassElement> types) { | 1376 void set types(List<ClassElement> types) { |
| 1486 for (ClassElement type in types) { | 1377 for (ClassElement type in types) { |
| 1487 (type as ClassElementImpl).enclosingElement = this; | 1378 (type as ClassElementImpl).enclosingElement = this; |
| 1488 } | 1379 } |
| 1489 this._types = types; | 1380 this._types = types; |
| 1490 } | 1381 } |
| 1491 | 1382 |
| 1492 @override | 1383 @override |
| 1493 bool operator ==(Object object) => | 1384 bool operator ==(Object object) => |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1572 safelyVisitChildren(_accessors, visitor); | 1463 safelyVisitChildren(_accessors, visitor); |
| 1573 safelyVisitChildren(_enums, visitor); | 1464 safelyVisitChildren(_enums, visitor); |
| 1574 safelyVisitChildren(_functions, visitor); | 1465 safelyVisitChildren(_functions, visitor); |
| 1575 safelyVisitChildren(_typeAliases, visitor); | 1466 safelyVisitChildren(_typeAliases, visitor); |
| 1576 safelyVisitChildren(_types, visitor); | 1467 safelyVisitChildren(_types, visitor); |
| 1577 safelyVisitChildren(_variables, visitor); | 1468 safelyVisitChildren(_variables, visitor); |
| 1578 } | 1469 } |
| 1579 } | 1470 } |
| 1580 | 1471 |
| 1581 /** | 1472 /** |
| 1582 * Instances of the class `ConstFieldElementImpl` implement a `FieldElement` for
a | 1473 * A [FieldElement] for a 'const' field that has an initializer. |
| 1583 * 'const' field that has an initializer. | |
| 1584 */ | 1474 */ |
| 1585 class ConstFieldElementImpl extends FieldElementImpl { | 1475 class ConstFieldElementImpl extends FieldElementImpl { |
| 1586 /** | 1476 /** |
| 1587 * The result of evaluating this variable's initializer. | 1477 * The result of evaluating this variable's initializer. |
| 1588 */ | 1478 */ |
| 1589 EvaluationResultImpl _result; | 1479 EvaluationResultImpl _result; |
| 1590 | 1480 |
| 1591 /** | 1481 /** |
| 1592 * Initialize a newly created field element to have the given name. | 1482 * Initialize a newly created field element to have the given [name]. |
| 1593 * | |
| 1594 * @param name the name of this element | |
| 1595 */ | 1483 */ |
| 1596 ConstFieldElementImpl.con1(Identifier name) : super.forNode(name); | 1484 ConstFieldElementImpl.con1(Identifier name) : super.forNode(name); |
| 1597 | 1485 |
| 1598 /** | 1486 /** |
| 1599 * Initialize a newly created synthetic field element to have the given name. | 1487 * Initialize a newly created synthetic field element to have the given |
| 1600 * | 1488 * [name] and [offset]. |
| 1601 * @param name the name of this element | |
| 1602 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
| 1603 * declaration of this element | |
| 1604 */ | 1489 */ |
| 1605 ConstFieldElementImpl.con2(String name, int offset) : super(name, offset); | 1490 ConstFieldElementImpl.con2(String name, int offset) : super(name, offset); |
| 1606 | 1491 |
| 1607 @override | 1492 @override |
| 1608 EvaluationResultImpl get evaluationResult => _result; | 1493 EvaluationResultImpl get evaluationResult => _result; |
| 1609 | 1494 |
| 1610 @override | 1495 @override |
| 1611 void set evaluationResult(EvaluationResultImpl result) { | 1496 void set evaluationResult(EvaluationResultImpl result) { |
| 1612 this._result = result; | 1497 this._result = result; |
| 1613 } | 1498 } |
| 1614 } | 1499 } |
| 1615 | 1500 |
| 1616 /** | 1501 /** |
| 1617 * Instances of the class `ConstLocalVariableElementImpl` implement a | 1502 * A [LocalVariableElement] for a local 'const' variable that has an |
| 1618 * `LocalVariableElement` for a local 'const' variable that has an initializer. | 1503 * initializer. |
| 1619 */ | 1504 */ |
| 1620 class ConstLocalVariableElementImpl extends LocalVariableElementImpl { | 1505 class ConstLocalVariableElementImpl extends LocalVariableElementImpl { |
| 1621 /** | 1506 /** |
| 1622 * The result of evaluating this variable's initializer. | 1507 * The result of evaluating this variable's initializer. |
| 1623 */ | 1508 */ |
| 1624 EvaluationResultImpl _result; | 1509 EvaluationResultImpl _result; |
| 1625 | 1510 |
| 1626 /** | 1511 /** |
| 1627 * Initialize a newly created local variable element to have the given name. | 1512 * Initialize a newly created local variable element to have the given [name]. |
| 1628 * | |
| 1629 * @param name the name of this element | |
| 1630 */ | 1513 */ |
| 1631 ConstLocalVariableElementImpl(Identifier name) : super.forNode(name); | 1514 ConstLocalVariableElementImpl(Identifier name) : super.forNode(name); |
| 1632 | 1515 |
| 1633 @override | 1516 @override |
| 1634 EvaluationResultImpl get evaluationResult => _result; | 1517 EvaluationResultImpl get evaluationResult => _result; |
| 1635 | 1518 |
| 1636 @override | 1519 @override |
| 1637 void set evaluationResult(EvaluationResultImpl result) { | 1520 void set evaluationResult(EvaluationResultImpl result) { |
| 1638 this._result = result; | 1521 this._result = result; |
| 1639 } | 1522 } |
| 1640 } | 1523 } |
| 1641 | 1524 |
| 1642 /** | 1525 /** |
| 1643 * The interface `ConstructorElement` defines the behavior of elements represent
ing a | 1526 * An element representing a constructor or a factory method defined within a |
| 1644 * constructor or a factory method defined within a type. | 1527 * class. |
| 1645 */ | 1528 */ |
| 1646 abstract class ConstructorElement | 1529 abstract class ConstructorElement |
| 1647 implements ClassMemberElement, ExecutableElement { | 1530 implements ClassMemberElement, ExecutableElement { |
| 1648 /** | 1531 /** |
| 1649 * Return `true` if this constructor is a const constructor. | 1532 * Return `true` if this constructor is a const constructor. |
| 1650 * | |
| 1651 * @return `true` if this constructor is a const constructor | |
| 1652 */ | 1533 */ |
| 1653 bool get isConst; | 1534 bool get isConst; |
| 1654 | 1535 |
| 1655 /** | 1536 /** |
| 1656 * Return `true` if this constructor can be used as a default constructor - un
named and has | 1537 * Return `true` if this constructor can be used as a default constructor - |
| 1657 * no required parameters. | 1538 * unnamed and has no required parameters. |
| 1658 * | |
| 1659 * @return `true` if this constructor can be used as a default constructor. | |
| 1660 */ | 1539 */ |
| 1661 bool get isDefaultConstructor; | 1540 bool get isDefaultConstructor; |
| 1662 | 1541 |
| 1663 /** | 1542 /** |
| 1664 * Return `true` if this constructor represents a factory constructor. | 1543 * Return `true` if this constructor represents a factory constructor. |
| 1665 * | |
| 1666 * @return `true` if this constructor represents a factory constructor | |
| 1667 */ | 1544 */ |
| 1668 bool get isFactory; | 1545 bool get isFactory; |
| 1669 | 1546 |
| 1670 /** | 1547 /** |
| 1671 * Return the offset of the character immediately following the last character | 1548 * Return the offset of the character immediately following the last character |
| 1672 * of this constructor's name, or `null` if not named. | 1549 * of this constructor's name, or `null` if not named. |
| 1673 */ | 1550 */ |
| 1674 int get nameEnd; | 1551 int get nameEnd; |
| 1675 | 1552 |
| 1676 /** | 1553 /** |
| 1677 * Return the resolved [ConstructorDeclaration] node that declares this | 1554 * Return the resolved [ConstructorDeclaration] node that declares this |
| 1678 * [ConstructorElement] . | 1555 * [ConstructorElement] . |
| 1679 * | 1556 * |
| 1680 * This method is expensive, because resolved AST might be evicted from cache,
so parsing and | 1557 * This method is expensive, because resolved AST might be evicted from cache, |
| 1681 * resolving will be performed. | 1558 * so parsing and resolving will be performed. |
| 1682 * | |
| 1683 * @return the resolved [ConstructorDeclaration], not `null`. | |
| 1684 */ | 1559 */ |
| 1685 @override | 1560 @override |
| 1686 ConstructorDeclaration get node; | 1561 ConstructorDeclaration get node; |
| 1687 | 1562 |
| 1688 /** | 1563 /** |
| 1689 * Return the offset of the `.` before this constructor name, or `null` if | 1564 * Return the offset of the `.` before this constructor name, or `null` if |
| 1690 * not named. | 1565 * not named. |
| 1691 */ | 1566 */ |
| 1692 int get periodOffset; | 1567 int get periodOffset; |
| 1693 | 1568 |
| 1694 /** | 1569 /** |
| 1695 * Return the constructor to which this constructor is redirecting, or `null`
if this | 1570 * Return the constructor to which this constructor is redirecting, or `null` |
| 1696 * constructor does not redirect to another constructor or if the library cont
aining this | 1571 * if this constructor does not redirect to another constructor or if the |
| 1697 * constructor has not yet been resolved. | 1572 * library containing this constructor has not yet been resolved. |
| 1698 * | |
| 1699 * @return the constructor to which this constructor is redirecting | |
| 1700 */ | 1573 */ |
| 1701 ConstructorElement get redirectedConstructor; | 1574 ConstructorElement get redirectedConstructor; |
| 1702 } | 1575 } |
| 1703 | 1576 |
| 1704 /** | 1577 /** |
| 1705 * Instances of the class `ConstructorElementImpl` implement a `ConstructorEleme
nt`. | 1578 * A concrete implementation of a [ConstructorElement]. |
| 1706 */ | 1579 */ |
| 1707 class ConstructorElementImpl extends ExecutableElementImpl | 1580 class ConstructorElementImpl extends ExecutableElementImpl |
| 1708 implements ConstructorElement { | 1581 implements ConstructorElement { |
| 1709 /** | 1582 /** |
| 1710 * An empty list of constructor elements. | 1583 * An empty list of constructor elements. |
| 1711 */ | 1584 */ |
| 1712 static const List<ConstructorElement> EMPTY_ARRAY = | 1585 static const List<ConstructorElement> EMPTY_ARRAY = |
| 1713 const <ConstructorElement>[]; | 1586 const <ConstructorElement>[]; |
| 1714 | 1587 |
| 1715 /** | 1588 /** |
| 1716 * The constructor to which this constructor is redirecting. | 1589 * The constructor to which this constructor is redirecting. |
| 1717 */ | 1590 */ |
| 1718 ConstructorElement redirectedConstructor; | 1591 ConstructorElement redirectedConstructor; |
| 1719 | 1592 |
| 1720 /** | 1593 /** |
| 1721 * The initializers for this constructor (used for evaluating constant instanc
e creation | 1594 * The initializers for this constructor (used for evaluating constant |
| 1722 * expressions). | 1595 * instance creation expressions). |
| 1723 */ | 1596 */ |
| 1724 List<ConstructorInitializer> constantInitializers; | 1597 List<ConstructorInitializer> constantInitializers; |
| 1725 | 1598 |
| 1726 /** | 1599 /** |
| 1727 * The offset of the `.` before this constructor name or `null` if not named. | 1600 * The offset of the `.` before this constructor name or `null` if not named. |
| 1728 */ | 1601 */ |
| 1729 int periodOffset; | 1602 int periodOffset; |
| 1730 | 1603 |
| 1731 /** | 1604 /** |
| 1732 * Return the offset of the character immediately following the last character | 1605 * Return the offset of the character immediately following the last character |
| 1733 * of this constructor's name, or `null` if not named. | 1606 * of this constructor's name, or `null` if not named. |
| 1734 */ | 1607 */ |
| 1735 int nameEnd; | 1608 int nameEnd; |
| 1736 | 1609 |
| 1737 /** | 1610 /** |
| 1738 * Initialize a newly created constructor element to have the given name. | 1611 * Initialize a newly created constructor element to have the given [name] and |
| 1739 * | 1612 * [offset]. |
| 1740 * @param name the name of this element | |
| 1741 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
| 1742 * declaration of this element | |
| 1743 */ | 1613 */ |
| 1744 ConstructorElementImpl(String name, int nameOffset) : super(name, nameOffset); | 1614 ConstructorElementImpl(String name, int offset) : super(name, offset); |
| 1745 | 1615 |
| 1746 /** | 1616 /** |
| 1747 * Initialize a newly created constructor element to have the given name. | 1617 * Initialize a newly created constructor element to have the given [name]. |
| 1748 * | |
| 1749 * @param name the name of this element | |
| 1750 */ | 1618 */ |
| 1751 ConstructorElementImpl.forNode(Identifier name) : super.forNode(name); | 1619 ConstructorElementImpl.forNode(Identifier name) : super.forNode(name); |
| 1752 | 1620 |
| 1753 /** | 1621 /** |
| 1754 * Set whether this constructor represents a 'const' constructor to the given
value. | 1622 * Set whether this constructor represents a 'const' constructor. |
| 1755 * | |
| 1756 * @param isConst `true` if this constructor represents a 'const' constructor | |
| 1757 */ | 1623 */ |
| 1758 void set const2(bool isConst) { | 1624 void set const2(bool isConst) { |
| 1759 setModifier(Modifier.CONST, isConst); | 1625 setModifier(Modifier.CONST, isConst); |
| 1760 } | 1626 } |
| 1761 | 1627 |
| 1762 @override | 1628 @override |
| 1763 ClassElement get enclosingElement => super.enclosingElement as ClassElement; | 1629 ClassElement get enclosingElement => super.enclosingElement as ClassElement; |
| 1764 | 1630 |
| 1765 /** | 1631 /** |
| 1766 * Set whether this constructor represents a factory method to the given value
. | 1632 * Set whether this constructor represents a factory method. |
| 1767 * | |
| 1768 * @param isFactory `true` if this constructor represents a factory method | |
| 1769 */ | 1633 */ |
| 1770 void set factory(bool isFactory) { | 1634 void set factory(bool isFactory) { |
| 1771 setModifier(Modifier.FACTORY, isFactory); | 1635 setModifier(Modifier.FACTORY, isFactory); |
| 1772 } | 1636 } |
| 1773 | 1637 |
| 1774 @override | 1638 @override |
| 1775 bool get isConst => hasModifier(Modifier.CONST); | 1639 bool get isConst => hasModifier(Modifier.CONST); |
| 1776 | 1640 |
| 1777 @override | 1641 @override |
| 1778 bool get isDefaultConstructor { | 1642 bool get isDefaultConstructor { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1826 String name = displayName; | 1690 String name = displayName; |
| 1827 if (name != null && !name.isEmpty) { | 1691 if (name != null && !name.isEmpty) { |
| 1828 buffer.write("."); | 1692 buffer.write("."); |
| 1829 buffer.write(name); | 1693 buffer.write(name); |
| 1830 } | 1694 } |
| 1831 super.appendTo(buffer); | 1695 super.appendTo(buffer); |
| 1832 } | 1696 } |
| 1833 } | 1697 } |
| 1834 | 1698 |
| 1835 /** | 1699 /** |
| 1836 * Instances of the class `ConstructorMember` represent a constructor element de
fined in a | 1700 * A constructor element defined in a parameterized type where the values of the |
| 1837 * parameterized type where the values of the type parameters are known. | 1701 * type parameters are known. |
| 1838 */ | 1702 */ |
| 1839 class ConstructorMember extends ExecutableMember implements ConstructorElement { | 1703 class ConstructorMember extends ExecutableMember implements ConstructorElement { |
| 1840 /** | 1704 /** |
| 1841 * Initialize a newly created element to represent a constructor of the given
parameterized type. | 1705 * Initialize a newly created element to represent a constructor, based on the |
| 1842 * | 1706 * [baseElement], defined by the [definingType]. |
| 1843 * @param baseElement the element on which the parameterized element was creat
ed | |
| 1844 * @param definingType the type in which the element is defined | |
| 1845 */ | 1707 */ |
| 1846 ConstructorMember(ConstructorElement baseElement, InterfaceType definingType) | 1708 ConstructorMember(ConstructorElement baseElement, InterfaceType definingType) |
| 1847 : super(baseElement, definingType); | 1709 : super(baseElement, definingType); |
| 1848 | 1710 |
| 1849 @override | 1711 @override |
| 1850 ConstructorElement get baseElement => super.baseElement as ConstructorElement; | 1712 ConstructorElement get baseElement => super.baseElement as ConstructorElement; |
| 1851 | 1713 |
| 1852 @override | 1714 @override |
| 1853 InterfaceType get definingType => super.definingType as InterfaceType; | 1715 InterfaceType get definingType => super.definingType as InterfaceType; |
| 1854 | 1716 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1902 } | 1764 } |
| 1903 buffer.write(")"); | 1765 buffer.write(")"); |
| 1904 if (type != null) { | 1766 if (type != null) { |
| 1905 buffer.write(Element.RIGHT_ARROW); | 1767 buffer.write(Element.RIGHT_ARROW); |
| 1906 buffer.write(type.returnType); | 1768 buffer.write(type.returnType); |
| 1907 } | 1769 } |
| 1908 return buffer.toString(); | 1770 return buffer.toString(); |
| 1909 } | 1771 } |
| 1910 | 1772 |
| 1911 /** | 1773 /** |
| 1912 * If the given constructor's type is different when any type parameters from
the defining type's | 1774 * If the given [constructor]'s type is different when any type parameters |
| 1913 * declaration are replaced with the actual type arguments from the defining t
ype, create a | 1775 * from the defining type's declaration are replaced with the actual type |
| 1914 * constructor member representing the given constructor. Return the member th
at was created, or | 1776 * arguments from the [definingType], create a constructor member representing |
| 1915 * the base constructor if no member was created. | 1777 * the given constructor. Return the member that was created, or the original |
| 1916 * | 1778 * constructor if no member was created. |
| 1917 * @param baseConstructor the base constructor for which a member might be cre
ated | |
| 1918 * @param definingType the type defining the parameters and arguments to be us
ed in the | |
| 1919 * substitution | |
| 1920 * @return the constructor element that will return the correctly substituted
types | |
| 1921 */ | 1779 */ |
| 1922 static ConstructorElement from( | 1780 static ConstructorElement from( |
| 1923 ConstructorElement baseConstructor, InterfaceType definingType) { | 1781 ConstructorElement constructor, InterfaceType definingType) { |
| 1924 if (baseConstructor == null || definingType.typeArguments.length == 0) { | 1782 if (constructor == null || definingType.typeArguments.length == 0) { |
| 1925 return baseConstructor; | 1783 return constructor; |
| 1926 } | 1784 } |
| 1927 FunctionType baseType = baseConstructor.type; | 1785 FunctionType baseType = constructor.type; |
| 1928 if (baseType == null) { | 1786 if (baseType == null) { |
| 1929 // TODO(brianwilkerson) We need to understand when this can happen. | 1787 // TODO(brianwilkerson) We need to understand when this can happen. |
| 1930 return baseConstructor; | 1788 return constructor; |
| 1931 } | 1789 } |
| 1932 List<DartType> argumentTypes = definingType.typeArguments; | 1790 List<DartType> argumentTypes = definingType.typeArguments; |
| 1933 List<DartType> parameterTypes = definingType.element.type.typeArguments; | 1791 List<DartType> parameterTypes = definingType.element.type.typeArguments; |
| 1934 FunctionType substitutedType = | 1792 FunctionType substitutedType = |
| 1935 baseType.substitute2(argumentTypes, parameterTypes); | 1793 baseType.substitute2(argumentTypes, parameterTypes); |
| 1936 if (baseType == substitutedType) { | 1794 if (baseType == substitutedType) { |
| 1937 return baseConstructor; | 1795 return constructor; |
| 1938 } | 1796 } |
| 1939 // TODO(brianwilkerson) Consider caching the substituted type in the | 1797 // TODO(brianwilkerson) Consider caching the substituted type in the |
| 1940 // instance. It would use more memory but speed up some operations. | 1798 // instance. It would use more memory but speed up some operations. |
| 1941 // We need to see how often the type is being re-computed. | 1799 // We need to see how often the type is being re-computed. |
| 1942 return new ConstructorMember(baseConstructor, definingType); | 1800 return new ConstructorMember(constructor, definingType); |
| 1943 } | 1801 } |
| 1944 } | 1802 } |
| 1945 | 1803 |
| 1946 /** | 1804 /** |
| 1947 * Instances of the class `ConstTopLevelVariableElementImpl` implement a | 1805 * A [TopLevelVariableElement] for a top-level 'const' variable that has an |
| 1948 * `TopLevelVariableElement` for a top-level 'const' variable that has an initia
lizer. | 1806 * initializer. |
| 1949 */ | 1807 */ |
| 1950 class ConstTopLevelVariableElementImpl extends TopLevelVariableElementImpl { | 1808 class ConstTopLevelVariableElementImpl extends TopLevelVariableElementImpl { |
| 1951 /** | 1809 /** |
| 1952 * The result of evaluating this variable's initializer. | 1810 * The result of evaluating this variable's initializer. |
| 1953 */ | 1811 */ |
| 1954 EvaluationResultImpl _result; | 1812 EvaluationResultImpl _result; |
| 1955 | 1813 |
| 1956 /** | 1814 /** |
| 1957 * Initialize a newly created top-level variable element to have the given nam
e. | 1815 * Initialize a newly created top-level variable element to have the given |
| 1958 * | 1816 * [name]. |
| 1959 * @param name the name of this element | |
| 1960 */ | 1817 */ |
| 1961 ConstTopLevelVariableElementImpl(Identifier name) : super.forNode(name); | 1818 ConstTopLevelVariableElementImpl(Identifier name) : super.forNode(name); |
| 1962 | 1819 |
| 1963 @override | 1820 @override |
| 1964 EvaluationResultImpl get evaluationResult => _result; | 1821 EvaluationResultImpl get evaluationResult => _result; |
| 1965 | 1822 |
| 1966 @override | 1823 @override |
| 1967 void set evaluationResult(EvaluationResultImpl result) { | 1824 void set evaluationResult(EvaluationResultImpl result) { |
| 1968 this._result = result; | 1825 this._result = result; |
| 1969 } | 1826 } |
| 1970 } | 1827 } |
| 1971 | 1828 |
| 1972 /** | 1829 /** |
| 1973 * The interface `DartType` defines the behavior of objects representing the | 1830 * The type associated with elements in the element model. |
| 1974 * declared type of elements in the element model. | |
| 1975 */ | 1831 */ |
| 1976 abstract class DartType { | 1832 abstract class DartType { |
| 1977 /** | 1833 /** |
| 1978 * Return the name of this type as it should appear when presented to users in | 1834 * Return the name of this type as it should appear when presented to users in |
| 1979 * contexts such as error messages. | 1835 * contexts such as error messages. |
| 1980 */ | 1836 */ |
| 1981 String get displayName; | 1837 String get displayName; |
| 1982 | 1838 |
| 1983 /** | 1839 /** |
| 1984 * Return the element representing the declaration of this type, or `null` if | 1840 * Return the element representing the declaration of this type, or `null` if |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2070 * type directly. | 1926 * type directly. |
| 2071 * | 1927 * |
| 2072 * Note too that the current implementation of this method is only guaranteed | 1928 * Note too that the current implementation of this method is only guaranteed |
| 2073 * to work when the argument types are type variables. | 1929 * to work when the argument types are type variables. |
| 2074 */ | 1930 */ |
| 2075 DartType substitute2( | 1931 DartType substitute2( |
| 2076 List<DartType> argumentTypes, List<DartType> parameterTypes); | 1932 List<DartType> argumentTypes, List<DartType> parameterTypes); |
| 2077 } | 1933 } |
| 2078 | 1934 |
| 2079 /** | 1935 /** |
| 2080 * Instances of the class `DefaultFieldFormalParameterElementImpl` implement a | 1936 * A [FieldFormalParameterElementImpl] for parameters that have an initializer. |
| 2081 * `FieldFormalParameterElementImpl` for parameters that have an initializer. | |
| 2082 */ | 1937 */ |
| 2083 class DefaultFieldFormalParameterElementImpl | 1938 class DefaultFieldFormalParameterElementImpl |
| 2084 extends FieldFormalParameterElementImpl { | 1939 extends FieldFormalParameterElementImpl { |
| 2085 /** | 1940 /** |
| 2086 * The result of evaluating this variable's initializer. | 1941 * The result of evaluating this variable's initializer. |
| 2087 */ | 1942 */ |
| 2088 EvaluationResultImpl _result; | 1943 EvaluationResultImpl _result; |
| 2089 | 1944 |
| 2090 /** | 1945 /** |
| 2091 * Initialize a newly created parameter element to have the given name. | 1946 * Initialize a newly created parameter element to have the given [name]. |
| 2092 * | |
| 2093 * @param name the name of this element | |
| 2094 */ | 1947 */ |
| 2095 DefaultFieldFormalParameterElementImpl(Identifier name) : super(name); | 1948 DefaultFieldFormalParameterElementImpl(Identifier name) : super(name); |
| 2096 | 1949 |
| 2097 @override | 1950 @override |
| 2098 EvaluationResultImpl get evaluationResult => _result; | 1951 EvaluationResultImpl get evaluationResult => _result; |
| 2099 | 1952 |
| 2100 @override | 1953 @override |
| 2101 void set evaluationResult(EvaluationResultImpl result) { | 1954 void set evaluationResult(EvaluationResultImpl result) { |
| 2102 this._result = result; | 1955 this._result = result; |
| 2103 } | 1956 } |
| 2104 } | 1957 } |
| 2105 | 1958 |
| 2106 /** | 1959 /** |
| 2107 * Instances of the class `DefaultParameterElementImpl` implement a `ParameterEl
ement` | 1960 * A [ParameterElement] for parameters that have an initializer. |
| 2108 * for parameters that have an initializer. | |
| 2109 */ | 1961 */ |
| 2110 class DefaultParameterElementImpl extends ParameterElementImpl { | 1962 class DefaultParameterElementImpl extends ParameterElementImpl { |
| 2111 /** | 1963 /** |
| 2112 * The result of evaluating this variable's initializer. | 1964 * The result of evaluating this variable's initializer. |
| 2113 */ | 1965 */ |
| 2114 EvaluationResultImpl _result; | 1966 EvaluationResultImpl _result; |
| 2115 | 1967 |
| 2116 /** | 1968 /** |
| 2117 * Initialize a newly created parameter element to have the given name. | 1969 * Initialize a newly created parameter element to have the given [name]. |
| 2118 * | |
| 2119 * @param name the name of this element | |
| 2120 */ | 1970 */ |
| 2121 DefaultParameterElementImpl(Identifier name) : super.forNode(name); | 1971 DefaultParameterElementImpl(Identifier name) : super.forNode(name); |
| 2122 | 1972 |
| 2123 @override | 1973 @override |
| 2124 EvaluationResultImpl get evaluationResult => _result; | 1974 EvaluationResultImpl get evaluationResult => _result; |
| 2125 | 1975 |
| 2126 @override | 1976 @override |
| 2127 void set evaluationResult(EvaluationResultImpl result) { | 1977 void set evaluationResult(EvaluationResultImpl result) { |
| 2128 this._result = result; | 1978 this._result = result; |
| 2129 } | 1979 } |
| 2130 } | 1980 } |
| 2131 | 1981 |
| 2132 /** | 1982 /** |
| 2133 * Instances of the class `DynamicElementImpl` represent the synthetic element r
epresenting | 1983 * The synthetic element representing the declaration of the type `dynamic`. |
| 2134 * the declaration of the type `dynamic`. | |
| 2135 */ | 1984 */ |
| 2136 class DynamicElementImpl extends ElementImpl { | 1985 class DynamicElementImpl extends ElementImpl { |
| 2137 /** | 1986 /** |
| 2138 * Return the unique instance of this class. | 1987 * Return the unique instance of this class. |
| 2139 * | |
| 2140 * @return the unique instance of this class | |
| 2141 */ | 1988 */ |
| 2142 static DynamicElementImpl get instance => | 1989 static DynamicElementImpl get instance => |
| 2143 DynamicTypeImpl.instance.element as DynamicElementImpl; | 1990 DynamicTypeImpl.instance.element as DynamicElementImpl; |
| 2144 | 1991 |
| 2145 /** | 1992 /** |
| 2146 * The type defined by this element. | 1993 * The type defined by this element. |
| 2147 */ | 1994 */ |
| 2148 DynamicTypeImpl type; | 1995 DynamicTypeImpl type; |
| 2149 | 1996 |
| 2150 /** | 1997 /** |
| 2151 * Initialize a newly created instance of this class. Instances of this class
should <b>not</b> be | 1998 * Initialize a newly created instance of this class. Instances of this class |
| 2152 * created except as part of creating the type associated with this element. T
he single instance | 1999 * should <b>not</b> be created except as part of creating the type associated |
| 2153 * of this class should be accessed through the method [getInstance]. | 2000 * with this element. The single instance of this class should be accessed |
| 2001 * through the method [getInstance]. |
| 2154 */ | 2002 */ |
| 2155 DynamicElementImpl() : super(Keyword.DYNAMIC.syntax, -1) { | 2003 DynamicElementImpl() : super(Keyword.DYNAMIC.syntax, -1) { |
| 2156 setModifier(Modifier.SYNTHETIC, true); | 2004 setModifier(Modifier.SYNTHETIC, true); |
| 2157 } | 2005 } |
| 2158 | 2006 |
| 2159 @override | 2007 @override |
| 2160 ElementKind get kind => ElementKind.DYNAMIC; | 2008 ElementKind get kind => ElementKind.DYNAMIC; |
| 2161 | 2009 |
| 2162 @override | 2010 @override |
| 2163 accept(ElementVisitor visitor) => null; | 2011 accept(ElementVisitor visitor) => null; |
| 2164 } | 2012 } |
| 2165 | 2013 |
| 2166 /** | 2014 /** |
| 2167 * The unique instance of the class `DynamicTypeImpl` implements the type `dynam
ic`. | 2015 * The [Type] representing the type `dynamic`. |
| 2168 */ | 2016 */ |
| 2169 class DynamicTypeImpl extends TypeImpl { | 2017 class DynamicTypeImpl extends TypeImpl { |
| 2170 /** | 2018 /** |
| 2171 * The unique instance of this class. | 2019 * The unique instance of this class. |
| 2172 */ | 2020 */ |
| 2173 static DynamicTypeImpl _INSTANCE = new DynamicTypeImpl._(); | 2021 static DynamicTypeImpl _INSTANCE = new DynamicTypeImpl._(); |
| 2174 | 2022 |
| 2175 /** | 2023 /** |
| 2176 * Return the unique instance of this class. | 2024 * Return the unique instance of this class. |
| 2177 * | |
| 2178 * @return the unique instance of this class | |
| 2179 */ | 2025 */ |
| 2180 static DynamicTypeImpl get instance => _INSTANCE; | 2026 static DynamicTypeImpl get instance => _INSTANCE; |
| 2181 | 2027 |
| 2182 /** | 2028 /** |
| 2183 * Prevent the creation of instances of this class. | 2029 * Prevent the creation of instances of this class. |
| 2184 */ | 2030 */ |
| 2185 DynamicTypeImpl._() | 2031 DynamicTypeImpl._() |
| 2186 : super(new DynamicElementImpl(), Keyword.DYNAMIC.syntax) { | 2032 : super(new DynamicElementImpl(), Keyword.DYNAMIC.syntax) { |
| 2187 (element as DynamicElementImpl).type = this; | 2033 (element as DynamicElementImpl).type = this; |
| 2188 } | 2034 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2228 for (int i = 0; i < length; i++) { | 2074 for (int i = 0; i < length; i++) { |
| 2229 if (parameterTypes[i] == this) { | 2075 if (parameterTypes[i] == this) { |
| 2230 return argumentTypes[i]; | 2076 return argumentTypes[i]; |
| 2231 } | 2077 } |
| 2232 } | 2078 } |
| 2233 return this; | 2079 return this; |
| 2234 } | 2080 } |
| 2235 } | 2081 } |
| 2236 | 2082 |
| 2237 /** | 2083 /** |
| 2238 * The interface `Element` defines the behavior common to all of the elements in
the element | 2084 * The base class for all of the elements in the element model. Generally |
| 2239 * model. Generally speaking, the element model is a semantic model of the progr
am that represents | 2085 * speaking, the element model is a semantic model of the program that |
| 2240 * things that are declared with a name and hence can be referenced elsewhere in
the code. | 2086 * represents things that are declared with a name and hence can be referenced |
| 2087 * elsewhere in the code. |
| 2241 * | 2088 * |
| 2242 * There are two exceptions to the general case. First, there are elements in th
e element model that | 2089 * There are two exceptions to the general case. First, there are elements in |
| 2243 * are created for the convenience of various kinds of analysis but that do not
have any | 2090 * the element model that are created for the convenience of various kinds of |
| 2244 * corresponding declaration within the source code. Such elements are marked as
being | 2091 * analysis but that do not have any corresponding declaration within the source |
| 2245 * <i>synthetic</i>. Examples of synthetic elements include | 2092 * code. Such elements are marked as being <i>synthetic</i>. Examples of |
| 2246 * * default constructors in classes that do not define any explicit constructor
s, | 2093 * synthetic elements include |
| 2094 * * default constructors in classes that do not define any explicit |
| 2095 * constructors, |
| 2247 * * getters and setters that are induced by explicit field declarations, | 2096 * * getters and setters that are induced by explicit field declarations, |
| 2248 * * fields that are induced by explicit declarations of getters and setters, an
d | 2097 * * fields that are induced by explicit declarations of getters and setters, |
| 2098 * and |
| 2249 * * functions representing the initialization expression for a variable. | 2099 * * functions representing the initialization expression for a variable. |
| 2250 * | 2100 * |
| 2251 * Second, there are elements in the element model that do not have a name. Thes
e correspond to | 2101 * Second, there are elements in the element model that do not have a name. |
| 2252 * unnamed functions and exist in order to more accurately represent the semanti
c structure of the | 2102 * These correspond to unnamed functions and exist in order to more accurately |
| 2253 * program. | 2103 * represent the semantic structure of the program. |
| 2254 */ | 2104 */ |
| 2255 abstract class Element { | 2105 abstract class Element { |
| 2256 /** | 2106 /** |
| 2257 * An Unicode right arrow. | 2107 * An Unicode right arrow. |
| 2258 */ | 2108 */ |
| 2259 static final String RIGHT_ARROW = " \u2192 "; | 2109 static final String RIGHT_ARROW = " \u2192 "; |
| 2260 | 2110 |
| 2261 /** | 2111 /** |
| 2262 * A comparator that can be used to sort elements by their name offset. Elemen
ts with a smaller | 2112 * A comparator that can be used to sort elements by their name offset. |
| 2263 * offset will be sorted to be before elements with a larger name offset. | 2113 * Elements with a smaller offset will be sorted to be before elements with a |
| 2114 * larger name offset. |
| 2264 */ | 2115 */ |
| 2265 static final Comparator<Element> SORT_BY_OFFSET = (Element firstElement, | 2116 static final Comparator<Element> SORT_BY_OFFSET = (Element firstElement, |
| 2266 Element secondElement) => | 2117 Element secondElement) => |
| 2267 firstElement.nameOffset - secondElement.nameOffset; | 2118 firstElement.nameOffset - secondElement.nameOffset; |
| 2268 | 2119 |
| 2269 /** | 2120 /** |
| 2270 * Return the analysis context in which this element is defined. | 2121 * Return the analysis context in which this element is defined. |
| 2271 * | |
| 2272 * @return the analysis context in which this element is defined | |
| 2273 */ | 2122 */ |
| 2274 AnalysisContext get context; | 2123 AnalysisContext get context; |
| 2275 | 2124 |
| 2276 /** | 2125 /** |
| 2277 * Return the display name of this element, or `null` if this element does not
have a name. | 2126 * Return the display name of this element, or `null` if this element does not |
| 2127 * have a name. |
| 2278 * | 2128 * |
| 2279 * In most cases the name and the display name are the same. Differences thoug
h are cases such as | 2129 * In most cases the name and the display name are the same. Differences |
| 2280 * setters where the name of some setter `set f(x)` is `f=`, instead of `f`. | 2130 * though are cases such as setters where the name of some setter `set f(x)` |
| 2281 * | 2131 * is `f=`, instead of `f`. |
| 2282 * @return the display name of this element | |
| 2283 */ | 2132 */ |
| 2284 String get displayName; | 2133 String get displayName; |
| 2285 | 2134 |
| 2286 /** | 2135 /** |
| 2287 * Return the element that either physically or logically encloses this elemen
t. This will be | 2136 * Return the element that either physically or logically encloses this |
| 2288 * `null` if this element is a library because libraries are the top-level ele
ments in the | 2137 * element. This will be `null` if this element is a library because libraries |
| 2289 * model. | 2138 * are the top-level elements in the model. |
| 2290 * | |
| 2291 * @return the element that encloses this element | |
| 2292 */ | 2139 */ |
| 2293 Element get enclosingElement; | 2140 Element get enclosingElement; |
| 2294 | 2141 |
| 2295 /** | 2142 /** |
| 2296 * The unique integer identifier of this element. | 2143 * The unique integer identifier of this element. |
| 2297 */ | 2144 */ |
| 2298 int get id; | 2145 int get id; |
| 2299 | 2146 |
| 2300 /** | 2147 /** |
| 2301 * Return `true` if this element has an annotation of the form '@deprecated' o
r | 2148 * Return `true` if this element has an annotation of the form '@deprecated' |
| 2302 * '@Deprecated('..')'. | 2149 * or '@Deprecated('..')'. |
| 2303 * | |
| 2304 * @return `true` if this element is deprecated | |
| 2305 */ | 2150 */ |
| 2306 bool get isDeprecated; | 2151 bool get isDeprecated; |
| 2307 | 2152 |
| 2308 /** | 2153 /** |
| 2309 * Return `true` if this element has an annotation of the form '@override'. | 2154 * Return `true` if this element has an annotation of the form '@override'. |
| 2310 * | |
| 2311 * @return `true` if this element is overridden | |
| 2312 */ | 2155 */ |
| 2313 bool get isOverride; | 2156 bool get isOverride; |
| 2314 | 2157 |
| 2315 /** | 2158 /** |
| 2316 * Return `true` if this element is private. Private elements are visible only
within the | 2159 * Return `true` if this element is private. Private elements are visible only |
| 2317 * library in which they are declared. | 2160 * within the library in which they are declared. |
| 2318 * | |
| 2319 * @return `true` if this element is private | |
| 2320 */ | 2161 */ |
| 2321 bool get isPrivate; | 2162 bool get isPrivate; |
| 2322 | 2163 |
| 2323 /** | 2164 /** |
| 2324 * Return `true` if this element is public. Public elements are visible within
any library | 2165 * Return `true` if this element is public. Public elements are visible within |
| 2325 * that imports the library in which they are declared. | 2166 * any library that imports the library in which they are declared. |
| 2326 * | |
| 2327 * @return `true` if this element is public | |
| 2328 */ | 2167 */ |
| 2329 bool get isPublic; | 2168 bool get isPublic; |
| 2330 | 2169 |
| 2331 /** | 2170 /** |
| 2332 * Return `true` if this element is synthetic. A synthetic element is an eleme
nt that is not | 2171 * Return `true` if this element is synthetic. A synthetic element is an |
| 2333 * represented in the source code explicitly, but is implied by the source cod
e, such as the | 2172 * element that is not represented in the source code explicitly, but is |
| 2334 * default constructor for a class that does not explicitly define any constru
ctors. | 2173 * implied by the source code, such as the default constructor for a class |
| 2335 * | 2174 * that does not explicitly define any constructors. |
| 2336 * @return `true` if this element is synthetic | |
| 2337 */ | 2175 */ |
| 2338 bool get isSynthetic; | 2176 bool get isSynthetic; |
| 2339 | 2177 |
| 2340 /** | 2178 /** |
| 2341 * Return the kind of element that this is. | 2179 * Return the kind of element that this is. |
| 2342 * | |
| 2343 * @return the kind of this element | |
| 2344 */ | 2180 */ |
| 2345 ElementKind get kind; | 2181 ElementKind get kind; |
| 2346 | 2182 |
| 2347 /** | 2183 /** |
| 2348 * Return the library that contains this element. This will be the element its
elf if it is a | 2184 * Return the library that contains this element. This will be the element |
| 2349 * library element. This will be `null` if this element is an HTML file becaus
e HTML files | 2185 * itself if it is a library element. This will be `null` if this element is |
| 2350 * are not contained in libraries. | 2186 * an HTML file because HTML files are not contained in libraries. |
| 2351 * | |
| 2352 * @return the library that contains this element | |
| 2353 */ | 2187 */ |
| 2354 LibraryElement get library; | 2188 LibraryElement get library; |
| 2355 | 2189 |
| 2356 /** | 2190 /** |
| 2357 * Return an object representing the location of this element in the element m
odel. The object can | 2191 * Return an object representing the location of this element in the element |
| 2358 * be used to locate this element at a later time. | 2192 * model. The object can be used to locate this element at a later time. |
| 2359 * | |
| 2360 * @return the location of this element in the element model | |
| 2361 */ | 2193 */ |
| 2362 ElementLocation get location; | 2194 ElementLocation get location; |
| 2363 | 2195 |
| 2364 /** | 2196 /** |
| 2365 * Return an array containing all of the metadata associated with this element
. The array will be | 2197 * Return a list containing all of the metadata associated with this element. |
| 2366 * empty if the element does not have any metadata or if the library containin
g this element has | 2198 * The array will be empty if the element does not have any metadata or if the |
| 2367 * not yet been resolved. | 2199 * library containing this element has not yet been resolved. |
| 2368 * | |
| 2369 * @return the metadata associated with this element | |
| 2370 */ | 2200 */ |
| 2371 List<ElementAnnotation> get metadata; | 2201 List<ElementAnnotation> get metadata; |
| 2372 | 2202 |
| 2373 /** | 2203 /** |
| 2374 * Return the name of this element, or `null` if this element does not have a
name. | 2204 * Return the name of this element, or `null` if this element does not have a |
| 2375 * | 2205 * name. |
| 2376 * @return the name of this element | |
| 2377 */ | 2206 */ |
| 2378 String get name; | 2207 String get name; |
| 2379 | 2208 |
| 2380 /** | 2209 /** |
| 2381 * Return the offset of the name of this element in the file that contains the
declaration of this | 2210 * Return the offset of the name of this element in the file that contains the |
| 2382 * element, or `-1` if this element is synthetic, does not have a name, or oth
erwise does | 2211 * declaration of this element, or `-1` if this element is synthetic, does not |
| 2383 * not have an offset. | 2212 * have a name, or otherwise does not have an offset. |
| 2384 * | |
| 2385 * @return the offset of the name of this element | |
| 2386 */ | 2213 */ |
| 2387 int get nameOffset; | 2214 int get nameOffset; |
| 2388 | 2215 |
| 2389 /** | 2216 /** |
| 2390 * Return the resolved [AstNode] node that declares this [Element]. | 2217 * Return the resolved [AstNode] node that declares this element, or `null` if |
| 2218 * this element is synthetic or isn't contained in a compilation unit, such as |
| 2219 * a [LibraryElement]. |
| 2391 * | 2220 * |
| 2392 * This method is expensive, because resolved AST might be evicted from cache,
so parsing and | 2221 * This method is expensive, because resolved AST might be evicted from cache, |
| 2393 * resolving will be performed. | 2222 * so parsing and resolving will be performed. |
| 2394 * | 2223 * |
| 2395 * <b>Note:</b> This method cannot be used in an async environment. | 2224 * <b>Note:</b> This method cannot be used in an async environment. |
| 2396 * | |
| 2397 * @return the resolved [AstNode], maybe `null` if [Element] is synthetic or | |
| 2398 * isn't contained in a compilation unit, such as a [LibraryElement]. | |
| 2399 */ | 2225 */ |
| 2400 AstNode get node; | 2226 AstNode get node; |
| 2401 | 2227 |
| 2402 /** | 2228 /** |
| 2403 * Return the source that contains this element, or `null` if this element is
not contained | 2229 * Return the source that contains this element, or `null` if this element is |
| 2404 * in a source. | 2230 * not contained in a source. |
| 2405 * | |
| 2406 * @return the source that contains this element | |
| 2407 */ | 2231 */ |
| 2408 Source get source; | 2232 Source get source; |
| 2409 | 2233 |
| 2410 /** | 2234 /** |
| 2411 * Return the resolved [CompilationUnit] that declares this [Element]. | 2235 * Return the resolved [CompilationUnit] that declares this element, or `null` |
| 2236 * if this element is synthetic. |
| 2412 * | 2237 * |
| 2413 * This method is expensive, because resolved AST might have been already evic
ted from cache, so | 2238 * This method is expensive, because resolved AST might have been already |
| 2414 * parsing and resolving will be performed. | 2239 * evicted from cache, so parsing and resolving will be performed. |
| 2415 * | |
| 2416 * @return the resolved [CompilationUnit], maybe `null` if synthetic [Element]
. | |
| 2417 */ | 2240 */ |
| 2418 CompilationUnit get unit; | 2241 CompilationUnit get unit; |
| 2419 | 2242 |
| 2420 /** | 2243 /** |
| 2421 * Use the given visitor to visit this element. | 2244 * Use the given [visitor] to visit this element. Return the value returned by |
| 2422 * | 2245 * the visitor as a result of visiting this element. |
| 2423 * @param visitor the visitor that will visit this element | |
| 2424 * @return the value returned by the visitor as a result of visiting this elem
ent | |
| 2425 */ | 2246 */ |
| 2426 accept(ElementVisitor visitor); | 2247 accept(ElementVisitor visitor); |
| 2427 | 2248 |
| 2428 /** | 2249 /** |
| 2429 * Return the documentation comment for this element as it appears in the orig
inal source | 2250 * Return the documentation comment for this element as it appears in the |
| 2430 * (complete with the beginning and ending delimiters), or `null` if this elem
ent does not | 2251 * original source (complete with the beginning and ending delimiters), or |
| 2431 * have a documentation comment associated with it. This can be a long-running
operation if the | 2252 * `null` if this element does not have a documentation comment associated |
| 2432 * information needed to access the comment is not cached. | 2253 * with it. This can be a long-running operation if the information needed to |
| 2254 * access the comment is not cached. |
| 2433 * | 2255 * |
| 2434 * @return this element's documentation comment | 2256 * Throws [AnalysisException] if the documentation comment could not be |
| 2435 * @throws AnalysisException if the documentation comment could not be determi
ned because the | 2257 * determined because the analysis could not be performed |
| 2436 * analysis could not be performed | |
| 2437 */ | 2258 */ |
| 2438 String computeDocumentationComment(); | 2259 String computeDocumentationComment(); |
| 2439 | 2260 |
| 2440 /** | 2261 /** |
| 2441 * Return the element of the given class that most immediately encloses this e
lement, or | 2262 * Return the most immediate ancestor of this element for which the |
| 2442 * `null` if there is no enclosing element of the given class. | 2263 * [predicate] returns `true`, or `null` if there is no such ancestor. Note |
| 2443 * | 2264 * that this element will never be returned. |
| 2444 * @param elementClass the class of the element to be returned | |
| 2445 * @return the element that encloses this element | |
| 2446 */ | 2265 */ |
| 2447 Element getAncestor(Predicate<Element> predicate); | 2266 Element getAncestor(Predicate<Element> predicate); |
| 2448 | 2267 |
| 2449 /** | 2268 /** |
| 2450 * Return a display name for the given element that includes the path to the c
ompilation unit in | 2269 * Return a display name for the given element that includes the path to the |
| 2451 * which the type is defined. | 2270 * compilation unit in which the type is defined. If [shortName] is `null` |
| 2452 * | 2271 * then [getDisplayName] will be used as the name of this element. Otherwise |
| 2453 * @param shortName the short display name. If null, [getDisplayName] is used. | 2272 * the provided name will be used. |
| 2454 * @return a display name that can help distinguish between two types with the
same name | |
| 2455 */ | 2273 */ |
| 2274 // TODO(brianwilkerson) Make the parameter optional. |
| 2456 String getExtendedDisplayName(String shortName); | 2275 String getExtendedDisplayName(String shortName); |
| 2457 | 2276 |
| 2458 /** | 2277 /** |
| 2459 * Return `true` if this element, assuming that it is within scope, is accessi
ble to code in | 2278 * Return `true` if this element, assuming that it is within scope, is |
| 2460 * the given library. This is defined by the Dart Language Specification in se
ction 3.2: | 2279 * accessible to code in the given [library]. This is defined by the Dart |
| 2461 * <blockquote> A declaration <i>m</i> is accessible to library <i>L</i> if <i
>m</i> is declared | 2280 * Language Specification in section 3.2: |
| 2462 * in <i>L</i> or if <i>m</i> is public. </blockquote> | 2281 * <blockquote> |
| 2463 * | 2282 * A declaration <i>m</i> is accessible to library <i>L</i> if <i>m</i> is |
| 2464 * @param library the library in which a possible reference to this element wo
uld occur | 2283 * declared in <i>L</i> or if <i>m</i> is public. |
| 2465 * @return `true` if this element is accessible to code in the given library | 2284 * </blockquote> |
| 2466 */ | 2285 */ |
| 2467 bool isAccessibleIn(LibraryElement library); | 2286 bool isAccessibleIn(LibraryElement library); |
| 2468 | 2287 |
| 2469 /** | 2288 /** |
| 2470 * Use the given visitor to visit all of the children of this element. There i
s no guarantee of | 2289 * Use the given [visitor] to visit all of the children of this element. There |
| 2471 * the order in which the children will be visited. | 2290 * is no guarantee of the order in which the children will be visited. |
| 2472 * | |
| 2473 * @param visitor the visitor that will be used to visit the children of this
element | |
| 2474 */ | 2291 */ |
| 2475 void visitChildren(ElementVisitor visitor); | 2292 void visitChildren(ElementVisitor visitor); |
| 2476 } | 2293 } |
| 2477 | 2294 |
| 2478 /** | 2295 /** |
| 2479 * The interface `ElementAnnotation` defines the behavior of objects representin
g a single | 2296 * A single annotation associated with an element. |
| 2480 * annotation associated with an element. | |
| 2481 */ | 2297 */ |
| 2482 abstract class ElementAnnotation { | 2298 abstract class ElementAnnotation { |
| 2483 /** | 2299 /** |
| 2484 * Return the element representing the field, variable, or const constructor b
eing used as an | 2300 * Return the element representing the field, variable, or const constructor |
| 2485 * annotation. | 2301 * being used as an annotation. |
| 2486 * | |
| 2487 * @return the field, variable, or constructor being used as an annotation | |
| 2488 */ | 2302 */ |
| 2489 Element get element; | 2303 Element get element; |
| 2490 | 2304 |
| 2491 /** | 2305 /** |
| 2492 * Return `true` if this annotation marks the associated element as being depr
ecated. | 2306 * Return `true` if this annotation marks the associated element as being |
| 2493 * | 2307 * deprecated. |
| 2494 * @return `true` if this annotation marks the associated element as being dep
recated | |
| 2495 */ | 2308 */ |
| 2496 bool get isDeprecated; | 2309 bool get isDeprecated; |
| 2497 | 2310 |
| 2498 /** | 2311 /** |
| 2499 * Return `true` if this annotation marks the associated method as being expec
ted to | 2312 * Return `true` if this annotation marks the associated method as being |
| 2500 * override an inherited method. | 2313 * expected to override an inherited method. |
| 2501 * | |
| 2502 * @return `true` if this annotation marks the associated method as overriding
another | |
| 2503 * method | |
| 2504 */ | 2314 */ |
| 2505 bool get isOverride; | 2315 bool get isOverride; |
| 2506 | 2316 |
| 2507 /** | 2317 /** |
| 2508 * Return `true` if this annotation marks the associated class as implementing
a proxy | 2318 * Return `true` if this annotation marks the associated class as implementing |
| 2509 * object. | 2319 * a proxy object. |
| 2510 * | |
| 2511 * @return `true` if this annotation marks the associated class as implementin
g a proxy | |
| 2512 * object | |
| 2513 */ | 2320 */ |
| 2514 bool get isProxy; | 2321 bool get isProxy; |
| 2515 } | 2322 } |
| 2516 | 2323 |
| 2517 /** | 2324 /** |
| 2518 * Instances of the class `ElementAnnotationImpl` implement an [ElementAnnotatio
n]. | 2325 * A concrete implementation of an [ElementAnnotation]. |
| 2519 */ | 2326 */ |
| 2520 class ElementAnnotationImpl implements ElementAnnotation { | 2327 class ElementAnnotationImpl implements ElementAnnotation { |
| 2521 /** | 2328 /** |
| 2522 * An empty list of annotations. | 2329 * An empty list of annotations. |
| 2523 */ | 2330 */ |
| 2524 static const List<ElementAnnotationImpl> EMPTY_ARRAY = | 2331 static const List<ElementAnnotationImpl> EMPTY_ARRAY = |
| 2525 const <ElementAnnotationImpl>[]; | 2332 const <ElementAnnotationImpl>[]; |
| 2526 | 2333 |
| 2527 /** | 2334 /** |
| 2528 * The name of the class used to mark an element as being deprecated. | 2335 * The name of the class used to mark an element as being deprecated. |
| 2529 */ | 2336 */ |
| 2530 static String _DEPRECATED_CLASS_NAME = "Deprecated"; | 2337 static String _DEPRECATED_CLASS_NAME = "Deprecated"; |
| 2531 | 2338 |
| 2532 /** | 2339 /** |
| 2533 * The name of the top-level variable used to mark an element as being depreca
ted. | 2340 * The name of the top-level variable used to mark an element as being |
| 2341 * deprecated. |
| 2534 */ | 2342 */ |
| 2535 static String _DEPRECATED_VARIABLE_NAME = "deprecated"; | 2343 static String _DEPRECATED_VARIABLE_NAME = "deprecated"; |
| 2536 | 2344 |
| 2537 /** | 2345 /** |
| 2538 * The name of the top-level variable used to mark a method as being expected
to override an | 2346 * The name of the top-level variable used to mark a method as being expected |
| 2539 * inherited method. | 2347 * to override an inherited method. |
| 2540 */ | 2348 */ |
| 2541 static String _OVERRIDE_VARIABLE_NAME = "override"; | 2349 static String _OVERRIDE_VARIABLE_NAME = "override"; |
| 2542 | 2350 |
| 2543 /** | 2351 /** |
| 2544 * The name of the top-level variable used to mark a class as implementing a p
roxy object. | 2352 * The name of the top-level variable used to mark a class as implementing a |
| 2353 * proxy object. |
| 2545 */ | 2354 */ |
| 2546 static String PROXY_VARIABLE_NAME = "proxy"; | 2355 static String PROXY_VARIABLE_NAME = "proxy"; |
| 2547 | 2356 |
| 2548 /** | 2357 /** |
| 2549 * The element representing the field, variable, or constructor being used as
an annotation. | 2358 * The element representing the field, variable, or constructor being used as |
| 2359 * an annotation. |
| 2550 */ | 2360 */ |
| 2551 final Element element; | 2361 final Element element; |
| 2552 | 2362 |
| 2553 /** | 2363 /** |
| 2554 * The result of evaluating this annotation as a compile-time constant | 2364 * The result of evaluating this annotation as a compile-time constant |
| 2555 * expression, or `null` if the compilation unit containing the variable has | 2365 * expression, or `null` if the compilation unit containing the variable has |
| 2556 * not been resolved. | 2366 * not been resolved. |
| 2557 */ | 2367 */ |
| 2558 EvaluationResultImpl evaluationResult; | 2368 EvaluationResultImpl evaluationResult; |
| 2559 | 2369 |
| 2560 /** | 2370 /** |
| 2561 * Initialize a newly created annotation. | 2371 * Initialize a newly created annotation. The given [element] is the element |
| 2562 * | 2372 * representing the field, variable, or constructor being used as an |
| 2563 * @param element the element representing the field, variable, or constructor
being used as an | 2373 * annotation. |
| 2564 * annotation | |
| 2565 */ | 2374 */ |
| 2566 ElementAnnotationImpl(this.element); | 2375 ElementAnnotationImpl(this.element); |
| 2567 | 2376 |
| 2568 @override | 2377 @override |
| 2569 bool get isDeprecated { | 2378 bool get isDeprecated { |
| 2570 if (element != null) { | 2379 if (element != null) { |
| 2571 LibraryElement library = element.library; | 2380 LibraryElement library = element.library; |
| 2572 if (library != null && library.isDartCore) { | 2381 if (library != null && library.isDartCore) { |
| 2573 if (element is ConstructorElement) { | 2382 if (element is ConstructorElement) { |
| 2574 ConstructorElement constructorElement = element as ConstructorElement; | 2383 ConstructorElement constructorElement = element as ConstructorElement; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2611 } | 2420 } |
| 2612 } | 2421 } |
| 2613 return false; | 2422 return false; |
| 2614 } | 2423 } |
| 2615 | 2424 |
| 2616 @override | 2425 @override |
| 2617 String toString() => '@$element'; | 2426 String toString() => '@$element'; |
| 2618 } | 2427 } |
| 2619 | 2428 |
| 2620 /** | 2429 /** |
| 2621 * The abstract class `ElementImpl` implements the behavior common to objects th
at implement | 2430 * A base class for concrete implementations of an [Element]. |
| 2622 * an [Element]. | |
| 2623 */ | 2431 */ |
| 2624 abstract class ElementImpl implements Element { | 2432 abstract class ElementImpl implements Element { |
| 2625 static int _NEXT_ID = 0; | 2433 static int _NEXT_ID = 0; |
| 2626 | 2434 |
| 2627 final int id = _NEXT_ID++; | 2435 final int id = _NEXT_ID++; |
| 2628 | 2436 |
| 2629 /** | 2437 /** |
| 2630 * The enclosing element of this element, or `null` if this element is at the
root of the | 2438 * The enclosing element of this element, or `null` if this element is at the |
| 2631 * element structure. | 2439 * root of the element structure. |
| 2632 */ | 2440 */ |
| 2633 ElementImpl _enclosingElement; | 2441 ElementImpl _enclosingElement; |
| 2634 | 2442 |
| 2635 /** | 2443 /** |
| 2636 * The name of this element. | 2444 * The name of this element. |
| 2637 */ | 2445 */ |
| 2638 String _name; | 2446 String _name; |
| 2639 | 2447 |
| 2640 /** | 2448 /** |
| 2641 * The offset of the name of this element in the file that contains the | 2449 * The offset of the name of this element in the file that contains the |
| 2642 * declaration of this element. | 2450 * declaration of this element. |
| 2643 */ | 2451 */ |
| 2644 int _nameOffset = 0; | 2452 int _nameOffset = 0; |
| 2645 | 2453 |
| 2646 /** | 2454 /** |
| 2647 * A bit-encoded form of the modifiers associated with this element. | 2455 * A bit-encoded form of the modifiers associated with this element. |
| 2648 */ | 2456 */ |
| 2649 int _modifiers = 0; | 2457 int _modifiers = 0; |
| 2650 | 2458 |
| 2651 /** | 2459 /** |
| 2652 * An array containing all of the metadata associated with this element. | 2460 * A list containing all of the metadata associated with this element. |
| 2653 */ | 2461 */ |
| 2654 List<ElementAnnotation> metadata = ElementAnnotationImpl.EMPTY_ARRAY; | 2462 List<ElementAnnotation> metadata = ElementAnnotationImpl.EMPTY_ARRAY; |
| 2655 | 2463 |
| 2656 /** | 2464 /** |
| 2657 * A cached copy of the calculated hashCode for this element. | 2465 * A cached copy of the calculated hashCode for this element. |
| 2658 */ | 2466 */ |
| 2659 int _cachedHashCode; | 2467 int _cachedHashCode; |
| 2660 | 2468 |
| 2661 /** | 2469 /** |
| 2662 * A cached copy of the calculated location for this element. | 2470 * A cached copy of the calculated location for this element. |
| 2663 */ | 2471 */ |
| 2664 ElementLocation _cachedLocation; | 2472 ElementLocation _cachedLocation; |
| 2665 | 2473 |
| 2666 /** | 2474 /** |
| 2667 * Initialize a newly created element to have the given name. | 2475 * Initialize a newly created element to have the given [name] at the given |
| 2668 * | 2476 * [_nameOffset]. |
| 2669 * @param name the name of this element | |
| 2670 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
| 2671 * declaration of this element | |
| 2672 */ | 2477 */ |
| 2673 ElementImpl(String name, this._nameOffset) { | 2478 ElementImpl(String name, this._nameOffset) { |
| 2674 this._name = StringUtilities.intern(name); | 2479 this._name = StringUtilities.intern(name); |
| 2675 } | 2480 } |
| 2676 | 2481 |
| 2677 /** | 2482 /** |
| 2678 * Initialize a newly created element to have the given name. | 2483 * Initialize a newly created element to have the given [name]. |
| 2679 * | |
| 2680 * @param name the name of this element | |
| 2681 */ | 2484 */ |
| 2682 ElementImpl.forNode(Identifier name) | 2485 ElementImpl.forNode(Identifier name) |
| 2683 : this(name == null ? "" : name.name, name == null ? -1 : name.offset); | 2486 : this(name == null ? "" : name.name, name == null ? -1 : name.offset); |
| 2684 | 2487 |
| 2685 @override | 2488 @override |
| 2686 AnalysisContext get context { | 2489 AnalysisContext get context { |
| 2687 if (_enclosingElement == null) { | 2490 if (_enclosingElement == null) { |
| 2688 return null; | 2491 return null; |
| 2689 } | 2492 } |
| 2690 return _enclosingElement.context; | 2493 return _enclosingElement.context; |
| 2691 } | 2494 } |
| 2692 | 2495 |
| 2693 @override | 2496 @override |
| 2694 String get displayName => _name; | 2497 String get displayName => _name; |
| 2695 | 2498 |
| 2696 @override | 2499 @override |
| 2697 Element get enclosingElement => _enclosingElement; | 2500 Element get enclosingElement => _enclosingElement; |
| 2698 | 2501 |
| 2699 /** | 2502 /** |
| 2700 * Set the enclosing element of this element to the given element. | 2503 * Set the enclosing element of this element to the given [element]. |
| 2701 * | |
| 2702 * @param element the enclosing element of this element | |
| 2703 */ | 2504 */ |
| 2704 void set enclosingElement(Element element) { | 2505 void set enclosingElement(Element element) { |
| 2705 _enclosingElement = element as ElementImpl; | 2506 _enclosingElement = element as ElementImpl; |
| 2706 _cachedLocation = null; | 2507 _cachedLocation = null; |
| 2707 _cachedHashCode = null; | 2508 _cachedHashCode = null; |
| 2708 } | 2509 } |
| 2709 | 2510 |
| 2710 @override | 2511 @override |
| 2711 int get hashCode { | 2512 int get hashCode { |
| 2712 // TODO: We might want to re-visit this optimization in the future. | 2513 // TODO: We might want to re-visit this optimization in the future. |
| 2713 // We cache the hash code value as this is a very frequently called method. | 2514 // We cache the hash code value as this is a very frequently called method. |
| 2714 if (_cachedHashCode == null) { | 2515 if (_cachedHashCode == null) { |
| 2715 int hashIdentifier = identifier.hashCode; | 2516 int hashIdentifier = identifier.hashCode; |
| 2716 Element enclosing = enclosingElement; | 2517 Element enclosing = enclosingElement; |
| 2717 if (enclosing != null) { | 2518 if (enclosing != null) { |
| 2718 _cachedHashCode = hashIdentifier + enclosing.hashCode; | 2519 _cachedHashCode = hashIdentifier + enclosing.hashCode; |
| 2719 } else { | 2520 } else { |
| 2720 _cachedHashCode = hashIdentifier; | 2521 _cachedHashCode = hashIdentifier; |
| 2721 } | 2522 } |
| 2722 } | 2523 } |
| 2723 return _cachedHashCode; | 2524 return _cachedHashCode; |
| 2724 } | 2525 } |
| 2725 | 2526 |
| 2726 /** | 2527 /** |
| 2727 * Return an identifier that uniquely identifies this element among the childr
en of this element's | 2528 * Return an identifier that uniquely identifies this element among the |
| 2728 * parent. | 2529 * children of this element's parent. |
| 2729 * | |
| 2730 * @return an identifier that uniquely identifies this element relative to its
parent | |
| 2731 */ | 2530 */ |
| 2732 String get identifier => name; | 2531 String get identifier => name; |
| 2733 | 2532 |
| 2734 @override | 2533 @override |
| 2735 bool get isDeprecated { | 2534 bool get isDeprecated { |
| 2736 for (ElementAnnotation annotation in metadata) { | 2535 for (ElementAnnotation annotation in metadata) { |
| 2737 if (annotation.isDeprecated) { | 2536 if (annotation.isDeprecated) { |
| 2738 return true; | 2537 return true; |
| 2739 } | 2538 } |
| 2740 } | 2539 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2808 | 2607 |
| 2809 @override | 2608 @override |
| 2810 Source get source { | 2609 Source get source { |
| 2811 if (_enclosingElement == null) { | 2610 if (_enclosingElement == null) { |
| 2812 return null; | 2611 return null; |
| 2813 } | 2612 } |
| 2814 return _enclosingElement.source; | 2613 return _enclosingElement.source; |
| 2815 } | 2614 } |
| 2816 | 2615 |
| 2817 /** | 2616 /** |
| 2818 * Set whether this element is synthetic to correspond to the given value. | 2617 * Set whether this element is synthetic. |
| 2819 * | |
| 2820 * @param isSynthetic `true` if the element is synthetic | |
| 2821 */ | 2618 */ |
| 2822 void set synthetic(bool isSynthetic) { | 2619 void set synthetic(bool isSynthetic) { |
| 2823 setModifier(Modifier.SYNTHETIC, isSynthetic); | 2620 setModifier(Modifier.SYNTHETIC, isSynthetic); |
| 2824 } | 2621 } |
| 2825 | 2622 |
| 2826 @override | 2623 @override |
| 2827 CompilationUnit get unit => context.resolveCompilationUnit(source, library); | 2624 CompilationUnit get unit => context.resolveCompilationUnit(source, library); |
| 2828 | 2625 |
| 2829 @override | 2626 @override |
| 2830 bool operator ==(Object object) { | 2627 bool operator ==(Object object) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2854 @override | 2651 @override |
| 2855 String computeDocumentationComment() { | 2652 String computeDocumentationComment() { |
| 2856 AnalysisContext context = this.context; | 2653 AnalysisContext context = this.context; |
| 2857 if (context == null) { | 2654 if (context == null) { |
| 2858 return null; | 2655 return null; |
| 2859 } | 2656 } |
| 2860 return context.computeDocumentationComment(this); | 2657 return context.computeDocumentationComment(this); |
| 2861 } | 2658 } |
| 2862 | 2659 |
| 2863 /** | 2660 /** |
| 2864 * Set this [Element] as an enclosing for given. | 2661 * Set this element as the enclosing element for given [element]. |
| 2865 * | |
| 2866 * @param element the element to enclose, must be [ElementImpl] | |
| 2867 */ | 2662 */ |
| 2868 void encloseElement(ElementImpl element) { | 2663 void encloseElement(ElementImpl element) { |
| 2869 element.enclosingElement = this; | 2664 element.enclosingElement = this; |
| 2870 } | 2665 } |
| 2871 | 2666 |
| 2872 @override | 2667 @override |
| 2873 Element getAncestor(Predicate<Element> predicate) { | 2668 Element getAncestor(Predicate<Element> predicate) { |
| 2874 Element ancestor = _enclosingElement; | 2669 Element ancestor = _enclosingElement; |
| 2875 while (ancestor != null && !predicate(ancestor)) { | 2670 while (ancestor != null && !predicate(ancestor)) { |
| 2876 ancestor = ancestor.enclosingElement; | 2671 ancestor = ancestor.enclosingElement; |
| 2877 } | 2672 } |
| 2878 return ancestor; | 2673 return ancestor; |
| 2879 } | 2674 } |
| 2880 | 2675 |
| 2881 /** | 2676 /** |
| 2882 * Return the child of this element that is uniquely identified by the given i
dentifier, or | 2677 * Return the child of this element that is uniquely identified by the given |
| 2883 * `null` if there is no such child. | 2678 * [identifier], or `null` if there is no such child. |
| 2884 * | |
| 2885 * @param identifier the identifier used to select a child | |
| 2886 * @return the child of this element with the given identifier | |
| 2887 */ | 2679 */ |
| 2888 ElementImpl getChild(String identifier) => null; | 2680 ElementImpl getChild(String identifier) => null; |
| 2889 | 2681 |
| 2890 @override | 2682 @override |
| 2891 String getExtendedDisplayName(String shortName) { | 2683 String getExtendedDisplayName(String shortName) { |
| 2892 if (shortName == null) { | 2684 if (shortName == null) { |
| 2893 shortName = displayName; | 2685 shortName = displayName; |
| 2894 } | 2686 } |
| 2895 Source source = this.source; | 2687 Source source = this.source; |
| 2896 if (source != null) { | 2688 if (source != null) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2909 } | 2701 } |
| 2910 int offset = nameOffset; | 2702 int offset = nameOffset; |
| 2911 AstNode node = new NodeLocator.con1(offset).searchWithin(unit); | 2703 AstNode node = new NodeLocator.con1(offset).searchWithin(unit); |
| 2912 if (node == null) { | 2704 if (node == null) { |
| 2913 return null; | 2705 return null; |
| 2914 } | 2706 } |
| 2915 return node.getAncestor(predicate); | 2707 return node.getAncestor(predicate); |
| 2916 } | 2708 } |
| 2917 | 2709 |
| 2918 /** | 2710 /** |
| 2919 * Return `true` if this element has the given modifier associated with it. | 2711 * Return `true` if this element has the given [modifier] associated with it. |
| 2920 * | |
| 2921 * @param modifier the modifier being tested for | |
| 2922 * @return `true` if this element has the given modifier associated with it | |
| 2923 */ | 2712 */ |
| 2924 bool hasModifier(Modifier modifier) => | 2713 bool hasModifier(Modifier modifier) => |
| 2925 BooleanArray.getEnum(_modifiers, modifier); | 2714 BooleanArray.getEnum(_modifiers, modifier); |
| 2926 | 2715 |
| 2927 @override | 2716 @override |
| 2928 bool isAccessibleIn(LibraryElement library) { | 2717 bool isAccessibleIn(LibraryElement library) { |
| 2929 if (Identifier.isPrivateName(_name)) { | 2718 if (Identifier.isPrivateName(_name)) { |
| 2930 return library == this.library; | 2719 return library == this.library; |
| 2931 } | 2720 } |
| 2932 return true; | 2721 return true; |
| 2933 } | 2722 } |
| 2934 | 2723 |
| 2935 /** | 2724 /** |
| 2936 * If the given child is not `null`, use the given visitor to visit it. | 2725 * If the given [child] is not `null`, use the given [visitor] to visit it. |
| 2937 * | |
| 2938 * @param child the child to be visited | |
| 2939 * @param visitor the visitor to be used to visit the child | |
| 2940 */ | 2726 */ |
| 2941 void safelyVisitChild(Element child, ElementVisitor visitor) { | 2727 void safelyVisitChild(Element child, ElementVisitor visitor) { |
| 2942 if (child != null) { | 2728 if (child != null) { |
| 2943 child.accept(visitor); | 2729 child.accept(visitor); |
| 2944 } | 2730 } |
| 2945 } | 2731 } |
| 2946 | 2732 |
| 2947 /** | 2733 /** |
| 2948 * Use the given visitor to visit all of the children in the given array. | 2734 * Use the given [visitor] to visit all of the [children] in the given array. |
| 2949 * | |
| 2950 * @param children the children to be visited | |
| 2951 * @param visitor the visitor being used to visit the children | |
| 2952 */ | 2735 */ |
| 2953 void safelyVisitChildren(List<Element> children, ElementVisitor visitor) { | 2736 void safelyVisitChildren(List<Element> children, ElementVisitor visitor) { |
| 2954 if (children != null) { | 2737 if (children != null) { |
| 2955 for (Element child in children) { | 2738 for (Element child in children) { |
| 2956 child.accept(visitor); | 2739 child.accept(visitor); |
| 2957 } | 2740 } |
| 2958 } | 2741 } |
| 2959 } | 2742 } |
| 2960 | 2743 |
| 2961 /** | 2744 /** |
| 2962 * Set whether the given modifier is associated with this element to correspon
d to the given | 2745 * Set whether the given [modifier] is associated with this element to |
| 2963 * value. | 2746 * correspond to the given [value]. |
| 2964 * | |
| 2965 * @param modifier the modifier to be set | |
| 2966 * @param value `true` if the modifier is to be associated with this element | |
| 2967 */ | 2747 */ |
| 2968 void setModifier(Modifier modifier, bool value) { | 2748 void setModifier(Modifier modifier, bool value) { |
| 2969 _modifiers = BooleanArray.setEnum(_modifiers, modifier, value); | 2749 _modifiers = BooleanArray.setEnum(_modifiers, modifier, value); |
| 2970 } | 2750 } |
| 2971 | 2751 |
| 2972 @override | 2752 @override |
| 2973 String toString() { | 2753 String toString() { |
| 2974 StringBuffer buffer = new StringBuffer(); | 2754 StringBuffer buffer = new StringBuffer(); |
| 2975 appendTo(buffer); | 2755 appendTo(buffer); |
| 2976 return buffer.toString(); | 2756 return buffer.toString(); |
| 2977 } | 2757 } |
| 2978 | 2758 |
| 2979 @override | 2759 @override |
| 2980 void visitChildren(ElementVisitor visitor) { | 2760 void visitChildren(ElementVisitor visitor) { |
| 2981 // There are no children to visit | 2761 // There are no children to visit |
| 2982 } | 2762 } |
| 2983 } | 2763 } |
| 2984 | 2764 |
| 2985 /** | 2765 /** |
| 2986 * The enumeration `ElementKind` defines the various kinds of elements in the el
ement model. | 2766 * The enumeration `ElementKind` defines the various kinds of elements in the |
| 2767 * element model. |
| 2987 */ | 2768 */ |
| 2988 class ElementKind extends Enum<ElementKind> { | 2769 class ElementKind extends Enum<ElementKind> { |
| 2989 static const ElementKind CLASS = const ElementKind('CLASS', 0, "class"); | 2770 static const ElementKind CLASS = const ElementKind('CLASS', 0, "class"); |
| 2990 | 2771 |
| 2991 static const ElementKind COMPILATION_UNIT = | 2772 static const ElementKind COMPILATION_UNIT = |
| 2992 const ElementKind('COMPILATION_UNIT', 1, "compilation unit"); | 2773 const ElementKind('COMPILATION_UNIT', 1, "compilation unit"); |
| 2993 | 2774 |
| 2994 static const ElementKind CONSTRUCTOR = | 2775 static const ElementKind CONSTRUCTOR = |
| 2995 const ElementKind('CONSTRUCTOR', 2, "constructor"); | 2776 const ElementKind('CONSTRUCTOR', 2, "constructor"); |
| 2996 | 2777 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3079 TYPE_PARAMETER, | 2860 TYPE_PARAMETER, |
| 3080 UNIVERSE | 2861 UNIVERSE |
| 3081 ]; | 2862 ]; |
| 3082 | 2863 |
| 3083 /** | 2864 /** |
| 3084 * The name displayed in the UI for this kind of element. | 2865 * The name displayed in the UI for this kind of element. |
| 3085 */ | 2866 */ |
| 3086 final String displayName; | 2867 final String displayName; |
| 3087 | 2868 |
| 3088 /** | 2869 /** |
| 3089 * Initialize a newly created element kind to have the given display name. | 2870 * Initialize a newly created element kind to have the given [displayName]. |
| 3090 * | |
| 3091 * @param displayName the name displayed in the UI for this kind of element | |
| 3092 */ | 2871 */ |
| 3093 const ElementKind(String name, int ordinal, this.displayName) | 2872 const ElementKind(String name, int ordinal, this.displayName) |
| 3094 : super(name, ordinal); | 2873 : super(name, ordinal); |
| 3095 | 2874 |
| 3096 /** | 2875 /** |
| 3097 * Return the kind of the given element, or [ERROR] if the element is `null`.
This is | 2876 * Return the kind of the given [element], or [ERROR] if the element is |
| 3098 * a utility method that can reduce the need for null checks in other places. | 2877 * `null`. This is a utility method that can reduce the need for null checks |
| 3099 * | 2878 * in other places. |
| 3100 * @param element the element whose kind is to be returned | |
| 3101 * @return the kind of the given element | |
| 3102 */ | 2879 */ |
| 3103 static ElementKind of(Element element) { | 2880 static ElementKind of(Element element) { |
| 3104 if (element == null) { | 2881 if (element == null) { |
| 3105 return ERROR; | 2882 return ERROR; |
| 3106 } | 2883 } |
| 3107 return element.kind; | 2884 return element.kind; |
| 3108 } | 2885 } |
| 3109 } | 2886 } |
| 3110 | 2887 |
| 3111 /** | 2888 /** |
| 3112 * The interface `ElementLocation` defines the behavior of objects that represen
t the location | 2889 * The location of an element within the element model. |
| 3113 * of an element within the element model. | |
| 3114 */ | 2890 */ |
| 3115 abstract class ElementLocation { | 2891 abstract class ElementLocation { |
| 3116 /** | 2892 /** |
| 3117 * Return the path to the element whose location is represented by this object
. Clients must not | 2893 * Return the path to the element whose location is represented by this |
| 3118 * modify the returned array. | 2894 * object. Clients must not modify the returned array. |
| 3119 * | |
| 3120 * @return the path to the element whose location is represented by this objec
t | |
| 3121 */ | 2895 */ |
| 3122 List<String> get components; | 2896 List<String> get components; |
| 3123 | 2897 |
| 3124 /** | 2898 /** |
| 3125 * Return an encoded representation of this location that can be used to creat
e a location that is | 2899 * Return an encoded representation of this location that can be used to |
| 3126 * equal to this location. | 2900 * create a location that is equal to this location. |
| 3127 * | |
| 3128 * @return an encoded representation of this location | |
| 3129 */ | 2901 */ |
| 3130 String get encoding; | 2902 String get encoding; |
| 3131 } | 2903 } |
| 3132 | 2904 |
| 3133 /** | 2905 /** |
| 3134 * Instances of the class `ElementLocationImpl` implement an [ElementLocation]. | 2906 * A concrete implementation of an [ElementLocation]. |
| 3135 */ | 2907 */ |
| 3136 class ElementLocationImpl implements ElementLocation { | 2908 class ElementLocationImpl implements ElementLocation { |
| 3137 /** | 2909 /** |
| 3138 * The character used to separate components in the encoded form. | 2910 * The character used to separate components in the encoded form. |
| 3139 */ | 2911 */ |
| 3140 static int _SEPARATOR_CHAR = 0x3B; | 2912 static int _SEPARATOR_CHAR = 0x3B; |
| 3141 | 2913 |
| 3142 /** | 2914 /** |
| 3143 * The path to the element whose location is represented by this object. | 2915 * The path to the element whose location is represented by this object. |
| 3144 */ | 2916 */ |
| 3145 List<String> _components; | 2917 List<String> _components; |
| 3146 | 2918 |
| 3147 /** | 2919 /** |
| 3148 * The object managing [indexKeyId] and [indexLocationId]. | 2920 * The object managing [indexKeyId] and [indexLocationId]. |
| 3149 */ | 2921 */ |
| 3150 Object indexOwner; | 2922 Object indexOwner; |
| 3151 | 2923 |
| 3152 /** | 2924 /** |
| 3153 * A cached id of this location in index. | 2925 * A cached id of this location in index. |
| 3154 */ | 2926 */ |
| 3155 int indexKeyId; | 2927 int indexKeyId; |
| 3156 | 2928 |
| 3157 /** | 2929 /** |
| 3158 * A cached id of this location in index. | 2930 * A cached id of this location in index. |
| 3159 */ | 2931 */ |
| 3160 int indexLocationId; | 2932 int indexLocationId; |
| 3161 | 2933 |
| 3162 /** | 2934 /** |
| 3163 * Initialize a newly created location to represent the given element. | 2935 * Initialize a newly created location to represent the given [element]. |
| 3164 * | |
| 3165 * @param element the element whose location is being represented | |
| 3166 */ | 2936 */ |
| 3167 ElementLocationImpl.con1(Element element) { | 2937 ElementLocationImpl.con1(Element element) { |
| 3168 List<String> components = new List<String>(); | 2938 List<String> components = new List<String>(); |
| 3169 Element ancestor = element; | 2939 Element ancestor = element; |
| 3170 while (ancestor != null) { | 2940 while (ancestor != null) { |
| 3171 components.insert(0, (ancestor as ElementImpl).identifier); | 2941 components.insert(0, (ancestor as ElementImpl).identifier); |
| 3172 ancestor = ancestor.enclosingElement; | 2942 ancestor = ancestor.enclosingElement; |
| 3173 } | 2943 } |
| 3174 this._components = components; | 2944 this._components = components; |
| 3175 } | 2945 } |
| 3176 | 2946 |
| 3177 /** | 2947 /** |
| 3178 * Initialize a newly created location from the given encoded form. | 2948 * Initialize a newly created location from the given [encoding]. |
| 3179 * | |
| 3180 * @param encoding the encoded form of a location | |
| 3181 */ | 2949 */ |
| 3182 ElementLocationImpl.con2(String encoding) { | 2950 ElementLocationImpl.con2(String encoding) { |
| 3183 this._components = _decode(encoding); | 2951 this._components = _decode(encoding); |
| 3184 } | 2952 } |
| 3185 | 2953 |
| 3186 /** | 2954 /** |
| 3187 * Initialize a newly created location from the given components. | 2955 * Initialize a newly created location from the given [components]. |
| 3188 * | |
| 3189 * @param components the components of a location | |
| 3190 */ | 2956 */ |
| 3191 ElementLocationImpl.con3(List<String> components) { | 2957 ElementLocationImpl.con3(List<String> components) { |
| 3192 this._components = components; | 2958 this._components = components; |
| 3193 } | 2959 } |
| 3194 | 2960 |
| 3195 @override | 2961 @override |
| 3196 List<String> get components => _components; | 2962 List<String> get components => _components; |
| 3197 | 2963 |
| 3198 @override | 2964 @override |
| 3199 String get encoding { | 2965 String get encoding { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3237 return false; | 3003 return false; |
| 3238 } | 3004 } |
| 3239 } | 3005 } |
| 3240 return true; | 3006 return true; |
| 3241 } | 3007 } |
| 3242 | 3008 |
| 3243 @override | 3009 @override |
| 3244 String toString() => encoding; | 3010 String toString() => encoding; |
| 3245 | 3011 |
| 3246 /** | 3012 /** |
| 3247 * Decode the encoded form of a location into an array of components. | 3013 * Decode the [encoding] of a location into a list of components and return |
| 3248 * | 3014 * the components. |
| 3249 * @param encoding the encoded form of a location | |
| 3250 * @return the components that were encoded | |
| 3251 */ | 3015 */ |
| 3252 List<String> _decode(String encoding) { | 3016 List<String> _decode(String encoding) { |
| 3253 List<String> components = new List<String>(); | 3017 List<String> components = new List<String>(); |
| 3254 StringBuffer buffer = new StringBuffer(); | 3018 StringBuffer buffer = new StringBuffer(); |
| 3255 int index = 0; | 3019 int index = 0; |
| 3256 int length = encoding.length; | 3020 int length = encoding.length; |
| 3257 while (index < length) { | 3021 while (index < length) { |
| 3258 int currentChar = encoding.codeUnitAt(index); | 3022 int currentChar = encoding.codeUnitAt(index); |
| 3259 if (currentChar == _SEPARATOR_CHAR) { | 3023 if (currentChar == _SEPARATOR_CHAR) { |
| 3260 if (index + 1 < length && | 3024 if (index + 1 < length && |
| 3261 encoding.codeUnitAt(index + 1) == _SEPARATOR_CHAR) { | 3025 encoding.codeUnitAt(index + 1) == _SEPARATOR_CHAR) { |
| 3262 buffer.writeCharCode(_SEPARATOR_CHAR); | 3026 buffer.writeCharCode(_SEPARATOR_CHAR); |
| 3263 index += 2; | 3027 index += 2; |
| 3264 } else { | 3028 } else { |
| 3265 components.add(buffer.toString()); | 3029 components.add(buffer.toString()); |
| 3266 buffer = new StringBuffer(); | 3030 buffer = new StringBuffer(); |
| 3267 index++; | 3031 index++; |
| 3268 } | 3032 } |
| 3269 } else { | 3033 } else { |
| 3270 buffer.writeCharCode(currentChar); | 3034 buffer.writeCharCode(currentChar); |
| 3271 index++; | 3035 index++; |
| 3272 } | 3036 } |
| 3273 } | 3037 } |
| 3274 components.add(buffer.toString()); | 3038 components.add(buffer.toString()); |
| 3275 return components; | 3039 return components; |
| 3276 } | 3040 } |
| 3277 | 3041 |
| 3278 /** | 3042 /** |
| 3279 * Append an encoded form of the given component to the given builder. | 3043 * Append an encoded form of the given [component] to the given [buffer]. |
| 3280 * | |
| 3281 * @param builder the builder to which the encoded component is to be appended | |
| 3282 * @param component the component to be appended to the builder | |
| 3283 */ | 3044 */ |
| 3284 void _encode(StringBuffer buffer, String component) { | 3045 void _encode(StringBuffer buffer, String component) { |
| 3285 int length = component.length; | 3046 int length = component.length; |
| 3286 for (int i = 0; i < length; i++) { | 3047 for (int i = 0; i < length; i++) { |
| 3287 int currentChar = component.codeUnitAt(i); | 3048 int currentChar = component.codeUnitAt(i); |
| 3288 if (currentChar == _SEPARATOR_CHAR) { | 3049 if (currentChar == _SEPARATOR_CHAR) { |
| 3289 buffer.writeCharCode(_SEPARATOR_CHAR); | 3050 buffer.writeCharCode(_SEPARATOR_CHAR); |
| 3290 } | 3051 } |
| 3291 buffer.writeCharCode(currentChar); | 3052 buffer.writeCharCode(currentChar); |
| 3292 } | 3053 } |
| 3293 } | 3054 } |
| 3294 } | 3055 } |
| 3295 | 3056 |
| 3296 /** | 3057 /** |
| 3297 * The class `ElementPair` is a pair of [Element]s. [Object.==] and | 3058 * A pair of [Element]s. [Object.==] and |
| 3298 * [Object.hashCode] so this class can be used in hashed data structures. | 3059 * [Object.hashCode] so this class can be used in hashed data structures. |
| 3299 */ | 3060 */ |
| 3300 class ElementPair { | 3061 class ElementPair { |
| 3301 /** | 3062 /** |
| 3302 * The first [Element]. | 3063 * The first [Element]. |
| 3303 */ | 3064 */ |
| 3304 final Element _first; | 3065 final Element _first; |
| 3305 | 3066 |
| 3306 /** | 3067 /** |
| 3307 * The second [Element]. | 3068 * The second [Element]. |
| 3308 */ | 3069 */ |
| 3309 final Element _second; | 3070 final Element _second; |
| 3310 | 3071 |
| 3311 /** | 3072 /** |
| 3312 * A cached copy of the calculated hashCode for this element. | 3073 * A cached copy of the calculated hashCode for this element. |
| 3313 */ | 3074 */ |
| 3314 int _cachedHashCode; | 3075 int _cachedHashCode; |
| 3315 | 3076 |
| 3316 /** | 3077 /** |
| 3317 * The sole constructor for this class, taking two [Element]s. | 3078 * Initialize a newly created pair of elements consisting of the [_first] and |
| 3318 * | 3079 * [_second] elements. |
| 3319 * @param first the first element | |
| 3320 * @param second the second element | |
| 3321 */ | 3080 */ |
| 3322 ElementPair(this._first, this._second) { | 3081 ElementPair(this._first, this._second) { |
| 3323 _cachedHashCode = JenkinsSmiHash.hash2(_first.hashCode, _second.hashCode); | 3082 _cachedHashCode = JenkinsSmiHash.hash2(_first.hashCode, _second.hashCode); |
| 3324 } | 3083 } |
| 3325 | 3084 |
| 3326 /** | 3085 /** |
| 3327 * Return the first element. | 3086 * Return the first element. |
| 3328 * | |
| 3329 * @return the first element | |
| 3330 */ | 3087 */ |
| 3331 Element get firstElt => _first; | 3088 Element get firstElt => _first; |
| 3332 | 3089 |
| 3333 @override | 3090 @override |
| 3334 int get hashCode { | 3091 int get hashCode { |
| 3335 return _cachedHashCode; | 3092 return _cachedHashCode; |
| 3336 } | 3093 } |
| 3337 | 3094 |
| 3338 /** | 3095 /** |
| 3339 * Return the second element | 3096 * Return the second element |
| 3340 * | |
| 3341 * @return the second element | |
| 3342 */ | 3097 */ |
| 3343 Element get secondElt => _second; | 3098 Element get secondElt => _second; |
| 3344 | 3099 |
| 3345 @override | 3100 @override |
| 3346 bool operator ==(Object object) { | 3101 bool operator ==(Object object) { |
| 3347 if (identical(object, this)) { | 3102 if (identical(object, this)) { |
| 3348 return true; | 3103 return true; |
| 3349 } | 3104 } |
| 3350 return object is ElementPair && | 3105 return object is ElementPair && |
| 3351 _first == object._first && | 3106 _first == object._first && |
| 3352 _second == object._second; | 3107 _second == object._second; |
| 3353 } | 3108 } |
| 3354 } | 3109 } |
| 3355 | 3110 |
| 3356 /** | 3111 /** |
| 3357 * The interface `ElementVisitor` defines the behavior of objects that can be us
ed to visit an | 3112 * An object that can be used to visit an element structure. |
| 3358 * element structure. | |
| 3359 */ | 3113 */ |
| 3360 abstract class ElementVisitor<R> { | 3114 abstract class ElementVisitor<R> { |
| 3361 R visitClassElement(ClassElement element); | 3115 R visitClassElement(ClassElement element); |
| 3362 | 3116 |
| 3363 R visitCompilationUnitElement(CompilationUnitElement element); | 3117 R visitCompilationUnitElement(CompilationUnitElement element); |
| 3364 | 3118 |
| 3365 R visitConstructorElement(ConstructorElement element); | 3119 R visitConstructorElement(ConstructorElement element); |
| 3366 | 3120 |
| 3367 R visitEmbeddedHtmlScriptElement(EmbeddedHtmlScriptElement element); | 3121 R visitEmbeddedHtmlScriptElement(EmbeddedHtmlScriptElement element); |
| 3368 | 3122 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3397 R visitPrefixElement(PrefixElement element); | 3151 R visitPrefixElement(PrefixElement element); |
| 3398 | 3152 |
| 3399 R visitPropertyAccessorElement(PropertyAccessorElement element); | 3153 R visitPropertyAccessorElement(PropertyAccessorElement element); |
| 3400 | 3154 |
| 3401 R visitTopLevelVariableElement(TopLevelVariableElement element); | 3155 R visitTopLevelVariableElement(TopLevelVariableElement element); |
| 3402 | 3156 |
| 3403 R visitTypeParameterElement(TypeParameterElement element); | 3157 R visitTypeParameterElement(TypeParameterElement element); |
| 3404 } | 3158 } |
| 3405 | 3159 |
| 3406 /** | 3160 /** |
| 3407 * The interface `EmbeddedHtmlScriptElement` defines the behavior of elements re
presenting a | 3161 * A script tag in an HTML file having content that defines a Dart library. |
| 3408 * script tag in an HTML file having content that defines a Dart library. | |
| 3409 */ | 3162 */ |
| 3410 abstract class EmbeddedHtmlScriptElement implements HtmlScriptElement { | 3163 abstract class EmbeddedHtmlScriptElement implements HtmlScriptElement { |
| 3411 /** | 3164 /** |
| 3412 * Return the library element defined by the content of the script tag. | 3165 * Return the library element defined by the content of the script tag. |
| 3413 * | |
| 3414 * @return the library element (not `null`) | |
| 3415 */ | 3166 */ |
| 3416 LibraryElement get scriptLibrary; | 3167 LibraryElement get scriptLibrary; |
| 3417 } | 3168 } |
| 3418 | 3169 |
| 3419 /** | 3170 /** |
| 3420 * Instances of the class `EmbeddedHtmlScriptElementImpl` implement an | 3171 * A concrete implementation of an [EmbeddedHtmlScriptElement]. |
| 3421 * [EmbeddedHtmlScriptElement]. | |
| 3422 */ | 3172 */ |
| 3423 class EmbeddedHtmlScriptElementImpl extends HtmlScriptElementImpl | 3173 class EmbeddedHtmlScriptElementImpl extends HtmlScriptElementImpl |
| 3424 implements EmbeddedHtmlScriptElement { | 3174 implements EmbeddedHtmlScriptElement { |
| 3425 /** | 3175 /** |
| 3426 * The library defined by the script tag's content. | 3176 * The library defined by the script tag's content. |
| 3427 */ | 3177 */ |
| 3428 LibraryElement _scriptLibrary; | 3178 LibraryElement _scriptLibrary; |
| 3429 | 3179 |
| 3430 /** | 3180 /** |
| 3431 * Initialize a newly created script element to have the specified tag name an
d offset. | 3181 * Initialize a newly created script element to represent the given [node]. |
| 3432 * | |
| 3433 * @param node the XML node from which this element is derived (not `null`) | |
| 3434 */ | 3182 */ |
| 3435 EmbeddedHtmlScriptElementImpl(XmlTagNode node) : super(node); | 3183 EmbeddedHtmlScriptElementImpl(XmlTagNode node) : super(node); |
| 3436 | 3184 |
| 3437 @override | 3185 @override |
| 3438 ElementKind get kind => ElementKind.EMBEDDED_HTML_SCRIPT; | 3186 ElementKind get kind => ElementKind.EMBEDDED_HTML_SCRIPT; |
| 3439 | 3187 |
| 3440 @override | 3188 @override |
| 3441 LibraryElement get scriptLibrary => _scriptLibrary; | 3189 LibraryElement get scriptLibrary => _scriptLibrary; |
| 3442 | 3190 |
| 3443 /** | 3191 /** |
| 3444 * Set the script library defined by the script tag's content. | 3192 * Set the script library defined by the script tag's content to the given |
| 3445 * | 3193 * [library]. |
| 3446 * @param scriptLibrary the library or `null` if none | |
| 3447 */ | 3194 */ |
| 3448 void set scriptLibrary(LibraryElementImpl scriptLibrary) { | 3195 void set scriptLibrary(LibraryElementImpl library) { |
| 3449 scriptLibrary.enclosingElement = this; | 3196 library.enclosingElement = this; |
| 3450 this._scriptLibrary = scriptLibrary; | 3197 _scriptLibrary = library; |
| 3451 } | 3198 } |
| 3452 | 3199 |
| 3453 @override | 3200 @override |
| 3454 accept(ElementVisitor visitor) => | 3201 accept(ElementVisitor visitor) => |
| 3455 visitor.visitEmbeddedHtmlScriptElement(this); | 3202 visitor.visitEmbeddedHtmlScriptElement(this); |
| 3456 | 3203 |
| 3457 @override | 3204 @override |
| 3458 void visitChildren(ElementVisitor visitor) { | 3205 void visitChildren(ElementVisitor visitor) { |
| 3459 safelyVisitChild(_scriptLibrary, visitor); | 3206 safelyVisitChild(_scriptLibrary, visitor); |
| 3460 } | 3207 } |
| 3461 } | 3208 } |
| 3462 | 3209 |
| 3463 /** | 3210 /** |
| 3464 * The interface `ExecutableElement` defines the behavior of elements representi
ng an | 3211 * An element representing an executable object, including functions, methods, |
| 3465 * executable object, including functions, methods, constructors, getters, and s
etters. | 3212 * constructors, getters, and setters. |
| 3466 */ | 3213 */ |
| 3467 abstract class ExecutableElement implements Element { | 3214 abstract class ExecutableElement implements Element { |
| 3468 /** | 3215 /** |
| 3469 * Return an array containing all of the functions defined within this executa
ble element. | 3216 * Return a list containing all of the functions defined within this |
| 3470 * | 3217 * executable element. |
| 3471 * @return the functions defined within this executable element | |
| 3472 */ | 3218 */ |
| 3473 List<FunctionElement> get functions; | 3219 List<FunctionElement> get functions; |
| 3474 | 3220 |
| 3475 /** | 3221 /** |
| 3476 * Return `true` if this executable element has body marked as being asynchron
ous. | 3222 * Return `true` if this executable element has body marked as being |
| 3477 * | 3223 * asynchronous. |
| 3478 * @return `true` if this executable element has body marked as being asynchro
nous | |
| 3479 */ | 3224 */ |
| 3480 bool get isAsynchronous; | 3225 bool get isAsynchronous; |
| 3481 | 3226 |
| 3482 /** | 3227 /** |
| 3483 * Return `true` if this executable element has a body marked as being a gener
ator. | 3228 * Return `true` if this executable element has a body marked as being a |
| 3484 * | 3229 * generator. |
| 3485 * @return `true` if this executable element has a body marked as being a gene
rator | |
| 3486 */ | 3230 */ |
| 3487 bool get isGenerator; | 3231 bool get isGenerator; |
| 3488 | 3232 |
| 3489 /** | 3233 /** |
| 3490 * Return `true` if this executable element is an operator. The test may be ba
sed on the | 3234 * Return `true` if this executable element is an operator. The test may be |
| 3491 * name of the executable element, in which case the result will be correct wh
en the name is | 3235 * based on the name of the executable element, in which case the result will |
| 3492 * legal. | 3236 * be correct when the name is legal. |
| 3493 * | |
| 3494 * @return `true` if this executable element is an operator | |
| 3495 */ | 3237 */ |
| 3496 bool get isOperator; | 3238 bool get isOperator; |
| 3497 | 3239 |
| 3498 /** | 3240 /** |
| 3499 * Return `true` if this element is a static element. A static element is an e
lement that is | 3241 * Return `true` if this element is a static element. A static element is an |
| 3500 * not associated with a particular instance, but rather with an entire librar
y or class. | 3242 * element that is not associated with a particular instance, but rather with |
| 3501 * | 3243 * an entire library or class. |
| 3502 * @return `true` if this executable element is a static element | |
| 3503 */ | 3244 */ |
| 3504 bool get isStatic; | 3245 bool get isStatic; |
| 3505 | 3246 |
| 3506 /** | 3247 /** |
| 3507 * Return `true` if this executable element has a body marked as being synchro
nous. | 3248 * Return `true` if this executable element has a body marked as being |
| 3508 * | 3249 * synchronous. |
| 3509 * @return `true` if this executable element has a body marked as being synchr
onous | |
| 3510 */ | 3250 */ |
| 3511 bool get isSynchronous; | 3251 bool get isSynchronous; |
| 3512 | 3252 |
| 3513 /** | 3253 /** |
| 3514 * Return an array containing all of the labels defined within this executable
element. | 3254 * Return a list containing all of the labels defined within this executable |
| 3515 * | 3255 * element. |
| 3516 * @return the labels defined within this executable element | |
| 3517 */ | 3256 */ |
| 3518 List<LabelElement> get labels; | 3257 List<LabelElement> get labels; |
| 3519 | 3258 |
| 3520 /** | 3259 /** |
| 3521 * Return an array containing all of the local variables defined within this e
xecutable element. | 3260 * Return a list containing all of the local variables defined within this |
| 3522 * | 3261 * executable element. |
| 3523 * @return the local variables defined within this executable element | |
| 3524 */ | 3262 */ |
| 3525 List<LocalVariableElement> get localVariables; | 3263 List<LocalVariableElement> get localVariables; |
| 3526 | 3264 |
| 3527 /** | 3265 /** |
| 3528 * Return an array containing all of the parameters defined by this executable
element. | 3266 * Return a list containing all of the parameters defined by this executable |
| 3529 * | 3267 * element. |
| 3530 * @return the parameters defined by this executable element | |
| 3531 */ | 3268 */ |
| 3532 List<ParameterElement> get parameters; | 3269 List<ParameterElement> get parameters; |
| 3533 | 3270 |
| 3534 /** | 3271 /** |
| 3535 * Return the return type defined by this executable element. | 3272 * Return the return type defined by this executable element. |
| 3536 * | |
| 3537 * @return the return type defined by this executable element | |
| 3538 */ | 3273 */ |
| 3539 DartType get returnType; | 3274 DartType get returnType; |
| 3540 | 3275 |
| 3541 /** | 3276 /** |
| 3542 * Return the type of function defined by this executable element. | 3277 * Return the type of function defined by this executable element. |
| 3543 * | |
| 3544 * @return the type of function defined by this executable element | |
| 3545 */ | 3278 */ |
| 3546 FunctionType get type; | 3279 FunctionType get type; |
| 3547 } | 3280 } |
| 3548 | 3281 |
| 3549 /** | 3282 /** |
| 3550 * The abstract class `ExecutableElementImpl` implements the behavior common to | 3283 * A base class for concrete implementations of an [ExecutableElement]. |
| 3551 * `ExecutableElement`s. | |
| 3552 */ | 3284 */ |
| 3553 abstract class ExecutableElementImpl extends ElementImpl | 3285 abstract class ExecutableElementImpl extends ElementImpl |
| 3554 implements ExecutableElement { | 3286 implements ExecutableElement { |
| 3555 /** | 3287 /** |
| 3556 * An empty list of executable elements. | 3288 * An empty list of executable elements. |
| 3557 */ | 3289 */ |
| 3558 static const List<ExecutableElement> EMPTY_ARRAY = const <ExecutableElement>[ | 3290 static const List<ExecutableElement> EMPTY_ARRAY = const <ExecutableElement>[ |
| 3559 ]; | 3291 ]; |
| 3560 | 3292 |
| 3561 /** | 3293 /** |
| 3562 * An array containing all of the functions defined within this executable ele
ment. | 3294 * A list containing all of the functions defined within this executable |
| 3295 * element. |
| 3563 */ | 3296 */ |
| 3564 List<FunctionElement> _functions = FunctionElementImpl.EMPTY_ARRAY; | 3297 List<FunctionElement> _functions = FunctionElementImpl.EMPTY_ARRAY; |
| 3565 | 3298 |
| 3566 /** | 3299 /** |
| 3567 * An array containing all of the labels defined within this executable elemen
t. | 3300 * A list containing all of the labels defined within this executable element. |
| 3568 */ | 3301 */ |
| 3569 List<LabelElement> _labels = LabelElementImpl.EMPTY_ARRAY; | 3302 List<LabelElement> _labels = LabelElementImpl.EMPTY_ARRAY; |
| 3570 | 3303 |
| 3571 /** | 3304 /** |
| 3572 * An array containing all of the local variables defined within this executab
le element. | 3305 * A list containing all of the local variables defined within this executable |
| 3306 * element. |
| 3573 */ | 3307 */ |
| 3574 List<LocalVariableElement> _localVariables = | 3308 List<LocalVariableElement> _localVariables = |
| 3575 LocalVariableElementImpl.EMPTY_ARRAY; | 3309 LocalVariableElementImpl.EMPTY_ARRAY; |
| 3576 | 3310 |
| 3577 /** | 3311 /** |
| 3578 * An array containing all of the parameters defined by this executable elemen
t. | 3312 * A list containing all of the parameters defined by this executable element. |
| 3579 */ | 3313 */ |
| 3580 List<ParameterElement> _parameters = ParameterElementImpl.EMPTY_ARRAY; | 3314 List<ParameterElement> _parameters = ParameterElementImpl.EMPTY_ARRAY; |
| 3581 | 3315 |
| 3582 /** | 3316 /** |
| 3583 * The return type defined by this executable element. | 3317 * The return type defined by this executable element. |
| 3584 */ | 3318 */ |
| 3585 DartType returnType; | 3319 DartType returnType; |
| 3586 | 3320 |
| 3587 /** | 3321 /** |
| 3588 * The type of function defined by this executable element. | 3322 * The type of function defined by this executable element. |
| 3589 */ | 3323 */ |
| 3590 FunctionType type; | 3324 FunctionType type; |
| 3591 | 3325 |
| 3592 /** | 3326 /** |
| 3593 * Initialize a newly created executable element to have the given name. | 3327 * Initialize a newly created executable element to have the given [name] and |
| 3594 * | 3328 * [offset]. |
| 3595 * @param name the name of this element | |
| 3596 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
| 3597 * declaration of this element | |
| 3598 */ | 3329 */ |
| 3599 ExecutableElementImpl(String name, int nameOffset) : super(name, nameOffset); | 3330 ExecutableElementImpl(String name, int offset) : super(name, offset); |
| 3600 | 3331 |
| 3601 /** | 3332 /** |
| 3602 * Initialize a newly created executable element to have the given name. | 3333 * Initialize a newly created executable element to have the given [name]. |
| 3603 * | |
| 3604 * @param name the name of this element | |
| 3605 */ | 3334 */ |
| 3606 ExecutableElementImpl.forNode(Identifier name) : super.forNode(name); | 3335 ExecutableElementImpl.forNode(Identifier name) : super.forNode(name); |
| 3607 | 3336 |
| 3608 /** | 3337 /** |
| 3609 * Set whether this method's body is asynchronous to correspond to the given v
alue. | 3338 * Set whether this method's body is asynchronous. |
| 3610 * | |
| 3611 * @param isAsynchronous `true` if the method's body is asynchronous | |
| 3612 */ | 3339 */ |
| 3613 void set asynchronous(bool isAsynchronous) { | 3340 void set asynchronous(bool isAsynchronous) { |
| 3614 setModifier(Modifier.ASYNCHRONOUS, isAsynchronous); | 3341 setModifier(Modifier.ASYNCHRONOUS, isAsynchronous); |
| 3615 } | 3342 } |
| 3616 | 3343 |
| 3617 @override | 3344 @override |
| 3618 List<FunctionElement> get functions => _functions; | 3345 List<FunctionElement> get functions => _functions; |
| 3619 | 3346 |
| 3620 /** | 3347 /** |
| 3621 * Set the functions defined within this executable element to the given funct
ions. | 3348 * Set the functions defined within this executable element to the given |
| 3622 * | 3349 * [functions]. |
| 3623 * @param functions the functions defined within this executable element | |
| 3624 */ | 3350 */ |
| 3625 void set functions(List<FunctionElement> functions) { | 3351 void set functions(List<FunctionElement> functions) { |
| 3626 for (FunctionElement function in functions) { | 3352 for (FunctionElement function in functions) { |
| 3627 (function as FunctionElementImpl).enclosingElement = this; | 3353 (function as FunctionElementImpl).enclosingElement = this; |
| 3628 } | 3354 } |
| 3629 this._functions = functions; | 3355 this._functions = functions; |
| 3630 } | 3356 } |
| 3631 | 3357 |
| 3632 /** | 3358 /** |
| 3633 * Set whether this method's body is a generator to correspond to the given va
lue. | 3359 * Set whether this method's body is a generator. |
| 3634 * | |
| 3635 * @param isGenerator `true` if the method's body is a generator | |
| 3636 */ | 3360 */ |
| 3637 void set generator(bool isGenerator) { | 3361 void set generator(bool isGenerator) { |
| 3638 setModifier(Modifier.GENERATOR, isGenerator); | 3362 setModifier(Modifier.GENERATOR, isGenerator); |
| 3639 } | 3363 } |
| 3640 | 3364 |
| 3641 @override | 3365 @override |
| 3642 bool get isAsynchronous => hasModifier(Modifier.ASYNCHRONOUS); | 3366 bool get isAsynchronous => hasModifier(Modifier.ASYNCHRONOUS); |
| 3643 | 3367 |
| 3644 @override | 3368 @override |
| 3645 bool get isGenerator => hasModifier(Modifier.GENERATOR); | 3369 bool get isGenerator => hasModifier(Modifier.GENERATOR); |
| 3646 | 3370 |
| 3647 @override | 3371 @override |
| 3648 bool get isOperator => false; | 3372 bool get isOperator => false; |
| 3649 | 3373 |
| 3650 @override | 3374 @override |
| 3651 bool get isSynchronous => !hasModifier(Modifier.ASYNCHRONOUS); | 3375 bool get isSynchronous => !hasModifier(Modifier.ASYNCHRONOUS); |
| 3652 | 3376 |
| 3653 @override | 3377 @override |
| 3654 List<LabelElement> get labels => _labels; | 3378 List<LabelElement> get labels => _labels; |
| 3655 | 3379 |
| 3656 /** | 3380 /** |
| 3657 * Set the labels defined within this executable element to the given labels. | 3381 * Set the labels defined within this executable element to the given |
| 3658 * | 3382 * [labels]. |
| 3659 * @param labels the labels defined within this executable element | |
| 3660 */ | 3383 */ |
| 3661 void set labels(List<LabelElement> labels) { | 3384 void set labels(List<LabelElement> labels) { |
| 3662 for (LabelElement label in labels) { | 3385 for (LabelElement label in labels) { |
| 3663 (label as LabelElementImpl).enclosingElement = this; | 3386 (label as LabelElementImpl).enclosingElement = this; |
| 3664 } | 3387 } |
| 3665 this._labels = labels; | 3388 this._labels = labels; |
| 3666 } | 3389 } |
| 3667 | 3390 |
| 3668 @override | 3391 @override |
| 3669 List<LocalVariableElement> get localVariables => _localVariables; | 3392 List<LocalVariableElement> get localVariables => _localVariables; |
| 3670 | 3393 |
| 3671 /** | 3394 /** |
| 3672 * Set the local variables defined within this executable element to the given
variables. | 3395 * Set the local variables defined within this executable element to the given |
| 3673 * | 3396 * [variables]. |
| 3674 * @param localVariables the local variables defined within this executable el
ement | |
| 3675 */ | 3397 */ |
| 3676 void set localVariables(List<LocalVariableElement> localVariables) { | 3398 void set localVariables(List<LocalVariableElement> variables) { |
| 3677 for (LocalVariableElement variable in localVariables) { | 3399 for (LocalVariableElement variable in variables) { |
| 3678 (variable as LocalVariableElementImpl).enclosingElement = this; | 3400 (variable as LocalVariableElementImpl).enclosingElement = this; |
| 3679 } | 3401 } |
| 3680 this._localVariables = localVariables; | 3402 this._localVariables = variables; |
| 3681 } | 3403 } |
| 3682 | 3404 |
| 3683 @override | 3405 @override |
| 3684 List<ParameterElement> get parameters => _parameters; | 3406 List<ParameterElement> get parameters => _parameters; |
| 3685 | 3407 |
| 3686 /** | 3408 /** |
| 3687 * Set the parameters defined by this executable element to the given paramete
rs. | 3409 * Set the parameters defined by this executable element to the given |
| 3688 * | 3410 * [parameters]. |
| 3689 * @param parameters the parameters defined by this executable element | |
| 3690 */ | 3411 */ |
| 3691 void set parameters(List<ParameterElement> parameters) { | 3412 void set parameters(List<ParameterElement> parameters) { |
| 3692 for (ParameterElement parameter in parameters) { | 3413 for (ParameterElement parameter in parameters) { |
| 3693 (parameter as ParameterElementImpl).enclosingElement = this; | 3414 (parameter as ParameterElementImpl).enclosingElement = this; |
| 3694 } | 3415 } |
| 3695 this._parameters = parameters; | 3416 this._parameters = parameters; |
| 3696 } | 3417 } |
| 3697 | 3418 |
| 3698 @override | 3419 @override |
| 3699 void appendTo(StringBuffer buffer) { | 3420 void appendTo(StringBuffer buffer) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3765 void visitChildren(ElementVisitor visitor) { | 3486 void visitChildren(ElementVisitor visitor) { |
| 3766 super.visitChildren(visitor); | 3487 super.visitChildren(visitor); |
| 3767 safelyVisitChildren(_functions, visitor); | 3488 safelyVisitChildren(_functions, visitor); |
| 3768 safelyVisitChildren(_labels, visitor); | 3489 safelyVisitChildren(_labels, visitor); |
| 3769 safelyVisitChildren(_localVariables, visitor); | 3490 safelyVisitChildren(_localVariables, visitor); |
| 3770 safelyVisitChildren(_parameters, visitor); | 3491 safelyVisitChildren(_parameters, visitor); |
| 3771 } | 3492 } |
| 3772 } | 3493 } |
| 3773 | 3494 |
| 3774 /** | 3495 /** |
| 3775 * The abstract class `ExecutableMember` defines the behavior common to members
that represent | 3496 * An executable element defined in a parameterized type where the values of the |
| 3776 * an executable element defined in a parameterized type where the values of the
type parameters are | 3497 * type parameters are known. |
| 3777 * known. | |
| 3778 */ | 3498 */ |
| 3779 abstract class ExecutableMember extends Member implements ExecutableElement { | 3499 abstract class ExecutableMember extends Member implements ExecutableElement { |
| 3780 /** | 3500 /** |
| 3781 * Initialize a newly created element to represent an executable element of th
e given | 3501 * Initialize a newly created element to represent a constructor, based on the |
| 3782 * parameterized type. | 3502 * [baseElement], defined by the [definingType]. |
| 3783 * | |
| 3784 * @param baseElement the element on which the parameterized element was creat
ed | |
| 3785 * @param definingType the type in which the element is defined | |
| 3786 */ | 3503 */ |
| 3787 ExecutableMember(ExecutableElement baseElement, InterfaceType definingType) | 3504 ExecutableMember(ExecutableElement baseElement, InterfaceType definingType) |
| 3788 : super(baseElement, definingType); | 3505 : super(baseElement, definingType); |
| 3789 | 3506 |
| 3790 @override | 3507 @override |
| 3791 ExecutableElement get baseElement => super.baseElement as ExecutableElement; | 3508 ExecutableElement get baseElement => super.baseElement as ExecutableElement; |
| 3792 | 3509 |
| 3793 @override | 3510 @override |
| 3794 List<FunctionElement> get functions { | 3511 List<FunctionElement> get functions { |
| 3795 // | 3512 // |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3856 // below so that we can safely invoke them. | 3573 // below so that we can safely invoke them. |
| 3857 super.visitChildren(visitor); | 3574 super.visitChildren(visitor); |
| 3858 safelyVisitChildren(baseElement.functions, visitor); | 3575 safelyVisitChildren(baseElement.functions, visitor); |
| 3859 safelyVisitChildren(labels, visitor); | 3576 safelyVisitChildren(labels, visitor); |
| 3860 safelyVisitChildren(baseElement.localVariables, visitor); | 3577 safelyVisitChildren(baseElement.localVariables, visitor); |
| 3861 safelyVisitChildren(parameters, visitor); | 3578 safelyVisitChildren(parameters, visitor); |
| 3862 } | 3579 } |
| 3863 } | 3580 } |
| 3864 | 3581 |
| 3865 /** | 3582 /** |
| 3866 * The interface `ExportElement` defines the behavior of objects representing in
formation | 3583 * An export directive within a library. |
| 3867 * about a single export directive within a library. | |
| 3868 */ | 3584 */ |
| 3869 abstract class ExportElement implements Element, UriReferencedElement { | 3585 abstract class ExportElement implements Element, UriReferencedElement { |
| 3870 /** | 3586 /** |
| 3871 * An empty list of export elements. | 3587 * An empty list of export elements. |
| 3872 */ | 3588 */ |
| 3873 static const List<ExportElement> EMPTY_ARRAY = const <ExportElement>[]; | 3589 static const List<ExportElement> EMPTY_ARRAY = const <ExportElement>[]; |
| 3874 | 3590 |
| 3875 /** | 3591 /** |
| 3876 * Return an array containing the combinators that were specified as part of t
he export directive | 3592 * Return a list containing the combinators that were specified as part of the |
| 3877 * in the order in which they were specified. | 3593 * export directive in the order in which they were specified. |
| 3878 * | |
| 3879 * @return the combinators specified in the export directive | |
| 3880 */ | 3594 */ |
| 3881 List<NamespaceCombinator> get combinators; | 3595 List<NamespaceCombinator> get combinators; |
| 3882 | 3596 |
| 3883 /** | 3597 /** |
| 3884 * Return the library that is exported from this library by this export direct
ive. | 3598 * Return the library that is exported from this library by this export |
| 3885 * | 3599 * directive. |
| 3886 * @return the library that is exported from this library | |
| 3887 */ | 3600 */ |
| 3888 LibraryElement get exportedLibrary; | 3601 LibraryElement get exportedLibrary; |
| 3889 } | 3602 } |
| 3890 | 3603 |
| 3891 /** | 3604 /** |
| 3892 * Instances of the class `ExportElementImpl` implement an [ExportElement]. | 3605 * A concrete implementation of an [ExportElement]. |
| 3893 */ | 3606 */ |
| 3894 class ExportElementImpl extends UriReferencedElementImpl | 3607 class ExportElementImpl extends UriReferencedElementImpl |
| 3895 implements ExportElement { | 3608 implements ExportElement { |
| 3896 /** | 3609 /** |
| 3897 * The library that is exported from this library by this export directive. | 3610 * The library that is exported from this library by this export directive. |
| 3898 */ | 3611 */ |
| 3899 LibraryElement exportedLibrary; | 3612 LibraryElement exportedLibrary; |
| 3900 | 3613 |
| 3901 /** | 3614 /** |
| 3902 * The combinators that were specified as part of the export directive in the
order in which they | 3615 * The combinators that were specified as part of the export directive in the |
| 3903 * were specified. | 3616 * order in which they were specified. |
| 3904 */ | 3617 */ |
| 3905 List<NamespaceCombinator> combinators = NamespaceCombinator.EMPTY_ARRAY; | 3618 List<NamespaceCombinator> combinators = NamespaceCombinator.EMPTY_ARRAY; |
| 3906 | 3619 |
| 3907 /** | 3620 /** |
| 3908 * Initialize a newly created export element. | 3621 * Initialize a newly created export element. |
| 3909 */ | 3622 */ |
| 3910 ExportElementImpl() : super(null, -1); | 3623 ExportElementImpl() : super(null, -1); |
| 3911 | 3624 |
| 3912 @override | 3625 @override |
| 3913 String get identifier => exportedLibrary.name; | 3626 String get identifier => exportedLibrary.name; |
| 3914 | 3627 |
| 3915 @override | 3628 @override |
| 3916 ElementKind get kind => ElementKind.EXPORT; | 3629 ElementKind get kind => ElementKind.EXPORT; |
| 3917 | 3630 |
| 3918 @override | 3631 @override |
| 3919 accept(ElementVisitor visitor) => visitor.visitExportElement(this); | 3632 accept(ElementVisitor visitor) => visitor.visitExportElement(this); |
| 3920 | 3633 |
| 3921 @override | 3634 @override |
| 3922 void appendTo(StringBuffer buffer) { | 3635 void appendTo(StringBuffer buffer) { |
| 3923 buffer.write("export "); | 3636 buffer.write("export "); |
| 3924 (exportedLibrary as LibraryElementImpl).appendTo(buffer); | 3637 (exportedLibrary as LibraryElementImpl).appendTo(buffer); |
| 3925 } | 3638 } |
| 3926 } | 3639 } |
| 3927 | 3640 |
| 3928 /** | 3641 /** |
| 3929 * The interface `ExternalHtmlScriptElement` defines the behavior of elements re
presenting a | 3642 * A script tag in an HTML file having a `source` attribute that references a |
| 3930 * script tag in an HTML file having a `source` attribute that references a Dart
library | 3643 * Dart library source file. |
| 3931 * source file. | |
| 3932 */ | 3644 */ |
| 3933 abstract class ExternalHtmlScriptElement implements HtmlScriptElement { | 3645 abstract class ExternalHtmlScriptElement implements HtmlScriptElement { |
| 3934 /** | 3646 /** |
| 3935 * Return the source referenced by this element, or `null` if this element doe
s not | 3647 * Return the source referenced by this element, or `null` if this element |
| 3936 * reference a Dart library source file. | 3648 * does not reference a Dart library source file. |
| 3937 * | |
| 3938 * @return the source for the external Dart library | |
| 3939 */ | 3649 */ |
| 3940 Source get scriptSource; | 3650 Source get scriptSource; |
| 3941 } | 3651 } |
| 3942 | 3652 |
| 3943 /** | 3653 /** |
| 3944 * Instances of the class `ExternalHtmlScriptElementImpl` implement an | 3654 * A concrete implementation of an [ExternalHtmlScriptElement]. |
| 3945 * [ExternalHtmlScriptElement]. | |
| 3946 */ | 3655 */ |
| 3947 class ExternalHtmlScriptElementImpl extends HtmlScriptElementImpl | 3656 class ExternalHtmlScriptElementImpl extends HtmlScriptElementImpl |
| 3948 implements ExternalHtmlScriptElement { | 3657 implements ExternalHtmlScriptElement { |
| 3949 /** | 3658 /** |
| 3950 * The source specified in the `source` attribute or `null` if unspecified. | 3659 * The source specified in the `source` attribute or `null` if unspecified. |
| 3951 */ | 3660 */ |
| 3952 Source scriptSource; | 3661 Source scriptSource; |
| 3953 | 3662 |
| 3954 /** | 3663 /** |
| 3955 * Initialize a newly created script element to have the specified tag name an
d offset. | 3664 * Initialize a newly created script element to correspond to the given |
| 3956 * | 3665 * [node]. |
| 3957 * @param node the XML node from which this element is derived (not `null`) | |
| 3958 */ | 3666 */ |
| 3959 ExternalHtmlScriptElementImpl(XmlTagNode node) : super(node); | 3667 ExternalHtmlScriptElementImpl(XmlTagNode node) : super(node); |
| 3960 | 3668 |
| 3961 @override | 3669 @override |
| 3962 ElementKind get kind => ElementKind.EXTERNAL_HTML_SCRIPT; | 3670 ElementKind get kind => ElementKind.EXTERNAL_HTML_SCRIPT; |
| 3963 | 3671 |
| 3964 @override | 3672 @override |
| 3965 accept(ElementVisitor visitor) => | 3673 accept(ElementVisitor visitor) => |
| 3966 visitor.visitExternalHtmlScriptElement(this); | 3674 visitor.visitExternalHtmlScriptElement(this); |
| 3967 } | 3675 } |
| 3968 | 3676 |
| 3969 /** | 3677 /** |
| 3970 * The interface `FieldElement` defines the behavior of elements representing a
field defined | 3678 * A field defined within a type. |
| 3971 * within a type. | |
| 3972 */ | 3679 */ |
| 3973 abstract class FieldElement | 3680 abstract class FieldElement |
| 3974 implements ClassMemberElement, PropertyInducingElement { | 3681 implements ClassMemberElement, PropertyInducingElement { |
| 3975 /** | 3682 /** |
| 3976 * Return {@code true} if this element is an enum constant. | 3683 * Return {@code true} if this element is an enum constant. |
| 3977 * | |
| 3978 * @return {@code true} if this an enum constant | |
| 3979 */ | 3684 */ |
| 3980 bool get isEnumConstant; | 3685 bool get isEnumConstant; |
| 3981 } | 3686 } |
| 3982 | 3687 |
| 3983 /** | 3688 /** |
| 3984 * Instances of the class `FieldElementImpl` implement a `FieldElement`. | 3689 * A concrete implementation of a [FieldElement]. |
| 3985 */ | 3690 */ |
| 3986 class FieldElementImpl extends PropertyInducingElementImpl | 3691 class FieldElementImpl extends PropertyInducingElementImpl |
| 3987 implements FieldElement { | 3692 implements FieldElement { |
| 3988 /** | 3693 /** |
| 3989 * An empty list of field elements. | 3694 * An empty list of field elements. |
| 3990 */ | 3695 */ |
| 3991 static const List<FieldElement> EMPTY_ARRAY = const <FieldElement>[]; | 3696 static const List<FieldElement> EMPTY_ARRAY = const <FieldElement>[]; |
| 3992 | 3697 |
| 3993 /** | 3698 /** |
| 3994 * Initialize a newly created synthetic field element to have the given name. | 3699 * Initialize a newly created synthetic field element to have the given [name] |
| 3995 * | 3700 * at the given [offset]. |
| 3996 * @param name the name of this element | |
| 3997 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
| 3998 * declaration of this element | |
| 3999 */ | 3701 */ |
| 4000 FieldElementImpl(String name, int nameOffset) : super(name, nameOffset); | 3702 FieldElementImpl(String name, int offset) : super(name, offset); |
| 4001 | 3703 |
| 4002 /** | 3704 /** |
| 4003 * Initialize a newly created field element to have the given name. | 3705 * Initialize a newly created field element to have the given [name]. |
| 4004 * | |
| 4005 * @param name the name of this element | |
| 4006 */ | 3706 */ |
| 4007 FieldElementImpl.forNode(Identifier name) : super.forNode(name); | 3707 FieldElementImpl.forNode(Identifier name) : super.forNode(name); |
| 4008 | 3708 |
| 4009 @override | 3709 @override |
| 4010 ClassElement get enclosingElement => super.enclosingElement as ClassElement; | 3710 ClassElement get enclosingElement => super.enclosingElement as ClassElement; |
| 4011 | 3711 |
| 4012 @override | 3712 @override |
| 4013 bool get isEnumConstant => | 3713 bool get isEnumConstant => |
| 4014 enclosingElement != null ? enclosingElement.isEnum : false; | 3714 enclosingElement != null ? enclosingElement.isEnum : false; |
| 4015 | 3715 |
| 4016 @override | 3716 @override |
| 4017 bool get isStatic => hasModifier(Modifier.STATIC); | 3717 bool get isStatic => hasModifier(Modifier.STATIC); |
| 4018 | 3718 |
| 4019 @override | 3719 @override |
| 4020 ElementKind get kind => ElementKind.FIELD; | 3720 ElementKind get kind => ElementKind.FIELD; |
| 4021 | 3721 |
| 4022 /** | 3722 /** |
| 4023 * Set whether this field is static to correspond to the given value. | 3723 * Set whether this field is static. |
| 4024 * | |
| 4025 * @param isStatic `true` if the field is static | |
| 4026 */ | 3724 */ |
| 4027 void set static(bool isStatic) { | 3725 void set static(bool isStatic) { |
| 4028 setModifier(Modifier.STATIC, isStatic); | 3726 setModifier(Modifier.STATIC, isStatic); |
| 4029 } | 3727 } |
| 4030 | 3728 |
| 4031 @override | 3729 @override |
| 4032 accept(ElementVisitor visitor) => visitor.visitFieldElement(this); | 3730 accept(ElementVisitor visitor) => visitor.visitFieldElement(this); |
| 4033 } | 3731 } |
| 4034 | 3732 |
| 4035 /** | 3733 /** |
| 4036 * The interface `FieldFormalParameterElement` defines the behavior of elements
representing a | 3734 * A field formal parameter defined within a constructor element. |
| 4037 * field formal parameter defined within a constructor element. | |
| 4038 */ | 3735 */ |
| 4039 abstract class FieldFormalParameterElement implements ParameterElement { | 3736 abstract class FieldFormalParameterElement implements ParameterElement { |
| 4040 /** | 3737 /** |
| 4041 * Return the field element associated with this field formal parameter, or `n
ull` if the | 3738 * Return the field element associated with this field formal parameter, or |
| 4042 * parameter references a field that doesn't exist. | 3739 * `null` if the parameter references a field that doesn't exist. |
| 4043 * | |
| 4044 * @return the field element associated with this field formal parameter | |
| 4045 */ | 3740 */ |
| 4046 FieldElement get field; | 3741 FieldElement get field; |
| 4047 } | 3742 } |
| 4048 | 3743 |
| 4049 /** | 3744 /** |
| 4050 * Instances of the class `FieldFormalParameterElementImpl` extend | 3745 * A [ParameterElementImpl] that has the additional information of the |
| 4051 * [ParameterElementImpl] to provide the additional information of the [FieldEle
ment] | 3746 * [FieldElement] associated with the parameter. |
| 4052 * associated with the parameter. | |
| 4053 */ | 3747 */ |
| 4054 class FieldFormalParameterElementImpl extends ParameterElementImpl | 3748 class FieldFormalParameterElementImpl extends ParameterElementImpl |
| 4055 implements FieldFormalParameterElement { | 3749 implements FieldFormalParameterElement { |
| 4056 /** | 3750 /** |
| 4057 * The field associated with this field formal parameter. | 3751 * The field associated with this field formal parameter. |
| 4058 */ | 3752 */ |
| 4059 FieldElement field; | 3753 FieldElement field; |
| 4060 | 3754 |
| 4061 /** | 3755 /** |
| 4062 * Initialize a newly created parameter element to have the given name. | 3756 * Initialize a newly created parameter element to have the given [name]. |
| 4063 * | |
| 4064 * @param name the name of this element | |
| 4065 */ | 3757 */ |
| 4066 FieldFormalParameterElementImpl(Identifier name) : super.forNode(name); | 3758 FieldFormalParameterElementImpl(Identifier name) : super.forNode(name); |
| 4067 | 3759 |
| 4068 @override | 3760 @override |
| 4069 bool get isInitializingFormal => true; | 3761 bool get isInitializingFormal => true; |
| 4070 | 3762 |
| 4071 @override | 3763 @override |
| 4072 accept(ElementVisitor visitor) => | 3764 accept(ElementVisitor visitor) => |
| 4073 visitor.visitFieldFormalParameterElement(this); | 3765 visitor.visitFieldFormalParameterElement(this); |
| 4074 } | 3766 } |
| 4075 | 3767 |
| 4076 /** | 3768 /** |
| 4077 * Instances of the class `FieldFormalParameterMember` represent a parameter ele
ment defined | 3769 * A parameter element defined in a parameterized type where the values of the |
| 4078 * in a parameterized type where the values of the type parameters are known. | 3770 * type parameters are known. |
| 4079 */ | 3771 */ |
| 4080 class FieldFormalParameterMember extends ParameterMember | 3772 class FieldFormalParameterMember extends ParameterMember |
| 4081 implements FieldFormalParameterElement { | 3773 implements FieldFormalParameterElement { |
| 4082 /** | 3774 /** |
| 4083 * Initialize a newly created element to represent a parameter of the given pa
rameterized type. | 3775 * Initialize a newly created element to represent a constructor, based on the |
| 4084 * | 3776 * [baseElement], defined by the [definingType]. |
| 4085 * @param baseElement the element on which the parameterized element was creat
ed | |
| 4086 * @param definingType the type in which the element is defined | |
| 4087 */ | 3777 */ |
| 4088 FieldFormalParameterMember( | 3778 FieldFormalParameterMember( |
| 4089 FieldFormalParameterElement baseElement, ParameterizedType definingType) | 3779 FieldFormalParameterElement baseElement, ParameterizedType definingType) |
| 4090 : super(baseElement, definingType); | 3780 : super(baseElement, definingType); |
| 4091 | 3781 |
| 4092 @override | 3782 @override |
| 4093 FieldElement get field { | 3783 FieldElement get field { |
| 4094 FieldElement field = (baseElement as FieldFormalParameterElement).field; | 3784 FieldElement field = (baseElement as FieldFormalParameterElement).field; |
| 4095 if (field is FieldElement) { | 3785 if (field is FieldElement) { |
| 4096 return FieldMember.from(field, definingType); | 3786 return FieldMember.from(field, definingType); |
| 4097 } | 3787 } |
| 4098 return field; | 3788 return field; |
| 4099 } | 3789 } |
| 4100 | 3790 |
| 4101 @override | 3791 @override |
| 4102 accept(ElementVisitor visitor) => | 3792 accept(ElementVisitor visitor) => |
| 4103 visitor.visitFieldFormalParameterElement(this); | 3793 visitor.visitFieldFormalParameterElement(this); |
| 4104 } | 3794 } |
| 4105 | 3795 |
| 4106 /** | 3796 /** |
| 4107 * Instances of the class `FieldMember` represent a field element defined in a p
arameterized | 3797 * A field element defined in a parameterized type where the values of the type |
| 4108 * type where the values of the type parameters are known. | 3798 * parameters are known. |
| 4109 */ | 3799 */ |
| 4110 class FieldMember extends VariableMember implements FieldElement { | 3800 class FieldMember extends VariableMember implements FieldElement { |
| 4111 /** | 3801 /** |
| 4112 * Initialize a newly created element to represent a field of the given parame
terized type. | 3802 * Initialize a newly created element to represent a constructor, based on the |
| 4113 * | 3803 * [baseElement], defined by the [definingType]. |
| 4114 * @param baseElement the element on which the parameterized element was creat
ed | |
| 4115 * @param definingType the type in which the element is defined | |
| 4116 */ | 3804 */ |
| 4117 FieldMember(FieldElement baseElement, InterfaceType definingType) | 3805 FieldMember(FieldElement baseElement, InterfaceType definingType) |
| 4118 : super(baseElement, definingType); | 3806 : super(baseElement, definingType); |
| 4119 | 3807 |
| 4120 @override | 3808 @override |
| 4121 FieldElement get baseElement => super.baseElement as FieldElement; | 3809 FieldElement get baseElement => super.baseElement as FieldElement; |
| 4122 | 3810 |
| 4123 @override | 3811 @override |
| 4124 InterfaceType get definingType => super.definingType as InterfaceType; | 3812 InterfaceType get definingType => super.definingType as InterfaceType; |
| 4125 | 3813 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 4143 PropertyAccessorElement get setter => | 3831 PropertyAccessorElement get setter => |
| 4144 PropertyAccessorMember.from(baseElement.setter, definingType); | 3832 PropertyAccessorMember.from(baseElement.setter, definingType); |
| 4145 | 3833 |
| 4146 @override | 3834 @override |
| 4147 accept(ElementVisitor visitor) => visitor.visitFieldElement(this); | 3835 accept(ElementVisitor visitor) => visitor.visitFieldElement(this); |
| 4148 | 3836 |
| 4149 @override | 3837 @override |
| 4150 String toString() => '$type $displayName'; | 3838 String toString() => '$type $displayName'; |
| 4151 | 3839 |
| 4152 /** | 3840 /** |
| 4153 * If the given field's type is different when any type parameters from the de
fining type's | 3841 * If the given [field]'s type is different when any type parameters from the |
| 4154 * declaration are replaced with the actual type arguments from the defining t
ype, create a field | 3842 * defining type's declaration are replaced with the actual type arguments |
| 4155 * member representing the given field. Return the member that was created, or
the base field if | 3843 * from the [definingType], create a field member representing the given |
| 4156 * no member was created. | 3844 * field. Return the member that was created, or the base field if no member |
| 4157 * | 3845 * was created. |
| 4158 * @param baseField the base field for which a member might be created | |
| 4159 * @param definingType the type defining the parameters and arguments to be us
ed in the | |
| 4160 * substitution | |
| 4161 * @return the field element that will return the correctly substituted types | |
| 4162 */ | 3846 */ |
| 4163 static FieldElement from(FieldElement baseField, InterfaceType definingType) { | 3847 static FieldElement from(FieldElement field, InterfaceType definingType) { |
| 4164 if (!_isChangedByTypeSubstitution(baseField, definingType)) { | 3848 if (!_isChangedByTypeSubstitution(field, definingType)) { |
| 4165 return baseField; | 3849 return field; |
| 4166 } | 3850 } |
| 4167 // TODO(brianwilkerson) Consider caching the substituted type in the | 3851 // TODO(brianwilkerson) Consider caching the substituted type in the |
| 4168 // instance. It would use more memory but speed up some operations. | 3852 // instance. It would use more memory but speed up some operations. |
| 4169 // We need to see how often the type is being re-computed. | 3853 // We need to see how often the type is being re-computed. |
| 4170 return new FieldMember(baseField, definingType); | 3854 return new FieldMember(field, definingType); |
| 4171 } | 3855 } |
| 4172 | 3856 |
| 4173 /** | 3857 /** |
| 4174 * Determine whether the given field's type is changed when type parameters fr
om the defining | 3858 * Determine whether the given [field]'s type is changed when type parameters |
| 4175 * type's declaration are replaced with the actual type arguments from the def
ining type. | 3859 * from the [definingType]'s declaration are replaced with the actual type |
| 4176 * | 3860 * arguments from the defining type. |
| 4177 * @param baseField the base field | |
| 4178 * @param definingType the type defining the parameters and arguments to be us
ed in the | |
| 4179 * substitution | |
| 4180 * @return true if the type is changed by type substitution. | |
| 4181 */ | 3861 */ |
| 4182 static bool _isChangedByTypeSubstitution( | 3862 static bool _isChangedByTypeSubstitution( |
| 4183 FieldElement baseField, InterfaceType definingType) { | 3863 FieldElement field, InterfaceType definingType) { |
| 4184 List<DartType> argumentTypes = definingType.typeArguments; | 3864 List<DartType> argumentTypes = definingType.typeArguments; |
| 4185 if (baseField != null && argumentTypes.length != 0) { | 3865 if (field != null && argumentTypes.length != 0) { |
| 4186 DartType baseType = baseField.type; | 3866 DartType baseType = field.type; |
| 4187 List<DartType> parameterTypes = definingType.element.type.typeArguments; | 3867 List<DartType> parameterTypes = definingType.element.type.typeArguments; |
| 4188 if (baseType != null) { | 3868 if (baseType != null) { |
| 4189 DartType substitutedType = | 3869 DartType substitutedType = |
| 4190 baseType.substitute2(argumentTypes, parameterTypes); | 3870 baseType.substitute2(argumentTypes, parameterTypes); |
| 4191 if (baseType != substitutedType) { | 3871 if (baseType != substitutedType) { |
| 4192 return true; | 3872 return true; |
| 4193 } | 3873 } |
| 4194 } | 3874 } |
| 4195 // If the field has a propagated type, then we need to check whether the | 3875 // If the field has a propagated type, then we need to check whether the |
| 4196 // propagated type needs substitution. | 3876 // propagated type needs substitution. |
| 4197 DartType basePropagatedType = baseField.propagatedType; | 3877 DartType basePropagatedType = field.propagatedType; |
| 4198 if (basePropagatedType != null) { | 3878 if (basePropagatedType != null) { |
| 4199 DartType substitutedPropagatedType = | 3879 DartType substitutedPropagatedType = |
| 4200 basePropagatedType.substitute2(argumentTypes, parameterTypes); | 3880 basePropagatedType.substitute2(argumentTypes, parameterTypes); |
| 4201 if (basePropagatedType != substitutedPropagatedType) { | 3881 if (basePropagatedType != substitutedPropagatedType) { |
| 4202 return true; | 3882 return true; |
| 4203 } | 3883 } |
| 4204 } | 3884 } |
| 4205 } | 3885 } |
| 4206 return false; | 3886 return false; |
| 4207 } | 3887 } |
| 4208 } | 3888 } |
| 4209 | 3889 |
| 4210 /** | 3890 /** |
| 4211 * The interface `FunctionElement` defines the behavior of elements representing
a function. | 3891 * A (non-method) function. This can be either a top-level function, a local |
| 3892 * function, a closure, or the initialization expression for a field or |
| 3893 * variable. |
| 4212 */ | 3894 */ |
| 4213 abstract class FunctionElement implements ExecutableElement, LocalElement { | 3895 abstract class FunctionElement implements ExecutableElement, LocalElement { |
| 4214 /** | 3896 /** |
| 4215 * The name of the method that can be implemented by a class to allow its inst
ances to be invoked | 3897 * The name of the method that can be implemented by a class to allow its |
| 4216 * as if they were a function. | 3898 * instances to be invoked as if they were a function. |
| 4217 */ | 3899 */ |
| 4218 static final String CALL_METHOD_NAME = "call"; | 3900 static final String CALL_METHOD_NAME = "call"; |
| 4219 | 3901 |
| 4220 /** | 3902 /** |
| 4221 * The name of the method that will be invoked if an attempt is made to invoke
an undefined method | 3903 * The name of the method that will be invoked if an attempt is made to invoke |
| 4222 * on an object. | 3904 * an undefined method on an object. |
| 4223 */ | 3905 */ |
| 4224 static final String NO_SUCH_METHOD_METHOD_NAME = "noSuchMethod"; | 3906 static final String NO_SUCH_METHOD_METHOD_NAME = "noSuchMethod"; |
| 4225 | 3907 |
| 4226 /** | 3908 /** |
| 4227 * The name of the synthetic function defined for libraries that are deferred. | 3909 * The name of the synthetic function defined for libraries that are deferred. |
| 4228 */ | 3910 */ |
| 4229 static final String LOAD_LIBRARY_NAME = "loadLibrary"; | 3911 static final String LOAD_LIBRARY_NAME = "loadLibrary"; |
| 4230 | 3912 |
| 4231 /** | 3913 /** |
| 4232 * Return the resolved [FunctionDeclaration] node that declares this [Function
Element] | 3914 * Return the resolved function declaration node that declares this element. |
| 4233 * . | |
| 4234 * | 3915 * |
| 4235 * This method is expensive, because resolved AST might be evicted from cache,
so parsing and | 3916 * This method is expensive, because resolved AST might be evicted from cache, |
| 4236 * resolving will be performed. | 3917 * so parsing and resolving will be performed. |
| 4237 * | |
| 4238 * @return the resolved [FunctionDeclaration], not `null`. | |
| 4239 */ | 3918 */ |
| 4240 @override | 3919 @override |
| 4241 FunctionDeclaration get node; | 3920 FunctionDeclaration get node; |
| 4242 } | 3921 } |
| 4243 | 3922 |
| 4244 /** | 3923 /** |
| 4245 * Instances of the class `FunctionElementImpl` implement a `FunctionElement`. | 3924 * A concrete implementation of a [FunctionElement]. |
| 4246 */ | 3925 */ |
| 4247 class FunctionElementImpl extends ExecutableElementImpl | 3926 class FunctionElementImpl extends ExecutableElementImpl |
| 4248 implements FunctionElement { | 3927 implements FunctionElement { |
| 4249 /** | 3928 /** |
| 4250 * An empty list of function elements. | 3929 * An empty list of function elements. |
| 4251 */ | 3930 */ |
| 4252 static const List<FunctionElement> EMPTY_ARRAY = const <FunctionElement>[]; | 3931 static const List<FunctionElement> EMPTY_ARRAY = const <FunctionElement>[]; |
| 4253 | 3932 |
| 4254 /** | 3933 /** |
| 4255 * The offset to the beginning of the visible range for this element. | 3934 * The offset to the beginning of the visible range for this element. |
| 4256 */ | 3935 */ |
| 4257 int _visibleRangeOffset = 0; | 3936 int _visibleRangeOffset = 0; |
| 4258 | 3937 |
| 4259 /** | 3938 /** |
| 4260 * The length of the visible range for this element, or `-1` if this element d
oes not have a | 3939 * The length of the visible range for this element, or `-1` if this element |
| 4261 * visible range. | 3940 * does not have a visible range. |
| 4262 */ | 3941 */ |
| 4263 int _visibleRangeLength = -1; | 3942 int _visibleRangeLength = -1; |
| 4264 | 3943 |
| 4265 /** | 3944 /** |
| 4266 * Initialize a newly created function element to have the given name and offs
et. | 3945 * Initialize a newly created function element to have the given [name] and |
| 4267 * | 3946 * [offset]. |
| 4268 * @param name the name of this element | |
| 4269 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
| 4270 * declaration of this element | |
| 4271 */ | 3947 */ |
| 4272 FunctionElementImpl(String name, int nameOffset) : super(name, nameOffset); | 3948 FunctionElementImpl(String name, int offset) : super(name, offset); |
| 4273 | 3949 |
| 4274 /** | 3950 /** |
| 4275 * Initialize a newly created function element to have the given name. | 3951 * Initialize a newly created function element to have the given [name]. |
| 4276 * | |
| 4277 * @param name the name of this element | |
| 4278 */ | 3952 */ |
| 4279 FunctionElementImpl.forNode(Identifier name) : super.forNode(name); | 3953 FunctionElementImpl.forNode(Identifier name) : super.forNode(name); |
| 4280 | 3954 |
| 4281 /** | 3955 /** |
| 4282 * Initialize a newly created function element to have no name and the given o
ffset. This is used | 3956 * Initialize a newly created function element to have no name and the given |
| 4283 * for function expressions, which have no name. | 3957 * [offset]. This is used for function expressions, that have no name. |
| 4284 * | |
| 4285 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
| 4286 * declaration of this element | |
| 4287 */ | 3958 */ |
| 4288 FunctionElementImpl.forOffset(int nameOffset) : super("", nameOffset); | 3959 FunctionElementImpl.forOffset(int nameOffset) : super("", nameOffset); |
| 4289 | 3960 |
| 4290 @override | 3961 @override |
| 4291 String get identifier { | 3962 String get identifier { |
| 4292 String identifier = super.identifier; | 3963 String identifier = super.identifier; |
| 4293 if (!isStatic) { | 3964 if (!isStatic) { |
| 4294 identifier += "@$nameOffset"; | 3965 identifier += "@$nameOffset"; |
| 4295 } | 3966 } |
| 4296 return identifier; | 3967 return identifier; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4320 @override | 3991 @override |
| 4321 void appendTo(StringBuffer buffer) { | 3992 void appendTo(StringBuffer buffer) { |
| 4322 String name = displayName; | 3993 String name = displayName; |
| 4323 if (name != null) { | 3994 if (name != null) { |
| 4324 buffer.write(name); | 3995 buffer.write(name); |
| 4325 } | 3996 } |
| 4326 super.appendTo(buffer); | 3997 super.appendTo(buffer); |
| 4327 } | 3998 } |
| 4328 | 3999 |
| 4329 /** | 4000 /** |
| 4330 * Set the visible range for this element to the range starting at the given o
ffset with the given | 4001 * Set the visible range for this element to the range starting at the given |
| 4331 * length. | 4002 * [offset] with the given [length]. |
| 4332 * | |
| 4333 * @param offset the offset to the beginning of the visible range for this ele
ment | |
| 4334 * @param length the length of the visible range for this element, or `-1` if
this element | |
| 4335 * does not have a visible range | |
| 4336 */ | 4003 */ |
| 4337 void setVisibleRange(int offset, int length) { | 4004 void setVisibleRange(int offset, int length) { |
| 4338 _visibleRangeOffset = offset; | 4005 _visibleRangeOffset = offset; |
| 4339 _visibleRangeLength = length; | 4006 _visibleRangeLength = length; |
| 4340 } | 4007 } |
| 4341 } | 4008 } |
| 4342 | 4009 |
| 4343 /** | 4010 /** |
| 4344 * The interface `FunctionType` defines the behavior common to objects represent
ing the type | 4011 * The type of a function, method, constructor, getter, or setter. Function |
| 4345 * of a function, method, constructor, getter, or setter. Function types come in
three variations: | 4012 * types come in three variations: |
| 4346 * <ol> | 4013 * |
| 4347 * * The types of functions that only have required parameters. These have the g
eneral form | 4014 * * The types of functions that only have required parameters. These have the |
| 4348 * <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T</i>. | 4015 * general form <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T</i>. |
| 4349 * * The types of functions with optional positional parameters. These have the
general form | 4016 * * The types of functions with optional positional parameters. These have the |
| 4350 * <i>(T<sub>1</sub>, …, T<sub>n</sub>, [T<sub>n+1</sub>, …, T<sub
>n+k</sub>]) → | 4017 * general form <i>(T<sub>1</sub>, …, T<sub>n</sub>, [T<sub>n+1</sub> |
| 4351 * T</i>. | 4018 * …, T<sub>n+k</sub>]) → T</i>. |
| 4352 * * The types of functions with named parameters. These have the general form <
i>(T<sub>1</sub>, | 4019 * * The types of functions with named parameters. These have the general form |
| 4353 * …, T<sub>n</sub>, {T<sub>x1</sub> x1, …, T<sub>xk</sub> xk}) &r
arr; T</i>. | 4020 * <i>(T<sub>1</sub>, …, T<sub>n</sub>, {T<sub>x1</sub> x1, …, |
| 4354 * </ol> | 4021 * T<sub>xk</sub> xk}) → T</i>. |
| 4355 */ | 4022 */ |
| 4356 abstract class FunctionType implements ParameterizedType { | 4023 abstract class FunctionType implements ParameterizedType { |
| 4357 /** | 4024 /** |
| 4358 * Return a map from the names of named parameters to the types of the named p
arameters of this | 4025 * Return a map from the names of named parameters to the types of the named |
| 4359 * type of function. The entries in the map will be iterated in the same order
as the order in | 4026 * parameters of this type of function. The entries in the map will be |
| 4360 * which the named parameters were defined. If there were no named parameters
declared then the | 4027 * iterated in the same order as the order in which the named parameters were |
| 4361 * map will be empty. | 4028 * defined. If there were no named parameters declared then the map will be |
| 4362 * | 4029 * empty. |
| 4363 * @return a map from the name to the types of the named parameters of this ty
pe of function | |
| 4364 */ | 4030 */ |
| 4365 Map<String, DartType> get namedParameterTypes; | 4031 Map<String, DartType> get namedParameterTypes; |
| 4366 | 4032 |
| 4367 /** | 4033 /** |
| 4368 * Return an array containing the types of the normal parameters of this type
of function. The | 4034 * Return a list containing the types of the normal parameters of this type of |
| 4369 * parameter types are in the same order as they appear in the declaration of
the function. | 4035 * function. The parameter types are in the same order as they appear in the |
| 4370 * | 4036 * declaration of the function. |
| 4371 * @return the types of the normal parameters of this type of function | |
| 4372 */ | 4037 */ |
| 4373 List<DartType> get normalParameterTypes; | 4038 List<DartType> get normalParameterTypes; |
| 4374 | 4039 |
| 4375 /** | 4040 /** |
| 4376 * Return a map from the names of optional (positional) parameters to the type
s of the optional | 4041 * Return a map from the names of optional (positional) parameters to the |
| 4377 * parameters of this type of function. The entries in the map will be iterate
d in the same order | 4042 * types of the optional parameters of this type of function. The entries in |
| 4378 * as the order in which the optional parameters were defined. If there were n
o optional | 4043 * the map will be iterated in the same order as the order in which the |
| 4379 * parameters declared then the map will be empty. | 4044 * optional parameters were defined. If there were no optional parameters |
| 4380 * | 4045 * declared then the map will be empty. |
| 4381 * @return a map from the name to the types of the optional parameters of this
type of function | |
| 4382 */ | 4046 */ |
| 4383 List<DartType> get optionalParameterTypes; | 4047 List<DartType> get optionalParameterTypes; |
| 4384 | 4048 |
| 4385 /** | 4049 /** |
| 4386 * Return an array containing the parameters elements of this type of function
. The parameter | 4050 * Return a list containing the parameters elements of this type of function. |
| 4387 * types are in the same order as they appear in the declaration of the functi
on. | 4051 * The parameter types are in the same order as they appear in the declaration |
| 4388 * | 4052 * of the function. |
| 4389 * @return the parameters elements of this type of function | |
| 4390 */ | 4053 */ |
| 4391 List<ParameterElement> get parameters; | 4054 List<ParameterElement> get parameters; |
| 4392 | 4055 |
| 4393 /** | 4056 /** |
| 4394 * Return the type of object returned by this type of function. | 4057 * Return the type of object returned by this type of function. |
| 4395 * | |
| 4396 * @return the type of object returned by this type of function | |
| 4397 */ | 4058 */ |
| 4398 DartType get returnType; | 4059 DartType get returnType; |
| 4399 | 4060 |
| 4400 /** | 4061 /** |
| 4401 * Return `true` if this type is a subtype of the given type. | 4062 * Return `true` if this type is a subtype of the given [type]. |
| 4402 * | 4063 * |
| 4403 * A function type <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T</i> is
a subtype of the | 4064 * A function type <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T</i> is |
| 4404 * function type <i>(S<sub>1</sub>, …, S<sub>n</sub>) → S</i>, if
all of the following | 4065 * a subtype of the function type <i>(S<sub>1</sub>, …, S<sub>n</sub>) |
| 4405 * conditions are met: | 4066 * → S</i>, if all of the following conditions are met: |
| 4067 * |
| 4406 * * Either | 4068 * * Either |
| 4407 * * <i>S</i> is void, or | 4069 * * <i>S</i> is void, or |
| 4408 * * <i>T ⇔ S</i>. | 4070 * * <i>T ⇔ S</i>. |
| 4409 * | 4071 * |
| 4410 * * For all <i>i</i>, 1 <= <i>i</i> <= <i>n</i>, <i>T<sub>i</sub> ⇔ S<su
b>i</sub></i>. | 4072 * * For all <i>i</i>, 1 <= <i>i</i> <= <i>n</i>, <i>T<sub>i</sub> ⇔ |
| 4411 * A function type <i>(T<sub>1</sub>, …, T<sub>n</sub>, [T<sub>n+1</sub
>, …, | 4073 * S<sub>i</sub></i>. |
| 4412 * T<sub>n+k</sub>]) → T</i> is a subtype of the function type <i>(S<sub>
1</sub>, …, | 4074 * |
| 4413 * S<sub>n</sub>, [S<sub>n+1</sub>, …, S<sub>n+m</sub>]) → S</i>,
if all of the | 4075 * A function type <i>(T<sub>1</sub>, …, T<sub>n</sub>, |
| 4076 * [T<sub>n+1</sub>, …, T<sub>n+k</sub>]) → T</i> is a subtype of |
| 4077 * the function type <i>(S<sub>1</sub>, …, S<sub>n</sub>, |
| 4078 * [S<sub>n+1</sub>, …, S<sub>n+m</sub>]) → S</i>, if all of the |
| 4414 * following conditions are met: | 4079 * following conditions are met: |
| 4080 * |
| 4415 * * Either | 4081 * * Either |
| 4416 * * <i>S</i> is void, or | 4082 * * <i>S</i> is void, or |
| 4417 * * <i>T ⇔ S</i>. | 4083 * * <i>T ⇔ S</i>. |
| 4418 * | 4084 * |
| 4419 * * <i>k</i> >= <i>m</i> and for all <i>i</i>, 1 <= <i>i</i> <= <i>n+m</i>, <
i>T<sub>i</sub> | 4085 * * <i>k</i> >= <i>m</i> and for all <i>i</i>, 1 <= <i>i</i> <= <i>n+m</i>, |
| 4420 * ⇔ S<sub>i</sub></i>. | 4086 * <i>T<sub>i</sub> ⇔ S<sub>i</sub></i>. |
| 4421 * A function type <i>(T<sub>1</sub>, …, T<sub>n</sub>, {T<sub>x1</sub>
x1, …, | 4087 * |
| 4422 * T<sub>xk</sub> xk}) → T</i> is a subtype of the function type <i>(S<su
b>1</sub>, …, | 4088 * A function type <i>(T<sub>1</sub>, …, T<sub>n</sub>, |
| 4423 * S<sub>n</sub>, {S<sub>y1</sub> y1, …, S<sub>ym</sub> ym}) → S</
i>, if all of the | 4089 * {T<sub>x1</sub> x1, …, T<sub>xk</sub> xk}) → T</i> is a subtype |
| 4424 * following conditions are met: | 4090 * of the function type <i>(S<sub>1</sub>, …, S<sub>n</sub>, |
| 4091 * {S<sub>y1</sub> y1, …, S<sub>ym</sub> ym}) → S</i>, if all of |
| 4092 * the following conditions are met: |
| 4425 * * Either | 4093 * * Either |
| 4426 * * <i>S</i> is void, | 4094 * * <i>S</i> is void, |
| 4427 * * or <i>T ⇔ S</i>. | 4095 * * or <i>T ⇔ S</i>. |
| 4428 * | 4096 * |
| 4429 * * For all <i>i</i>, 1 <= <i>i</i> <= <i>n</i>, <i>T<sub>i</sub> ⇔ S<su
b>i</sub></i>. | 4097 * * For all <i>i</i>, 1 <= <i>i</i> <= <i>n</i>, <i>T<sub>i</sub> ⇔ |
| 4430 * * <i>k</i> >= <i>m</i> and <i>y<sub>i</sub></i> in <i>{x<sub>1</sub>, &hell
ip;, | 4098 * S<sub>i</sub></i>. |
| 4431 * x<sub>k</sub>}</i>, 1 <= <i>i</i> <= <i>m</i>. | 4099 * * <i>k</i> >= <i>m</i> and <i>y<sub>i</sub></i> in <i>{x<sub>1</sub>, |
| 4432 * * For all <i>y<sub>i</sub></i> in <i>{y<sub>1</sub>, …, y<sub>m</sub
>}</i>, | 4100 * …, x<sub>k</sub>}</i>, 1 <= <i>i</i> <= <i>m</i>. |
| 4433 * <i>y<sub>i</sub> = x<sub>j</sub> => Tj ⇔ Si</i>. | 4101 * * For all <i>y<sub>i</sub></i> in <i>{y<sub>1</sub>, …, |
| 4102 * y<sub>m</sub>}</i>, <i>y<sub>i</sub> = x<sub>j</sub> => Tj ⇔ Si</i>. |
| 4103 * |
| 4434 * In addition, the following subtype rules apply: | 4104 * In addition, the following subtype rules apply: |
| 4435 * | 4105 * |
| 4436 * <i>(T<sub>1</sub>, …, T<sub>n</sub>, []) → T <: (T<sub>1</sub>,
…, | 4106 * <i>(T<sub>1</sub>, …, T<sub>n</sub>, []) → T <: (T<sub>1</sub>, |
| 4437 * T<sub>n</sub>) → T.</i><br> | 4107 * …, T<sub>n</sub>) → T.</i><br> |
| 4438 * <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T <: (T<sub>1</sub>, &he
llip;, | 4108 * <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T <: (T<sub>1</sub>, |
| 4439 * T<sub>n</sub>, {}) → T.</i><br> | 4109 * …, T<sub>n</sub>, {}) → T.</i><br> |
| 4440 * <i>(T<sub>1</sub>, …, T<sub>n</sub>, {}) → T <: (T<sub>1</sub>,
…, | 4110 * <i>(T<sub>1</sub>, …, T<sub>n</sub>, {}) → T <: (T<sub>1</sub>, |
| 4441 * T<sub>n</sub>) → T.</i><br> | 4111 * …, T<sub>n</sub>) → T.</i><br> |
| 4442 * <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T <: (T<sub>1</sub>, &he
llip;, | 4112 * <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T <: (T<sub>1</sub>, |
| 4443 * T<sub>n</sub>, []) → T.</i> | 4113 * …, T<sub>n</sub>, []) → T.</i> |
| 4444 * | 4114 * |
| 4445 * All functions implement the class `Function`. However not all function type
s are a | 4115 * All functions implement the class `Function`. However not all function |
| 4446 * subtype of `Function`. If an interface type <i>I</i> includes a method name
d | 4116 * types are a subtype of `Function`. If an interface type <i>I</i> includes a |
| 4447 * `call()`, and the type of `call()` is the function type <i>F</i>, then <i>I
</i> is | 4117 * method named `call()`, and the type of `call()` is the function type |
| 4448 * considered to be a subtype of <i>F</i>. | 4118 * <i>F</i>, then <i>I</i> is considered to be a subtype of <i>F</i>. |
| 4449 * | |
| 4450 * @param type the type being compared with this type | |
| 4451 * @return `true` if this type is a subtype of the given type | |
| 4452 */ | 4119 */ |
| 4453 @override | 4120 @override |
| 4454 bool isSubtypeOf(DartType type); | 4121 bool isSubtypeOf(DartType type); |
| 4455 | 4122 |
| 4456 @override | 4123 @override |
| 4457 FunctionType substitute2( | 4124 FunctionType substitute2( |
| 4458 List<DartType> argumentTypes, List<DartType> parameterTypes); | 4125 List<DartType> argumentTypes, List<DartType> parameterTypes); |
| 4459 | 4126 |
| 4460 /** | 4127 /** |
| 4461 * Return the type resulting from substituting the given arguments for this ty
pe's parameters. | 4128 * Return the type resulting from substituting the given [argumentTypes] for |
| 4462 * This is fully equivalent to `substitute(argumentTypes, getTypeArguments())`
. | 4129 * this type's parameters. This is fully equivalent to |
| 4463 * | 4130 * `substitute(argumentTypes, getTypeArguments())`. |
| 4464 * @param argumentTypes the actual type arguments being substituted for the ty
pe parameters | |
| 4465 * @return the result of performing the substitution | |
| 4466 */ | 4131 */ |
| 4467 FunctionType substitute3(List<DartType> argumentTypes); | 4132 FunctionType substitute3(List<DartType> argumentTypes); |
| 4468 } | 4133 } |
| 4469 | 4134 |
| 4470 /** | 4135 /** |
| 4471 * The interface `FunctionTypeAliasElement` defines the behavior of elements rep
resenting a | 4136 * A function type alias (`typedef`). |
| 4472 * function type alias (`typedef`). | |
| 4473 */ | 4137 */ |
| 4474 abstract class FunctionTypeAliasElement implements Element { | 4138 abstract class FunctionTypeAliasElement implements Element { |
| 4475 /** | 4139 /** |
| 4476 * Return the compilation unit in which this type alias is defined. | 4140 * Return the compilation unit in which this type alias is defined. |
| 4477 * | |
| 4478 * @return the compilation unit in which this type alias is defined | |
| 4479 */ | 4141 */ |
| 4480 @override | 4142 @override |
| 4481 CompilationUnitElement get enclosingElement; | 4143 CompilationUnitElement get enclosingElement; |
| 4482 | 4144 |
| 4483 /** | 4145 /** |
| 4484 * Return the resolved [FunctionTypeAlias] node that declares this | 4146 * Return the resolved function type alias node that declares this element. |
| 4485 * [FunctionTypeAliasElement] . | |
| 4486 * | 4147 * |
| 4487 * This method is expensive, because resolved AST might be evicted from cache,
so parsing and | 4148 * This method is expensive, because resolved AST might be evicted from cache, |
| 4488 * resolving will be performed. | 4149 * so parsing and resolving will be performed. |
| 4489 * | |
| 4490 * @return the resolved [FunctionTypeAlias], not `null`. | |
| 4491 */ | 4150 */ |
| 4492 @override | 4151 @override |
| 4493 FunctionTypeAlias get node; | 4152 FunctionTypeAlias get node; |
| 4494 | 4153 |
| 4495 /** | 4154 /** |
| 4496 * Return an array containing all of the parameters defined by this type alias
. | 4155 * Return a list containing all of the parameters defined by this type alias. |
| 4497 * | |
| 4498 * @return the parameters defined by this type alias | |
| 4499 */ | 4156 */ |
| 4500 List<ParameterElement> get parameters; | 4157 List<ParameterElement> get parameters; |
| 4501 | 4158 |
| 4502 /** | 4159 /** |
| 4503 * Return the return type defined by this type alias. | 4160 * Return the return type defined by this type alias. |
| 4504 * | |
| 4505 * @return the return type defined by this type alias | |
| 4506 */ | 4161 */ |
| 4507 DartType get returnType; | 4162 DartType get returnType; |
| 4508 | 4163 |
| 4509 /** | 4164 /** |
| 4510 * Return the type of function defined by this type alias. | 4165 * Return the type of function defined by this type alias. |
| 4511 * | |
| 4512 * @return the type of function defined by this type alias | |
| 4513 */ | 4166 */ |
| 4514 FunctionType get type; | 4167 FunctionType get type; |
| 4515 | 4168 |
| 4516 /** | 4169 /** |
| 4517 * Return an array containing all of the type parameters defined for this type
. | 4170 * Return a list containing all of the type parameters defined for this type. |
| 4518 * | |
| 4519 * @return the type parameters defined for this type | |
| 4520 */ | 4171 */ |
| 4521 List<TypeParameterElement> get typeParameters; | 4172 List<TypeParameterElement> get typeParameters; |
| 4522 } | 4173 } |
| 4523 | 4174 |
| 4524 /** | 4175 /** |
| 4525 * Instances of the class `FunctionTypeAliasElementImpl` implement a | 4176 * A concrete implementation of a [FunctionTypeAliasElement]. |
| 4526 * `FunctionTypeAliasElement`. | |
| 4527 */ | 4177 */ |
| 4528 class FunctionTypeAliasElementImpl extends ElementImpl | 4178 class FunctionTypeAliasElementImpl extends ElementImpl |
| 4529 implements FunctionTypeAliasElement { | 4179 implements FunctionTypeAliasElement { |
| 4530 /** | 4180 /** |
| 4531 * An empty array of type alias elements. | 4181 * An empty array of type alias elements. |
| 4532 */ | 4182 */ |
| 4533 static List<FunctionTypeAliasElement> EMPTY_ARRAY = | 4183 static List<FunctionTypeAliasElement> EMPTY_ARRAY = |
| 4534 new List<FunctionTypeAliasElement>(0); | 4184 new List<FunctionTypeAliasElement>(0); |
| 4535 | 4185 |
| 4536 /** | 4186 /** |
| 4537 * An array containing all of the parameters defined by this type alias. | 4187 * A list containing all of the parameters defined by this type alias. |
| 4538 */ | 4188 */ |
| 4539 List<ParameterElement> _parameters = ParameterElementImpl.EMPTY_ARRAY; | 4189 List<ParameterElement> _parameters = ParameterElementImpl.EMPTY_ARRAY; |
| 4540 | 4190 |
| 4541 /** | 4191 /** |
| 4542 * The return type defined by this type alias. | 4192 * The return type defined by this type alias. |
| 4543 */ | 4193 */ |
| 4544 DartType returnType; | 4194 DartType returnType; |
| 4545 | 4195 |
| 4546 /** | 4196 /** |
| 4547 * The type of function defined by this type alias. | 4197 * The type of function defined by this type alias. |
| 4548 */ | 4198 */ |
| 4549 FunctionType type; | 4199 FunctionType type; |
| 4550 | 4200 |
| 4551 /** | 4201 /** |
| 4552 * An array containing all of the type parameters defined for this type. | 4202 * A list containing all of the type parameters defined for this type. |
| 4553 */ | 4203 */ |
| 4554 List<TypeParameterElement> _typeParameters = | 4204 List<TypeParameterElement> _typeParameters = |
| 4555 TypeParameterElementImpl.EMPTY_ARRAY; | 4205 TypeParameterElementImpl.EMPTY_ARRAY; |
| 4556 | 4206 |
| 4557 /** | 4207 /** |
| 4558 * Initialize a newly created type alias element to have the given name. | 4208 * Initialize a newly created type alias element to have the given name. |
| 4559 * | 4209 * |
| 4560 * [name] the name of this element | 4210 * [name] the name of this element |
| 4561 * [nameOffset] the offset of the name of this element in the file that | 4211 * [nameOffset] the offset of the name of this element in the file that |
| 4562 * contains the declaration of this element | 4212 * contains the declaration of this element |
| 4563 */ | 4213 */ |
| 4564 FunctionTypeAliasElementImpl(String name, int nameOffset) | 4214 FunctionTypeAliasElementImpl(String name, int nameOffset) |
| 4565 : super(name, nameOffset); | 4215 : super(name, nameOffset); |
| 4566 | 4216 |
| 4567 /** | 4217 /** |
| 4568 * Initialize a newly created type alias element to have the given name. | 4218 * Initialize a newly created type alias element to have the given [name]. |
| 4569 * | |
| 4570 * @param name the name of this element | |
| 4571 */ | 4219 */ |
| 4572 FunctionTypeAliasElementImpl.forNode(Identifier name) : super.forNode(name); | 4220 FunctionTypeAliasElementImpl.forNode(Identifier name) : super.forNode(name); |
| 4573 | 4221 |
| 4574 @override | 4222 @override |
| 4575 CompilationUnitElement get enclosingElement => | 4223 CompilationUnitElement get enclosingElement => |
| 4576 super.enclosingElement as CompilationUnitElement; | 4224 super.enclosingElement as CompilationUnitElement; |
| 4577 | 4225 |
| 4578 @override | 4226 @override |
| 4579 ElementKind get kind => ElementKind.FUNCTION_TYPE_ALIAS; | 4227 ElementKind get kind => ElementKind.FUNCTION_TYPE_ALIAS; |
| 4580 | 4228 |
| 4581 @override | 4229 @override |
| 4582 FunctionTypeAlias get node => | 4230 FunctionTypeAlias get node => |
| 4583 getNodeMatching((node) => node is FunctionTypeAlias); | 4231 getNodeMatching((node) => node is FunctionTypeAlias); |
| 4584 | 4232 |
| 4585 @override | 4233 @override |
| 4586 List<ParameterElement> get parameters => _parameters; | 4234 List<ParameterElement> get parameters => _parameters; |
| 4587 | 4235 |
| 4588 /** | 4236 /** |
| 4589 * Set the parameters defined by this type alias to the given parameters. | 4237 * Set the parameters defined by this type alias to the given [parameters]. |
| 4590 * | |
| 4591 * @param parameters the parameters defined by this type alias | |
| 4592 */ | 4238 */ |
| 4593 void set parameters(List<ParameterElement> parameters) { | 4239 void set parameters(List<ParameterElement> parameters) { |
| 4594 if (parameters != null) { | 4240 if (parameters != null) { |
| 4595 for (ParameterElement parameter in parameters) { | 4241 for (ParameterElement parameter in parameters) { |
| 4596 (parameter as ParameterElementImpl).enclosingElement = this; | 4242 (parameter as ParameterElementImpl).enclosingElement = this; |
| 4597 } | 4243 } |
| 4598 } | 4244 } |
| 4599 this._parameters = parameters; | 4245 this._parameters = parameters; |
| 4600 } | 4246 } |
| 4601 | 4247 |
| 4602 @override | 4248 @override |
| 4603 List<TypeParameterElement> get typeParameters => _typeParameters; | 4249 List<TypeParameterElement> get typeParameters => _typeParameters; |
| 4604 | 4250 |
| 4605 /** | 4251 /** |
| 4606 * Set the type parameters defined for this type to the given parameters. | 4252 * Set the type parameters defined for this type to the given |
| 4607 * | 4253 * [typeParameters]. |
| 4608 * @param typeParameters the type parameters defined for this type | |
| 4609 */ | 4254 */ |
| 4610 void set typeParameters(List<TypeParameterElement> typeParameters) { | 4255 void set typeParameters(List<TypeParameterElement> typeParameters) { |
| 4611 for (TypeParameterElement typeParameter in typeParameters) { | 4256 for (TypeParameterElement typeParameter in typeParameters) { |
| 4612 (typeParameter as TypeParameterElementImpl).enclosingElement = this; | 4257 (typeParameter as TypeParameterElementImpl).enclosingElement = this; |
| 4613 } | 4258 } |
| 4614 this._typeParameters = typeParameters; | 4259 this._typeParameters = typeParameters; |
| 4615 } | 4260 } |
| 4616 | 4261 |
| 4617 @override | 4262 @override |
| 4618 accept(ElementVisitor visitor) => visitor.visitFunctionTypeAliasElement(this); | 4263 accept(ElementVisitor visitor) => visitor.visitFunctionTypeAliasElement(this); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4660 for (TypeParameterElement typeParameter in _typeParameters) { | 4305 for (TypeParameterElement typeParameter in _typeParameters) { |
| 4661 if ((typeParameter as TypeParameterElementImpl).identifier == | 4306 if ((typeParameter as TypeParameterElementImpl).identifier == |
| 4662 identifier) { | 4307 identifier) { |
| 4663 return typeParameter as TypeParameterElementImpl; | 4308 return typeParameter as TypeParameterElementImpl; |
| 4664 } | 4309 } |
| 4665 } | 4310 } |
| 4666 return null; | 4311 return null; |
| 4667 } | 4312 } |
| 4668 | 4313 |
| 4669 /** | 4314 /** |
| 4670 * Set the parameters defined by this type alias to the given parameters witho
ut becoming the | 4315 * Set the parameters defined by this type alias to the given [parameters] |
| 4671 * parent of the parameters. This should only be used by the [TypeResolverVisi
tor] when | 4316 * without becoming the parent of the parameters. This should only be used by |
| 4672 * creating a synthetic type alias. | 4317 * the [TypeResolverVisitor] when creating a synthetic type alias. |
| 4673 * | |
| 4674 * @param parameters the parameters defined by this type alias | |
| 4675 */ | 4318 */ |
| 4676 void shareParameters(List<ParameterElement> parameters) { | 4319 void shareParameters(List<ParameterElement> parameters) { |
| 4677 this._parameters = parameters; | 4320 this._parameters = parameters; |
| 4678 } | 4321 } |
| 4679 | 4322 |
| 4680 /** | 4323 /** |
| 4681 * Set the type parameters defined for this type to the given parameters witho
ut becoming the | 4324 * Set the type parameters defined for this type to the given [typeParameters] |
| 4682 * parent of the parameters. This should only be used by the [TypeResolverVisi
tor] when | 4325 * without becoming the parent of the parameters. This should only be used by |
| 4683 * creating a synthetic type alias. | 4326 * the [TypeResolverVisitor] when creating a synthetic type alias. |
| 4684 * | |
| 4685 * @param typeParameters the type parameters defined for this type | |
| 4686 */ | 4327 */ |
| 4687 void shareTypeParameters(List<TypeParameterElement> typeParameters) { | 4328 void shareTypeParameters(List<TypeParameterElement> typeParameters) { |
| 4688 this._typeParameters = typeParameters; | 4329 this._typeParameters = typeParameters; |
| 4689 } | 4330 } |
| 4690 | 4331 |
| 4691 @override | 4332 @override |
| 4692 void visitChildren(ElementVisitor visitor) { | 4333 void visitChildren(ElementVisitor visitor) { |
| 4693 super.visitChildren(visitor); | 4334 super.visitChildren(visitor); |
| 4694 safelyVisitChildren(_parameters, visitor); | 4335 safelyVisitChildren(_parameters, visitor); |
| 4695 safelyVisitChildren(_typeParameters, visitor); | 4336 safelyVisitChildren(_typeParameters, visitor); |
| 4696 } | 4337 } |
| 4697 } | 4338 } |
| 4698 | 4339 |
| 4699 /** | 4340 /** |
| 4700 * Instances of the class `FunctionTypeImpl` defines the behavior common to obje
cts | 4341 * The type of a function, method, constructor, getter, or setter. |
| 4701 * representing the type of a function, method, constructor, getter, or setter. | |
| 4702 */ | 4342 */ |
| 4703 class FunctionTypeImpl extends TypeImpl implements FunctionType { | 4343 class FunctionTypeImpl extends TypeImpl implements FunctionType { |
| 4704 /** | 4344 /** |
| 4705 * An array containing the actual types of the type arguments. | 4345 * A list containing the actual types of the type arguments. |
| 4706 */ | 4346 */ |
| 4707 List<DartType> typeArguments = TypeImpl.EMPTY_ARRAY; | 4347 List<DartType> typeArguments = TypeImpl.EMPTY_ARRAY; |
| 4708 | 4348 |
| 4709 /** | 4349 /** |
| 4710 * Initialize a newly created function type to be declared by the given elemen
t and to have the | 4350 * Initialize a newly created function type to be declared by the given |
| 4711 * given name. | 4351 * [element]. |
| 4712 * | |
| 4713 * @param element the element representing the declaration of the function typ
e | |
| 4714 */ | 4352 */ |
| 4715 FunctionTypeImpl.con1(ExecutableElement element) : super(element, null); | 4353 FunctionTypeImpl.con1(ExecutableElement element) : super(element, null); |
| 4716 | 4354 |
| 4717 /** | 4355 /** |
| 4718 * Initialize a newly created function type to be declared by the given elemen
t and to have the | 4356 * Initialize a newly created function type to be declared by the given |
| 4719 * given name. | 4357 * [element]. |
| 4720 * | |
| 4721 * @param element the element representing the declaration of the function typ
e | |
| 4722 */ | 4358 */ |
| 4723 FunctionTypeImpl.con2(FunctionTypeAliasElement element) | 4359 FunctionTypeImpl.con2(FunctionTypeAliasElement element) |
| 4724 : super(element, element == null ? null : element.name); | 4360 : super(element, element == null ? null : element.name); |
| 4725 | 4361 |
| 4726 /** | 4362 /** |
| 4727 * @return the base parameter elements of this function element, not `null`. | 4363 * Return the base parameter elements of this function element. |
| 4728 */ | 4364 */ |
| 4729 List<ParameterElement> get baseParameters { | 4365 List<ParameterElement> get baseParameters { |
| 4730 Element element = this.element; | 4366 Element element = this.element; |
| 4731 if (element is ExecutableElement) { | 4367 if (element is ExecutableElement) { |
| 4732 return element.parameters; | 4368 return element.parameters; |
| 4733 } else { | 4369 } else { |
| 4734 return (element as FunctionTypeAliasElement).parameters; | 4370 return (element as FunctionTypeAliasElement).parameters; |
| 4735 } | 4371 } |
| 4736 } | 4372 } |
| 4737 | 4373 |
| 4738 /** | 4374 /** |
| 4739 * Return the return type defined by this function's element. | 4375 * Return the return type defined by this function's element. |
| 4740 * | |
| 4741 * @return the return type defined by this function's element | |
| 4742 */ | 4376 */ |
| 4743 DartType get baseReturnType { | 4377 DartType get baseReturnType { |
| 4744 Element element = this.element; | 4378 Element element = this.element; |
| 4745 if (element is ExecutableElement) { | 4379 if (element is ExecutableElement) { |
| 4746 return element.returnType; | 4380 return element.returnType; |
| 4747 } else { | 4381 } else { |
| 4748 return (element as FunctionTypeAliasElement).returnType; | 4382 return (element as FunctionTypeAliasElement).returnType; |
| 4749 } | 4383 } |
| 4750 } | 4384 } |
| 4751 | 4385 |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5295 } | 4929 } |
| 5296 } | 4930 } |
| 5297 } | 4931 } |
| 5298 DartType tRetType = t.returnType; | 4932 DartType tRetType = t.returnType; |
| 5299 DartType sRetType = s.returnType; | 4933 DartType sRetType = s.returnType; |
| 5300 return sRetType.isVoid || | 4934 return sRetType.isVoid || |
| 5301 (tRetType as TypeImpl).isAssignableTo2(sRetType, visitedTypePairs); | 4935 (tRetType as TypeImpl).isAssignableTo2(sRetType, visitedTypePairs); |
| 5302 } | 4936 } |
| 5303 | 4937 |
| 5304 /** | 4938 /** |
| 5305 * Return `true` if this type is assignable to the given type. A function type
<i>T</i> may | 4939 * Return `true` if this type is assignable to the given [type]. A function |
| 5306 * be assigned to a function type <i>S</i>, written <i>T</i> ⇔ <i>S</i>,
iff <i>T</i> <: | 4940 * type <i>T</i> may be assigned to a function type <i>S</i>, written <i>T</i> |
| 5307 * <i>S</i> (Function Types section of spec). Note that this is more restricti
ve than the | 4941 * ⇔ <i>S</i>, iff <i>T</i> <: <i>S</i> (Function Types section of spec). |
| 5308 * "may be assigned to" rule for interface types. | 4942 * Note that this is more restrictive than the "may be assigned to" rule for |
| 5309 * | 4943 * interface types. |
| 5310 * | |
| 5311 * @param type the type being compared with this type | |
| 5312 * @return `true` if this type is assignable to the given type | |
| 5313 */ | 4944 */ |
| 5314 @override | 4945 @override |
| 5315 bool isAssignableTo(DartType type) => | 4946 bool isAssignableTo(DartType type) => |
| 5316 isSubtypeOf2(type, new HashSet<TypeImpl_TypePair>()); | 4947 isSubtypeOf2(type, new HashSet<TypeImpl_TypePair>()); |
| 5317 | 4948 |
| 5318 @override | 4949 @override |
| 5319 FunctionTypeImpl substitute2( | 4950 FunctionTypeImpl substitute2( |
| 5320 List<DartType> argumentTypes, List<DartType> parameterTypes) { | 4951 List<DartType> argumentTypes, List<DartType> parameterTypes) { |
| 5321 if (argumentTypes.length != parameterTypes.length) { | 4952 if (argumentTypes.length != parameterTypes.length) { |
| 5322 throw new IllegalArgumentException( | 4953 throw new IllegalArgumentException( |
| 5323 "argumentTypes.length (${argumentTypes.length}) != parameterTypes.leng
th (${parameterTypes.length})"); | 4954 "argumentTypes.length (${argumentTypes.length}) != parameterTypes.leng
th (${parameterTypes.length})"); |
| 5324 } | 4955 } |
| 5325 if (argumentTypes.length == 0) { | 4956 if (argumentTypes.length == 0) { |
| 5326 return this; | 4957 return this; |
| 5327 } | 4958 } |
| 5328 Element element = this.element; | 4959 Element element = this.element; |
| 5329 FunctionTypeImpl newType = (element is ExecutableElement) | 4960 FunctionTypeImpl newType = (element is ExecutableElement) |
| 5330 ? new FunctionTypeImpl.con1(element) | 4961 ? new FunctionTypeImpl.con1(element) |
| 5331 : new FunctionTypeImpl.con2(element as FunctionTypeAliasElement); | 4962 : new FunctionTypeImpl.con2(element as FunctionTypeAliasElement); |
| 5332 newType.typeArguments = | 4963 newType.typeArguments = |
| 5333 TypeImpl.substitute(typeArguments, argumentTypes, parameterTypes); | 4964 TypeImpl.substitute(typeArguments, argumentTypes, parameterTypes); |
| 5334 return newType; | 4965 return newType; |
| 5335 } | 4966 } |
| 5336 | 4967 |
| 5337 @override | 4968 @override |
| 5338 FunctionTypeImpl substitute3(List<DartType> argumentTypes) => | 4969 FunctionTypeImpl substitute3(List<DartType> argumentTypes) => |
| 5339 substitute2(argumentTypes, typeArguments); | 4970 substitute2(argumentTypes, typeArguments); |
| 5340 | 4971 |
| 5341 /** | 4972 /** |
| 5342 * Return `true` if all of the name/type pairs in the first map are equal to t
he | 4973 * Return `true` if all of the name/type pairs in the first map ([firstTypes]) |
| 5343 * corresponding name/type pairs in the second map. The maps are expected to i
terate over their | 4974 * are equal to the corresponding name/type pairs in the second map |
| 5344 * entries in the same order in which those entries were added to the map. | 4975 * ([secondTypes]). The maps are expected to iterate over their entries in the |
| 5345 * | 4976 * same order in which those entries were added to the map. The set of |
| 5346 * @param firstTypes the first map of name/type pairs being compared | 4977 * [visitedElementPairs] is used to prevent infinite recursion in the case of |
| 5347 * @param secondTypes the second map of name/type pairs being compared | 4978 * cyclic type structures. |
| 5348 * @param visitedElementPairs a set of visited element pairs | |
| 5349 * @return `true` if all of the name/type pairs in the first map are equal to
the | |
| 5350 * corresponding name/type pairs in the second map | |
| 5351 */ | 4979 */ |
| 5352 static bool _equals(Map<String, DartType> firstTypes, | 4980 static bool _equals(Map<String, DartType> firstTypes, |
| 5353 Map<String, DartType> secondTypes, Set<ElementPair> visitedElementPairs) { | 4981 Map<String, DartType> secondTypes, Set<ElementPair> visitedElementPairs) { |
| 5354 if (secondTypes.length != firstTypes.length) { | 4982 if (secondTypes.length != firstTypes.length) { |
| 5355 return false; | 4983 return false; |
| 5356 } | 4984 } |
| 5357 Iterator<String> firstKeys = firstTypes.keys.iterator; | 4985 Iterator<String> firstKeys = firstTypes.keys.iterator; |
| 5358 Iterator<String> secondKeys = secondTypes.keys.iterator; | 4986 Iterator<String> secondKeys = secondTypes.keys.iterator; |
| 5359 while (firstKeys.moveNext() && secondKeys.moveNext()) { | 4987 while (firstKeys.moveNext() && secondKeys.moveNext()) { |
| 5360 String firstKey = firstKeys.current; | 4988 String firstKey = firstKeys.current; |
| 5361 String secondKey = secondKeys.current; | 4989 String secondKey = secondKeys.current; |
| 5362 TypeImpl firstType = firstTypes[firstKey]; | 4990 TypeImpl firstType = firstTypes[firstKey]; |
| 5363 TypeImpl secondType = secondTypes[secondKey]; | 4991 TypeImpl secondType = secondTypes[secondKey]; |
| 5364 if (firstKey != secondKey || | 4992 if (firstKey != secondKey || |
| 5365 !firstType.internalEquals(secondType, visitedElementPairs)) { | 4993 !firstType.internalEquals(secondType, visitedElementPairs)) { |
| 5366 return false; | 4994 return false; |
| 5367 } | 4995 } |
| 5368 } | 4996 } |
| 5369 return true; | 4997 return true; |
| 5370 } | 4998 } |
| 5371 } | 4999 } |
| 5372 | 5000 |
| 5373 /** | 5001 /** |
| 5374 * Instances of the class `GeneralizingElementVisitor` implement an element visi
tor that will | 5002 * An element visitor that will recursively visit all of the elements in an |
| 5375 * recursively visit all of the elements in an element model (like instances of
the class | 5003 * element model (like instances of the class [RecursiveElementVisitor]). In |
| 5376 * [RecursiveElementVisitor]). In addition, when an element of a specific type i
s visited not | 5004 * addition, when an element of a specific type is visited not only will the |
| 5377 * only will the visit method for that specific type of element be invoked, but
additional methods | 5005 * visit method for that specific type of element be invoked, but additional |
| 5378 * for the supertypes of that element will also be invoked. For example, using a
n instance of this | 5006 * methods for the supertypes of that element will also be invoked. For example, |
| 5379 * class to visit a [MethodElement] will cause the method | 5007 * using an instance of this class to visit a [MethodElement] will cause the |
| 5380 * [visitMethodElement] to be invoked but will also cause the methods | 5008 * method [visitMethodElement] to be invoked but will also cause the methods |
| 5381 * [visitExecutableElement] and [visitElement] to be | 5009 * [visitExecutableElement] and [visitElement] to be subsequently invoked. This |
| 5382 * subsequently invoked. This allows visitors to be written that visit all execu
table elements | 5010 * allows visitors to be written that visit all executable elements without |
| 5383 * without needing to override the visit method for each of the specific subclas
ses of | 5011 * needing to override the visit method for each of the specific subclasses of |
| 5384 * [ExecutableElement]. | 5012 * [ExecutableElement]. |
| 5385 * | 5013 * |
| 5386 * Note, however, that unlike many visitors, element visitors visit objects base
d on the interfaces | 5014 * Note, however, that unlike many visitors, element visitors visit objects |
| 5387 * implemented by those elements. Because interfaces form a graph structure rath
er than a tree | 5015 * based on the interfaces implemented by those elements. Because interfaces |
| 5388 * structure the way classes do, and because it is generally undesirable for an
object to be visited | 5016 * form a graph structure rather than a tree structure the way classes do, and |
| 5389 * more than once, this class flattens the interface graph into a pseudo-tree. I
n particular, this | 5017 * because it is generally undesirable for an object to be visited more than |
| 5390 * class treats elements as if the element types were structured in the followin
g way: | 5018 * once, this class flattens the interface graph into a pseudo-tree. In |
| 5391 * | 5019 * particular, this class treats elements as if the element types were |
| 5020 * structured in the following way: |
| 5392 * | 5021 * |
| 5393 * <pre> | 5022 * <pre> |
| 5394 * Element | 5023 * Element |
| 5395 * ClassElement | 5024 * ClassElement |
| 5396 * CompilationUnitElement | 5025 * CompilationUnitElement |
| 5397 * ExecutableElement | 5026 * ExecutableElement |
| 5398 * ConstructorElement | 5027 * ConstructorElement |
| 5399 * LocalElement | 5028 * LocalElement |
| 5400 * FunctionElement | 5029 * FunctionElement |
| 5401 * MethodElement | 5030 * MethodElement |
| 5402 * PropertyAccessorElement | 5031 * PropertyAccessorElement |
| 5403 * ExportElement | 5032 * ExportElement |
| 5404 * HtmlElement | 5033 * HtmlElement |
| 5405 * ImportElement | 5034 * ImportElement |
| 5406 * LabelElement | 5035 * LabelElement |
| 5407 * LibraryElement | 5036 * LibraryElement |
| 5408 * MultiplyDefinedElement | 5037 * MultiplyDefinedElement |
| 5409 * PrefixElement | 5038 * PrefixElement |
| 5410 * TypeAliasElement | 5039 * TypeAliasElement |
| 5411 * TypeParameterElement | 5040 * TypeParameterElement |
| 5412 * UndefinedElement | 5041 * UndefinedElement |
| 5413 * VariableElement | 5042 * VariableElement |
| 5414 * PropertyInducingElement | 5043 * PropertyInducingElement |
| 5415 * FieldElement | 5044 * FieldElement |
| 5416 * TopLevelVariableElement | 5045 * TopLevelVariableElement |
| 5417 * LocalElement | 5046 * LocalElement |
| 5418 * LocalVariableElement | 5047 * LocalVariableElement |
| 5419 * ParameterElement | 5048 * ParameterElement |
| 5420 * FieldFormalParameterElement | 5049 * FieldFormalParameterElement |
| 5421 * </pre> | 5050 * </pre> |
| 5422 * | 5051 * |
| 5423 * Subclasses that override a visit method must either invoke the overridden vis
it method or | 5052 * Subclasses that override a visit method must either invoke the overridden |
| 5424 * explicitly invoke the more general visit method. Failure to do so will cause
the visit methods | 5053 * visit method or explicitly invoke the more general visit method. Failure to |
| 5425 * for superclasses of the element to not be invoked and will cause the children
of the visited node | 5054 * do so will cause the visit methods for superclasses of the element to not be |
| 5426 * to not be visited. | 5055 * invoked and will cause the children of the visited node to not be visited. |
| 5427 */ | 5056 */ |
| 5428 class GeneralizingElementVisitor<R> implements ElementVisitor<R> { | 5057 class GeneralizingElementVisitor<R> implements ElementVisitor<R> { |
| 5429 @override | 5058 @override |
| 5430 R visitClassElement(ClassElement element) => visitElement(element); | 5059 R visitClassElement(ClassElement element) => visitElement(element); |
| 5431 | 5060 |
| 5432 @override | 5061 @override |
| 5433 R visitCompilationUnitElement(CompilationUnitElement element) => | 5062 R visitCompilationUnitElement(CompilationUnitElement element) => |
| 5434 visitElement(element); | 5063 visitElement(element); |
| 5435 | 5064 |
| 5436 @override | 5065 @override |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5526 visitPropertyInducingElement(element); | 5155 visitPropertyInducingElement(element); |
| 5527 | 5156 |
| 5528 @override | 5157 @override |
| 5529 R visitTypeParameterElement(TypeParameterElement element) => | 5158 R visitTypeParameterElement(TypeParameterElement element) => |
| 5530 visitElement(element); | 5159 visitElement(element); |
| 5531 | 5160 |
| 5532 R visitVariableElement(VariableElement element) => visitElement(element); | 5161 R visitVariableElement(VariableElement element) => visitElement(element); |
| 5533 } | 5162 } |
| 5534 | 5163 |
| 5535 /** | 5164 /** |
| 5536 * The interface `HideElementCombinator` defines the behavior of combinators tha
t cause some | 5165 * A combinator that causes some of the names in a namespace to be hidden when |
| 5537 * of the names in a namespace to be hidden when being imported. | 5166 * being imported. |
| 5538 */ | 5167 */ |
| 5539 abstract class HideElementCombinator implements NamespaceCombinator { | 5168 abstract class HideElementCombinator implements NamespaceCombinator { |
| 5540 /** | 5169 /** |
| 5541 * Return an array containing the names that are not to be made visible in the
importing library | 5170 * Return a list containing the names that are not to be made visible in the |
| 5542 * even if they are defined in the imported library. | 5171 * importing library even if they are defined in the imported library. |
| 5543 * | |
| 5544 * @return the names from the imported library that are hidden from the import
ing library | |
| 5545 */ | 5172 */ |
| 5546 List<String> get hiddenNames; | 5173 List<String> get hiddenNames; |
| 5547 } | 5174 } |
| 5548 | 5175 |
| 5549 /** | 5176 /** |
| 5550 * Instances of the class `HideElementCombinatorImpl` implement a | 5177 * A concrete implementation of a [HideElementCombinator]. |
| 5551 * [HideElementCombinator]. | |
| 5552 */ | 5178 */ |
| 5553 class HideElementCombinatorImpl implements HideElementCombinator { | 5179 class HideElementCombinatorImpl implements HideElementCombinator { |
| 5554 /** | 5180 /** |
| 5555 * The names that are not to be made visible in the importing library even if
they are defined in | 5181 * The names that are not to be made visible in the importing library even if |
| 5556 * the imported library. | 5182 * they are defined in the imported library. |
| 5557 */ | 5183 */ |
| 5558 List<String> hiddenNames = StringUtilities.EMPTY_ARRAY; | 5184 List<String> hiddenNames = StringUtilities.EMPTY_ARRAY; |
| 5559 | 5185 |
| 5560 @override | 5186 @override |
| 5561 String toString() { | 5187 String toString() { |
| 5562 StringBuffer buffer = new StringBuffer(); | 5188 StringBuffer buffer = new StringBuffer(); |
| 5563 buffer.write("show "); | 5189 buffer.write("show "); |
| 5564 int count = hiddenNames.length; | 5190 int count = hiddenNames.length; |
| 5565 for (int i = 0; i < count; i++) { | 5191 for (int i = 0; i < count; i++) { |
| 5566 if (i > 0) { | 5192 if (i > 0) { |
| 5567 buffer.write(", "); | 5193 buffer.write(", "); |
| 5568 } | 5194 } |
| 5569 buffer.write(hiddenNames[i]); | 5195 buffer.write(hiddenNames[i]); |
| 5570 } | 5196 } |
| 5571 return buffer.toString(); | 5197 return buffer.toString(); |
| 5572 } | 5198 } |
| 5573 } | 5199 } |
| 5574 | 5200 |
| 5575 /** | 5201 /** |
| 5576 * The interface `HtmlElement` defines the behavior of elements representing an
HTML file. | 5202 * An HTML file. |
| 5577 */ | 5203 */ |
| 5578 abstract class HtmlElement implements Element { | 5204 abstract class HtmlElement implements Element { |
| 5579 /** | 5205 /** |
| 5580 * Return an array containing all of the script elements contained in the HTML
file. This includes | 5206 * Return a list containing all of the script elements contained in the HTML |
| 5581 * scripts with libraries that are defined by the content of a script tag as w
ell as libraries | 5207 * file. This includes scripts with libraries that are defined by the content |
| 5582 * that are referenced in the {@core source} attribute of a script tag. | 5208 * of a script tag as well as libraries that are referenced in the `source` |
| 5583 * | 5209 * attribute of a script tag. |
| 5584 * @return the script elements in the HTML file (not `null`, contains no `null
`s) | |
| 5585 */ | 5210 */ |
| 5586 List<HtmlScriptElement> get scripts; | 5211 List<HtmlScriptElement> get scripts; |
| 5587 } | 5212 } |
| 5588 | 5213 |
| 5589 /** | 5214 /** |
| 5590 * Instances of the class `HtmlElementImpl` implement an [HtmlElement]. | 5215 * A concrete implementation of an [HtmlElement]. |
| 5591 */ | 5216 */ |
| 5592 class HtmlElementImpl extends ElementImpl implements HtmlElement { | 5217 class HtmlElementImpl extends ElementImpl implements HtmlElement { |
| 5593 /** | 5218 /** |
| 5594 * An empty list of HTML file elements. | 5219 * An empty list of HTML file elements. |
| 5595 */ | 5220 */ |
| 5596 static const List<HtmlElement> EMPTY_ARRAY = const <HtmlElement>[]; | 5221 static const List<HtmlElement> EMPTY_ARRAY = const <HtmlElement>[]; |
| 5597 | 5222 |
| 5598 /** | 5223 /** |
| 5599 * The analysis context in which this library is defined. | 5224 * The analysis context in which this library is defined. |
| 5600 */ | 5225 */ |
| 5601 final AnalysisContext context; | 5226 final AnalysisContext context; |
| 5602 | 5227 |
| 5603 /** | 5228 /** |
| 5604 * The scripts contained in or referenced from script tags in the HTML file. | 5229 * The scripts contained in or referenced from script tags in the HTML file. |
| 5605 */ | 5230 */ |
| 5606 List<HtmlScriptElement> _scripts = HtmlScriptElementImpl.EMPTY_ARRAY; | 5231 List<HtmlScriptElement> _scripts = HtmlScriptElementImpl.EMPTY_ARRAY; |
| 5607 | 5232 |
| 5608 /** | 5233 /** |
| 5609 * The source that corresponds to this HTML file. | 5234 * The source that corresponds to this HTML file. |
| 5610 */ | 5235 */ |
| 5611 Source source; | 5236 Source source; |
| 5612 | 5237 |
| 5613 /** | 5238 /** |
| 5614 * Initialize a newly created HTML element to have the given name. | 5239 * Initialize a newly created HTML element in the given [context] to have the |
| 5615 * | 5240 * given [name]. |
| 5616 * @param context the analysis context in which the HTML file is defined | |
| 5617 * @param name the name of this element | |
| 5618 */ | 5241 */ |
| 5619 HtmlElementImpl(this.context, String name) : super(name, -1); | 5242 HtmlElementImpl(this.context, String name) : super(name, -1); |
| 5620 | 5243 |
| 5621 @override | 5244 @override |
| 5622 int get hashCode => source.hashCode; | 5245 int get hashCode => source.hashCode; |
| 5623 | 5246 |
| 5624 @override | 5247 @override |
| 5625 String get identifier => source.encoding; | 5248 String get identifier => source.encoding; |
| 5626 | 5249 |
| 5627 @override | 5250 @override |
| 5628 ElementKind get kind => ElementKind.HTML; | 5251 ElementKind get kind => ElementKind.HTML; |
| 5629 | 5252 |
| 5630 @override | 5253 @override |
| 5631 List<HtmlScriptElement> get scripts => _scripts; | 5254 List<HtmlScriptElement> get scripts => _scripts; |
| 5632 | 5255 |
| 5633 /** | 5256 /** |
| 5634 * Set the scripts contained in the HTML file to the given scripts. | 5257 * Set the scripts contained in the HTML file to the given [scripts]. |
| 5635 * | |
| 5636 * @param scripts the scripts | |
| 5637 */ | 5258 */ |
| 5638 void set scripts(List<HtmlScriptElement> scripts) { | 5259 void set scripts(List<HtmlScriptElement> scripts) { |
| 5639 if (scripts.length == 0) { | 5260 if (scripts.length == 0) { |
| 5640 this._scripts = HtmlScriptElementImpl.EMPTY_ARRAY; | 5261 this._scripts = HtmlScriptElementImpl.EMPTY_ARRAY; |
| 5641 return; | 5262 return; |
| 5642 } | 5263 } |
| 5643 for (HtmlScriptElement script in scripts) { | 5264 for (HtmlScriptElement script in scripts) { |
| 5644 (script as HtmlScriptElementImpl).enclosingElement = this; | 5265 (script as HtmlScriptElementImpl).enclosingElement = this; |
| 5645 } | 5266 } |
| 5646 this._scripts = scripts; | 5267 this._scripts = scripts; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 5667 } | 5288 } |
| 5668 | 5289 |
| 5669 @override | 5290 @override |
| 5670 void visitChildren(ElementVisitor visitor) { | 5291 void visitChildren(ElementVisitor visitor) { |
| 5671 super.visitChildren(visitor); | 5292 super.visitChildren(visitor); |
| 5672 safelyVisitChildren(_scripts, visitor); | 5293 safelyVisitChildren(_scripts, visitor); |
| 5673 } | 5294 } |
| 5674 } | 5295 } |
| 5675 | 5296 |
| 5676 /** | 5297 /** |
| 5677 * The interface `HtmlScriptElement` defines the behavior of elements representi
ng a script | 5298 * A script tag in an HTML file. |
| 5678 * tag in an HTML file. | |
| 5679 * | 5299 * |
| 5680 * See [EmbeddedHtmlScriptElement], and [ExternalHtmlScriptElement], | 5300 * See [EmbeddedHtmlScriptElement], and [ExternalHtmlScriptElement]. |
| 5681 */ | 5301 */ |
| 5682 abstract class HtmlScriptElement implements Element {} | 5302 abstract class HtmlScriptElement implements Element {} |
| 5683 | 5303 |
| 5684 /** | 5304 /** |
| 5685 * Instances of the class `HtmlScriptElementImpl` implement an [HtmlScriptElemen
t]. | 5305 * A concrete implementation of an [HtmlScriptElement]. |
| 5686 */ | 5306 */ |
| 5687 abstract class HtmlScriptElementImpl extends ElementImpl | 5307 abstract class HtmlScriptElementImpl extends ElementImpl |
| 5688 implements HtmlScriptElement { | 5308 implements HtmlScriptElement { |
| 5689 /** | 5309 /** |
| 5690 * An empty list of HTML script elements. | 5310 * An empty list of HTML script elements. |
| 5691 */ | 5311 */ |
| 5692 static const List<HtmlScriptElement> EMPTY_ARRAY = const <HtmlScriptElement>[ | 5312 static const List<HtmlScriptElement> EMPTY_ARRAY = const <HtmlScriptElement>[ |
| 5693 ]; | 5313 ]; |
| 5694 | 5314 |
| 5695 /** | 5315 /** |
| 5696 * Initialize a newly created script element to have the specified tag name an
d offset. | 5316 * Initialize a newly created script element corresponding to the given |
| 5697 * | 5317 * [node]. |
| 5698 * @param node the XML node from which this element is derived (not `null`) | |
| 5699 */ | 5318 */ |
| 5700 HtmlScriptElementImpl(XmlTagNode node) | 5319 HtmlScriptElementImpl(XmlTagNode node) |
| 5701 : super(node.tag, node.tagToken.offset); | 5320 : super(node.tag, node.tagToken.offset); |
| 5702 } | 5321 } |
| 5703 | 5322 |
| 5704 /** | 5323 /** |
| 5705 * The interface `ImportElement` defines the behavior of objects representing in
formation | 5324 * A single import directive within a library. |
| 5706 * about a single import directive within a library. | |
| 5707 */ | 5325 */ |
| 5708 abstract class ImportElement implements Element, UriReferencedElement { | 5326 abstract class ImportElement implements Element, UriReferencedElement { |
| 5709 /** | 5327 /** |
| 5710 * An empty list of import elements. | 5328 * An empty list of import elements. |
| 5711 */ | 5329 */ |
| 5712 static const List<ImportElement> EMPTY_ARRAY = const <ImportElement>[]; | 5330 static const List<ImportElement> EMPTY_ARRAY = const <ImportElement>[]; |
| 5713 | 5331 |
| 5714 /** | 5332 /** |
| 5715 * Return an array containing the combinators that were specified as part of t
he import directive | 5333 * Return a list containing the combinators that were specified as part of the |
| 5716 * in the order in which they were specified. | 5334 * import directive in the order in which they were specified. |
| 5717 * | |
| 5718 * @return the combinators specified in the import directive | |
| 5719 */ | 5335 */ |
| 5720 List<NamespaceCombinator> get combinators; | 5336 List<NamespaceCombinator> get combinators; |
| 5721 | 5337 |
| 5722 /** | 5338 /** |
| 5723 * Return the library that is imported into this library by this import direct
ive. | 5339 * Return the library that is imported into this library by this import |
| 5724 * | 5340 * directive. |
| 5725 * @return the library that is imported into this library | |
| 5726 */ | 5341 */ |
| 5727 LibraryElement get importedLibrary; | 5342 LibraryElement get importedLibrary; |
| 5728 | 5343 |
| 5729 /** | 5344 /** |
| 5730 * Return `true` if this import is for a deferred library. | 5345 * Return `true` if this import is for a deferred library. |
| 5731 * | |
| 5732 * @return `true` if this import is for a deferred library | |
| 5733 */ | 5346 */ |
| 5734 bool get isDeferred; | 5347 bool get isDeferred; |
| 5735 | 5348 |
| 5736 /** | 5349 /** |
| 5737 * Return the prefix that was specified as part of the import directive, or `n
ull` if there | 5350 * Return the prefix that was specified as part of the import directive, or |
| 5738 * was no prefix specified. | 5351 * `null` if there was no prefix specified. |
| 5739 * | |
| 5740 * @return the prefix that was specified as part of the import directive | |
| 5741 */ | 5352 */ |
| 5742 PrefixElement get prefix; | 5353 PrefixElement get prefix; |
| 5743 | 5354 |
| 5744 /** | 5355 /** |
| 5745 * Return the offset of the prefix of this import in the file that contains th
is import directive, | 5356 * Return the offset of the prefix of this import in the file that contains |
| 5746 * or `-1` if this import is synthetic, does not have a prefix, or otherwise d
oes not have | 5357 * this import directive, or `-1` if this import is synthetic, does not have a |
| 5747 * an offset. | 5358 * prefix, or otherwise does not have an offset. |
| 5748 * | |
| 5749 * @return the offset of the prefix of this import | |
| 5750 */ | 5359 */ |
| 5751 int get prefixOffset; | 5360 int get prefixOffset; |
| 5752 } | 5361 } |
| 5753 | 5362 |
| 5754 /** | 5363 /** |
| 5755 * Instances of the class `ImportElementImpl` implement an [ImportElement]. | 5364 * A concrete implementation of an [ImportElement]. |
| 5756 */ | 5365 */ |
| 5757 class ImportElementImpl extends UriReferencedElementImpl | 5366 class ImportElementImpl extends UriReferencedElementImpl |
| 5758 implements ImportElement { | 5367 implements ImportElement { |
| 5759 /** | 5368 /** |
| 5760 * The offset of the prefix of this import in the file that contains the this
import directive, or | 5369 * The offset of the prefix of this import in the file that contains the this |
| 5761 * `-1` if this import is synthetic. | 5370 * import directive, or `-1` if this import is synthetic. |
| 5762 */ | 5371 */ |
| 5763 int prefixOffset = 0; | 5372 int prefixOffset = 0; |
| 5764 | 5373 |
| 5765 /** | 5374 /** |
| 5766 * The library that is imported into this library by this import directive. | 5375 * The library that is imported into this library by this import directive. |
| 5767 */ | 5376 */ |
| 5768 LibraryElement importedLibrary; | 5377 LibraryElement importedLibrary; |
| 5769 | 5378 |
| 5770 /** | 5379 /** |
| 5771 * The combinators that were specified as part of the import directive in the
order in which they | 5380 * The combinators that were specified as part of the import directive in the |
| 5772 * were specified. | 5381 * order in which they were specified. |
| 5773 */ | 5382 */ |
| 5774 List<NamespaceCombinator> combinators = NamespaceCombinator.EMPTY_ARRAY; | 5383 List<NamespaceCombinator> combinators = NamespaceCombinator.EMPTY_ARRAY; |
| 5775 | 5384 |
| 5776 /** | 5385 /** |
| 5777 * The prefix that was specified as part of the import directive, or `null` if
there was no | 5386 * The prefix that was specified as part of the import directive, or `null` if |
| 5778 * prefix specified. | 5387 * there was no prefix specified. |
| 5779 */ | 5388 */ |
| 5780 PrefixElement prefix; | 5389 PrefixElement prefix; |
| 5781 | 5390 |
| 5782 /** | 5391 /** |
| 5783 * Initialize a newly created import element. | 5392 * Initialize a newly created import element at the given [offset]. The offset |
| 5784 * | 5393 * may be `-1` if the import is synthetic. |
| 5785 * @param offset the directive offset, may be `-1` if synthetic. | |
| 5786 */ | 5394 */ |
| 5787 ImportElementImpl(int offset) : super(null, offset); | 5395 ImportElementImpl(int offset) : super(null, offset); |
| 5788 | 5396 |
| 5789 /** | 5397 /** |
| 5790 * Set whether this import is for a deferred library to correspond to the give
n value. | 5398 * Set whether this import is for a deferred library. |
| 5791 * | |
| 5792 * @param isDeferred `true` if this import is for a deferred library | |
| 5793 */ | 5399 */ |
| 5794 void set deferred(bool isDeferred) { | 5400 void set deferred(bool isDeferred) { |
| 5795 setModifier(Modifier.DEFERRED, isDeferred); | 5401 setModifier(Modifier.DEFERRED, isDeferred); |
| 5796 } | 5402 } |
| 5797 | 5403 |
| 5798 @override | 5404 @override |
| 5799 String get identifier => | 5405 String get identifier => |
| 5800 "${(importedLibrary as LibraryElementImpl).identifier}@$nameOffset"; | 5406 "${(importedLibrary as LibraryElementImpl).identifier}@$nameOffset"; |
| 5801 | 5407 |
| 5802 @override | 5408 @override |
| (...skipping 12 matching lines...) Expand all Loading... |
| 5815 } | 5421 } |
| 5816 | 5422 |
| 5817 @override | 5423 @override |
| 5818 void visitChildren(ElementVisitor visitor) { | 5424 void visitChildren(ElementVisitor visitor) { |
| 5819 super.visitChildren(visitor); | 5425 super.visitChildren(visitor); |
| 5820 safelyVisitChild(prefix, visitor); | 5426 safelyVisitChild(prefix, visitor); |
| 5821 } | 5427 } |
| 5822 } | 5428 } |
| 5823 | 5429 |
| 5824 /** | 5430 /** |
| 5825 * The interface `InterfaceType` defines the behavior common to objects represen
ting the type | 5431 * The type introduced by either a class or an interface, or a reference to such |
| 5826 * introduced by either a class or an interface, or a reference to such a type. | 5432 * a type. |
| 5827 */ | 5433 */ |
| 5828 abstract class InterfaceType implements ParameterizedType { | 5434 abstract class InterfaceType implements ParameterizedType { |
| 5829 /** | 5435 /** |
| 5830 * An empty list of types. | 5436 * An empty list of types. |
| 5831 */ | 5437 */ |
| 5832 static const List<InterfaceType> EMPTY_ARRAY = const <InterfaceType>[]; | 5438 static const List<InterfaceType> EMPTY_ARRAY = const <InterfaceType>[]; |
| 5833 | 5439 |
| 5834 /** | 5440 /** |
| 5835 * Return an array containing all of the accessors (getters and setters) decla
red in this type. | 5441 * Return a list containing all of the accessors (getters and setters) |
| 5836 * | 5442 * declared in this type. |
| 5837 * @return the accessors declared in this type | |
| 5838 */ | 5443 */ |
| 5839 List<PropertyAccessorElement> get accessors; | 5444 List<PropertyAccessorElement> get accessors; |
| 5840 | 5445 |
| 5841 @override | 5446 @override |
| 5842 ClassElement get element; | 5447 ClassElement get element; |
| 5843 | 5448 |
| 5844 /** | 5449 /** |
| 5845 * Return an array containing all of the interfaces that are implemented by th
is interface. Note | 5450 * Return a list containing all of the interfaces that are implemented by this |
| 5846 * that this is <b>not</b>, in general, equivalent to getting the interfaces f
rom this type's | 5451 * interface. Note that this is <b>not</b>, in general, equivalent to getting |
| 5847 * element because the types returned by this method will have had their type
parameters replaced. | 5452 * the interfaces from this type's element because the types returned by this |
| 5453 * method will have had their type parameters replaced. |
| 5454 */ |
| 5455 List<InterfaceType> get interfaces; |
| 5456 |
| 5457 /** |
| 5458 * Return a list containing all of the methods declared in this type. |
| 5459 */ |
| 5460 List<MethodElement> get methods; |
| 5461 |
| 5462 /** |
| 5463 * Return a list containing all of the mixins that are applied to the class |
| 5464 * being extended in order to derive the superclass of this class. Note that |
| 5465 * this is <b>not</b>, in general, equivalent to getting the mixins from this |
| 5466 * type's element because the types returned by this method will have had |
| 5467 * their type parameters replaced. |
| 5468 */ |
| 5469 List<InterfaceType> get mixins; |
| 5470 |
| 5471 /** |
| 5472 * Return the type representing the superclass of this type, or null if this |
| 5473 * type represents the class 'Object'. Note that this is <b>not</b>, in |
| 5474 * general, equivalent to getting the superclass from this type's element |
| 5475 * because the type returned by this method will have had it's type parameters |
| 5476 * replaced. |
| 5477 */ |
| 5478 InterfaceType get superclass; |
| 5479 |
| 5480 /** |
| 5481 * Return the element representing the getter with the given [name] that is |
| 5482 * declared in this class, or `null` if this class does not declare a getter |
| 5483 * with the given name. |
| 5484 */ |
| 5485 PropertyAccessorElement getGetter(String name); |
| 5486 |
| 5487 /** |
| 5488 * Return the least upper bound of this type and the given [type], or `null` |
| 5489 * if there is no least upper bound. |
| 5848 * | 5490 * |
| 5849 * @return the interfaces that are implemented by this type | 5491 * Given two interfaces <i>I</i> and <i>J</i>, let <i>S<sub>I</sub></i> be the |
| 5850 */ | 5492 * set of superinterfaces of <i>I<i>, let <i>S<sub>J</sub></i> be the set of |
| 5851 List<InterfaceType> get interfaces; | 5493 * superinterfaces of <i>J</i> and let <i>S = (I ∪ S<sub>I</sub>) ∩ |
| 5852 | 5494 * (J ∪ S<sub>J</sub>)</i>. Furthermore, we define <i>S<sub>n</sub> = |
| 5853 /** | 5495 * {T | T ∈ S ∧ depth(T) = n}</i> for any finite <i>n</i>, where |
| 5854 * Return an array containing all of the methods declared in this type. | 5496 * <i>depth(T)</i> is the number of steps in the longest inheritance path from |
| 5497 * <i>T</i> to <i>Object</i>. Let <i>q</i> be the largest number such that |
| 5498 * <i>S<sub>q</sub></i> has cardinality one. The least upper bound of <i>I</i> |
| 5499 * and <i>J</i> is the sole element of <i>S<sub>q</sub></i>. |
| 5500 */ |
| 5501 @override |
| 5502 DartType getLeastUpperBound(DartType type); |
| 5503 |
| 5504 /** |
| 5505 * Return the element representing the method with the given [name] that is |
| 5506 * declared in this class, or `null` if this class does not declare a method |
| 5507 * with the given name. |
| 5508 */ |
| 5509 MethodElement getMethod(String name); |
| 5510 |
| 5511 /** |
| 5512 * Return the element representing the setter with the given [name] that is |
| 5513 * declared in this class, or `null` if this class does not declare a setter |
| 5514 * with the given name. |
| 5515 */ |
| 5516 PropertyAccessorElement getSetter(String name); |
| 5517 |
| 5518 /** |
| 5519 * Return `true` if this type is a direct supertype of the given [type]. The |
| 5520 * implicit interface of class <i>I</i> is a direct supertype of the implicit |
| 5521 * interface of class <i>J</i> iff: |
| 5855 * | 5522 * |
| 5856 * @return the methods declared in this type | |
| 5857 */ | |
| 5858 List<MethodElement> get methods; | |
| 5859 | |
| 5860 /** | |
| 5861 * Return an array containing all of the mixins that are applied to the class
being extended in | |
| 5862 * order to derive the superclass of this class. Note that this is <b>not</b>,
in general, | |
| 5863 * equivalent to getting the mixins from this type's element because the types
returned by this | |
| 5864 * method will have had their type parameters replaced. | |
| 5865 * | |
| 5866 * @return the mixins that are applied to derive the superclass of this class | |
| 5867 */ | |
| 5868 List<InterfaceType> get mixins; | |
| 5869 | |
| 5870 /** | |
| 5871 * Return the type representing the superclass of this type, or null if this t
ype represents the | |
| 5872 * class 'Object'. Note that this is <b>not</b>, in general, equivalent to get
ting the superclass | |
| 5873 * from this type's element because the type returned by this method will have
had it's type | |
| 5874 * parameters replaced. | |
| 5875 * | |
| 5876 * @return the superclass of this type | |
| 5877 */ | |
| 5878 InterfaceType get superclass; | |
| 5879 | |
| 5880 /** | |
| 5881 * Return the element representing the getter with the given name that is decl
ared in this class, | |
| 5882 * or `null` if this class does not declare a getter with the given name. | |
| 5883 * | |
| 5884 * @param getterName the name of the getter to be returned | |
| 5885 * @return the getter declared in this class with the given name | |
| 5886 */ | |
| 5887 PropertyAccessorElement getGetter(String getterName); | |
| 5888 | |
| 5889 /** | |
| 5890 * Return the least upper bound of this type and the given type, or `null` if
there is no | |
| 5891 * least upper bound. | |
| 5892 * | |
| 5893 * Given two interfaces <i>I</i> and <i>J</i>, let <i>S<sub>I</sub></i> be the
set of | |
| 5894 * superinterfaces of <i>I<i>, let <i>S<sub>J</sub></i> be the set of superint
erfaces of <i>J</i> | |
| 5895 * and let <i>S = (I ∪ S<sub>I</sub>) ∩ (J ∪ S<sub>J</sub>)</i>. F
urthermore, we | |
| 5896 * define <i>S<sub>n</sub> = {T | T ∈ S ∧ depth(T) = n}</i> for any f
inite <i>n</i>, | |
| 5897 * where <i>depth(T)</i> is the number of steps in the longest inheritance pat
h from <i>T</i> to | |
| 5898 * <i>Object</i>. Let <i>q</i> be the largest number such that <i>S<sub>q</sub
></i> has | |
| 5899 * cardinality one. The least upper bound of <i>I</i> and <i>J</i> is the sole
element of | |
| 5900 * <i>S<sub>q</sub></i>. | |
| 5901 * | |
| 5902 * @param type the other type used to compute the least upper bound | |
| 5903 * @return the least upper bound of this type and the given type | |
| 5904 */ | |
| 5905 @override | |
| 5906 DartType getLeastUpperBound(DartType type); | |
| 5907 | |
| 5908 /** | |
| 5909 * Return the element representing the method with the given name that is decl
ared in this class, | |
| 5910 * or `null` if this class does not declare a method with the given name. | |
| 5911 * | |
| 5912 * @param methodName the name of the method to be returned | |
| 5913 * @return the method declared in this class with the given name | |
| 5914 */ | |
| 5915 MethodElement getMethod(String methodName); | |
| 5916 | |
| 5917 /** | |
| 5918 * Return the element representing the setter with the given name that is decl
ared in this class, | |
| 5919 * or `null` if this class does not declare a setter with the given name. | |
| 5920 * | |
| 5921 * @param setterName the name of the setter to be returned | |
| 5922 * @return the setter declared in this class with the given name | |
| 5923 */ | |
| 5924 PropertyAccessorElement getSetter(String setterName); | |
| 5925 | |
| 5926 /** | |
| 5927 * Return `true` if this type is a direct supertype of the given type. The imp
licit | |
| 5928 * interface of class <i>I</i> is a direct supertype of the implicit interface
of class <i>J</i> | |
| 5929 * iff: | |
| 5930 * * <i>I</i> is Object, and <i>J</i> has no extends clause. | 5523 * * <i>I</i> is Object, and <i>J</i> has no extends clause. |
| 5931 * * <i>I</i> is listed in the extends clause of <i>J</i>. | 5524 * * <i>I</i> is listed in the extends clause of <i>J</i>. |
| 5932 * * <i>I</i> is listed in the implements clause of <i>J</i>. | 5525 * * <i>I</i> is listed in the implements clause of <i>J</i>. |
| 5933 * * <i>I</i> is listed in the with clause of <i>J</i>. | 5526 * * <i>I</i> is listed in the with clause of <i>J</i>. |
| 5934 * * <i>J</i> is a mixin application of the mixin of <i>I</i>. | 5527 * * <i>J</i> is a mixin application of the mixin of <i>I</i>. |
| 5528 */ |
| 5529 bool isDirectSupertypeOf(InterfaceType type); |
| 5530 |
| 5531 /** |
| 5532 * Return `true` if this type is more specific than the given [type]. An |
| 5533 * interface type <i>T</i> is more specific than an interface type <i>S</i>, |
| 5534 * written <i>T « S</i>, if one of the following conditions is met: |
| 5935 * | 5535 * |
| 5936 * @param type the type being compared with this type | |
| 5937 * @return `true` if this type is a direct supertype of the given type | |
| 5938 */ | |
| 5939 bool isDirectSupertypeOf(InterfaceType type); | |
| 5940 | |
| 5941 /** | |
| 5942 * Return `true` if this type is more specific than the given type. An interfa
ce type | |
| 5943 * <i>T</i> is more specific than an interface type <i>S</i>, written <i>T &la
quo; S</i>, if one | |
| 5944 * of the following conditions is met: | |
| 5945 * * Reflexivity: <i>T</i> is <i>S</i>. | 5536 * * Reflexivity: <i>T</i> is <i>S</i>. |
| 5946 * * <i>T</i> is bottom. | 5537 * * <i>T</i> is bottom. |
| 5947 * * <i>S</i> is dynamic. | 5538 * * <i>S</i> is dynamic. |
| 5948 * * Direct supertype: <i>S</i> is a direct supertype of <i>T</i>. | 5539 * * Direct supertype: <i>S</i> is a direct supertype of <i>T</i>. |
| 5949 * * <i>T</i> is a type parameter and <i>S</i> is the upper bound of <i>T</i>. | 5540 * * <i>T</i> is a type parameter and <i>S</i> is the upper bound of <i>T</i>. |
| 5950 * * Covariance: <i>T</i> is of the form <i>I<T<sub>1</sub>, …, T<su
b>n</sub>></i> | 5541 * * Covariance: <i>T</i> is of the form <i>I<T<sub>1</sub>, …, |
| 5951 * and S</i> is of the form <i>I<S<sub>1</sub>, …, S<sub>n</sub>>
</i> and | 5542 * T<sub>n</sub>></i> and S</i> is of the form <i>I<S<sub>1</sub>, |
| 5952 * <i>T<sub>i</sub> « S<sub>i</sub></i>, <i>1 <= i <= n</i>. | 5543 * …, S<sub>n</sub>></i> and <i>T<sub>i</sub> « |
| 5544 * S<sub>i</sub></i>, <i>1 <= i <= n</i>. |
| 5953 * * Transitivity: <i>T « U</i> and <i>U « S</i>. | 5545 * * Transitivity: <i>T « U</i> and <i>U « S</i>. |
| 5954 * | |
| 5955 * @param type the type being compared with this type | |
| 5956 * @return `true` if this type is more specific than the given type | |
| 5957 */ | 5546 */ |
| 5958 @override | 5547 @override |
| 5959 bool isMoreSpecificThan(DartType type); | 5548 bool isMoreSpecificThan(DartType type); |
| 5960 | 5549 |
| 5961 /** | 5550 /** |
| 5962 * Return `true` if this type is a subtype of the given type. An interface typ
e <i>T</i> is | 5551 * Return `true` if this type is a subtype of the given [type]. An interface |
| 5963 * a subtype of an interface type <i>S</i>, written <i>T</i> <: <i>S</i>, iff | 5552 * type <i>T</i> is a subtype of an interface type <i>S</i>, written <i>T</i> |
| 5964 * <i>[bottom/dynamic]T</i> « <i>S</i> (<i>T</i> is more specific than <
i>S</i>). If an | 5553 * <: <i>S</i>, iff <i>[bottom/dynamic]T</i> « <i>S</i> (<i>T</i> is |
| 5965 * interface type <i>I</i> includes a method named <i>call()</i>, and the type
of <i>call()</i> is | 5554 * more specific than <i>S</i>). If an interface type <i>I</i> includes a |
| 5966 * the function type <i>F</i>, then <i>I</i> is considered to be a subtype of
<i>F</i>. | 5555 * method named <i>call()</i>, and the type of <i>call()</i> is the function |
| 5967 * | 5556 * type <i>F</i>, then <i>I</i> is considered to be a subtype of <i>F</i>. |
| 5968 * @param type the type being compared with this type | |
| 5969 * @return `true` if this type is a subtype of the given type | |
| 5970 */ | 5557 */ |
| 5971 @override | 5558 @override |
| 5972 bool isSubtypeOf(DartType type); | 5559 bool isSubtypeOf(DartType type); |
| 5973 | 5560 |
| 5974 /** | 5561 /** |
| 5975 * Return the element representing the constructor that results from looking u
p the given | 5562 * Return the element representing the constructor that results from looking |
| 5976 * constructor in this class with respect to the given library, or `null` if t
he look up | 5563 * up the constructor with the given [name] in this class with respect to the |
| 5977 * fails. The behavior of this method is defined by the Dart Language Specific
ation in section | 5564 * given [library], or `null` if the look up fails. The behavior of this |
| 5978 * 12.11.1: <blockquote>If <i>e</i> is of the form <b>new</b> <i>T.id()</i> th
en let <i>q<i> be | 5565 * method is defined by the Dart Language Specification in section 12.11.1: |
| 5979 * the constructor <i>T.id</i>, otherwise let <i>q<i> be the constructor <i>T<
i>. Otherwise, if | 5566 * <blockquote> |
| 5980 * <i>q</i> is not defined or not accessible, a NoSuchMethodException is throw
n. </blockquote> | 5567 * If <i>e</i> is of the form <b>new</b> <i>T.id()</i> then let <i>q<i> be the |
| 5981 * | 5568 * constructor <i>T.id</i>, otherwise let <i>q<i> be the constructor <i>T<i>. |
| 5982 * @param constructorName the name of the constructor being looked up | 5569 * Otherwise, if <i>q</i> is not defined or not accessible, a |
| 5983 * @param library the library with respect to which the lookup is being perfor
med | 5570 * NoSuchMethodException is thrown. |
| 5984 * @return the result of looking up the given constructor in this class with r
espect to the given | 5571 * </blockquote> |
| 5985 * library | 5572 */ |
| 5986 */ | 5573 ConstructorElement lookUpConstructor(String name, LibraryElement library); |
| 5987 ConstructorElement lookUpConstructor( | 5574 |
| 5988 String constructorName, LibraryElement library); | 5575 /** |
| 5989 | 5576 * Return the element representing the getter that results from looking up the |
| 5990 /** | 5577 * getter with the given [name] in this class with respect to the given |
| 5991 * Return the element representing the getter that results from looking up the
given getter in | 5578 * [library], or `null` if the look up fails. The behavior of this method is |
| 5992 * this class with respect to the given library, or `null` if the look up fail
s. The | 5579 * defined by the Dart Language Specification in section 12.15.1: |
| 5993 * behavior of this method is defined by the Dart Language Specification in se
ction 12.15.1: | 5580 * <blockquote> |
| 5994 * <blockquote>The result of looking up getter (respectively setter) <i>m</i>
in class <i>C</i> | 5581 * The result of looking up getter (respectively setter) <i>m</i> in class |
| 5995 * with respect to library <i>L</i> is: | 5582 * <i>C</i> with respect to library <i>L</i> is: |
| 5996 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is | 5583 * * If <i>C</i> declares an instance getter (respectively setter) named |
| 5997 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. | 5584 * <i>m</i> that is accessible to <i>L</i>, then that getter (respectively |
| 5998 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result | 5585 * setter) is the result of the lookup. Otherwise, if <i>C</i> has a |
| 5999 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. | 5586 * superclass <i>S</i>, then the result of the lookup is the result of |
| 5587 * looking up getter (respectively setter) <i>m</i> in <i>S</i> with respect |
| 5588 * to <i>L</i>. Otherwise, we say that the lookup has failed. |
| 5589 * </blockquote> |
| 5590 */ |
| 5591 PropertyAccessorElement lookUpGetter( |
| 5592 String name, LibraryElement library); |
| 5593 |
| 5594 /** |
| 5595 * Return the element representing the getter that results from looking up the |
| 5596 * getter with the given [name] in the superclass of this class with respect |
| 5597 * to the given [library], or `null` if the look up fails. The behavior of |
| 5598 * this method is defined by the Dart Language Specification in section |
| 5599 * 12.15.1: |
| 5600 * <blockquote> |
| 5601 * The result of looking up getter (respectively setter) <i>m</i> in class |
| 5602 * <i>C</i> with respect to library <i>L</i> is: |
| 5603 * * If <i>C</i> declares an instance getter (respectively setter) named |
| 5604 * <i>m</i> that is accessible to <i>L</i>, then that getter (respectively |
| 5605 * setter) is the result of the lookup. Otherwise, if <i>C</i> has a |
| 5606 * superclass <i>S</i>, then the result of the lookup is the result of |
| 5607 * looking up getter (respectively setter) <i>m</i> in <i>S</i> with respect |
| 5608 * to <i>L</i>. Otherwise, we say that the lookup has failed. |
| 5609 * </blockquote> |
| 5610 */ |
| 5611 PropertyAccessorElement lookUpGetterInSuperclass( |
| 5612 String name, LibraryElement library); |
| 5613 |
| 5614 /** |
| 5615 * Return the element representing the method that results from looking up the |
| 5616 * method with the given [name] in this class with respect to the given |
| 5617 * [library], or `null` if the look up fails. The behavior of this method is |
| 5618 * defined by the Dart Language Specification in section 12.15.1: |
| 5619 * <blockquote> |
| 5620 * The result of looking up method <i>m</i> in class <i>C</i> with respect to |
| 5621 * library <i>L</i> is: |
| 5622 * * If <i>C</i> declares an instance method named <i>m</i> that is accessible |
| 5623 * to <i>L</i>, then that method is the result of the lookup. Otherwise, if |
| 5624 * <i>C</i> has a superclass <i>S</i>, then the result of the lookup is the |
| 5625 * result of looking up method <i>m</i> in <i>S</i> with respect to <i>L</i> |
| 5626 * Otherwise, we say that the lookup has failed. |
| 5627 * </blockquote> |
| 5628 */ |
| 5629 MethodElement lookUpMethod(String name, LibraryElement library); |
| 5630 |
| 5631 /** |
| 5632 * Return the element representing the method that results from looking up the |
| 5633 * method with the given [name] in the superclass of this class with respect |
| 5634 * to the given [library], or `null` if the look up fails. The behavior of |
| 5635 * this method is defined by the Dart Language Specification in section |
| 5636 * 12.15.1: |
| 5637 * <blockquote> |
| 5638 * The result of looking up method <i>m</i> in class <i>C</i> with respect to |
| 5639 * library <i>L</i> is: |
| 5640 * * If <i>C</i> declares an instance method named <i>m</i> that is accessible |
| 5641 * to <i>L</i>, then that method is the result of the lookup. Otherwise, if |
| 5642 * <i>C</i> has a superclass <i>S</i>, then the result of the lookup is the |
| 5643 * result of looking up method <i>m</i> in <i>S</i> with respect to <i>L</i>. |
| 6000 * Otherwise, we say that the lookup has failed. | 5644 * Otherwise, we say that the lookup has failed. |
| 6001 * </blockquote> | 5645 * </blockquote> |
| 6002 * | |
| 6003 * @param getterName the name of the getter being looked up | |
| 6004 * @param library the library with respect to which the lookup is being perfor
med | |
| 6005 * @return the result of looking up the given getter in this class with respec
t to the given | |
| 6006 * library | |
| 6007 */ | |
| 6008 PropertyAccessorElement lookUpGetter( | |
| 6009 String getterName, LibraryElement library); | |
| 6010 | |
| 6011 /** | |
| 6012 * Return the element representing the getter that results from looking up the
given getter in the | |
| 6013 * superclass of this class with respect to the given library, or `null` if th
e look up | |
| 6014 * fails. The behavior of this method is defined by the Dart Language Specific
ation in section | |
| 6015 * 12.15.1: <blockquote>The result of looking up getter (respectively setter)
<i>m</i> in class | |
| 6016 * <i>C</i> with respect to library <i>L</i> is: | |
| 6017 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is | |
| 6018 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. | |
| 6019 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result | |
| 6020 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. | |
| 6021 * Otherwise, we say that the lookup has failed. | |
| 6022 * </blockquote> | |
| 6023 * | |
| 6024 * @param getterName the name of the getter being looked up | |
| 6025 * @param library the library with respect to which the lookup is being perfor
med | |
| 6026 * @return the result of looking up the given getter in this class with respec
t to the given | |
| 6027 * library | |
| 6028 */ | |
| 6029 PropertyAccessorElement lookUpGetterInSuperclass( | |
| 6030 String getterName, LibraryElement library); | |
| 6031 | |
| 6032 /** | |
| 6033 * Return the element representing the method that results from looking up the
given method in | |
| 6034 * this class with respect to the given library, or `null` if the look up fail
s. The | |
| 6035 * behavior of this method is defined by the Dart Language Specification in se
ction 12.15.1: | |
| 6036 * <blockquote> The result of looking up method <i>m</i> in class <i>C</i> wit
h respect to library | |
| 6037 * <i>L</i> is: | |
| 6038 * * If <i>C</i> declares an instance method named <i>m</i> that is accessible
to <i>L</i>, then | |
| 6039 * that method is the result of the lookup. Otherwise, if <i>C</i> has a super
class <i>S</i>, then | |
| 6040 * the result of the lookup is the result of looking up method <i>m</i> in <i>
S</i> with respect | |
| 6041 * to <i>L</i>. Otherwise, we say that the lookup has failed. | |
| 6042 * </blockquote> | |
| 6043 * | |
| 6044 * @param methodName the name of the method being looked up | |
| 6045 * @param library the library with respect to which the lookup is being perfor
med | |
| 6046 * @return the result of looking up the given method in this class with respec
t to the given | |
| 6047 * library | |
| 6048 */ | |
| 6049 MethodElement lookUpMethod(String methodName, LibraryElement library); | |
| 6050 | |
| 6051 /** | |
| 6052 * Return the element representing the method that results from looking up the
given method in the | |
| 6053 * superclass of this class with respect to the given library, or `null` if th
e look up | |
| 6054 * fails. The behavior of this method is defined by the Dart Language Specific
ation in section | |
| 6055 * 12.15.1: <blockquote> The result of looking up method <i>m</i> in class <i>
C</i> with respect | |
| 6056 * to library <i>L</i> is: | |
| 6057 * * If <i>C</i> declares an instance method named <i>m</i> that is accessible
to <i>L</i>, then | |
| 6058 * that method is the result of the lookup. Otherwise, if <i>C</i> has a super
class <i>S</i>, then | |
| 6059 * the result of the lookup is the result of looking up method <i>m</i> in <i>
S</i> with respect | |
| 6060 * to <i>L</i>. Otherwise, we say that the lookup has failed. | |
| 6061 * </blockquote> | |
| 6062 * | |
| 6063 * @param methodName the name of the method being looked up | |
| 6064 * @param library the library with respect to which the lookup is being perfor
med | |
| 6065 * @return the result of looking up the given method in this class with respec
t to the given | |
| 6066 * library | |
| 6067 */ | 5646 */ |
| 6068 MethodElement lookUpMethodInSuperclass( | 5647 MethodElement lookUpMethodInSuperclass( |
| 6069 String methodName, LibraryElement library); | 5648 String name, LibraryElement library); |
| 6070 | 5649 |
| 6071 /** | 5650 /** |
| 6072 * Return the element representing the setter that results from looking up the
given setter in | 5651 * Return the element representing the setter that results from looking up the |
| 6073 * this class with respect to the given library, or `null` if the look up fail
s. The | 5652 * setter with the given [name] in this class with respect to the given |
| 6074 * behavior of this method is defined by the Dart Language Specification in se
ction 12.16: | 5653 * [library], or `null` if the look up fails. The behavior of this method is |
| 6075 * <blockquote> The result of looking up getter (respectively setter) <i>m</i>
in class <i>C</i> | 5654 * defined by the Dart Language Specification in section 12.16: |
| 6076 * with respect to library <i>L</i> is: | 5655 * <blockquote> |
| 6077 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is | 5656 * The result of looking up getter (respectively setter) <i>m</i> in class |
| 6078 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. | 5657 * <i>C</i> with respect to library <i>L</i> is: |
| 6079 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result | 5658 * * If <i>C</i> declares an instance getter (respectively setter) named |
| 6080 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. | 5659 * <i>m</i> that is accessible to <i>L</i>, then that getter (respectively |
| 6081 * Otherwise, we say that the lookup has failed. | 5660 * setter) is the result of the lookup. Otherwise, if <i>C</i> has a |
| 6082 * </blockquote> | 5661 * superclass <i>S</i>, then the result of the lookup is the result of |
| 6083 * | 5662 * looking up getter (respectively setter) <i>m</i> in <i>S</i> with respect |
| 6084 * @param setterName the name of the setter being looked up | 5663 * to <i>L</i>. Otherwise, we say that the lookup has failed. |
| 6085 * @param library the library with respect to which the lookup is being perfor
med | 5664 * </blockquote> |
| 6086 * @return the result of looking up the given setter in this class with respec
t to the given | |
| 6087 * library | |
| 6088 */ | 5665 */ |
| 6089 PropertyAccessorElement lookUpSetter( | 5666 PropertyAccessorElement lookUpSetter( |
| 6090 String setterName, LibraryElement library); | 5667 String name, LibraryElement library); |
| 6091 | 5668 |
| 6092 /** | 5669 /** |
| 6093 * Return the element representing the setter that results from looking up the
given setter in the | 5670 * Return the element representing the setter that results from looking up the |
| 6094 * superclass of this class with respect to the given library, or `null` if th
e look up | 5671 * setter with the given [name] in the superclass of this class with respect |
| 6095 * fails. The behavior of this method is defined by the Dart Language Specific
ation in section | 5672 * to the given [library], or `null` if the look up fails. The behavior of |
| 6096 * 12.16: <blockquote> The result of looking up getter (respectively setter) <
i>m</i> in class | 5673 * this method is defined by the Dart Language Specification in section 12.16: |
| 6097 * <i>C</i> with respect to library <i>L</i> is: | 5674 * <blockquote> |
| 6098 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is | 5675 * The result of looking up getter (respectively setter) <i>m</i> in class |
| 6099 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. | 5676 * <i>C</i> with respect to library <i>L</i> is: |
| 6100 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result | 5677 * * If <i>C</i> declares an instance getter (respectively setter) named |
| 6101 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. | 5678 * <i>m</i> that is accessible to <i>L</i>, then that getter (respectively |
| 6102 * Otherwise, we say that the lookup has failed. | 5679 * setter) is the result of the lookup. Otherwise, if <i>C</i> has a |
| 6103 * </blockquote> | 5680 * superclass <i>S</i>, then the result of the lookup is the result of |
| 6104 * | 5681 * looking up getter (respectively setter) <i>m</i> in <i>S</i> with respect |
| 6105 * @param setterName the name of the setter being looked up | 5682 * to <i>L</i>. Otherwise, we say that the lookup has failed. |
| 6106 * @param library the library with respect to which the lookup is being perfor
med | 5683 * </blockquote> |
| 6107 * @return the result of looking up the given setter in this class with respec
t to the given | |
| 6108 * library | |
| 6109 */ | 5684 */ |
| 6110 PropertyAccessorElement lookUpSetterInSuperclass( | 5685 PropertyAccessorElement lookUpSetterInSuperclass( |
| 6111 String setterName, LibraryElement library); | 5686 String name, LibraryElement library); |
| 6112 | 5687 |
| 6113 @override | 5688 @override |
| 6114 InterfaceType substitute2( | 5689 InterfaceType substitute2( |
| 6115 List<DartType> argumentTypes, List<DartType> parameterTypes); | 5690 List<DartType> argumentTypes, List<DartType> parameterTypes); |
| 6116 | 5691 |
| 6117 /** | 5692 /** |
| 6118 * Return the type resulting from substituting the given arguments for this | 5693 * Return the type resulting from substituting the given arguments for this |
| 6119 * type's parameters. This is fully equivalent to `substitute2(argumentTypes, | 5694 * type's parameters. This is fully equivalent to `substitute2(argumentTypes, |
| 6120 * getTypeArguments())`. | 5695 * getTypeArguments())`. |
| 6121 */ | 5696 */ |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6177 lubArguments[i] = DynamicTypeImpl.instance; | 5752 lubArguments[i] = DynamicTypeImpl.instance; |
| 6178 } | 5753 } |
| 6179 } | 5754 } |
| 6180 InterfaceTypeImpl lub = new InterfaceTypeImpl.con1(firstElement); | 5755 InterfaceTypeImpl lub = new InterfaceTypeImpl.con1(firstElement); |
| 6181 lub.typeArguments = lubArguments; | 5756 lub.typeArguments = lubArguments; |
| 6182 return lub; | 5757 return lub; |
| 6183 } | 5758 } |
| 6184 } | 5759 } |
| 6185 | 5760 |
| 6186 /** | 5761 /** |
| 6187 * Instances of the class `InterfaceTypeImpl` defines the behavior common to obj
ects | 5762 * A concrete implementation of an [InterfaceType]. |
| 6188 * representing the type introduced by either a class or an interface, or a refe
rence to such a | |
| 6189 * type. | |
| 6190 */ | 5763 */ |
| 6191 class InterfaceTypeImpl extends TypeImpl implements InterfaceType { | 5764 class InterfaceTypeImpl extends TypeImpl implements InterfaceType { |
| 6192 /** | 5765 /** |
| 6193 * An array containing the actual types of the type arguments. | 5766 * A list containing the actual types of the type arguments. |
| 6194 */ | 5767 */ |
| 6195 List<DartType> typeArguments = TypeImpl.EMPTY_ARRAY; | 5768 List<DartType> typeArguments = TypeImpl.EMPTY_ARRAY; |
| 6196 | 5769 |
| 6197 /** | 5770 /** |
| 6198 * Initialize a newly created type to be declared by the given element. | 5771 * Initialize a newly created type to be declared by the given [element]. |
| 6199 * | |
| 6200 * @param element the element representing the declaration of the type | |
| 6201 */ | 5772 */ |
| 6202 InterfaceTypeImpl.con1(ClassElement element) | 5773 InterfaceTypeImpl.con1(ClassElement element) |
| 6203 : super(element, element.displayName); | 5774 : super(element, element.displayName); |
| 6204 | 5775 |
| 6205 /** | 5776 /** |
| 6206 * Initialize a newly created type to have the given name. This constructor sh
ould only be used in | 5777 * Initialize a newly created type to have the given [name]. This constructor |
| 6207 * cases where there is no declaration of the type. | 5778 * should only be used in cases where there is no declaration of the type. |
| 6208 * | |
| 6209 * @param name the name of the type | |
| 6210 */ | 5779 */ |
| 6211 InterfaceTypeImpl.con2(String name) : super(null, name); | 5780 InterfaceTypeImpl.con2(String name) : super(null, name); |
| 6212 | 5781 |
| 6213 @override | 5782 @override |
| 6214 List<PropertyAccessorElement> get accessors { | 5783 List<PropertyAccessorElement> get accessors { |
| 6215 List<PropertyAccessorElement> accessors = element.accessors; | 5784 List<PropertyAccessorElement> accessors = element.accessors; |
| 6216 List<PropertyAccessorElement> members = | 5785 List<PropertyAccessorElement> members = |
| 6217 new List<PropertyAccessorElement>(accessors.length); | 5786 new List<PropertyAccessorElement>(accessors.length); |
| 6218 for (int i = 0; i < accessors.length; i++) { | 5787 for (int i = 0; i < accessors.length; i++) { |
| 6219 members[i] = PropertyAccessorMember.from(accessors[i], this); | 5788 members[i] = PropertyAccessorMember.from(accessors[i], this); |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6893 for (InterfaceType mixinType in mixinTypes) { | 6462 for (InterfaceType mixinType in mixinTypes) { |
| 6894 if ((mixinType as InterfaceTypeImpl)._isSubtypeOf( | 6463 if ((mixinType as InterfaceTypeImpl)._isSubtypeOf( |
| 6895 typeS, visitedClasses, visitedTypePairs)) { | 6464 typeS, visitedClasses, visitedTypePairs)) { |
| 6896 return true; | 6465 return true; |
| 6897 } | 6466 } |
| 6898 } | 6467 } |
| 6899 return false; | 6468 return false; |
| 6900 } | 6469 } |
| 6901 | 6470 |
| 6902 /** | 6471 /** |
| 6903 * This method computes the longest inheritance path from some passed [Type] t
o Object. | 6472 * Return the length of the longest inheritance path from the given [type] to |
| 6473 * Object. |
| 6904 * | 6474 * |
| 6905 * @param type the [Type] to compute the longest inheritance path of from the
passed | |
| 6906 * [Type] to Object | |
| 6907 * @return the computed longest inheritance path to Object | |
| 6908 * See [InterfaceType.getLeastUpperBound]. | 6475 * See [InterfaceType.getLeastUpperBound]. |
| 6909 */ | 6476 */ |
| 6910 static int computeLongestInheritancePathToObject(InterfaceType type) => | 6477 static int computeLongestInheritancePathToObject(InterfaceType type) => |
| 6911 _computeLongestInheritancePathToObject( | 6478 _computeLongestInheritancePathToObject( |
| 6912 type, 0, new HashSet<ClassElement>()); | 6479 type, 0, new HashSet<ClassElement>()); |
| 6913 | 6480 |
| 6914 /** | 6481 /** |
| 6915 * Returns the set of all superinterfaces of the passed [Type]. | 6482 * Returns the set of all superinterfaces of the given [type]. |
| 6916 * | 6483 * |
| 6917 * @param type the [Type] to compute the set of superinterfaces of | |
| 6918 * @return the [Set] of superinterfaces of the passed [Type] | |
| 6919 * See [getLeastUpperBound]. | 6484 * See [getLeastUpperBound]. |
| 6920 */ | 6485 */ |
| 6921 static Set<InterfaceType> computeSuperinterfaceSet(InterfaceType type) => | 6486 static Set<InterfaceType> computeSuperinterfaceSet(InterfaceType type) => |
| 6922 _computeSuperinterfaceSet(type, new HashSet<InterfaceType>()); | 6487 _computeSuperinterfaceSet(type, new HashSet<InterfaceType>()); |
| 6923 | 6488 |
| 6924 /** | 6489 /** |
| 6925 * This method computes the longest inheritance path from some passed [Type] t
o Object. This | 6490 * Return the length of the longest inheritance path from a subtype of the |
| 6926 * method calls itself recursively, callers should use the public method | 6491 * given [type] to Object, where the given [depth] is the length of the |
| 6927 * [computeLongestInheritancePathToObject]. | 6492 * longest path from the subtype to this type. The set of [visitedTypes] is |
| 6493 * used to prevent infinite recursion in the case of a cyclic type structure. |
| 6928 * | 6494 * |
| 6929 * @param type the [Type] to compute the longest inheritance path of from the
passed | |
| 6930 * [Type] to Object | |
| 6931 * @param depth a field used recursively | |
| 6932 * @param visitedClasses the classes that have already been visited | |
| 6933 * @return the computed longest inheritance path to Object | |
| 6934 * See [computeLongestInheritancePathToObject], and [getLeastUpperBound]. | 6495 * See [computeLongestInheritancePathToObject], and [getLeastUpperBound]. |
| 6935 */ | 6496 */ |
| 6936 static int _computeLongestInheritancePathToObject( | 6497 static int _computeLongestInheritancePathToObject( |
| 6937 InterfaceType type, int depth, HashSet<ClassElement> visitedClasses) { | 6498 InterfaceType type, int depth, HashSet<ClassElement> visitedTypes) { |
| 6938 ClassElement classElement = type.element; | 6499 ClassElement classElement = type.element; |
| 6939 // Object case | 6500 // Object case |
| 6940 if (classElement.supertype == null || | 6501 if (classElement.supertype == null || |
| 6941 visitedClasses.contains(classElement)) { | 6502 visitedTypes.contains(classElement)) { |
| 6942 return depth; | 6503 return depth; |
| 6943 } | 6504 } |
| 6944 int longestPath = 1; | 6505 int longestPath = 1; |
| 6945 try { | 6506 try { |
| 6946 visitedClasses.add(classElement); | 6507 visitedTypes.add(classElement); |
| 6947 List<InterfaceType> superinterfaces = classElement.interfaces; | 6508 List<InterfaceType> superinterfaces = classElement.interfaces; |
| 6948 int pathLength; | 6509 int pathLength; |
| 6949 if (superinterfaces.length > 0) { | 6510 if (superinterfaces.length > 0) { |
| 6950 // loop through each of the superinterfaces recursively calling this | 6511 // loop through each of the superinterfaces recursively calling this |
| 6951 // method and keeping track of the longest path to return | 6512 // method and keeping track of the longest path to return |
| 6952 for (InterfaceType superinterface in superinterfaces) { | 6513 for (InterfaceType superinterface in superinterfaces) { |
| 6953 pathLength = _computeLongestInheritancePathToObject( | 6514 pathLength = _computeLongestInheritancePathToObject( |
| 6954 superinterface, depth + 1, visitedClasses); | 6515 superinterface, depth + 1, visitedTypes); |
| 6955 if (pathLength > longestPath) { | 6516 if (pathLength > longestPath) { |
| 6956 longestPath = pathLength; | 6517 longestPath = pathLength; |
| 6957 } | 6518 } |
| 6958 } | 6519 } |
| 6959 } | 6520 } |
| 6960 // finally, perform this same check on the super type | 6521 // finally, perform this same check on the super type |
| 6961 // TODO(brianwilkerson) Does this also need to add in the number of mixin | 6522 // TODO(brianwilkerson) Does this also need to add in the number of mixin |
| 6962 // classes? | 6523 // classes? |
| 6963 InterfaceType supertype = classElement.supertype; | 6524 InterfaceType supertype = classElement.supertype; |
| 6964 pathLength = _computeLongestInheritancePathToObject( | 6525 pathLength = _computeLongestInheritancePathToObject( |
| 6965 supertype, depth + 1, visitedClasses); | 6526 supertype, depth + 1, visitedTypes); |
| 6966 if (pathLength > longestPath) { | 6527 if (pathLength > longestPath) { |
| 6967 longestPath = pathLength; | 6528 longestPath = pathLength; |
| 6968 } | 6529 } |
| 6969 } finally { | 6530 } finally { |
| 6970 visitedClasses.remove(classElement); | 6531 visitedTypes.remove(classElement); |
| 6971 } | 6532 } |
| 6972 return longestPath; | 6533 return longestPath; |
| 6973 } | 6534 } |
| 6974 | 6535 |
| 6975 /** | 6536 /** |
| 6976 * Returns the set of all superinterfaces of the passed [Type]. This is a recu
rsive method, | 6537 * Add all of the superinterfaces of the given [type] to the given [set]. |
| 6977 * callers should call the public [computeSuperinterfaceSet]. | 6538 * Return the [set] as a convenience. |
| 6978 * | 6539 * |
| 6979 * @param type the [Type] to compute the set of superinterfaces of | |
| 6980 * @param set a [HashSet] used recursively by this method | |
| 6981 * @return the [Set] of superinterfaces of the passed [Type] | |
| 6982 * See [computeSuperinterfaceSet], and [getLeastUpperBound]. | 6540 * See [computeSuperinterfaceSet], and [getLeastUpperBound]. |
| 6983 */ | 6541 */ |
| 6984 static Set<InterfaceType> _computeSuperinterfaceSet( | 6542 static Set<InterfaceType> _computeSuperinterfaceSet( |
| 6985 InterfaceType type, HashSet<InterfaceType> set) { | 6543 InterfaceType type, HashSet<InterfaceType> set) { |
| 6986 Element element = type.element; | 6544 Element element = type.element; |
| 6987 if (element != null) { | 6545 if (element != null) { |
| 6988 List<InterfaceType> superinterfaces = type.interfaces; | 6546 List<InterfaceType> superinterfaces = type.interfaces; |
| 6989 for (InterfaceType superinterface in superinterfaces) { | 6547 for (InterfaceType superinterface in superinterfaces) { |
| 6990 if (set.add(superinterface)) { | 6548 if (set.add(superinterface)) { |
| 6991 _computeSuperinterfaceSet(superinterface, set); | 6549 _computeSuperinterfaceSet(superinterface, set); |
| 6992 } | 6550 } |
| 6993 } | 6551 } |
| 6994 InterfaceType supertype = type.superclass; | 6552 InterfaceType supertype = type.superclass; |
| 6995 if (supertype != null) { | 6553 if (supertype != null) { |
| 6996 if (set.add(supertype)) { | 6554 if (set.add(supertype)) { |
| 6997 _computeSuperinterfaceSet(supertype, set); | 6555 _computeSuperinterfaceSet(supertype, set); |
| 6998 } | 6556 } |
| 6999 } | 6557 } |
| 7000 } | 6558 } |
| 7001 return set; | 6559 return set; |
| 7002 } | 6560 } |
| 7003 | 6561 |
| 7004 /** | 6562 /** |
| 7005 * Return the intersection of the given sets of types, where intersection is b
ased on the equality | 6563 * Return the intersection of the [first] and [second] sets of types, where |
| 7006 * of the types themselves. | 6564 * intersection is based on the equality of the types themselves. |
| 7007 * | |
| 7008 * @param first the first set of types to be intersected | |
| 7009 * @param second the second set of types to be intersected | |
| 7010 * @return the intersection of the given sets of types | |
| 7011 */ | 6565 */ |
| 7012 static List<InterfaceType> _intersection( | 6566 static List<InterfaceType> _intersection( |
| 7013 Set<InterfaceType> first, Set<InterfaceType> second) { | 6567 Set<InterfaceType> first, Set<InterfaceType> second) { |
| 7014 Set<InterfaceType> result = new HashSet<InterfaceType>.from(first); | 6568 Set<InterfaceType> result = new HashSet<InterfaceType>.from(first); |
| 7015 result.retainAll(second); | 6569 result.retainAll(second); |
| 7016 return new List.from(result); | 6570 return new List.from(result); |
| 7017 } | 6571 } |
| 7018 } | 6572 } |
| 7019 | 6573 |
| 7020 /** | 6574 /** |
| 7021 * The interface `LabelElement` defines the behavior of elements representing a
label | 6575 * A label associated with a statement. |
| 7022 * associated with a statement. | |
| 7023 */ | 6576 */ |
| 7024 abstract class LabelElement implements Element { | 6577 abstract class LabelElement implements Element { |
| 7025 /** | 6578 /** |
| 7026 * Return the executable element in which this label is defined. | 6579 * Return the executable element in which this label is defined. |
| 7027 * | |
| 7028 * @return the executable element in which this label is defined | |
| 7029 */ | 6580 */ |
| 7030 @override | 6581 @override |
| 7031 ExecutableElement get enclosingElement; | 6582 ExecutableElement get enclosingElement; |
| 7032 } | 6583 } |
| 7033 | 6584 |
| 7034 /** | 6585 /** |
| 7035 * Instances of the class `LabelElementImpl` implement a `LabelElement`. | 6586 * A concrete implementation of a [LabelElement]. |
| 7036 */ | 6587 */ |
| 7037 class LabelElementImpl extends ElementImpl implements LabelElement { | 6588 class LabelElementImpl extends ElementImpl implements LabelElement { |
| 7038 /** | 6589 /** |
| 7039 * An empty list of label elements. | 6590 * An empty list of label elements. |
| 7040 */ | 6591 */ |
| 7041 static const List<LabelElement> EMPTY_ARRAY = const <LabelElement>[]; | 6592 static const List<LabelElement> EMPTY_ARRAY = const <LabelElement>[]; |
| 7042 | 6593 |
| 7043 /** | 6594 /** |
| 7044 * A flag indicating whether this label is associated with a `switch` statemen
t. | 6595 * A flag indicating whether this label is associated with a `switch` |
| 6596 * statement. |
| 7045 */ | 6597 */ |
| 6598 // TODO(brianwilkerson) Make this a modifier. |
| 7046 final bool _onSwitchStatement; | 6599 final bool _onSwitchStatement; |
| 7047 | 6600 |
| 7048 /** | 6601 /** |
| 7049 * A flag indicating whether this label is associated with a `switch` member (
`case` | 6602 * A flag indicating whether this label is associated with a `switch` member |
| 7050 * or `default`). | 6603 * (`case` or `default`). |
| 7051 */ | 6604 */ |
| 6605 // TODO(brianwilkerson) Make this a modifier. |
| 7052 final bool _onSwitchMember; | 6606 final bool _onSwitchMember; |
| 7053 | 6607 |
| 7054 /** | 6608 /** |
| 7055 * Initialize a newly created label element to have the given name. | 6609 * Initialize a newly created label element to have the given [name]. |
| 7056 * | 6610 * [onSwitchStatement] should be `true` if this label is associated with a |
| 7057 * @param name the name of this element | 6611 * `switch` statement and [onSwitchMember] should be `true` if this label is |
| 7058 * @param onSwitchStatement `true` if this label is associated with a `switch` | 6612 * associated with a `switch` member. |
| 7059 * statement | |
| 7060 * @param onSwitchMember `true` if this label is associated with a `switch` me
mber | |
| 7061 */ | 6613 */ |
| 7062 LabelElementImpl( | 6614 LabelElementImpl( |
| 7063 Identifier name, this._onSwitchStatement, this._onSwitchMember) | 6615 Identifier name, this._onSwitchStatement, this._onSwitchMember) |
| 7064 : super.forNode(name); | 6616 : super.forNode(name); |
| 7065 | 6617 |
| 7066 @override | 6618 @override |
| 7067 ExecutableElement get enclosingElement => | 6619 ExecutableElement get enclosingElement => |
| 7068 super.enclosingElement as ExecutableElement; | 6620 super.enclosingElement as ExecutableElement; |
| 7069 | 6621 |
| 7070 /** | 6622 /** |
| 7071 * Return `true` if this label is associated with a `switch` member (`case` or | 6623 * Return `true` if this label is associated with a `switch` member (`case` or |
| 7072 * `default`). | 6624 * `default`). |
| 7073 * | |
| 7074 * @return `true` if this label is associated with a `switch` member | |
| 7075 */ | 6625 */ |
| 7076 bool get isOnSwitchMember => _onSwitchMember; | 6626 bool get isOnSwitchMember => _onSwitchMember; |
| 7077 | 6627 |
| 7078 /** | 6628 /** |
| 7079 * Return `true` if this label is associated with a `switch` statement. | 6629 * Return `true` if this label is associated with a `switch` statement. |
| 7080 * | |
| 7081 * @return `true` if this label is associated with a `switch` statement | |
| 7082 */ | 6630 */ |
| 7083 bool get isOnSwitchStatement => _onSwitchStatement; | 6631 bool get isOnSwitchStatement => _onSwitchStatement; |
| 7084 | 6632 |
| 7085 @override | 6633 @override |
| 7086 ElementKind get kind => ElementKind.LABEL; | 6634 ElementKind get kind => ElementKind.LABEL; |
| 7087 | 6635 |
| 7088 @override | 6636 @override |
| 7089 accept(ElementVisitor visitor) => visitor.visitLabelElement(this); | 6637 accept(ElementVisitor visitor) => visitor.visitLabelElement(this); |
| 7090 } | 6638 } |
| 7091 | 6639 |
| 7092 /** | 6640 /** |
| 7093 * The interface `LibraryElement` defines the behavior of elements representing
a library. | 6641 * A library. |
| 7094 */ | 6642 */ |
| 7095 abstract class LibraryElement implements Element { | 6643 abstract class LibraryElement implements Element { |
| 7096 /** | 6644 /** |
| 7097 * Return the compilation unit that defines this library. | 6645 * Return the compilation unit that defines this library. |
| 7098 * | |
| 7099 * @return the compilation unit that defines this library | |
| 7100 */ | 6646 */ |
| 7101 CompilationUnitElement get definingCompilationUnit; | 6647 CompilationUnitElement get definingCompilationUnit; |
| 7102 | 6648 |
| 7103 /** | 6649 /** |
| 7104 * Return the entry point for this library, or `null` if this library does not
have an entry | 6650 * Return the entry point for this library, or `null` if this library does not |
| 7105 * point. The entry point is defined to be a zero argument top-level function
whose name is | 6651 * have an entry point. The entry point is defined to be a zero argument |
| 7106 * `main`. | 6652 * top-level function whose name is `main`. |
| 7107 * | |
| 7108 * @return the entry point for this library | |
| 7109 */ | 6653 */ |
| 7110 FunctionElement get entryPoint; | 6654 FunctionElement get entryPoint; |
| 7111 | 6655 |
| 7112 /** | 6656 /** |
| 7113 * Return an array containing all of the libraries that are exported from this
library. | 6657 * Return a list containing all of the libraries that are exported from this |
| 7114 * | 6658 * library. |
| 7115 * @return an array containing all of the libraries that are exported from thi
s library | |
| 7116 */ | 6659 */ |
| 7117 List<LibraryElement> get exportedLibraries; | 6660 List<LibraryElement> get exportedLibraries; |
| 7118 | 6661 |
| 7119 /** | 6662 /** |
| 7120 * Return an array containing all of the exports defined in this library. | 6663 * Return a list containing all of the exports defined in this library. |
| 7121 * | |
| 7122 * @return the exports defined in this library | |
| 7123 */ | 6664 */ |
| 7124 List<ExportElement> get exports; | 6665 List<ExportElement> get exports; |
| 7125 | 6666 |
| 7126 /** | 6667 /** |
| 7127 * Return `true` if the defining compilation unit of this library contains at
least one | 6668 * Return `true` if the defining compilation unit of this library contains at |
| 7128 * import directive whose URI uses the "dart-ext" scheme. | 6669 * least one import directive whose URI uses the "dart-ext" scheme. |
| 7129 */ | 6670 */ |
| 7130 bool get hasExtUri; | 6671 bool get hasExtUri; |
| 7131 | 6672 |
| 7132 /** | 6673 /** |
| 7133 * Return `true` if this library defines a top-level function named `loadLibra
ry`. | 6674 * Return `true` if this library defines a top-level function named |
| 7134 * | 6675 * `loadLibrary`. |
| 7135 * @return `true` if this library defines a top-level function named `loadLibr
ary` | |
| 7136 */ | 6676 */ |
| 7137 bool get hasLoadLibraryFunction; | 6677 bool get hasLoadLibraryFunction; |
| 7138 | 6678 |
| 7139 /** | 6679 /** |
| 7140 * Return an array containing all of the libraries that are imported into this
library. This | 6680 * Return a list containing all of the libraries that are imported into this |
| 7141 * includes all of the libraries that are imported using a prefix (also availa
ble through the | 6681 * library. This includes all of the libraries that are imported using a |
| 7142 * prefixes returned by [getPrefixes]) and those that are imported without a p
refix. | 6682 * prefix (also available through the prefixes returned by [getPrefixes]) and |
| 7143 * | 6683 * those that are imported without a prefix. |
| 7144 * @return an array containing all of the libraries that are imported into thi
s library | |
| 7145 */ | 6684 */ |
| 7146 List<LibraryElement> get importedLibraries; | 6685 List<LibraryElement> get importedLibraries; |
| 7147 | 6686 |
| 7148 /** | 6687 /** |
| 7149 * Return an array containing all of the imports defined in this library. | 6688 * Return a list containing all of the imports defined in this library. |
| 7150 * | |
| 7151 * @return the imports defined in this library | |
| 7152 */ | 6689 */ |
| 7153 List<ImportElement> get imports; | 6690 List<ImportElement> get imports; |
| 7154 | 6691 |
| 7155 /** | 6692 /** |
| 7156 * Return `true` if this library is an application that can be run in the brow
ser. | 6693 * Return `true` if this library is an application that can be run in the |
| 7157 * | 6694 * browser. |
| 7158 * @return `true` if this library is an application that can be run in the bro
wser | |
| 7159 */ | 6695 */ |
| 7160 bool get isBrowserApplication; | 6696 bool get isBrowserApplication; |
| 7161 | 6697 |
| 7162 /** | 6698 /** |
| 7163 * Return `true` if this library is the dart:core library. | 6699 * Return `true` if this library is the dart:core library. |
| 7164 * | |
| 7165 * @return `true` if this library is the dart:core library | |
| 7166 */ | 6700 */ |
| 7167 bool get isDartCore; | 6701 bool get isDartCore; |
| 7168 | 6702 |
| 7169 /** | 6703 /** |
| 7170 * Return `true` if this library is the dart:core library. | 6704 * Return `true` if this library is the dart:core library. |
| 7171 * | |
| 7172 * @return `true` if this library is the dart:core library | |
| 7173 */ | 6705 */ |
| 7174 bool get isInSdk; | 6706 bool get isInSdk; |
| 7175 | 6707 |
| 7176 /** | 6708 /** |
| 7177 * Return the element representing the synthetic function `loadLibrary` that i
s implicitly | 6709 * Return the element representing the synthetic function `loadLibrary` that |
| 7178 * defined for this library if the library is imported using a deferred import
. | 6710 * is implicitly defined for this library if the library is imported using a |
| 6711 * deferred import. |
| 7179 */ | 6712 */ |
| 7180 FunctionElement get loadLibraryFunction; | 6713 FunctionElement get loadLibraryFunction; |
| 7181 | 6714 |
| 7182 /** | 6715 /** |
| 7183 * Return an array containing all of the compilation units that are included i
n this library using | 6716 * Return a list containing all of the compilation units that are included in |
| 7184 * a `part` directive. This does not include the defining compilation unit tha
t contains the | 6717 * this library using a `part` directive. This does not include the defining |
| 7185 * `part` directives. | 6718 * compilation unit that contains the `part` directives. |
| 7186 * | |
| 7187 * @return the compilation units that are included in this library | |
| 7188 */ | 6719 */ |
| 7189 List<CompilationUnitElement> get parts; | 6720 List<CompilationUnitElement> get parts; |
| 7190 | 6721 |
| 7191 /** | 6722 /** |
| 7192 * Return an array containing elements for each of the prefixes used to `impor
t` libraries | 6723 * Return a list containing elements for each of the prefixes used to `import` |
| 7193 * into this library. Each prefix can be used in more than one `import` direct
ive. | 6724 * libraries into this library. Each prefix can be used in more than one |
| 7194 * | 6725 * `import` directive. |
| 7195 * @return the prefixes used to `import` libraries into this library | |
| 7196 */ | 6726 */ |
| 7197 List<PrefixElement> get prefixes; | 6727 List<PrefixElement> get prefixes; |
| 7198 | 6728 |
| 7199 /** | 6729 /** |
| 7200 * Return an array containing all of the compilation units this library consis
ts of. This includes | 6730 * Return a list containing all of the compilation units this library consists |
| 7201 * the defining compilation unit and units included using the `part` directive
. | 6731 * of. This includes the defining compilation unit and units included using |
| 7202 * | 6732 * the `part` directive. |
| 7203 * @return the compilation units this library consists of | |
| 7204 */ | 6733 */ |
| 7205 List<CompilationUnitElement> get units; | 6734 List<CompilationUnitElement> get units; |
| 7206 | 6735 |
| 7207 /** | 6736 /** |
| 7208 * Return an array containing all directly and indirectly imported libraries. | 6737 * Return a list containing all directly and indirectly imported libraries. |
| 7209 * | |
| 7210 * @return all directly and indirectly imported libraries | |
| 7211 */ | 6738 */ |
| 7212 List<LibraryElement> get visibleLibraries; | 6739 List<LibraryElement> get visibleLibraries; |
| 7213 | 6740 |
| 7214 /** | 6741 /** |
| 7215 * Return an array containing all of the imports that share the given prefix,
or an empty array if | 6742 * Return a list containing all of the imports that share the given [prefix], |
| 7216 * there are no such imports. | 6743 * or an empty array if there are no such imports. |
| 7217 * | |
| 7218 * @param prefixElement the prefix element shared by the returned imports | |
| 7219 */ | 6744 */ |
| 7220 List<ImportElement> getImportsWithPrefix(PrefixElement prefixElement); | 6745 List<ImportElement> getImportsWithPrefix(PrefixElement prefix); |
| 7221 | 6746 |
| 7222 /** | 6747 /** |
| 7223 * Return the class defined in this library that has the given name, or `null`
if this | 6748 * Return the class defined in this library that has the given [name], or |
| 7224 * library does not define a class with the given name. | 6749 * `null` if this library does not define a class with the given name. |
| 7225 * | |
| 7226 * @param className the name of the class to be returned | |
| 7227 * @return the class with the given name that is defined in this library | |
| 7228 */ | 6750 */ |
| 7229 ClassElement getType(String className); | 6751 ClassElement getType(String className); |
| 7230 | 6752 |
| 7231 /** | 6753 /** |
| 7232 * Return `true` if this library is up to date with respect to the given time
stamp. If any | 6754 * Return `true` if this library is up to date with respect to the given |
| 7233 * transitively referenced Source is newer than the time stamp, this method re
turns false. | 6755 * [timeStamp]. If any transitively referenced Source is newer than the time |
| 7234 * | 6756 * stamp, this method returns false. |
| 7235 * @param timeStamp the time stamp to compare against | |
| 7236 * @return `true` if this library is up to date with respect to the given time
stamp | |
| 7237 */ | 6757 */ |
| 7238 bool isUpToDate(int timeStamp); | 6758 bool isUpToDate(int timeStamp); |
| 7239 } | 6759 } |
| 7240 | 6760 |
| 7241 /** | 6761 /** |
| 7242 * Instances of the class `LibraryElementImpl` implement a `LibraryElement`. | 6762 * A concrete implementation of a [LibraryElement]. |
| 7243 */ | 6763 */ |
| 7244 class LibraryElementImpl extends ElementImpl implements LibraryElement { | 6764 class LibraryElementImpl extends ElementImpl implements LibraryElement { |
| 7245 /** | 6765 /** |
| 7246 * An empty list of library elements. | 6766 * An empty list of library elements. |
| 7247 */ | 6767 */ |
| 7248 static const List<LibraryElement> EMPTY_ARRAY = const <LibraryElement>[]; | 6768 static const List<LibraryElement> EMPTY_ARRAY = const <LibraryElement>[]; |
| 7249 | 6769 |
| 7250 /** | 6770 /** |
| 7251 * The analysis context in which this library is defined. | 6771 * The analysis context in which this library is defined. |
| 7252 */ | 6772 */ |
| 7253 final AnalysisContext context; | 6773 final AnalysisContext context; |
| 7254 | 6774 |
| 7255 /** | 6775 /** |
| 7256 * The compilation unit that defines this library. | 6776 * The compilation unit that defines this library. |
| 7257 */ | 6777 */ |
| 7258 CompilationUnitElement _definingCompilationUnit; | 6778 CompilationUnitElement _definingCompilationUnit; |
| 7259 | 6779 |
| 7260 /** | 6780 /** |
| 7261 * The entry point for this library, or `null` if this library does not have a
n entry point. | 6781 * The entry point for this library, or `null` if this library does not have |
| 6782 * an entry point. |
| 7262 */ | 6783 */ |
| 7263 FunctionElement entryPoint; | 6784 FunctionElement entryPoint; |
| 7264 | 6785 |
| 7265 /** | 6786 /** |
| 7266 * An array containing specifications of all of the imports defined in this li
brary. | 6787 * A list containing specifications of all of the imports defined in this |
| 6788 * library. |
| 7267 */ | 6789 */ |
| 7268 List<ImportElement> _imports = ImportElement.EMPTY_ARRAY; | 6790 List<ImportElement> _imports = ImportElement.EMPTY_ARRAY; |
| 7269 | 6791 |
| 7270 /** | 6792 /** |
| 7271 * An array containing specifications of all of the exports defined in this li
brary. | 6793 * A list containing specifications of all of the exports defined in this |
| 6794 * library. |
| 7272 */ | 6795 */ |
| 7273 List<ExportElement> _exports = ExportElement.EMPTY_ARRAY; | 6796 List<ExportElement> _exports = ExportElement.EMPTY_ARRAY; |
| 7274 | 6797 |
| 7275 /** | 6798 /** |
| 7276 * An array containing all of the compilation units that are included in this
library using a | 6799 * A list containing all of the compilation units that are included in this |
| 7277 * `part` directive. | 6800 * library using a `part` directive. |
| 7278 */ | 6801 */ |
| 7279 List<CompilationUnitElement> _parts = CompilationUnitElementImpl.EMPTY_ARRAY; | 6802 List<CompilationUnitElement> _parts = CompilationUnitElementImpl.EMPTY_ARRAY; |
| 7280 | 6803 |
| 7281 /** | 6804 /** |
| 7282 * The element representing the synthetic function `loadLibrary` that is defin
ed for this | 6805 * The element representing the synthetic function `loadLibrary` that is |
| 7283 * library, or `null` if the element has not yet been created. | 6806 * defined for this library, or `null` if the element has not yet been created
. |
| 7284 */ | 6807 */ |
| 7285 FunctionElement _loadLibraryFunction; | 6808 FunctionElement _loadLibraryFunction; |
| 7286 | 6809 |
| 7287 /** | 6810 /** |
| 7288 * Initialize a newly created library element to have the given name. | 6811 * Initialize a newly created library element in the given [context] to have |
| 7289 * | 6812 * the given [name] and [offset]. |
| 7290 * @param context the analysis context in which the library is defined | |
| 7291 * @param name the name of this element | |
| 7292 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
| 7293 * declaration of this element | |
| 7294 */ | 6813 */ |
| 7295 LibraryElementImpl(this.context, String name, int nameOffset) | 6814 LibraryElementImpl(this.context, String name, int offset) |
| 7296 : super(name, nameOffset); | 6815 : super(name, offset); |
| 7297 | 6816 |
| 7298 /** | 6817 /** |
| 7299 * Initialize a newly created library element to have the given name. | 6818 * Initialize a newly created library element in the given [context] to have |
| 7300 * | 6819 * the given [name]. |
| 7301 * @param context the analysis context in which the library is defined | |
| 7302 * @param name the name of this element | |
| 7303 */ | 6820 */ |
| 7304 LibraryElementImpl.forNode(this.context, LibraryIdentifier name) | 6821 LibraryElementImpl.forNode(this.context, LibraryIdentifier name) |
| 7305 : super.forNode(name); | 6822 : super.forNode(name); |
| 7306 | 6823 |
| 7307 @override | 6824 @override |
| 7308 CompilationUnitElement get definingCompilationUnit => | 6825 CompilationUnitElement get definingCompilationUnit => |
| 7309 _definingCompilationUnit; | 6826 _definingCompilationUnit; |
| 7310 | 6827 |
| 7311 /** | 6828 /** |
| 7312 * Set the compilation unit that defines this library to the given compilation
unit. | 6829 * Set the compilation unit that defines this library to the given compilation |
| 7313 * | 6830 * [unit]. |
| 7314 * @param definingCompilationUnit the compilation unit that defines this libra
ry | |
| 7315 */ | 6831 */ |
| 7316 void set definingCompilationUnit( | 6832 void set definingCompilationUnit(CompilationUnitElement unit) { |
| 7317 CompilationUnitElement definingCompilationUnit) { | 6833 (unit as CompilationUnitElementImpl).enclosingElement = this; |
| 7318 (definingCompilationUnit as CompilationUnitElementImpl).enclosingElement = | 6834 this._definingCompilationUnit = unit; |
| 7319 this; | |
| 7320 this._definingCompilationUnit = definingCompilationUnit; | |
| 7321 } | 6835 } |
| 7322 | 6836 |
| 7323 @override | 6837 @override |
| 7324 List<LibraryElement> get exportedLibraries { | 6838 List<LibraryElement> get exportedLibraries { |
| 7325 HashSet<LibraryElement> libraries = new HashSet<LibraryElement>(); | 6839 HashSet<LibraryElement> libraries = new HashSet<LibraryElement>(); |
| 7326 for (ExportElement element in _exports) { | 6840 for (ExportElement element in _exports) { |
| 7327 LibraryElement library = element.exportedLibrary; | 6841 LibraryElement library = element.exportedLibrary; |
| 7328 if (library != null) { | 6842 if (library != null) { |
| 7329 libraries.add(library); | 6843 libraries.add(library); |
| 7330 } | 6844 } |
| 7331 } | 6845 } |
| 7332 return new List.from(libraries); | 6846 return new List.from(libraries); |
| 7333 } | 6847 } |
| 7334 | 6848 |
| 7335 @override | 6849 @override |
| 7336 List<ExportElement> get exports => _exports; | 6850 List<ExportElement> get exports => _exports; |
| 7337 | 6851 |
| 7338 /** | 6852 /** |
| 7339 * Set the specifications of all of the exports defined in this library to the
given array. | 6853 * Set the specifications of all of the exports defined in this library to the |
| 7340 * | 6854 * given list of [exports]. |
| 7341 * @param exports the specifications of all of the exports defined in this lib
rary | |
| 7342 */ | 6855 */ |
| 7343 void set exports(List<ExportElement> exports) { | 6856 void set exports(List<ExportElement> exports) { |
| 7344 for (ExportElement exportElement in exports) { | 6857 for (ExportElement exportElement in exports) { |
| 7345 (exportElement as ExportElementImpl).enclosingElement = this; | 6858 (exportElement as ExportElementImpl).enclosingElement = this; |
| 7346 } | 6859 } |
| 7347 this._exports = exports; | 6860 this._exports = exports; |
| 7348 } | 6861 } |
| 7349 | 6862 |
| 7350 @override | 6863 @override |
| 7351 bool get hasExtUri => hasModifier(Modifier.HAS_EXT_URI); | 6864 bool get hasExtUri => hasModifier(Modifier.HAS_EXT_URI); |
| 7352 | 6865 |
| 7353 /** | 6866 /** |
| 7354 * Set whether this library has an import of a "dart-ext" URI to the given val
ue. | 6867 * Set whether this library has an import of a "dart-ext" URI. |
| 7355 * | |
| 7356 * @param hasExtUri `true` if this library has an import of a "dart-ext" URI | |
| 7357 */ | 6868 */ |
| 7358 void set hasExtUri(bool hasExtUri) { | 6869 void set hasExtUri(bool hasExtUri) { |
| 7359 setModifier(Modifier.HAS_EXT_URI, hasExtUri); | 6870 setModifier(Modifier.HAS_EXT_URI, hasExtUri); |
| 7360 } | 6871 } |
| 7361 | 6872 |
| 7362 @override | 6873 @override |
| 7363 int get hashCode => _definingCompilationUnit.hashCode; | 6874 int get hashCode => _definingCompilationUnit.hashCode; |
| 7364 | 6875 |
| 7365 @override | 6876 @override |
| 7366 bool get hasLoadLibraryFunction { | 6877 bool get hasLoadLibraryFunction { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 7387 libraries.add(library); | 6898 libraries.add(library); |
| 7388 } | 6899 } |
| 7389 } | 6900 } |
| 7390 return new List.from(libraries); | 6901 return new List.from(libraries); |
| 7391 } | 6902 } |
| 7392 | 6903 |
| 7393 @override | 6904 @override |
| 7394 List<ImportElement> get imports => _imports; | 6905 List<ImportElement> get imports => _imports; |
| 7395 | 6906 |
| 7396 /** | 6907 /** |
| 7397 * Set the specifications of all of the imports defined in this library to the
given array. | 6908 * Set the specifications of all of the imports defined in this library to the |
| 7398 * | 6909 * given list of [imports]. |
| 7399 * @param imports the specifications of all of the imports defined in this lib
rary | |
| 7400 */ | 6910 */ |
| 7401 void set imports(List<ImportElement> imports) { | 6911 void set imports(List<ImportElement> imports) { |
| 7402 for (ImportElement importElement in imports) { | 6912 for (ImportElement importElement in imports) { |
| 7403 (importElement as ImportElementImpl).enclosingElement = this; | 6913 (importElement as ImportElementImpl).enclosingElement = this; |
| 7404 PrefixElementImpl prefix = importElement.prefix as PrefixElementImpl; | 6914 PrefixElementImpl prefix = importElement.prefix as PrefixElementImpl; |
| 7405 if (prefix != null) { | 6915 if (prefix != null) { |
| 7406 prefix.enclosingElement = this; | 6916 prefix.enclosingElement = this; |
| 7407 } | 6917 } |
| 7408 } | 6918 } |
| 7409 this._imports = imports; | 6919 this._imports = imports; |
| 7410 } | 6920 } |
| 7411 | 6921 |
| 7412 @override | 6922 @override |
| 7413 bool get isBrowserApplication => | 6923 bool get isBrowserApplication => |
| 7414 entryPoint != null && isOrImportsBrowserLibrary; | 6924 entryPoint != null && isOrImportsBrowserLibrary; |
| 7415 | 6925 |
| 7416 @override | 6926 @override |
| 7417 bool get isDartCore => name == "dart.core"; | 6927 bool get isDartCore => name == "dart.core"; |
| 7418 | 6928 |
| 7419 @override | 6929 @override |
| 7420 bool get isInSdk => | 6930 bool get isInSdk => |
| 7421 StringUtilities.startsWith5(name, 0, 0x64, 0x61, 0x72, 0x74, 0x2E); | 6931 StringUtilities.startsWith5(name, 0, 0x64, 0x61, 0x72, 0x74, 0x2E); |
| 7422 | 6932 |
| 7423 /** | 6933 /** |
| 7424 * Answer `true` if the receiver directly or indirectly imports the dart:html
libraries. | 6934 * Return `true` if the receiver directly or indirectly imports the |
| 7425 * | 6935 * 'dart:html' libraries. |
| 7426 * @return `true` if the receiver directly or indirectly imports the dart:html
libraries | |
| 7427 */ | 6936 */ |
| 7428 bool get isOrImportsBrowserLibrary { | 6937 bool get isOrImportsBrowserLibrary { |
| 7429 List<LibraryElement> visited = new List<LibraryElement>(); | 6938 List<LibraryElement> visited = new List<LibraryElement>(); |
| 7430 Source htmlLibSource = context.sourceFactory.forUri(DartSdk.DART_HTML); | 6939 Source htmlLibSource = context.sourceFactory.forUri(DartSdk.DART_HTML); |
| 7431 visited.add(this); | 6940 visited.add(this); |
| 7432 for (int index = 0; index < visited.length; index++) { | 6941 for (int index = 0; index < visited.length; index++) { |
| 7433 LibraryElement library = visited[index]; | 6942 LibraryElement library = visited[index]; |
| 7434 Source source = library.definingCompilationUnit.source; | 6943 Source source = library.definingCompilationUnit.source; |
| 7435 if (source == htmlLibSource) { | 6944 if (source == htmlLibSource) { |
| 7436 return true; | 6945 return true; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 7463 function.synthetic = true; | 6972 function.synthetic = true; |
| 7464 function.enclosingElement = this; | 6973 function.enclosingElement = this; |
| 7465 function.returnType = loadLibraryReturnType; | 6974 function.returnType = loadLibraryReturnType; |
| 7466 function.type = new FunctionTypeImpl.con1(function); | 6975 function.type = new FunctionTypeImpl.con1(function); |
| 7467 _loadLibraryFunction = function; | 6976 _loadLibraryFunction = function; |
| 7468 } | 6977 } |
| 7469 return _loadLibraryFunction; | 6978 return _loadLibraryFunction; |
| 7470 } | 6979 } |
| 7471 | 6980 |
| 7472 /** | 6981 /** |
| 7473 * Return the object representing the type "Future" from the dart:async librar
y, or the type | 6982 * Return the object representing the type 'Future' from the 'dart:async' |
| 7474 * "void" if the type "Future" cannot be accessed. | 6983 * library, or the type 'void' if the type 'Future' cannot be accessed. |
| 7475 * | |
| 7476 * @return the type "Future" from the dart:async library | |
| 7477 */ | 6984 */ |
| 7478 DartType get loadLibraryReturnType { | 6985 DartType get loadLibraryReturnType { |
| 7479 try { | 6986 try { |
| 7480 Source asyncSource = context.sourceFactory.forUri(DartSdk.DART_ASYNC); | 6987 Source asyncSource = context.sourceFactory.forUri(DartSdk.DART_ASYNC); |
| 7481 if (asyncSource == null) { | 6988 if (asyncSource == null) { |
| 7482 AnalysisEngine.instance.logger | 6989 AnalysisEngine.instance.logger |
| 7483 .logError("Could not create a source for dart:async"); | 6990 .logError("Could not create a source for dart:async"); |
| 7484 return VoidTypeImpl.instance; | 6991 return VoidTypeImpl.instance; |
| 7485 } | 6992 } |
| 7486 LibraryElement asyncElement = context.computeLibraryElement(asyncSource); | 6993 LibraryElement asyncElement = context.computeLibraryElement(asyncSource); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 7502 "Could not build the element model for dart:async", | 7009 "Could not build the element model for dart:async", |
| 7503 new CaughtException(exception, stackTrace)); | 7010 new CaughtException(exception, stackTrace)); |
| 7504 return VoidTypeImpl.instance; | 7011 return VoidTypeImpl.instance; |
| 7505 } | 7012 } |
| 7506 } | 7013 } |
| 7507 | 7014 |
| 7508 @override | 7015 @override |
| 7509 List<CompilationUnitElement> get parts => _parts; | 7016 List<CompilationUnitElement> get parts => _parts; |
| 7510 | 7017 |
| 7511 /** | 7018 /** |
| 7512 * Set the compilation units that are included in this library using a `part`
directive. | 7019 * Set the compilation units that are included in this library using a `part` |
| 7513 * | 7020 * directive to the given list of [parts]. |
| 7514 * @param parts the compilation units that are included in this library using
a `part` | |
| 7515 * directive | |
| 7516 */ | 7021 */ |
| 7517 void set parts(List<CompilationUnitElement> parts) { | 7022 void set parts(List<CompilationUnitElement> parts) { |
| 7518 for (CompilationUnitElement compilationUnit in parts) { | 7023 for (CompilationUnitElement compilationUnit in parts) { |
| 7519 (compilationUnit as CompilationUnitElementImpl).enclosingElement = this; | 7024 (compilationUnit as CompilationUnitElementImpl).enclosingElement = this; |
| 7520 } | 7025 } |
| 7521 this._parts = parts; | 7026 this._parts = parts; |
| 7522 } | 7027 } |
| 7523 | 7028 |
| 7524 @override | 7029 @override |
| 7525 List<PrefixElement> get prefixes { | 7030 List<PrefixElement> get prefixes { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7624 @override | 7129 @override |
| 7625 void visitChildren(ElementVisitor visitor) { | 7130 void visitChildren(ElementVisitor visitor) { |
| 7626 super.visitChildren(visitor); | 7131 super.visitChildren(visitor); |
| 7627 safelyVisitChild(_definingCompilationUnit, visitor); | 7132 safelyVisitChild(_definingCompilationUnit, visitor); |
| 7628 safelyVisitChildren(_exports, visitor); | 7133 safelyVisitChildren(_exports, visitor); |
| 7629 safelyVisitChildren(_imports, visitor); | 7134 safelyVisitChildren(_imports, visitor); |
| 7630 safelyVisitChildren(_parts, visitor); | 7135 safelyVisitChildren(_parts, visitor); |
| 7631 } | 7136 } |
| 7632 | 7137 |
| 7633 /** | 7138 /** |
| 7634 * Recursively fills set of visible libraries for [getVisibleElementsLibraries
]. | 7139 * Recursively fills set of visible libraries for |
| 7140 * [getVisibleElementsLibraries]. |
| 7635 */ | 7141 */ |
| 7636 void _addVisibleLibraries( | 7142 void _addVisibleLibraries( |
| 7637 Set<LibraryElement> visibleLibraries, bool includeExports) { | 7143 Set<LibraryElement> visibleLibraries, bool includeExports) { |
| 7638 // maybe already processed | 7144 // maybe already processed |
| 7639 if (!visibleLibraries.add(this)) { | 7145 if (!visibleLibraries.add(this)) { |
| 7640 return; | 7146 return; |
| 7641 } | 7147 } |
| 7642 // add imported libraries | 7148 // add imported libraries |
| 7643 for (ImportElement importElement in _imports) { | 7149 for (ImportElement importElement in _imports) { |
| 7644 LibraryElement importedLibrary = importElement.importedLibrary; | 7150 LibraryElement importedLibrary = importElement.importedLibrary; |
| 7645 if (importedLibrary != null) { | 7151 if (importedLibrary != null) { |
| 7646 (importedLibrary as LibraryElementImpl)._addVisibleLibraries( | 7152 (importedLibrary as LibraryElementImpl)._addVisibleLibraries( |
| 7647 visibleLibraries, true); | 7153 visibleLibraries, true); |
| 7648 } | 7154 } |
| 7649 } | 7155 } |
| 7650 // add exported libraries | 7156 // add exported libraries |
| 7651 if (includeExports) { | 7157 if (includeExports) { |
| 7652 for (ExportElement exportElement in _exports) { | 7158 for (ExportElement exportElement in _exports) { |
| 7653 LibraryElement exportedLibrary = exportElement.exportedLibrary; | 7159 LibraryElement exportedLibrary = exportElement.exportedLibrary; |
| 7654 if (exportedLibrary != null) { | 7160 if (exportedLibrary != null) { |
| 7655 (exportedLibrary as LibraryElementImpl)._addVisibleLibraries( | 7161 (exportedLibrary as LibraryElementImpl)._addVisibleLibraries( |
| 7656 visibleLibraries, true); | 7162 visibleLibraries, true); |
| 7657 } | 7163 } |
| 7658 } | 7164 } |
| 7659 } | 7165 } |
| 7660 } | 7166 } |
| 7661 | 7167 |
| 7662 /** | 7168 /** |
| 7663 * Determine if the given library is up to date with respect to the given time
stamp. | 7169 * Return `true` if the given [library] is up to date with respect to the |
| 7664 * | 7170 * given [timeStamp]. The set of [visitedLibraries] is used to prevent |
| 7665 * @param library the library to process | 7171 * infinite recusion in the case of mutually dependent libraries. |
| 7666 * @param timeStamp the time stamp to check against | |
| 7667 * @param visitedLibraries the set of visited libraries | |
| 7668 */ | 7172 */ |
| 7669 static bool _safeIsUpToDate(LibraryElement library, int timeStamp, | 7173 static bool _safeIsUpToDate(LibraryElement library, int timeStamp, |
| 7670 Set<LibraryElement> visitedLibraries) { | 7174 Set<LibraryElement> visitedLibraries) { |
| 7671 if (!visitedLibraries.contains(library)) { | 7175 if (!visitedLibraries.contains(library)) { |
| 7672 visitedLibraries.add(library); | 7176 visitedLibraries.add(library); |
| 7673 AnalysisContext context = library.context; | 7177 AnalysisContext context = library.context; |
| 7674 // Check the defining compilation unit. | 7178 // Check the defining compilation unit. |
| 7675 if (timeStamp < | 7179 if (timeStamp < |
| 7676 context | 7180 context |
| 7677 .getModificationStamp(library.definingCompilationUnit.source)) { | 7181 .getModificationStamp(library.definingCompilationUnit.source)) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 7694 if (!_safeIsUpToDate(exportedLibrary, timeStamp, visitedLibraries)) { | 7198 if (!_safeIsUpToDate(exportedLibrary, timeStamp, visitedLibraries)) { |
| 7695 return false; | 7199 return false; |
| 7696 } | 7200 } |
| 7697 } | 7201 } |
| 7698 } | 7202 } |
| 7699 return true; | 7203 return true; |
| 7700 } | 7204 } |
| 7701 } | 7205 } |
| 7702 | 7206 |
| 7703 /** | 7207 /** |
| 7704 * The interface `LocalElement` defines the behavior of elements that can be (bu
t are not | 7208 * An element that can be (but are not required to be) defined within a method |
| 7705 * required to be) defined within a method or function (an [ExecutableElement]). | 7209 * or function (an [ExecutableElement]). |
| 7706 */ | 7210 */ |
| 7707 abstract class LocalElement implements Element { | 7211 abstract class LocalElement implements Element { |
| 7708 /** | 7212 /** |
| 7709 * Return a source range that covers the approximate portion of the source in
which the name of | 7213 * Return a source range that covers the approximate portion of the source in |
| 7710 * this element is visible, or `null` if there is no single range of character
s within which | 7214 * which the name of this element is visible, or `null` if there is no single |
| 7711 * the element name is visible. | 7215 * range of characters within which the element name is visible. |
| 7712 * * For a local variable, this includes everything from the end of the variab
le's initializer | |
| 7713 * to the end of the block that encloses the variable declaration. | |
| 7714 * * For a parameter, this includes the body of the method or function that de
clares the | |
| 7715 * parameter. | |
| 7716 * * For a local function, this includes everything from the beginning of the
function's body to | |
| 7717 * the end of the block that encloses the function declaration. | |
| 7718 * * For top-level functions, `null` will be returned because they are potenti
ally visible | |
| 7719 * in multiple sources. | |
| 7720 * | 7216 * |
| 7721 * @return the range of characters in which the name of this element is visibl
e | 7217 * * For a local variable, this includes everything from the end of the |
| 7218 * variable's initializer to the end of the block that encloses the variable |
| 7219 * declaration. |
| 7220 * * For a parameter, this includes the body of the method or function that |
| 7221 * declares the parameter. |
| 7222 * * For a local function, this includes everything from the beginning of the |
| 7223 * function's body to the end of the block that encloses the function |
| 7224 * declaration. |
| 7225 * * For top-level functions, `null` will be returned because they are |
| 7226 * potentially visible in multiple sources. |
| 7722 */ | 7227 */ |
| 7723 SourceRange get visibleRange; | 7228 SourceRange get visibleRange; |
| 7724 } | 7229 } |
| 7725 | 7230 |
| 7726 /** | 7231 /** |
| 7727 * The interface `LocalVariableElement` defines the behavior common to elements
that represent | 7232 * A local variable. |
| 7728 * a local variable. | |
| 7729 */ | 7233 */ |
| 7730 abstract class LocalVariableElement implements LocalElement, VariableElement {} | 7234 abstract class LocalVariableElement implements LocalElement, VariableElement {} |
| 7731 | 7235 |
| 7732 /** | 7236 /** |
| 7733 * Instances of the class `LocalVariableElementImpl` implement a `LocalVariableE
lement`. | 7237 * A concrete implementation of a [LocalVariableElement]. |
| 7734 */ | 7238 */ |
| 7735 class LocalVariableElementImpl extends VariableElementImpl | 7239 class LocalVariableElementImpl extends VariableElementImpl |
| 7736 implements LocalVariableElement { | 7240 implements LocalVariableElement { |
| 7737 /** | 7241 /** |
| 7738 * An empty list of field elements. | 7242 * An empty list of field elements. |
| 7739 */ | 7243 */ |
| 7740 static const List<LocalVariableElement> EMPTY_ARRAY = | 7244 static const List<LocalVariableElement> EMPTY_ARRAY = |
| 7741 const <LocalVariableElement>[]; | 7245 const <LocalVariableElement>[]; |
| 7742 | 7246 |
| 7743 /** | 7247 /** |
| 7744 * The offset to the beginning of the visible range for this element. | 7248 * The offset to the beginning of the visible range for this element. |
| 7745 */ | 7249 */ |
| 7746 int _visibleRangeOffset = 0; | 7250 int _visibleRangeOffset = 0; |
| 7747 | 7251 |
| 7748 /** | 7252 /** |
| 7749 * The length of the visible range for this element, or `-1` if this element d
oes not have a | 7253 * The length of the visible range for this element, or `-1` if this element |
| 7750 * visible range. | 7254 * does not have a visible range. |
| 7751 */ | 7255 */ |
| 7752 int _visibleRangeLength = -1; | 7256 int _visibleRangeLength = -1; |
| 7753 | 7257 |
| 7754 /** | 7258 /** |
| 7755 * Initialize a newly created method element to have the given name. | 7259 * Initialize a newly created method element to have the given [name] and |
| 7756 * | 7260 * [offset]. |
| 7757 * @param name the name of this element | |
| 7758 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
| 7759 * declaration of this element | |
| 7760 */ | 7261 */ |
| 7761 LocalVariableElementImpl(String name, int nameOffset) | 7262 LocalVariableElementImpl(String name, int offset) |
| 7762 : super(name, nameOffset); | 7263 : super(name, offset); |
| 7763 | 7264 |
| 7764 /** | 7265 /** |
| 7765 * Initialize a newly created local variable element to have the given name. | 7266 * Initialize a newly created local variable element to have the given [name]. |
| 7766 * | |
| 7767 * @param name the name of this element | |
| 7768 */ | 7267 */ |
| 7769 LocalVariableElementImpl.forNode(Identifier name) : super.forNode(name); | 7268 LocalVariableElementImpl.forNode(Identifier name) : super.forNode(name); |
| 7770 | 7269 |
| 7771 @override | 7270 @override |
| 7772 String get identifier { | 7271 String get identifier { |
| 7773 int enclosingOffset = | 7272 int enclosingOffset = |
| 7774 enclosingElement != null ? enclosingElement.nameOffset : 0; | 7273 enclosingElement != null ? enclosingElement.nameOffset : 0; |
| 7775 int delta = nameOffset - enclosingOffset; | 7274 int delta = nameOffset - enclosingOffset; |
| 7776 return '${super.identifier}@$delta'; | 7275 return '${super.identifier}@$delta'; |
| 7777 } | 7276 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7813 } | 7312 } |
| 7814 | 7313 |
| 7815 /** | 7314 /** |
| 7816 * Specifies that this variable is potentially mutated somewhere in its scope. | 7315 * Specifies that this variable is potentially mutated somewhere in its scope. |
| 7817 */ | 7316 */ |
| 7818 void markPotentiallyMutatedInScope() { | 7317 void markPotentiallyMutatedInScope() { |
| 7819 setModifier(Modifier.POTENTIALLY_MUTATED_IN_SCOPE, true); | 7318 setModifier(Modifier.POTENTIALLY_MUTATED_IN_SCOPE, true); |
| 7820 } | 7319 } |
| 7821 | 7320 |
| 7822 /** | 7321 /** |
| 7823 * Set the visible range for this element to the range starting at the given o
ffset with the given | 7322 * Set the visible range for this element to the range starting at the given |
| 7824 * length. | 7323 * [offset] with the given [length]. |
| 7825 * | |
| 7826 * @param offset the offset to the beginning of the visible range for this ele
ment | |
| 7827 * @param length the length of the visible range for this element, or `-1` if
this element | |
| 7828 * does not have a visible range | |
| 7829 */ | 7324 */ |
| 7830 void setVisibleRange(int offset, int length) { | 7325 void setVisibleRange(int offset, int length) { |
| 7831 _visibleRangeOffset = offset; | 7326 _visibleRangeOffset = offset; |
| 7832 _visibleRangeLength = length; | 7327 _visibleRangeLength = length; |
| 7833 } | 7328 } |
| 7834 } | 7329 } |
| 7835 | 7330 |
| 7836 /** | 7331 /** |
| 7837 * The abstract class `Member` defines the behavior common to elements that repr
esent members | 7332 * An element defined in a parameterized type where the values of the type |
| 7838 * of parameterized types. | 7333 * parameters are known. |
| 7839 */ | 7334 */ |
| 7840 abstract class Member implements Element { | 7335 abstract class Member implements Element { |
| 7841 /** | 7336 /** |
| 7842 * The element on which the parameterized element was created. | 7337 * The element on which the parameterized element was created. |
| 7843 */ | 7338 */ |
| 7844 final Element _baseElement; | 7339 final Element _baseElement; |
| 7845 | 7340 |
| 7846 /** | 7341 /** |
| 7847 * The type in which the element is defined. | 7342 * The type in which the element is defined. |
| 7848 */ | 7343 */ |
| 7849 final ParameterizedType _definingType; | 7344 final ParameterizedType _definingType; |
| 7850 | 7345 |
| 7851 /** | 7346 /** |
| 7852 * Initialize a newly created element to represent the member of the given par
ameterized type. | 7347 * Initialize a newly created element to represent a constructor, based on the |
| 7853 * | 7348 * [baseElement], defined by the [definingType]. |
| 7854 * @param baseElement the element on which the parameterized element was creat
ed | |
| 7855 * @param definingType the type in which the element is defined | |
| 7856 */ | 7349 */ |
| 7857 Member(this._baseElement, this._definingType); | 7350 Member(this._baseElement, this._definingType); |
| 7858 | 7351 |
| 7859 /** | 7352 /** |
| 7860 * Return the element on which the parameterized element was created. | 7353 * Return the element on which the parameterized element was created. |
| 7861 * | |
| 7862 * @return the element on which the parameterized element was created | |
| 7863 */ | 7354 */ |
| 7864 Element get baseElement => _baseElement; | 7355 Element get baseElement => _baseElement; |
| 7865 | 7356 |
| 7866 @override | 7357 @override |
| 7867 AnalysisContext get context => _baseElement.context; | 7358 AnalysisContext get context => _baseElement.context; |
| 7868 | 7359 |
| 7869 /** | 7360 /** |
| 7870 * Return the type in which the element is defined. | 7361 * Return the type in which the element is defined. |
| 7871 * | |
| 7872 * @return the type in which the element is defined | |
| 7873 */ | 7362 */ |
| 7874 ParameterizedType get definingType => _definingType; | 7363 ParameterizedType get definingType => _definingType; |
| 7875 | 7364 |
| 7876 @override | 7365 @override |
| 7877 String get displayName => _baseElement.displayName; | 7366 String get displayName => _baseElement.displayName; |
| 7878 | 7367 |
| 7879 int get id => _baseElement.id; | 7368 int get id => _baseElement.id; |
| 7880 | 7369 |
| 7881 @override | 7370 @override |
| 7882 bool get isDeprecated => _baseElement.isDeprecated; | 7371 bool get isDeprecated => _baseElement.isDeprecated; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7930 | 7419 |
| 7931 @override | 7420 @override |
| 7932 String getExtendedDisplayName(String shortName) => | 7421 String getExtendedDisplayName(String shortName) => |
| 7933 _baseElement.getExtendedDisplayName(shortName); | 7422 _baseElement.getExtendedDisplayName(shortName); |
| 7934 | 7423 |
| 7935 @override | 7424 @override |
| 7936 bool isAccessibleIn(LibraryElement library) => | 7425 bool isAccessibleIn(LibraryElement library) => |
| 7937 _baseElement.isAccessibleIn(library); | 7426 _baseElement.isAccessibleIn(library); |
| 7938 | 7427 |
| 7939 /** | 7428 /** |
| 7940 * If the given child is not `null`, use the given visitor to visit it. | 7429 * If the given [child] is not `null`, use the given [visitor] to visit it. |
| 7941 * | |
| 7942 * @param child the child to be visited | |
| 7943 * @param visitor the visitor to be used to visit the child | |
| 7944 */ | 7430 */ |
| 7945 void safelyVisitChild(Element child, ElementVisitor visitor) { | 7431 void safelyVisitChild(Element child, ElementVisitor visitor) { |
| 7432 // TODO(brianwilkerson) Make this private |
| 7946 if (child != null) { | 7433 if (child != null) { |
| 7947 child.accept(visitor); | 7434 child.accept(visitor); |
| 7948 } | 7435 } |
| 7949 } | 7436 } |
| 7950 | 7437 |
| 7951 /** | 7438 /** |
| 7952 * Use the given visitor to visit all of the children in the given array. | 7439 * Use the given [visitor] to visit all of the [children]. |
| 7953 * | |
| 7954 * @param children the children to be visited | |
| 7955 * @param visitor the visitor being used to visit the children | |
| 7956 */ | 7440 */ |
| 7957 void safelyVisitChildren(List<Element> children, ElementVisitor visitor) { | 7441 void safelyVisitChildren(List<Element> children, ElementVisitor visitor) { |
| 7442 // TODO(brianwilkerson) Make this private |
| 7958 if (children != null) { | 7443 if (children != null) { |
| 7959 for (Element child in children) { | 7444 for (Element child in children) { |
| 7960 child.accept(visitor); | 7445 child.accept(visitor); |
| 7961 } | 7446 } |
| 7962 } | 7447 } |
| 7963 } | 7448 } |
| 7964 | 7449 |
| 7965 /** | 7450 /** |
| 7966 * Return the type that results from replacing the type parameters in the give
n type with the type | 7451 * Return the type that results from replacing the type parameters in the |
| 7967 * arguments. | 7452 * given [type] with the type arguments associated with this member. |
| 7968 * | |
| 7969 * @param type the type to be transformed | |
| 7970 * @return the result of transforming the type | |
| 7971 */ | 7453 */ |
| 7972 DartType substituteFor(DartType type) { | 7454 DartType substituteFor(DartType type) { |
| 7973 if (type == null) { | 7455 if (type == null) { |
| 7974 return null; | 7456 return null; |
| 7975 } | 7457 } |
| 7976 List<DartType> argumentTypes = _definingType.typeArguments; | 7458 List<DartType> argumentTypes = _definingType.typeArguments; |
| 7977 List<DartType> parameterTypes = | 7459 List<DartType> parameterTypes = |
| 7978 TypeParameterTypeImpl.getTypes(_definingType.typeParameters); | 7460 TypeParameterTypeImpl.getTypes(_definingType.typeParameters); |
| 7979 return type.substitute2(argumentTypes, parameterTypes); | 7461 return type.substitute2(argumentTypes, parameterTypes); |
| 7980 } | 7462 } |
| 7981 | 7463 |
| 7982 /** | 7464 /** |
| 7983 * Return the array of types that results from replacing the type parameters i
n the given types | 7465 * Return the list of types that results from replacing the type parameters in |
| 7984 * with the type arguments. | 7466 * the given [types] with the type arguments associated with this member. |
| 7985 * | |
| 7986 * @param types the types to be transformed | |
| 7987 * @return the result of transforming the types | |
| 7988 */ | 7467 */ |
| 7989 List<InterfaceType> substituteFor2(List<InterfaceType> types) { | 7468 List<InterfaceType> substituteFor2(List<InterfaceType> types) { |
| 7990 int count = types.length; | 7469 int count = types.length; |
| 7991 List<InterfaceType> substitutedTypes = new List<InterfaceType>(count); | 7470 List<InterfaceType> substitutedTypes = new List<InterfaceType>(count); |
| 7992 for (int i = 0; i < count; i++) { | 7471 for (int i = 0; i < count; i++) { |
| 7993 substitutedTypes[i] = substituteFor(types[i]); | 7472 substitutedTypes[i] = substituteFor(types[i]); |
| 7994 } | 7473 } |
| 7995 return substitutedTypes; | 7474 return substitutedTypes; |
| 7996 } | 7475 } |
| 7997 | 7476 |
| 7998 @override | 7477 @override |
| 7999 void visitChildren(ElementVisitor visitor) { | 7478 void visitChildren(ElementVisitor visitor) { |
| 8000 // There are no children to visit | 7479 // There are no children to visit |
| 8001 } | 7480 } |
| 8002 } | 7481 } |
| 8003 | 7482 |
| 8004 /** | 7483 /** |
| 8005 * The interface `MethodElement` defines the behavior of elements that represent
a method | 7484 * An element that represents a method defined within a type. |
| 8006 * defined within a type. | |
| 8007 */ | 7485 */ |
| 8008 abstract class MethodElement implements ClassMemberElement, ExecutableElement { | 7486 abstract class MethodElement implements ClassMemberElement, ExecutableElement { |
| 8009 /** | 7487 /** |
| 8010 * Return `true` if this method is abstract. Methods are abstract if they are
not external | 7488 * Return `true` if this method is abstract. Methods are abstract if they are |
| 8011 * and have no body. | 7489 * not external and have no body. |
| 8012 * | |
| 8013 * @return `true` if this method is abstract | |
| 8014 */ | 7490 */ |
| 8015 bool get isAbstract; | 7491 bool get isAbstract; |
| 8016 | 7492 |
| 8017 /** | 7493 /** |
| 8018 * Return the resolved [MethodDeclaration] node that declares this [MethodElem
ent]. | 7494 * Return the resolved [MethodDeclaration] node that declares this |
| 7495 * [MethodElement]. |
| 8019 * | 7496 * |
| 8020 * This method is expensive, because resolved AST might be evicted from cache,
so parsing and | 7497 * This method is expensive, because resolved AST might be evicted from cache, |
| 8021 * resolving will be performed. | 7498 * so parsing and resolving will be performed. |
| 8022 * | |
| 8023 * @return the resolved [MethodDeclaration], not `null`. | |
| 8024 */ | 7499 */ |
| 8025 @override | 7500 @override |
| 8026 MethodDeclaration get node; | 7501 MethodDeclaration get node; |
| 8027 } | 7502 } |
| 8028 | 7503 |
| 8029 /** | 7504 /** |
| 8030 * Instances of the class `MethodElementImpl` implement a `MethodElement`. | 7505 * A concrete implementation of a [MethodElement]. |
| 8031 */ | 7506 */ |
| 8032 class MethodElementImpl extends ExecutableElementImpl implements MethodElement { | 7507 class MethodElementImpl extends ExecutableElementImpl implements MethodElement { |
| 8033 /** | 7508 /** |
| 8034 * An empty list of method elements. | 7509 * An empty list of method elements. |
| 8035 */ | 7510 */ |
| 8036 static const List<MethodElement> EMPTY_ARRAY = const <MethodElement>[]; | 7511 static const List<MethodElement> EMPTY_ARRAY = const <MethodElement>[]; |
| 8037 | 7512 |
| 8038 /** | 7513 /** |
| 8039 * Initialize a newly created method element to have the given name. | 7514 * Initialize a newly created method element to have the given [name] at the |
| 8040 * | 7515 * given [offset]. |
| 8041 * @param name the name of this element | |
| 8042 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
| 8043 * declaration of this element | |
| 8044 */ | 7516 */ |
| 8045 MethodElementImpl(String name, int nameOffset) : super(name, nameOffset); | 7517 MethodElementImpl(String name, int offset) : super(name, offset); |
| 8046 | 7518 |
| 8047 /** | 7519 /** |
| 8048 * Initialize a newly created method element to have the given name. | 7520 * Initialize a newly created method element to have the given [name]. |
| 8049 * | |
| 8050 * @param name the name of this element | |
| 8051 */ | 7521 */ |
| 8052 MethodElementImpl.forNode(Identifier name) : super.forNode(name); | 7522 MethodElementImpl.forNode(Identifier name) : super.forNode(name); |
| 8053 | 7523 |
| 8054 /** | 7524 /** |
| 8055 * Set whether this method is abstract to correspond to the given value. | 7525 * Set whether this method is abstract. |
| 8056 * | |
| 8057 * @param isAbstract `true` if the method is abstract | |
| 8058 */ | 7526 */ |
| 8059 void set abstract(bool isAbstract) { | 7527 void set abstract(bool isAbstract) { |
| 8060 setModifier(Modifier.ABSTRACT, isAbstract); | 7528 setModifier(Modifier.ABSTRACT, isAbstract); |
| 8061 } | 7529 } |
| 8062 | 7530 |
| 8063 @override | 7531 @override |
| 8064 String get displayName { | 7532 String get displayName { |
| 8065 String displayName = super.displayName; | 7533 String displayName = super.displayName; |
| 8066 if ("unary-" == displayName) { | 7534 if ("unary-" == displayName) { |
| 8067 return "-"; | 7535 return "-"; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8103 } | 7571 } |
| 8104 } | 7572 } |
| 8105 return super.name; | 7573 return super.name; |
| 8106 } | 7574 } |
| 8107 | 7575 |
| 8108 @override | 7576 @override |
| 8109 MethodDeclaration get node => | 7577 MethodDeclaration get node => |
| 8110 getNodeMatching((node) => node is MethodDeclaration); | 7578 getNodeMatching((node) => node is MethodDeclaration); |
| 8111 | 7579 |
| 8112 /** | 7580 /** |
| 8113 * Set whether this method is static to correspond to the given value. | 7581 * Set whether this method is static. |
| 8114 * | |
| 8115 * @param isStatic `true` if the method is static | |
| 8116 */ | 7582 */ |
| 8117 void set static(bool isStatic) { | 7583 void set static(bool isStatic) { |
| 8118 setModifier(Modifier.STATIC, isStatic); | 7584 setModifier(Modifier.STATIC, isStatic); |
| 8119 } | 7585 } |
| 8120 | 7586 |
| 8121 @override | 7587 @override |
| 8122 accept(ElementVisitor visitor) => visitor.visitMethodElement(this); | 7588 accept(ElementVisitor visitor) => visitor.visitMethodElement(this); |
| 8123 | 7589 |
| 8124 @override | 7590 @override |
| 8125 void appendTo(StringBuffer buffer) { | 7591 void appendTo(StringBuffer buffer) { |
| 8126 buffer.write(enclosingElement.displayName); | 7592 buffer.write(enclosingElement.displayName); |
| 8127 buffer.write("."); | 7593 buffer.write("."); |
| 8128 buffer.write(displayName); | 7594 buffer.write(displayName); |
| 8129 super.appendTo(buffer); | 7595 super.appendTo(buffer); |
| 8130 } | 7596 } |
| 8131 } | 7597 } |
| 8132 | 7598 |
| 8133 /** | 7599 /** |
| 8134 * Instances of the class `MethodMember` represent a method element defined in a
parameterized | 7600 * A method element defined in a parameterized type where the values of the type |
| 8135 * type where the values of the type parameters are known. | 7601 * parameters are known. |
| 8136 */ | 7602 */ |
| 8137 class MethodMember extends ExecutableMember implements MethodElement { | 7603 class MethodMember extends ExecutableMember implements MethodElement { |
| 8138 /** | 7604 /** |
| 8139 * Initialize a newly created element to represent a method of the given param
eterized type. | 7605 * Initialize a newly created element to represent a constructor, based on the |
| 8140 * | 7606 * [baseElement], defined by the [definingType]. |
| 8141 * @param baseElement the element on which the parameterized element was creat
ed | |
| 8142 * @param definingType the type in which the element is defined | |
| 8143 */ | 7607 */ |
| 8144 MethodMember(MethodElement baseElement, InterfaceType definingType) | 7608 MethodMember(MethodElement baseElement, InterfaceType definingType) |
| 8145 : super(baseElement, definingType); | 7609 : super(baseElement, definingType); |
| 8146 | 7610 |
| 8147 @override | 7611 @override |
| 8148 MethodElement get baseElement => super.baseElement as MethodElement; | 7612 MethodElement get baseElement => super.baseElement as MethodElement; |
| 8149 | 7613 |
| 8150 @override | 7614 @override |
| 8151 ClassElement get enclosingElement => baseElement.enclosingElement; | 7615 ClassElement get enclosingElement => baseElement.enclosingElement; |
| 8152 | 7616 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 8178 } | 7642 } |
| 8179 buffer.write(")"); | 7643 buffer.write(")"); |
| 8180 if (type != null) { | 7644 if (type != null) { |
| 8181 buffer.write(Element.RIGHT_ARROW); | 7645 buffer.write(Element.RIGHT_ARROW); |
| 8182 buffer.write(type.returnType); | 7646 buffer.write(type.returnType); |
| 8183 } | 7647 } |
| 8184 return buffer.toString(); | 7648 return buffer.toString(); |
| 8185 } | 7649 } |
| 8186 | 7650 |
| 8187 /** | 7651 /** |
| 8188 * If the given method's type is different when any type parameters from the d
efining type's | 7652 * If the given [method]'s type is different when any type parameters from the |
| 8189 * declaration are replaced with the actual type arguments from the defining t
ype, create a method | 7653 * defining type's declaration are replaced with the actual type arguments |
| 8190 * member representing the given method. Return the member that was created, o
r the base method if | 7654 * from the [definingType], create a method member representing the given |
| 8191 * no member was created. | 7655 * method. Return the member that was created, or the base method if no member |
| 8192 * | 7656 * was created. |
| 8193 * @param baseMethod the base method for which a member might be created | |
| 8194 * @param definingType the type defining the parameters and arguments to be us
ed in the | |
| 8195 * substitution | |
| 8196 * @return the method element that will return the correctly substituted types | |
| 8197 */ | 7657 */ |
| 8198 static MethodElement from( | 7658 static MethodElement from( |
| 8199 MethodElement baseMethod, InterfaceType definingType) { | 7659 MethodElement method, InterfaceType definingType) { |
| 8200 if (baseMethod == null || definingType.typeArguments.length == 0) { | 7660 if (method == null || definingType.typeArguments.length == 0) { |
| 8201 return baseMethod; | 7661 return method; |
| 8202 } | 7662 } |
| 8203 FunctionType baseType = baseMethod.type; | 7663 FunctionType baseType = method.type; |
| 8204 List<DartType> argumentTypes = definingType.typeArguments; | 7664 List<DartType> argumentTypes = definingType.typeArguments; |
| 8205 List<DartType> parameterTypes = definingType.element.type.typeArguments; | 7665 List<DartType> parameterTypes = definingType.element.type.typeArguments; |
| 8206 FunctionType substitutedType = | 7666 FunctionType substitutedType = |
| 8207 baseType.substitute2(argumentTypes, parameterTypes); | 7667 baseType.substitute2(argumentTypes, parameterTypes); |
| 8208 if (baseType == substitutedType) { | 7668 if (baseType == substitutedType) { |
| 8209 return baseMethod; | 7669 return method; |
| 8210 } | 7670 } |
| 8211 // TODO(brianwilkerson) Consider caching the substituted type in the | 7671 // TODO(brianwilkerson) Consider caching the substituted type in the |
| 8212 // instance. It would use more memory but speed up some operations. | 7672 // instance. It would use more memory but speed up some operations. |
| 8213 // We need to see how often the type is being re-computed. | 7673 // We need to see how often the type is being re-computed. |
| 8214 return new MethodMember(baseMethod, definingType); | 7674 return new MethodMember(method, definingType); |
| 8215 } | 7675 } |
| 8216 } | 7676 } |
| 8217 | 7677 |
| 8218 /** | 7678 /** |
| 8219 * The enumeration `Modifier` defines constants for all of the modifiers defined
by the Dart | 7679 * The enumeration `Modifier` defines constants for all of the modifiers defined |
| 8220 * language and for a few additional flags that are useful. | 7680 * by the Dart language and for a few additional flags that are useful. |
| 8221 */ | 7681 */ |
| 8222 class Modifier extends Enum<Modifier> { | 7682 class Modifier extends Enum<Modifier> { |
| 8223 /** | 7683 /** |
| 8224 * Indicates that the modifier 'abstract' was applied to the element. | 7684 * Indicates that the modifier 'abstract' was applied to the element. |
| 8225 */ | 7685 */ |
| 8226 static const Modifier ABSTRACT = const Modifier('ABSTRACT', 0); | 7686 static const Modifier ABSTRACT = const Modifier('ABSTRACT', 0); |
| 8227 | 7687 |
| 8228 /** | 7688 /** |
| 8229 * Indicates that an executable element has a body marked as being asynchronou
s. | 7689 * Indicates that an executable element has a body marked as being |
| 7690 * asynchronous. |
| 8230 */ | 7691 */ |
| 8231 static const Modifier ASYNCHRONOUS = const Modifier('ASYNCHRONOUS', 1); | 7692 static const Modifier ASYNCHRONOUS = const Modifier('ASYNCHRONOUS', 1); |
| 8232 | 7693 |
| 8233 /** | 7694 /** |
| 8234 * Indicates that the modifier 'const' was applied to the element. | 7695 * Indicates that the modifier 'const' was applied to the element. |
| 8235 */ | 7696 */ |
| 8236 static const Modifier CONST = const Modifier('CONST', 2); | 7697 static const Modifier CONST = const Modifier('CONST', 2); |
| 8237 | 7698 |
| 8238 /** | 7699 /** |
| 8239 * Indicates that the import element represents a deferred library. | 7700 * Indicates that the import element represents a deferred library. |
| 8240 */ | 7701 */ |
| 8241 static const Modifier DEFERRED = const Modifier('DEFERRED', 3); | 7702 static const Modifier DEFERRED = const Modifier('DEFERRED', 3); |
| 8242 | 7703 |
| 8243 /** | 7704 /** |
| 8244 * Indicates that a class element was defined by an enum declaration. | 7705 * Indicates that a class element was defined by an enum declaration. |
| 8245 */ | 7706 */ |
| 8246 static const Modifier ENUM = const Modifier('ENUM', 4); | 7707 static const Modifier ENUM = const Modifier('ENUM', 4); |
| 8247 | 7708 |
| 8248 /** | 7709 /** |
| 8249 * Indicates that the modifier 'factory' was applied to the element. | 7710 * Indicates that the modifier 'factory' was applied to the element. |
| 8250 */ | 7711 */ |
| 8251 static const Modifier FACTORY = const Modifier('FACTORY', 5); | 7712 static const Modifier FACTORY = const Modifier('FACTORY', 5); |
| 8252 | 7713 |
| 8253 /** | 7714 /** |
| 8254 * Indicates that the modifier 'final' was applied to the element. | 7715 * Indicates that the modifier 'final' was applied to the element. |
| 8255 */ | 7716 */ |
| 8256 static const Modifier FINAL = const Modifier('FINAL', 6); | 7717 static const Modifier FINAL = const Modifier('FINAL', 6); |
| 8257 | 7718 |
| 8258 /** | 7719 /** |
| 8259 * Indicates that an executable element has a body marked as being a generator
. | 7720 * Indicates that an executable element has a body marked as being a |
| 7721 * generator. |
| 8260 */ | 7722 */ |
| 8261 static const Modifier GENERATOR = const Modifier('GENERATOR', 7); | 7723 static const Modifier GENERATOR = const Modifier('GENERATOR', 7); |
| 8262 | 7724 |
| 8263 /** | 7725 /** |
| 8264 * Indicates that the pseudo-modifier 'get' was applied to the element. | 7726 * Indicates that the pseudo-modifier 'get' was applied to the element. |
| 8265 */ | 7727 */ |
| 8266 static const Modifier GETTER = const Modifier('GETTER', 8); | 7728 static const Modifier GETTER = const Modifier('GETTER', 8); |
| 8267 | 7729 |
| 8268 /** | 7730 /** |
| 8269 * A flag used for libraries indicating that the defining compilation unit con
tains at least one | 7731 * A flag used for libraries indicating that the defining compilation unit |
| 8270 * import directive whose URI uses the "dart-ext" scheme. | 7732 * contains at least one import directive whose URI uses the "dart-ext" |
| 7733 * scheme. |
| 8271 */ | 7734 */ |
| 8272 static const Modifier HAS_EXT_URI = const Modifier('HAS_EXT_URI', 9); | 7735 static const Modifier HAS_EXT_URI = const Modifier('HAS_EXT_URI', 9); |
| 8273 | 7736 |
| 8274 /** | 7737 /** |
| 8275 * Indicates that a class can validly be used as a mixin. | 7738 * Indicates that a class can validly be used as a mixin. |
| 8276 */ | 7739 */ |
| 8277 static const Modifier MIXIN = const Modifier('MIXIN', 10); | 7740 static const Modifier MIXIN = const Modifier('MIXIN', 10); |
| 8278 | 7741 |
| 8279 /** | 7742 /** |
| 8280 * Indicates that an error has reported explaining why this class is an | 7743 * Indicates that an error has reported explaining why this class is an |
| 8281 * invalid mixin application. | 7744 * invalid mixin application. |
| 8282 */ | 7745 */ |
| 8283 static const Modifier MIXIN_ERRORS_REPORTED = | 7746 static const Modifier MIXIN_ERRORS_REPORTED = |
| 8284 const Modifier('MIXIN_ERRORS_REPORTED', 11); | 7747 const Modifier('MIXIN_ERRORS_REPORTED', 11); |
| 8285 | 7748 |
| 8286 /** | 7749 /** |
| 8287 * Indicates that the value of a parameter or local variable might be mutated
within the context. | 7750 * Indicates that the value of a parameter or local variable might be mutated |
| 7751 * within the context. |
| 8288 */ | 7752 */ |
| 8289 static const Modifier POTENTIALLY_MUTATED_IN_CONTEXT = | 7753 static const Modifier POTENTIALLY_MUTATED_IN_CONTEXT = |
| 8290 const Modifier('POTENTIALLY_MUTATED_IN_CONTEXT', 12); | 7754 const Modifier('POTENTIALLY_MUTATED_IN_CONTEXT', 12); |
| 8291 | 7755 |
| 8292 /** | 7756 /** |
| 8293 * Indicates that the value of a parameter or local variable might be mutated
within the scope. | 7757 * Indicates that the value of a parameter or local variable might be mutated |
| 7758 * within the scope. |
| 8294 */ | 7759 */ |
| 8295 static const Modifier POTENTIALLY_MUTATED_IN_SCOPE = | 7760 static const Modifier POTENTIALLY_MUTATED_IN_SCOPE = |
| 8296 const Modifier('POTENTIALLY_MUTATED_IN_SCOPE', 13); | 7761 const Modifier('POTENTIALLY_MUTATED_IN_SCOPE', 13); |
| 8297 | 7762 |
| 8298 /** | 7763 /** |
| 8299 * Indicates that a class contains an explicit reference to 'super'. | 7764 * Indicates that a class contains an explicit reference to 'super'. |
| 8300 */ | 7765 */ |
| 8301 static const Modifier REFERENCES_SUPER = | 7766 static const Modifier REFERENCES_SUPER = |
| 8302 const Modifier('REFERENCES_SUPER', 14); | 7767 const Modifier('REFERENCES_SUPER', 14); |
| 8303 | 7768 |
| 8304 /** | 7769 /** |
| 8305 * Indicates that the pseudo-modifier 'set' was applied to the element. | 7770 * Indicates that the pseudo-modifier 'set' was applied to the element. |
| 8306 */ | 7771 */ |
| 8307 static const Modifier SETTER = const Modifier('SETTER', 15); | 7772 static const Modifier SETTER = const Modifier('SETTER', 15); |
| 8308 | 7773 |
| 8309 /** | 7774 /** |
| 8310 * Indicates that the modifier 'static' was applied to the element. | 7775 * Indicates that the modifier 'static' was applied to the element. |
| 8311 */ | 7776 */ |
| 8312 static const Modifier STATIC = const Modifier('STATIC', 16); | 7777 static const Modifier STATIC = const Modifier('STATIC', 16); |
| 8313 | 7778 |
| 8314 /** | 7779 /** |
| 8315 * Indicates that the element does not appear in the source code but was impli
citly created. For | 7780 * Indicates that the element does not appear in the source code but was |
| 8316 * example, if a class does not define any constructors, an implicit zero-argu
ment constructor | 7781 * implicitly created. For example, if a class does not define any |
| 8317 * will be created and it will be marked as being synthetic. | 7782 * constructors, an implicit zero-argument constructor will be created and it |
| 7783 * will be marked as being synthetic. |
| 8318 */ | 7784 */ |
| 8319 static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 17); | 7785 static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 17); |
| 8320 | 7786 |
| 8321 /** | 7787 /** |
| 8322 * Indicates that a class was defined using an alias. TODO(brianwilkerson) Thi
s should be renamed | 7788 * Indicates that a class was defined using an alias. |
| 8323 * to 'ALIAS'. | 7789 * TODO(brianwilkerson) This should be renamed to 'ALIAS'. |
| 8324 */ | 7790 */ |
| 8325 static const Modifier TYPEDEF = const Modifier('TYPEDEF', 18); | 7791 static const Modifier TYPEDEF = const Modifier('TYPEDEF', 18); |
| 8326 | 7792 |
| 8327 static const List<Modifier> values = const [ | 7793 static const List<Modifier> values = const [ |
| 8328 ABSTRACT, | 7794 ABSTRACT, |
| 8329 ASYNCHRONOUS, | 7795 ASYNCHRONOUS, |
| 8330 CONST, | 7796 CONST, |
| 8331 DEFERRED, | 7797 DEFERRED, |
| 8332 ENUM, | 7798 ENUM, |
| 8333 FACTORY, | 7799 FACTORY, |
| 8334 FINAL, | 7800 FINAL, |
| 8335 GENERATOR, | 7801 GENERATOR, |
| 8336 GETTER, | 7802 GETTER, |
| 8337 HAS_EXT_URI, | 7803 HAS_EXT_URI, |
| 8338 MIXIN, | 7804 MIXIN, |
| 8339 MIXIN_ERRORS_REPORTED, | 7805 MIXIN_ERRORS_REPORTED, |
| 8340 POTENTIALLY_MUTATED_IN_CONTEXT, | 7806 POTENTIALLY_MUTATED_IN_CONTEXT, |
| 8341 POTENTIALLY_MUTATED_IN_SCOPE, | 7807 POTENTIALLY_MUTATED_IN_SCOPE, |
| 8342 REFERENCES_SUPER, | 7808 REFERENCES_SUPER, |
| 8343 SETTER, | 7809 SETTER, |
| 8344 STATIC, | 7810 STATIC, |
| 8345 SYNTHETIC, | 7811 SYNTHETIC, |
| 8346 TYPEDEF | 7812 TYPEDEF |
| 8347 ]; | 7813 ]; |
| 8348 | 7814 |
| 8349 const Modifier(String name, int ordinal) : super(name, ordinal); | 7815 const Modifier(String name, int ordinal) : super(name, ordinal); |
| 8350 } | 7816 } |
| 8351 | 7817 |
| 8352 /** | 7818 /** |
| 8353 * The interface `MultiplyDefinedElement` defines the behavior of pseudo-element
s that | 7819 * A pseudo-element that represents multiple elements defined within a single |
| 8354 * represent multiple elements defined within a single scope that have the same
name. This situation | 7820 * scope that have the same name. This situation is not allowed by the language, |
| 8355 * is not allowed by the language, so objects implementing this interface always
represent an error. | 7821 * so objects implementing this interface always represent an error. As a |
| 8356 * As a result, most of the normal operations on elements do not make sense and
will return useless | 7822 * result, most of the normal operations on elements do not make sense and will |
| 8357 * results. | 7823 * return useless results. |
| 8358 */ | 7824 */ |
| 8359 abstract class MultiplyDefinedElement implements Element { | 7825 abstract class MultiplyDefinedElement implements Element { |
| 8360 /** | 7826 /** |
| 8361 * Return an array containing all of the elements that were defined within the
scope to have the | 7827 * Return a list containing all of the elements that were defined within the |
| 8362 * same name. | 7828 * scope to have the same name. |
| 8363 * | |
| 8364 * @return the elements that were defined with the same name | |
| 8365 */ | 7829 */ |
| 8366 List<Element> get conflictingElements; | 7830 List<Element> get conflictingElements; |
| 8367 | 7831 |
| 8368 /** | 7832 /** |
| 8369 * Return the type of this element as the dynamic type. | 7833 * Return the type of this element as the dynamic type. |
| 8370 * | |
| 8371 * @return the type of this element as the dynamic type | |
| 8372 */ | 7834 */ |
| 8373 DartType get type; | 7835 DartType get type; |
| 8374 } | 7836 } |
| 8375 | 7837 |
| 8376 /** | 7838 /** |
| 8377 * Instances of the class `MultiplyDefinedElementImpl` represent a collection of
elements that | 7839 * A concrete implementation of a [MultiplyDefinedElement]. |
| 8378 * have the same name within the same scope. | |
| 8379 */ | 7840 */ |
| 8380 class MultiplyDefinedElementImpl implements MultiplyDefinedElement { | 7841 class MultiplyDefinedElementImpl implements MultiplyDefinedElement { |
| 8381 /** | 7842 /** |
| 8382 * The unique integer identifier of this element. | 7843 * The unique integer identifier of this element. |
| 8383 */ | 7844 */ |
| 8384 final int id = ElementImpl._NEXT_ID++; | 7845 final int id = ElementImpl._NEXT_ID++; |
| 8385 | 7846 |
| 8386 /** | 7847 /** |
| 8387 * The analysis context in which the multiply defined elements are defined. | 7848 * The analysis context in which the multiply defined elements are defined. |
| 8388 */ | 7849 */ |
| 8389 final AnalysisContext context; | 7850 final AnalysisContext context; |
| 8390 | 7851 |
| 8391 /** | 7852 /** |
| 8392 * The name of the conflicting elements. | 7853 * The name of the conflicting elements. |
| 8393 */ | 7854 */ |
| 8394 String _name; | 7855 String _name; |
| 8395 | 7856 |
| 8396 /** | 7857 /** |
| 8397 * A list containing all of the elements that conflict. | 7858 * A list containing all of the elements that conflict. |
| 8398 */ | 7859 */ |
| 8399 final List<Element> conflictingElements; | 7860 final List<Element> conflictingElements; |
| 8400 | 7861 |
| 8401 /** | 7862 /** |
| 8402 * Initialize a newly created element to represent a list of conflicting eleme
nts. | 7863 * Initialize a newly created element in the given [context] to represent a |
| 8403 * | 7864 * list of [conflictingElements]. |
| 8404 * @param context the analysis context in which the multiply defined elements
are defined | |
| 8405 * @param conflictingElements the elements that conflict | |
| 8406 */ | 7865 */ |
| 8407 MultiplyDefinedElementImpl(this.context, this.conflictingElements) { | 7866 MultiplyDefinedElementImpl(this.context, this.conflictingElements) { |
| 8408 _name = conflictingElements[0].name; | 7867 _name = conflictingElements[0].name; |
| 8409 } | 7868 } |
| 8410 | 7869 |
| 8411 @override | 7870 @override |
| 8412 String get displayName => _name; | 7871 String get displayName => _name; |
| 8413 | 7872 |
| 8414 @override | 7873 @override |
| 8415 Element get enclosingElement => null; | 7874 Element get enclosingElement => null; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8506 buffer.write("]"); | 7965 buffer.write("]"); |
| 8507 return buffer.toString(); | 7966 return buffer.toString(); |
| 8508 } | 7967 } |
| 8509 | 7968 |
| 8510 @override | 7969 @override |
| 8511 void visitChildren(ElementVisitor visitor) { | 7970 void visitChildren(ElementVisitor visitor) { |
| 8512 // There are no children to visit | 7971 // There are no children to visit |
| 8513 } | 7972 } |
| 8514 | 7973 |
| 8515 /** | 7974 /** |
| 8516 * Return an element that represents the given conflicting elements. | 7975 * Return an element in the given [context] that represents the fact that the |
| 8517 * | 7976 * [firstElement] and [secondElement] conflict. (If the elements are the same, |
| 8518 * @param context the analysis context in which the multiply defined elements
are defined | 7977 * then one of the two will be returned directly.) |
| 8519 * @param firstElement the first element that conflicts | |
| 8520 * @param secondElement the second element that conflicts | |
| 8521 */ | 7978 */ |
| 8522 static Element fromElements( | 7979 static Element fromElements( |
| 8523 AnalysisContext context, Element firstElement, Element secondElement) { | 7980 AnalysisContext context, Element firstElement, Element secondElement) { |
| 8524 List<Element> conflictingElements = | 7981 List<Element> conflictingElements = |
| 8525 _computeConflictingElements(firstElement, secondElement); | 7982 _computeConflictingElements(firstElement, secondElement); |
| 8526 int length = conflictingElements.length; | 7983 int length = conflictingElements.length; |
| 8527 if (length == 0) { | 7984 if (length == 0) { |
| 8528 return null; | 7985 return null; |
| 8529 } else if (length == 1) { | 7986 } else if (length == 1) { |
| 8530 return conflictingElements[0]; | 7987 return conflictingElements[0]; |
| 8531 } | 7988 } |
| 8532 return new MultiplyDefinedElementImpl(context, conflictingElements); | 7989 return new MultiplyDefinedElementImpl(context, conflictingElements); |
| 8533 } | 7990 } |
| 8534 | 7991 |
| 8535 /** | 7992 /** |
| 8536 * Add the given element to the list of elements. If the element is a multiply
-defined element, | 7993 * Add the given [element] to the list of [elements]. If the element is a |
| 8537 * add all of the conflicting elements that it represents. | 7994 * multiply-defined element, add all of the conflicting elements that it |
| 8538 * | 7995 * represents. |
| 8539 * @param elements the list to which the element(s) are to be added | |
| 8540 * @param element the element(s) to be added | |
| 8541 */ | 7996 */ |
| 8542 static void _add(HashSet<Element> elements, Element element) { | 7997 static void _add(HashSet<Element> elements, Element element) { |
| 8543 if (element is MultiplyDefinedElementImpl) { | 7998 if (element is MultiplyDefinedElementImpl) { |
| 8544 for (Element conflictingElement in element.conflictingElements) { | 7999 for (Element conflictingElement in element.conflictingElements) { |
| 8545 elements.add(conflictingElement); | 8000 elements.add(conflictingElement); |
| 8546 } | 8001 } |
| 8547 } else { | 8002 } else { |
| 8548 elements.add(element); | 8003 elements.add(element); |
| 8549 } | 8004 } |
| 8550 } | 8005 } |
| 8551 | 8006 |
| 8552 /** | 8007 /** |
| 8553 * Use the given elements to construct an array of conflicting elements. If ei
ther of the given | 8008 * Use the given elements to construct a list of conflicting elements. If |
| 8554 * elements are multiply-defined elements then the conflicting elements they r
epresent will be | 8009 * either the [firstElement] or [secondElement] are multiply-defined elements |
| 8555 * included in the array. Otherwise, the element itself will be included. | 8010 * then the conflicting elements they represent will be included in the array. |
| 8556 * | 8011 * Otherwise, the element itself will be included. |
| 8557 * @param firstElement the first element to be included | |
| 8558 * @param secondElement the second element to be included | |
| 8559 * @return an array containing all of the conflicting elements | |
| 8560 */ | 8012 */ |
| 8561 static List<Element> _computeConflictingElements( | 8013 static List<Element> _computeConflictingElements( |
| 8562 Element firstElement, Element secondElement) { | 8014 Element firstElement, Element secondElement) { |
| 8563 HashSet<Element> elements = new HashSet<Element>(); | 8015 HashSet<Element> elements = new HashSet<Element>(); |
| 8564 _add(elements, firstElement); | 8016 _add(elements, firstElement); |
| 8565 _add(elements, secondElement); | 8017 _add(elements, secondElement); |
| 8566 return new List.from(elements); | 8018 return new List.from(elements); |
| 8567 } | 8019 } |
| 8568 } | 8020 } |
| 8569 | 8021 |
| 8570 /** | 8022 /** |
| 8571 * The interface [MultiplyInheritedExecutableElement] defines all of the behavio
r of an | 8023 * An [ExecutableElement], with the additional information of a list of |
| 8572 * [ExecutableElement], with the additional information of an array of | |
| 8573 * [ExecutableElement]s from which this element was composed. | 8024 * [ExecutableElement]s from which this element was composed. |
| 8574 */ | 8025 */ |
| 8575 abstract class MultiplyInheritedExecutableElement implements ExecutableElement { | 8026 abstract class MultiplyInheritedExecutableElement implements ExecutableElement { |
| 8576 /** | 8027 /** |
| 8577 * Return an array containing all of the executable elements defined within th
is executable | 8028 * Return a list containing all of the executable elements defined within this |
| 8578 * element. | 8029 * executable element. |
| 8579 * | |
| 8580 * @return the elements defined within this executable element | |
| 8581 */ | 8030 */ |
| 8582 List<ExecutableElement> get inheritedElements; | 8031 List<ExecutableElement> get inheritedElements; |
| 8583 } | 8032 } |
| 8584 | 8033 |
| 8585 /** | 8034 /** |
| 8586 * The interface [MultiplyInheritedMethodElementImpl] defines all of the behavio
r of an | 8035 * A [MethodElementImpl], with the additional information of a list of |
| 8587 * [MethodElementImpl], with the additional information of an array of | |
| 8588 * [ExecutableElement]s from which this element was composed. | 8036 * [ExecutableElement]s from which this element was composed. |
| 8589 */ | 8037 */ |
| 8590 class MultiplyInheritedMethodElementImpl extends MethodElementImpl | 8038 class MultiplyInheritedMethodElementImpl extends MethodElementImpl |
| 8591 implements MultiplyInheritedExecutableElement { | 8039 implements MultiplyInheritedExecutableElement { |
| 8592 /** | 8040 /** |
| 8593 * An array the array of executable elements that were used to compose this el
ement. | 8041 * A list the array of executable elements that were used to compose this |
| 8042 * element. |
| 8594 */ | 8043 */ |
| 8595 List<ExecutableElement> _elements = MethodElementImpl.EMPTY_ARRAY; | 8044 List<ExecutableElement> _elements = MethodElementImpl.EMPTY_ARRAY; |
| 8596 | 8045 |
| 8597 MultiplyInheritedMethodElementImpl(Identifier name) : super.forNode(name) { | 8046 MultiplyInheritedMethodElementImpl(Identifier name) : super.forNode(name) { |
| 8598 synthetic = true; | 8047 synthetic = true; |
| 8599 } | 8048 } |
| 8600 | 8049 |
| 8601 @override | 8050 @override |
| 8602 List<ExecutableElement> get inheritedElements => _elements; | 8051 List<ExecutableElement> get inheritedElements => _elements; |
| 8603 | 8052 |
| 8604 void set inheritedElements(List<ExecutableElement> elements) { | 8053 void set inheritedElements(List<ExecutableElement> elements) { |
| 8605 this._elements = elements; | 8054 this._elements = elements; |
| 8606 } | 8055 } |
| 8607 } | 8056 } |
| 8608 | 8057 |
| 8609 /** | 8058 /** |
| 8610 * The interface [MultiplyInheritedPropertyAccessorElementImpl] defines all of t
he behavior of | 8059 * A [PropertyAccessorElementImpl], with the additional information of a list of |
| 8611 * an [PropertyAccessorElementImpl], with the additional information of an array
of | |
| 8612 * [ExecutableElement]s from which this element was composed. | 8060 * [ExecutableElement]s from which this element was composed. |
| 8613 */ | 8061 */ |
| 8614 class MultiplyInheritedPropertyAccessorElementImpl | 8062 class MultiplyInheritedPropertyAccessorElementImpl |
| 8615 extends PropertyAccessorElementImpl | 8063 extends PropertyAccessorElementImpl |
| 8616 implements MultiplyInheritedExecutableElement { | 8064 implements MultiplyInheritedExecutableElement { |
| 8617 /** | 8065 /** |
| 8618 * An array the array of executable elements that were used to compose this el
ement. | 8066 * A list the array of executable elements that were used to compose this |
| 8067 * element. |
| 8619 */ | 8068 */ |
| 8620 List<ExecutableElement> _elements = PropertyAccessorElementImpl.EMPTY_ARRAY; | 8069 List<ExecutableElement> _elements = PropertyAccessorElementImpl.EMPTY_ARRAY; |
| 8621 | 8070 |
| 8622 MultiplyInheritedPropertyAccessorElementImpl(Identifier name) | 8071 MultiplyInheritedPropertyAccessorElementImpl(Identifier name) |
| 8623 : super.forNode(name) { | 8072 : super.forNode(name) { |
| 8624 synthetic = true; | 8073 synthetic = true; |
| 8625 } | 8074 } |
| 8626 | 8075 |
| 8627 @override | 8076 @override |
| 8628 List<ExecutableElement> get inheritedElements => _elements; | 8077 List<ExecutableElement> get inheritedElements => _elements; |
| 8629 | 8078 |
| 8630 void set inheritedElements(List<ExecutableElement> elements) { | 8079 void set inheritedElements(List<ExecutableElement> elements) { |
| 8631 this._elements = elements; | 8080 this._elements = elements; |
| 8632 } | 8081 } |
| 8633 } | 8082 } |
| 8634 | 8083 |
| 8635 /** | 8084 /** |
| 8636 * The interface `NamespaceCombinator` defines the behavior common to objects th
at control how | 8085 * An object that controls how namespaces are combined. |
| 8637 * namespaces are combined. | |
| 8638 */ | 8086 */ |
| 8639 abstract class NamespaceCombinator { | 8087 abstract class NamespaceCombinator { |
| 8640 /** | 8088 /** |
| 8641 * An empty list of namespace combinators. | 8089 * An empty list of namespace combinators. |
| 8642 */ | 8090 */ |
| 8643 static const List<NamespaceCombinator> EMPTY_ARRAY = | 8091 static const List<NamespaceCombinator> EMPTY_ARRAY = |
| 8644 const <NamespaceCombinator>[]; | 8092 const <NamespaceCombinator>[]; |
| 8645 } | 8093 } |
| 8646 | 8094 |
| 8647 /** | 8095 /** |
| 8648 * The interface `ParameterElement` defines the behavior of elements representin
g a parameter | 8096 * A parameter defined within an executable element. |
| 8649 * defined within an executable element. | |
| 8650 */ | 8097 */ |
| 8651 abstract class ParameterElement implements LocalElement, VariableElement { | 8098 abstract class ParameterElement implements LocalElement, VariableElement { |
| 8652 /** | 8099 /** |
| 8653 * Return the Dart code of the default value, or `null` if no default value. | 8100 * Return the Dart code of the default value, or `null` if no default value. |
| 8654 * | |
| 8655 * @return the Dart code of the default value | |
| 8656 */ | 8101 */ |
| 8657 String get defaultValueCode; | 8102 String get defaultValueCode; |
| 8658 | 8103 |
| 8659 /** | 8104 /** |
| 8660 * Return `true` if this parameter is an initializing formal parameter. | 8105 * Return `true` if this parameter is an initializing formal parameter. |
| 8661 * | |
| 8662 * @return `true` if this parameter is an initializing formal parameter | |
| 8663 */ | 8106 */ |
| 8664 bool get isInitializingFormal; | 8107 bool get isInitializingFormal; |
| 8665 | 8108 |
| 8666 /** | 8109 /** |
| 8667 * Return the kind of this parameter. | 8110 * Return the kind of this parameter. |
| 8668 * | |
| 8669 * @return the kind of this parameter | |
| 8670 */ | 8111 */ |
| 8671 ParameterKind get parameterKind; | 8112 ParameterKind get parameterKind; |
| 8672 | 8113 |
| 8673 /** | 8114 /** |
| 8674 * Return an array containing all of the parameters defined by this parameter.
A parameter will | 8115 * Return a list containing all of the parameters defined by this parameter. |
| 8675 * only define other parameters if it is a function typed parameter. | 8116 * A parameter will only define other parameters if it is a function typed |
| 8676 * | 8117 * parameter. |
| 8677 * @return the parameters defined by this parameter element | |
| 8678 */ | 8118 */ |
| 8679 List<ParameterElement> get parameters; | 8119 List<ParameterElement> get parameters; |
| 8680 } | 8120 } |
| 8681 | 8121 |
| 8682 /** | 8122 /** |
| 8683 * Instances of the class `ParameterElementImpl` implement a `ParameterElement`. | 8123 * A concrete implementation of a [ParameterElement]. |
| 8684 */ | 8124 */ |
| 8685 class ParameterElementImpl extends VariableElementImpl | 8125 class ParameterElementImpl extends VariableElementImpl |
| 8686 implements ParameterElement { | 8126 implements ParameterElement { |
| 8687 /** | 8127 /** |
| 8688 * An empty list of field elements. | 8128 * An empty list of field elements. |
| 8689 */ | 8129 */ |
| 8690 static const List<ParameterElement> EMPTY_ARRAY = const <ParameterElement>[]; | 8130 static const List<ParameterElement> EMPTY_ARRAY = const <ParameterElement>[]; |
| 8691 | 8131 |
| 8692 /** | 8132 /** |
| 8693 * An array containing all of the parameters defined by this parameter element
. There will only be | 8133 * A list containing all of the parameters defined by this parameter element. |
| 8694 * parameters if this parameter is a function typed parameter. | 8134 * There will only be parameters if this parameter is a function typed |
| 8135 * parameter. |
| 8695 */ | 8136 */ |
| 8696 List<ParameterElement> _parameters = ParameterElementImpl.EMPTY_ARRAY; | 8137 List<ParameterElement> _parameters = ParameterElementImpl.EMPTY_ARRAY; |
| 8697 | 8138 |
| 8698 /** | 8139 /** |
| 8699 * The kind of this parameter. | 8140 * The kind of this parameter. |
| 8700 */ | 8141 */ |
| 8701 ParameterKind parameterKind; | 8142 ParameterKind parameterKind; |
| 8702 | 8143 |
| 8703 /** | 8144 /** |
| 8704 * The Dart code of the default value. | 8145 * The Dart code of the default value. |
| 8705 */ | 8146 */ |
| 8706 String _defaultValueCode; | 8147 String _defaultValueCode; |
| 8707 | 8148 |
| 8708 /** | 8149 /** |
| 8709 * The offset to the beginning of the visible range for this element. | 8150 * The offset to the beginning of the visible range for this element. |
| 8710 */ | 8151 */ |
| 8711 int _visibleRangeOffset = 0; | 8152 int _visibleRangeOffset = 0; |
| 8712 | 8153 |
| 8713 /** | 8154 /** |
| 8714 * The length of the visible range for this element, or `-1` if this element d
oes not have a | 8155 * The length of the visible range for this element, or `-1` if this element |
| 8715 * visible range. | 8156 * does not have a visible range. |
| 8716 */ | 8157 */ |
| 8717 int _visibleRangeLength = -1; | 8158 int _visibleRangeLength = -1; |
| 8718 | 8159 |
| 8719 /** | 8160 /** |
| 8720 * Initialize a newly created parameter element to have the given name. | 8161 * Initialize a newly created parameter element to have the given [name] and |
| 8721 * | 8162 * [offset]. |
| 8722 * @param name the name of this element | |
| 8723 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
| 8724 * declaration of this element | |
| 8725 */ | 8163 */ |
| 8726 ParameterElementImpl(String name, int nameOffset) : super(name, nameOffset); | 8164 ParameterElementImpl(String name, int nameOffset) : super(name, nameOffset); |
| 8727 | 8165 |
| 8728 /** | 8166 /** |
| 8729 * Initialize a newly created parameter element to have the given name. | 8167 * Initialize a newly created parameter element to have the given [name]. |
| 8730 * | |
| 8731 * @param name the name of this element | |
| 8732 */ | 8168 */ |
| 8733 ParameterElementImpl.forNode(Identifier name) : super.forNode(name); | 8169 ParameterElementImpl.forNode(Identifier name) : super.forNode(name); |
| 8734 | 8170 |
| 8735 @override | 8171 @override |
| 8736 String get defaultValueCode => _defaultValueCode; | 8172 String get defaultValueCode => _defaultValueCode; |
| 8737 | 8173 |
| 8738 /** | 8174 /** |
| 8739 * Set Dart code of the default value. | 8175 * Set Dart code of the default value. |
| 8740 */ | 8176 */ |
| 8741 void set defaultValueCode(String defaultValueCode) { | 8177 void set defaultValueCode(String defaultValueCode) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 8753 bool get isPotentiallyMutatedInScope => | 8189 bool get isPotentiallyMutatedInScope => |
| 8754 hasModifier(Modifier.POTENTIALLY_MUTATED_IN_SCOPE); | 8190 hasModifier(Modifier.POTENTIALLY_MUTATED_IN_SCOPE); |
| 8755 | 8191 |
| 8756 @override | 8192 @override |
| 8757 ElementKind get kind => ElementKind.PARAMETER; | 8193 ElementKind get kind => ElementKind.PARAMETER; |
| 8758 | 8194 |
| 8759 @override | 8195 @override |
| 8760 List<ParameterElement> get parameters => _parameters; | 8196 List<ParameterElement> get parameters => _parameters; |
| 8761 | 8197 |
| 8762 /** | 8198 /** |
| 8763 * Set the parameters defined by this executable element to the given paramete
rs. | 8199 * Set the parameters defined by this executable element to the given |
| 8764 * | 8200 * [parameters]. |
| 8765 * @param parameters the parameters defined by this executable element | |
| 8766 */ | 8201 */ |
| 8767 void set parameters(List<ParameterElement> parameters) { | 8202 void set parameters(List<ParameterElement> parameters) { |
| 8768 for (ParameterElement parameter in parameters) { | 8203 for (ParameterElement parameter in parameters) { |
| 8769 (parameter as ParameterElementImpl).enclosingElement = this; | 8204 (parameter as ParameterElementImpl).enclosingElement = this; |
| 8770 } | 8205 } |
| 8771 this._parameters = parameters; | 8206 this._parameters = parameters; |
| 8772 } | 8207 } |
| 8773 | 8208 |
| 8774 @override | 8209 @override |
| 8775 SourceRange get visibleRange { | 8210 SourceRange get visibleRange { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 8795 right = "]"; | 8230 right = "]"; |
| 8796 } else if (parameterKind == ParameterKind.REQUIRED) {} | 8231 } else if (parameterKind == ParameterKind.REQUIRED) {} |
| 8797 break; | 8232 break; |
| 8798 } | 8233 } |
| 8799 buffer.write(left); | 8234 buffer.write(left); |
| 8800 appendToWithoutDelimiters(buffer); | 8235 appendToWithoutDelimiters(buffer); |
| 8801 buffer.write(right); | 8236 buffer.write(right); |
| 8802 } | 8237 } |
| 8803 | 8238 |
| 8804 /** | 8239 /** |
| 8805 * Append the type and name of this parameter to the given builder. | 8240 * Append the type and name of this parameter to the given [buffer]. |
| 8806 * | |
| 8807 * @param builder the builder to which the type and name are to be appended | |
| 8808 */ | 8241 */ |
| 8809 void appendToWithoutDelimiters(StringBuffer buffer) { | 8242 void appendToWithoutDelimiters(StringBuffer buffer) { |
| 8810 buffer.write(type); | 8243 buffer.write(type); |
| 8811 buffer.write(" "); | 8244 buffer.write(" "); |
| 8812 buffer.write(displayName); | 8245 buffer.write(displayName); |
| 8813 if (_defaultValueCode != null) { | 8246 if (_defaultValueCode != null) { |
| 8814 if (parameterKind == ParameterKind.NAMED) { | 8247 if (parameterKind == ParameterKind.NAMED) { |
| 8815 buffer.write(": "); | 8248 buffer.write(": "); |
| 8816 } | 8249 } |
| 8817 if (parameterKind == ParameterKind.POSITIONAL) { | 8250 if (parameterKind == ParameterKind.POSITIONAL) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 8839 } | 8272 } |
| 8840 | 8273 |
| 8841 /** | 8274 /** |
| 8842 * Specifies that this variable is potentially mutated somewhere in its scope. | 8275 * Specifies that this variable is potentially mutated somewhere in its scope. |
| 8843 */ | 8276 */ |
| 8844 void markPotentiallyMutatedInScope() { | 8277 void markPotentiallyMutatedInScope() { |
| 8845 setModifier(Modifier.POTENTIALLY_MUTATED_IN_SCOPE, true); | 8278 setModifier(Modifier.POTENTIALLY_MUTATED_IN_SCOPE, true); |
| 8846 } | 8279 } |
| 8847 | 8280 |
| 8848 /** | 8281 /** |
| 8849 * Set the visible range for this element to the range starting at the given o
ffset with the given | 8282 * Set the visible range for this element to the range starting at the given |
| 8850 * length. | 8283 * [offset] with the given [length]. |
| 8851 * | |
| 8852 * @param offset the offset to the beginning of the visible range for this ele
ment | |
| 8853 * @param length the length of the visible range for this element, or `-1` if
this element | |
| 8854 * does not have a visible range | |
| 8855 */ | 8284 */ |
| 8856 void setVisibleRange(int offset, int length) { | 8285 void setVisibleRange(int offset, int length) { |
| 8857 _visibleRangeOffset = offset; | 8286 _visibleRangeOffset = offset; |
| 8858 _visibleRangeLength = length; | 8287 _visibleRangeLength = length; |
| 8859 } | 8288 } |
| 8860 | 8289 |
| 8861 @override | 8290 @override |
| 8862 void visitChildren(ElementVisitor visitor) { | 8291 void visitChildren(ElementVisitor visitor) { |
| 8863 super.visitChildren(visitor); | 8292 super.visitChildren(visitor); |
| 8864 safelyVisitChildren(_parameters, visitor); | 8293 safelyVisitChildren(_parameters, visitor); |
| 8865 } | 8294 } |
| 8866 } | 8295 } |
| 8867 | 8296 |
| 8868 /** | 8297 /** |
| 8869 * The interface `ParameterizedType` defines the behavior common to objects repr
esenting a | 8298 * A type with type parameters, such as a class or function type alias. |
| 8870 * type with type parameters, such as a class or function type alias. | |
| 8871 */ | 8299 */ |
| 8872 abstract class ParameterizedType implements DartType { | 8300 abstract class ParameterizedType implements DartType { |
| 8873 /** | 8301 /** |
| 8874 * Return an array containing the actual types of the type arguments. If this
type's element does | 8302 * Return a list containing the actual types of the type arguments. If this |
| 8875 * not have type parameters, then the array should be empty (although it is po
ssible for type | 8303 * type's element does not have type parameters, then the array should be |
| 8876 * arguments to be erroneously declared). If the element has type parameters a
nd the actual type | 8304 * empty (although it is possible for type arguments to be erroneously |
| 8877 * does not explicitly include argument values, then the type "dynamic" will b
e automatically | 8305 * declared). If the element has type parameters and the actual type does not |
| 8878 * provided. | 8306 * explicitly include argument values, then the type "dynamic" will be |
| 8879 * | 8307 * automatically provided. |
| 8880 * @return the actual types of the type arguments | |
| 8881 */ | 8308 */ |
| 8882 List<DartType> get typeArguments; | 8309 List<DartType> get typeArguments; |
| 8883 | 8310 |
| 8884 /** | 8311 /** |
| 8885 * Return an array containing all of the type parameters declared for this typ
e. | 8312 * Return a list containing all of the type parameters declared for this type. |
| 8886 * | |
| 8887 * @return the type parameters declared for this type | |
| 8888 */ | 8313 */ |
| 8889 List<TypeParameterElement> get typeParameters; | 8314 List<TypeParameterElement> get typeParameters; |
| 8890 } | 8315 } |
| 8891 | 8316 |
| 8892 /** | 8317 /** |
| 8893 * Instances of the class `ParameterMember` represent a parameter element define
d in a | 8318 * A parameter element defined in a parameterized type where the values of the |
| 8894 * parameterized type where the values of the type parameters are known. | 8319 * type parameters are known. |
| 8895 */ | 8320 */ |
| 8896 class ParameterMember extends VariableMember implements ParameterElement { | 8321 class ParameterMember extends VariableMember implements ParameterElement { |
| 8897 /** | 8322 /** |
| 8898 * Initialize a newly created element to represent a parameter of the given pa
rameterized type. | 8323 * Initialize a newly created element to represent a constructor, based on the |
| 8899 * | 8324 * [baseElement], defined by the [definingType]. |
| 8900 * @param baseElement the element on which the parameterized element was creat
ed | |
| 8901 * @param definingType the type in which the element is defined | |
| 8902 */ | 8325 */ |
| 8903 ParameterMember(ParameterElement baseElement, ParameterizedType definingType) | 8326 ParameterMember(ParameterElement baseElement, ParameterizedType definingType) |
| 8904 : super(baseElement, definingType); | 8327 : super(baseElement, definingType); |
| 8905 | 8328 |
| 8906 @override | 8329 @override |
| 8907 ParameterElement get baseElement => super.baseElement as ParameterElement; | 8330 ParameterElement get baseElement => super.baseElement as ParameterElement; |
| 8908 | 8331 |
| 8909 @override | 8332 @override |
| 8910 String get defaultValueCode => baseElement.defaultValueCode; | 8333 String get defaultValueCode => baseElement.defaultValueCode; |
| 8911 | 8334 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8975 return '$left$type ${baseElement.displayName}$right'; | 8398 return '$left$type ${baseElement.displayName}$right'; |
| 8976 } | 8399 } |
| 8977 | 8400 |
| 8978 @override | 8401 @override |
| 8979 void visitChildren(ElementVisitor visitor) { | 8402 void visitChildren(ElementVisitor visitor) { |
| 8980 super.visitChildren(visitor); | 8403 super.visitChildren(visitor); |
| 8981 safelyVisitChildren(parameters, visitor); | 8404 safelyVisitChildren(parameters, visitor); |
| 8982 } | 8405 } |
| 8983 | 8406 |
| 8984 /** | 8407 /** |
| 8985 * If the given parameter's type is different when any type parameters from th
e defining type's | 8408 * If the given [parameter]'s type is different when any type parameters from |
| 8986 * declaration are replaced with the actual type arguments from the defining t
ype, create a | 8409 * the defining type's declaration are replaced with the actual type |
| 8987 * parameter member representing the given parameter. Return the member that w
as created, or the | 8410 * arguments from the [definingType], create a parameter member representing |
| 8988 * base parameter if no member was created. | 8411 * the given parameter. Return the member that was created, or the base |
| 8989 * | 8412 * parameter if no member was created. |
| 8990 * @param baseParameter the base parameter for which a member might be created | |
| 8991 * @param definingType the type defining the parameters and arguments to be us
ed in the | |
| 8992 * substitution | |
| 8993 * @return the parameter element that will return the correctly substituted ty
pes | |
| 8994 */ | 8413 */ |
| 8995 static ParameterElement from( | 8414 static ParameterElement from( |
| 8996 ParameterElement baseParameter, ParameterizedType definingType) { | 8415 ParameterElement parameter, ParameterizedType definingType) { |
| 8997 if (baseParameter == null || definingType.typeArguments.length == 0) { | 8416 if (parameter == null || definingType.typeArguments.length == 0) { |
| 8998 return baseParameter; | 8417 return parameter; |
| 8999 } | 8418 } |
| 9000 // Check if parameter type depends on defining type type arguments. | 8419 // Check if parameter type depends on defining type type arguments. |
| 9001 // It is possible that we did not resolve field formal parameter yet, | 8420 // It is possible that we did not resolve field formal parameter yet, |
| 9002 // so skip this check for it. | 8421 // so skip this check for it. |
| 9003 bool isFieldFormal = baseParameter is FieldFormalParameterElement; | 8422 bool isFieldFormal = parameter is FieldFormalParameterElement; |
| 9004 if (!isFieldFormal) { | 8423 if (!isFieldFormal) { |
| 9005 DartType baseType = baseParameter.type; | 8424 DartType baseType = parameter.type; |
| 9006 List<DartType> argumentTypes = definingType.typeArguments; | 8425 List<DartType> argumentTypes = definingType.typeArguments; |
| 9007 List<DartType> parameterTypes = | 8426 List<DartType> parameterTypes = |
| 9008 TypeParameterTypeImpl.getTypes(definingType.typeParameters); | 8427 TypeParameterTypeImpl.getTypes(definingType.typeParameters); |
| 9009 DartType substitutedType = | 8428 DartType substitutedType = |
| 9010 baseType.substitute2(argumentTypes, parameterTypes); | 8429 baseType.substitute2(argumentTypes, parameterTypes); |
| 9011 if (baseType == substitutedType) { | 8430 if (baseType == substitutedType) { |
| 9012 return baseParameter; | 8431 return parameter; |
| 9013 } | 8432 } |
| 9014 } | 8433 } |
| 9015 // TODO(brianwilkerson) Consider caching the substituted type in the | 8434 // TODO(brianwilkerson) Consider caching the substituted type in the |
| 9016 // instance. It would use more memory but speed up some operations. | 8435 // instance. It would use more memory but speed up some operations. |
| 9017 // We need to see how often the type is being re-computed. | 8436 // We need to see how often the type is being re-computed. |
| 9018 if (isFieldFormal) { | 8437 if (isFieldFormal) { |
| 9019 return new FieldFormalParameterMember( | 8438 return new FieldFormalParameterMember( |
| 9020 baseParameter as FieldFormalParameterElement, definingType); | 8439 parameter as FieldFormalParameterElement, definingType); |
| 9021 } | 8440 } |
| 9022 return new ParameterMember(baseParameter, definingType); | 8441 return new ParameterMember(parameter, definingType); |
| 9023 } | 8442 } |
| 9024 } | 8443 } |
| 9025 | 8444 |
| 9026 /** | 8445 /** |
| 9027 * The interface `PrefixElement` defines the behavior common to elements that re
present a | 8446 * A prefix used to import one or more libraries into another library. |
| 9028 * prefix used to import one or more libraries into another library. | |
| 9029 */ | 8447 */ |
| 9030 abstract class PrefixElement implements Element { | 8448 abstract class PrefixElement implements Element { |
| 9031 /** | 8449 /** |
| 9032 * Return the library into which other libraries are imported using this prefi
x. | 8450 * Return the library into which other libraries are imported using this |
| 9033 * | 8451 * prefix. |
| 9034 * @return the library into which other libraries are imported using this pref
ix | |
| 9035 */ | 8452 */ |
| 9036 @override | 8453 @override |
| 9037 LibraryElement get enclosingElement; | 8454 LibraryElement get enclosingElement; |
| 9038 | 8455 |
| 9039 /** | 8456 /** |
| 9040 * Return an array containing all of the libraries that are imported using thi
s prefix. | 8457 * Return a list containing all of the libraries that are imported using this |
| 9041 * | 8458 * prefix. |
| 9042 * @return the libraries that are imported using this prefix | |
| 9043 */ | 8459 */ |
| 9044 List<LibraryElement> get importedLibraries; | 8460 List<LibraryElement> get importedLibraries; |
| 9045 } | 8461 } |
| 9046 | 8462 |
| 9047 /** | 8463 /** |
| 9048 * Instances of the class `PrefixElementImpl` implement a `PrefixElement`. | 8464 * A concrete implementation of a [PrefixElement]. |
| 9049 */ | 8465 */ |
| 9050 class PrefixElementImpl extends ElementImpl implements PrefixElement { | 8466 class PrefixElementImpl extends ElementImpl implements PrefixElement { |
| 9051 /** | 8467 /** |
| 9052 * An empty list of prefix elements. | 8468 * An empty list of prefix elements. |
| 9053 */ | 8469 */ |
| 9054 static const List<PrefixElement> EMPTY_ARRAY = const <PrefixElement>[]; | 8470 static const List<PrefixElement> EMPTY_ARRAY = const <PrefixElement>[]; |
| 9055 | 8471 |
| 9056 /** | 8472 /** |
| 9057 * An array containing all of the libraries that are imported using this prefi
x. | 8473 * A list containing all of the libraries that are imported using this prefix. |
| 9058 */ | 8474 */ |
| 9059 List<LibraryElement> _importedLibraries = LibraryElementImpl.EMPTY_ARRAY; | 8475 List<LibraryElement> _importedLibraries = LibraryElementImpl.EMPTY_ARRAY; |
| 9060 | 8476 |
| 9061 /** | 8477 /** |
| 9062 * Initialize a newly created method element to have the given name. | 8478 * Initialize a newly created method element to have the given [name] and |
| 9063 * | 8479 * [offset]. |
| 9064 * @param name the name of this element | |
| 9065 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
| 9066 * declaration of this element | |
| 9067 */ | 8480 */ |
| 9068 PrefixElementImpl(String name, int nameOffset) : super(name, nameOffset); | 8481 PrefixElementImpl(String name, int nameOffset) : super(name, nameOffset); |
| 9069 | 8482 |
| 9070 /** | 8483 /** |
| 9071 * Initialize a newly created prefix element to have the given name. | 8484 * Initialize a newly created prefix element to have the given [name]. |
| 9072 * | |
| 9073 * @param name the name of this element | |
| 9074 */ | 8485 */ |
| 9075 PrefixElementImpl.forNode(Identifier name) : super.forNode(name); | 8486 PrefixElementImpl.forNode(Identifier name) : super.forNode(name); |
| 9076 | 8487 |
| 9077 @override | 8488 @override |
| 9078 LibraryElement get enclosingElement => | 8489 LibraryElement get enclosingElement => |
| 9079 super.enclosingElement as LibraryElement; | 8490 super.enclosingElement as LibraryElement; |
| 9080 | 8491 |
| 9081 @override | 8492 @override |
| 9082 String get identifier => "_${super.identifier}"; | 8493 String get identifier => "_${super.identifier}"; |
| 9083 | 8494 |
| 9084 @override | 8495 @override |
| 9085 List<LibraryElement> get importedLibraries => _importedLibraries; | 8496 List<LibraryElement> get importedLibraries => _importedLibraries; |
| 9086 | 8497 |
| 9087 /** | 8498 /** |
| 9088 * Set the libraries that are imported using this prefix to the given librarie
s. | 8499 * Set the libraries that are imported using this prefix to the given |
| 9089 * | 8500 * [libraries]. |
| 9090 * @param importedLibraries the libraries that are imported using this prefix | |
| 9091 */ | 8501 */ |
| 9092 void set importedLibraries(List<LibraryElement> importedLibraries) { | 8502 void set importedLibraries(List<LibraryElement> libraries) { |
| 9093 for (LibraryElement library in importedLibraries) { | 8503 for (LibraryElement library in libraries) { |
| 9094 (library as LibraryElementImpl).enclosingElement = this; | 8504 (library as LibraryElementImpl).enclosingElement = this; |
| 9095 } | 8505 } |
| 9096 this._importedLibraries = importedLibraries; | 8506 _importedLibraries = libraries; |
| 9097 } | 8507 } |
| 9098 | 8508 |
| 9099 @override | 8509 @override |
| 9100 ElementKind get kind => ElementKind.PREFIX; | 8510 ElementKind get kind => ElementKind.PREFIX; |
| 9101 | 8511 |
| 9102 @override | 8512 @override |
| 9103 accept(ElementVisitor visitor) => visitor.visitPrefixElement(this); | 8513 accept(ElementVisitor visitor) => visitor.visitPrefixElement(this); |
| 9104 | 8514 |
| 9105 @override | 8515 @override |
| 9106 void appendTo(StringBuffer buffer) { | 8516 void appendTo(StringBuffer buffer) { |
| 9107 buffer.write("as "); | 8517 buffer.write("as "); |
| 9108 super.appendTo(buffer); | 8518 super.appendTo(buffer); |
| 9109 } | 8519 } |
| 9110 } | 8520 } |
| 9111 | 8521 |
| 9112 /** | 8522 /** |
| 9113 * The interface `PropertyAccessorElement` defines the behavior of elements repr
esenting a | 8523 * A getter or a setter. Note that explicitly defined property accessors |
| 9114 * getter or a setter. Note that explicitly defined property accessors implicitl
y define a synthetic | 8524 * implicitly define a synthetic field. Symmetrically, synthetic accessors are |
| 9115 * field. Symmetrically, synthetic accessors are implicitly created for explicit
ly defined fields. | 8525 * implicitly created for explicitly defined fields. The following rules apply: |
| 9116 * The following rules apply: | 8526 * |
| 9117 * * Every explicit field is represented by a non-synthetic [FieldElement]. | 8527 * * Every explicit field is represented by a non-synthetic [FieldElement]. |
| 9118 * * Every explicit field induces a getter and possibly a setter, both of which
are represented by | 8528 * * Every explicit field induces a getter and possibly a setter, both of which |
| 9119 * synthetic [PropertyAccessorElement]s. | 8529 * are represented by synthetic [PropertyAccessorElement]s. |
| 9120 * * Every explicit getter or setter is represented by a non-synthetic | 8530 * * Every explicit getter or setter is represented by a non-synthetic |
| 9121 * [PropertyAccessorElement]. | 8531 * [PropertyAccessorElement]. |
| 9122 * * Every explicit getter or setter (or pair thereof if they have the same name
) induces a field | 8532 * * Every explicit getter or setter (or pair thereof if they have the same |
| 9123 * that is represented by a synthetic [FieldElement]. | 8533 * name) induces a field that is represented by a synthetic [FieldElement]. |
| 9124 */ | 8534 */ |
| 9125 abstract class PropertyAccessorElement implements ExecutableElement { | 8535 abstract class PropertyAccessorElement implements ExecutableElement { |
| 9126 /** | 8536 /** |
| 9127 * Return the accessor representing the getter that corresponds to (has the sa
me name as) this | 8537 * Return the accessor representing the getter that corresponds to (has the |
| 9128 * setter, or `null` if this accessor is not a setter or if there is no corres
ponding | 8538 * same name as) this setter, or `null` if this accessor is not a setter or if |
| 9129 * getter. | 8539 * there is no corresponding getter. |
| 9130 * | |
| 9131 * @return the getter that corresponds to this setter | |
| 9132 */ | 8540 */ |
| 9133 PropertyAccessorElement get correspondingGetter; | 8541 PropertyAccessorElement get correspondingGetter; |
| 9134 | 8542 |
| 9135 /** | 8543 /** |
| 9136 * Return the accessor representing the setter that corresponds to (has the sa
me name as) this | 8544 * Return the accessor representing the setter that corresponds to (has the |
| 9137 * getter, or `null` if this accessor is not a getter or if there is no corres
ponding | 8545 * same name as) this getter, or `null` if this accessor is not a getter or if |
| 9138 * setter. | 8546 * there is no corresponding setter. |
| 9139 * | |
| 9140 * @return the setter that corresponds to this getter | |
| 9141 */ | 8547 */ |
| 9142 PropertyAccessorElement get correspondingSetter; | 8548 PropertyAccessorElement get correspondingSetter; |
| 9143 | 8549 |
| 9144 /** | 8550 /** |
| 9145 * Return `true` if this accessor is abstract. Accessors are abstract if they
are not | 8551 * Return `true` if this accessor is abstract. Accessors are abstract if they |
| 9146 * external and have no body. | 8552 * are not external and have no body. |
| 9147 * | |
| 9148 * @return `true` if this accessor is abstract | |
| 9149 */ | 8553 */ |
| 9150 bool get isAbstract; | 8554 bool get isAbstract; |
| 9151 | 8555 |
| 9152 /** | 8556 /** |
| 9153 * Return `true` if this accessor represents a getter. | 8557 * Return `true` if this accessor represents a getter. |
| 9154 * | |
| 9155 * @return `true` if this accessor represents a getter | |
| 9156 */ | 8558 */ |
| 9157 bool get isGetter; | 8559 bool get isGetter; |
| 9158 | 8560 |
| 9159 /** | 8561 /** |
| 9160 * Return `true` if this accessor represents a setter. | 8562 * Return `true` if this accessor represents a setter. |
| 9161 * | |
| 9162 * @return `true` if this accessor represents a setter | |
| 9163 */ | 8563 */ |
| 9164 bool get isSetter; | 8564 bool get isSetter; |
| 9165 | 8565 |
| 9166 /** | 8566 /** |
| 9167 * Return the field or top-level variable associated with this accessor. If th
is accessor was | 8567 * Return the field or top-level variable associated with this accessor. If |
| 9168 * explicitly defined (is not synthetic) then the variable associated with it
will be synthetic. | 8568 * this accessor was explicitly defined (is not synthetic) then the variable |
| 9169 * | 8569 * associated with it will be synthetic. |
| 9170 * @return the variable associated with this accessor | |
| 9171 */ | 8570 */ |
| 9172 PropertyInducingElement get variable; | 8571 PropertyInducingElement get variable; |
| 9173 } | 8572 } |
| 9174 | 8573 |
| 9175 /** | 8574 /** |
| 9176 * Instances of the class `PropertyAccessorElementImpl` implement a | 8575 * A concrete implementation of a [PropertyAccessorElement]. |
| 9177 * `PropertyAccessorElement`. | |
| 9178 */ | 8576 */ |
| 9179 class PropertyAccessorElementImpl extends ExecutableElementImpl | 8577 class PropertyAccessorElementImpl extends ExecutableElementImpl |
| 9180 implements PropertyAccessorElement { | 8578 implements PropertyAccessorElement { |
| 9181 /** | 8579 /** |
| 9182 * An empty list of property accessor elements. | 8580 * An empty list of property accessor elements. |
| 9183 */ | 8581 */ |
| 9184 static const List<PropertyAccessorElement> EMPTY_ARRAY = | 8582 static const List<PropertyAccessorElement> EMPTY_ARRAY = |
| 9185 const <PropertyAccessorElement>[]; | 8583 const <PropertyAccessorElement>[]; |
| 9186 | 8584 |
| 9187 /** | 8585 /** |
| 9188 * The variable associated with this accessor. | 8586 * The variable associated with this accessor. |
| 9189 */ | 8587 */ |
| 9190 PropertyInducingElement variable; | 8588 PropertyInducingElement variable; |
| 9191 | 8589 |
| 9192 /** | 8590 /** |
| 9193 * Initialize a newly created property accessor element to have the given name
. | 8591 * Initialize a newly created property accessor element to have the given |
| 9194 * | 8592 * [name]. |
| 9195 * @param name the name of this element | |
| 9196 */ | 8593 */ |
| 9197 PropertyAccessorElementImpl.forNode(Identifier name) : super.forNode(name); | 8594 PropertyAccessorElementImpl.forNode(Identifier name) : super.forNode(name); |
| 9198 | 8595 |
| 9199 /** | 8596 /** |
| 9200 * Initialize a newly created synthetic property accessor element to be associ
ated with the given | 8597 * Initialize a newly created synthetic property accessor element to be |
| 9201 * variable. | 8598 * associated with the given [variable]. |
| 9202 * | |
| 9203 * @param variable the variable with which this access is associated | |
| 9204 */ | 8599 */ |
| 9205 PropertyAccessorElementImpl.forVariable(PropertyInducingElementImpl variable) | 8600 PropertyAccessorElementImpl.forVariable(PropertyInducingElementImpl variable) |
| 9206 : super(variable.name, variable.nameOffset) { | 8601 : super(variable.name, variable.nameOffset) { |
| 9207 this.variable = variable; | 8602 this.variable = variable; |
| 9208 static = variable.isStatic; | 8603 static = variable.isStatic; |
| 9209 synthetic = true; | 8604 synthetic = true; |
| 9210 } | 8605 } |
| 9211 | 8606 |
| 9212 /** | 8607 /** |
| 9213 * Set whether this accessor is abstract to correspond to the given value. | 8608 * Set whether this accessor is abstract. |
| 9214 * | |
| 9215 * @param isAbstract `true` if the accessor is abstract | |
| 9216 */ | 8609 */ |
| 9217 void set abstract(bool isAbstract) { | 8610 void set abstract(bool isAbstract) { |
| 9218 setModifier(Modifier.ABSTRACT, isAbstract); | 8611 setModifier(Modifier.ABSTRACT, isAbstract); |
| 9219 } | 8612 } |
| 9220 | 8613 |
| 9221 @override | 8614 @override |
| 9222 PropertyAccessorElement get correspondingGetter { | 8615 PropertyAccessorElement get correspondingGetter { |
| 9223 if (isGetter || variable == null) { | 8616 if (isGetter || variable == null) { |
| 9224 return null; | 8617 return null; |
| 9225 } | 8618 } |
| 9226 return variable.getter; | 8619 return variable.getter; |
| 9227 } | 8620 } |
| 9228 | 8621 |
| 9229 @override | 8622 @override |
| 9230 PropertyAccessorElement get correspondingSetter { | 8623 PropertyAccessorElement get correspondingSetter { |
| 9231 if (isSetter || variable == null) { | 8624 if (isSetter || variable == null) { |
| 9232 return null; | 8625 return null; |
| 9233 } | 8626 } |
| 9234 return variable.setter; | 8627 return variable.setter; |
| 9235 } | 8628 } |
| 9236 | 8629 |
| 9237 /** | 8630 /** |
| 9238 * Set whether this accessor is a getter to correspond to the given value. | 8631 * Set whether this accessor is a getter. |
| 9239 * | |
| 9240 * @param isGetter `true` if the accessor is a getter | |
| 9241 */ | 8632 */ |
| 9242 void set getter(bool isGetter) { | 8633 void set getter(bool isGetter) { |
| 9243 setModifier(Modifier.GETTER, isGetter); | 8634 setModifier(Modifier.GETTER, isGetter); |
| 9244 } | 8635 } |
| 9245 | 8636 |
| 9246 @override | 8637 @override |
| 9247 int get hashCode => JenkinsSmiHash.hash2(super.hashCode, isGetter ? 1 : 2); | 8638 int get hashCode => JenkinsSmiHash.hash2(super.hashCode, isGetter ? 1 : 2); |
| 9248 | 8639 |
| 9249 @override | 8640 @override |
| 9250 String get identifier { | 8641 String get identifier { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9289 if (enclosingElement is ClassElement) { | 8680 if (enclosingElement is ClassElement) { |
| 9290 return getNodeMatching((node) => node is MethodDeclaration); | 8681 return getNodeMatching((node) => node is MethodDeclaration); |
| 9291 } | 8682 } |
| 9292 if (enclosingElement is CompilationUnitElement) { | 8683 if (enclosingElement is CompilationUnitElement) { |
| 9293 return getNodeMatching((node) => node is FunctionDeclaration); | 8684 return getNodeMatching((node) => node is FunctionDeclaration); |
| 9294 } | 8685 } |
| 9295 return null; | 8686 return null; |
| 9296 } | 8687 } |
| 9297 | 8688 |
| 9298 /** | 8689 /** |
| 9299 * Set whether this accessor is a setter to correspond to the given value. | 8690 * Set whether this accessor is a setter. |
| 9300 * | |
| 9301 * @param isSetter `true` if the accessor is a setter | |
| 9302 */ | 8691 */ |
| 9303 void set setter(bool isSetter) { | 8692 void set setter(bool isSetter) { |
| 9304 setModifier(Modifier.SETTER, isSetter); | 8693 setModifier(Modifier.SETTER, isSetter); |
| 9305 } | 8694 } |
| 9306 | 8695 |
| 9307 /** | 8696 /** |
| 9308 * Set whether this accessor is static to correspond to the given value. | 8697 * Set whether this accessor is static. |
| 9309 * | |
| 9310 * @param isStatic `true` if the accessor is static | |
| 9311 */ | 8698 */ |
| 9312 void set static(bool isStatic) { | 8699 void set static(bool isStatic) { |
| 9313 setModifier(Modifier.STATIC, isStatic); | 8700 setModifier(Modifier.STATIC, isStatic); |
| 9314 } | 8701 } |
| 9315 | 8702 |
| 9316 @override | 8703 @override |
| 9317 bool operator ==(Object object) => super == object && | 8704 bool operator ==(Object object) => super == object && |
| 9318 isGetter == (object as PropertyAccessorElement).isGetter; | 8705 isGetter == (object as PropertyAccessorElement).isGetter; |
| 9319 | 8706 |
| 9320 @override | 8707 @override |
| 9321 accept(ElementVisitor visitor) => visitor.visitPropertyAccessorElement(this); | 8708 accept(ElementVisitor visitor) => visitor.visitPropertyAccessorElement(this); |
| 9322 | 8709 |
| 9323 @override | 8710 @override |
| 9324 void appendTo(StringBuffer buffer) { | 8711 void appendTo(StringBuffer buffer) { |
| 9325 buffer.write(isGetter ? "get " : "set "); | 8712 buffer.write(isGetter ? "get " : "set "); |
| 9326 buffer.write(variable.displayName); | 8713 buffer.write(variable.displayName); |
| 9327 super.appendTo(buffer); | 8714 super.appendTo(buffer); |
| 9328 } | 8715 } |
| 9329 } | 8716 } |
| 9330 | 8717 |
| 9331 /** | 8718 /** |
| 9332 * Instances of the class `PropertyAccessorMember` represent a property accessor
element | 8719 * A property accessor element defined in a parameterized type where the values |
| 9333 * defined in a parameterized type where the values of the type parameters are k
nown. | 8720 * of the type parameters are known. |
| 9334 */ | 8721 */ |
| 9335 class PropertyAccessorMember extends ExecutableMember | 8722 class PropertyAccessorMember extends ExecutableMember |
| 9336 implements PropertyAccessorElement { | 8723 implements PropertyAccessorElement { |
| 9337 /** | 8724 /** |
| 9338 * Initialize a newly created element to represent a property accessor of the
given parameterized | 8725 * Initialize a newly created element to represent a constructor, based on the |
| 9339 * type. | 8726 * [baseElement], defined by the [definingType]. |
| 9340 * | |
| 9341 * @param baseElement the element on which the parameterized element was creat
ed | |
| 9342 * @param definingType the type in which the element is defined | |
| 9343 */ | 8727 */ |
| 9344 PropertyAccessorMember( | 8728 PropertyAccessorMember( |
| 9345 PropertyAccessorElement baseElement, InterfaceType definingType) | 8729 PropertyAccessorElement baseElement, InterfaceType definingType) |
| 9346 : super(baseElement, definingType); | 8730 : super(baseElement, definingType); |
| 9347 | 8731 |
| 9348 @override | 8732 @override |
| 9349 PropertyAccessorElement get baseElement => | 8733 PropertyAccessorElement get baseElement => |
| 9350 super.baseElement as PropertyAccessorElement; | 8734 super.baseElement as PropertyAccessorElement; |
| 9351 | 8735 |
| 9352 @override | 8736 @override |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9408 } | 8792 } |
| 9409 builder.write(")"); | 8793 builder.write(")"); |
| 9410 if (type != null) { | 8794 if (type != null) { |
| 9411 builder.write(Element.RIGHT_ARROW); | 8795 builder.write(Element.RIGHT_ARROW); |
| 9412 builder.write(type.returnType); | 8796 builder.write(type.returnType); |
| 9413 } | 8797 } |
| 9414 return builder.toString(); | 8798 return builder.toString(); |
| 9415 } | 8799 } |
| 9416 | 8800 |
| 9417 /** | 8801 /** |
| 9418 * If the given property accessor's type is different when any type parameters
from the defining | 8802 * If the given [accessor]'s type is different when any type parameters from |
| 9419 * type's declaration are replaced with the actual type arguments from the def
ining type, create a | 8803 * the defining type's declaration are replaced with the actual type |
| 9420 * property accessor member representing the given property accessor. Return t
he member that was | 8804 * arguments from the [definingType], create an accessor member representing |
| 9421 * created, or the base accessor if no member was created. | 8805 * the given accessor. Return the member that was created, or the base |
| 9422 * | 8806 * accessor if no member was created. |
| 9423 * @param baseAccessor the base property accessor for which a member might be
created | |
| 9424 * @param definingType the type defining the parameters and arguments to be us
ed in the | |
| 9425 * substitution | |
| 9426 * @return the property accessor element that will return the correctly substi
tuted types | |
| 9427 */ | 8807 */ |
| 9428 static PropertyAccessorElement from( | 8808 static PropertyAccessorElement from( |
| 9429 PropertyAccessorElement baseAccessor, InterfaceType definingType) { | 8809 PropertyAccessorElement accessor, InterfaceType definingType) { |
| 9430 if (!_isChangedByTypeSubstitution(baseAccessor, definingType)) { | 8810 if (!_isChangedByTypeSubstitution(accessor, definingType)) { |
| 9431 return baseAccessor; | 8811 return accessor; |
| 9432 } | 8812 } |
| 9433 // TODO(brianwilkerson) Consider caching the substituted type in the | 8813 // TODO(brianwilkerson) Consider caching the substituted type in the |
| 9434 // instance. It would use more memory but speed up some operations. | 8814 // instance. It would use more memory but speed up some operations. |
| 9435 // We need to see how often the type is being re-computed. | 8815 // We need to see how often the type is being re-computed. |
| 9436 return new PropertyAccessorMember(baseAccessor, definingType); | 8816 return new PropertyAccessorMember(accessor, definingType); |
| 9437 } | 8817 } |
| 9438 | 8818 |
| 9439 /** | 8819 /** |
| 9440 * Determine whether the given property accessor's type is changed when type p
arameters from the | 8820 * Determine whether the given property [accessor]'s type is changed when type |
| 9441 * defining type's declaration are replaced with the actual type arguments fro
m the defining type. | 8821 * parameters from the defining type's declaration are replaced with the |
| 9442 * | 8822 * actual type arguments from the [definingType]. |
| 9443 * @param baseAccessor the base property accessor | |
| 9444 * @param definingType the type defining the parameters and arguments to be us
ed in the | |
| 9445 * substitution | |
| 9446 * @return true if the type is changed by type substitution. | |
| 9447 */ | 8823 */ |
| 9448 static bool _isChangedByTypeSubstitution( | 8824 static bool _isChangedByTypeSubstitution( |
| 9449 PropertyAccessorElement baseAccessor, InterfaceType definingType) { | 8825 PropertyAccessorElement accessor, InterfaceType definingType) { |
| 9450 List<DartType> argumentTypes = definingType.typeArguments; | 8826 List<DartType> argumentTypes = definingType.typeArguments; |
| 9451 if (baseAccessor != null && argumentTypes.length != 0) { | 8827 if (accessor != null && argumentTypes.length != 0) { |
| 9452 FunctionType baseType = baseAccessor.type; | 8828 FunctionType baseType = accessor.type; |
| 9453 if (baseType == null) { | 8829 if (baseType == null) { |
| 9454 AnalysisEngine.instance.logger.logInformation( | 8830 AnalysisEngine.instance.logger.logInformation( |
| 9455 'Type of $baseAccessor is null in PropertyAccessorMember._isChangedB
yTypeSubstitution'); | 8831 'Type of $accessor is null in PropertyAccessorMember._isChangedByTyp
eSubstitution'); |
| 9456 return false; | 8832 return false; |
| 9457 } | 8833 } |
| 9458 List<DartType> parameterTypes = definingType.element.type.typeArguments; | 8834 List<DartType> parameterTypes = definingType.element.type.typeArguments; |
| 9459 FunctionType substitutedType = | 8835 FunctionType substitutedType = |
| 9460 baseType.substitute2(argumentTypes, parameterTypes); | 8836 baseType.substitute2(argumentTypes, parameterTypes); |
| 9461 if (baseType != substitutedType) { | 8837 if (baseType != substitutedType) { |
| 9462 return true; | 8838 return true; |
| 9463 } | 8839 } |
| 9464 // If this property accessor is based on a field, that field might have a | 8840 // If this property accessor is based on a field, that field might have a |
| 9465 // propagated type. In which case we need to check whether the propagated | 8841 // propagated type. In which case we need to check whether the propagated |
| 9466 // type of the field needs substitution. | 8842 // type of the field needs substitution. |
| 9467 PropertyInducingElement field = baseAccessor.variable; | 8843 PropertyInducingElement field = accessor.variable; |
| 9468 if (!field.isSynthetic) { | 8844 if (!field.isSynthetic) { |
| 9469 DartType baseFieldType = field.propagatedType; | 8845 DartType baseFieldType = field.propagatedType; |
| 9470 if (baseFieldType != null) { | 8846 if (baseFieldType != null) { |
| 9471 DartType substitutedFieldType = | 8847 DartType substitutedFieldType = |
| 9472 baseFieldType.substitute2(argumentTypes, parameterTypes); | 8848 baseFieldType.substitute2(argumentTypes, parameterTypes); |
| 9473 if (baseFieldType != substitutedFieldType) { | 8849 if (baseFieldType != substitutedFieldType) { |
| 9474 return true; | 8850 return true; |
| 9475 } | 8851 } |
| 9476 } | 8852 } |
| 9477 } | 8853 } |
| 9478 } | 8854 } |
| 9479 return false; | 8855 return false; |
| 9480 } | 8856 } |
| 9481 } | 8857 } |
| 9482 | 8858 |
| 9483 /** | 8859 /** |
| 9484 * The interface `PropertyInducingElement` defines the behavior of elements repr
esenting a | 8860 * A variable that has an associated getter and possibly a setter. Note that |
| 9485 * variable that has an associated getter and possibly a setter. Note that expli
citly defined | 8861 * explicitly defined variables implicitly define a synthetic getter and that |
| 9486 * variables implicitly define a synthetic getter and that non-`final` explicitl
y defined | 8862 * non-`final` explicitly defined variables implicitly define a synthetic |
| 9487 * variables implicitly define a synthetic setter. Symmetrically, synthetic fiel
ds are implicitly | 8863 * setter. Symmetrically, synthetic fields are implicitly created for explicitly |
| 9488 * created for explicitly defined getters and setters. The following rules apply
: | 8864 * defined getters and setters. The following rules apply: |
| 9489 * * Every explicit variable is represented by a non-synthetic [PropertyInducing
Element]. | 8865 * |
| 9490 * * Every explicit variable induces a getter and possibly a setter, both of whi
ch are represented | 8866 * * Every explicit variable is represented by a non-synthetic |
| 9491 * by synthetic [PropertyAccessorElement]s. | 8867 * [PropertyInducingElement]. |
| 8868 * * Every explicit variable induces a getter and possibly a setter, both of |
| 8869 * which are represented by synthetic [PropertyAccessorElement]s. |
| 9492 * * Every explicit getter or setter is represented by a non-synthetic | 8870 * * Every explicit getter or setter is represented by a non-synthetic |
| 9493 * [PropertyAccessorElement]. | 8871 * [PropertyAccessorElement]. |
| 9494 * * Every explicit getter or setter (or pair thereof if they have the same name
) induces a | 8872 * * Every explicit getter or setter (or pair thereof if they have the same |
| 9495 * variable that is represented by a synthetic [PropertyInducingElement]. | 8873 * name) induces a variable that is represented by a synthetic |
| 8874 * [PropertyInducingElement]. |
| 9496 */ | 8875 */ |
| 9497 abstract class PropertyInducingElement implements VariableElement { | 8876 abstract class PropertyInducingElement implements VariableElement { |
| 9498 /** | 8877 /** |
| 9499 * Return the getter associated with this variable. If this variable was expli
citly defined (is | 8878 * Return the getter associated with this variable. If this variable was |
| 9500 * not synthetic) then the getter associated with it will be synthetic. | 8879 * explicitly defined (is not synthetic) then the getter associated with it |
| 9501 * | 8880 * will be synthetic. |
| 9502 * @return the getter associated with this variable | |
| 9503 */ | 8881 */ |
| 9504 PropertyAccessorElement get getter; | 8882 PropertyAccessorElement get getter; |
| 9505 | 8883 |
| 9506 /** | 8884 /** |
| 9507 * Return `true` if this element is a static element. A static element is an e
lement that is | 8885 * Return `true` if this element is a static element. A static element is an |
| 9508 * not associated with a particular instance, but rather with an entire librar
y or class. | 8886 * element that is not associated with a particular instance, but rather with |
| 9509 * | 8887 * an entire library or class. |
| 9510 * @return `true` if this executable element is a static element | |
| 9511 */ | 8888 */ |
| 9512 bool get isStatic; | 8889 bool get isStatic; |
| 9513 | 8890 |
| 9514 /** | 8891 /** |
| 9515 * Return the propagated type of this variable, or `null` if type propagation
has not been | 8892 * Return the propagated type of this variable, or `null` if type propagation |
| 9516 * performed, for example because the variable is not final. | 8893 * has not been performed, for example because the variable is not final. |
| 9517 * | |
| 9518 * @return the propagated type of this variable | |
| 9519 */ | 8894 */ |
| 9520 DartType get propagatedType; | 8895 DartType get propagatedType; |
| 9521 | 8896 |
| 9522 /** | 8897 /** |
| 9523 * Return the setter associated with this variable, or `null` if the variable
is effectively | 8898 * Return the setter associated with this variable, or `null` if the variable |
| 9524 * `final` and therefore does not have a setter associated with it. (This can
happen either | 8899 * is effectively `final` and therefore does not have a setter associated with |
| 9525 * because the variable is explicitly defined as being `final` or because the
variable is | 8900 * it. (This can happen either because the variable is explicitly defined as |
| 9526 * induced by an explicit getter that does not have a corresponding setter.) I
f this variable was | 8901 * being `final` or because the variable is induced by an explicit getter that |
| 9527 * explicitly defined (is not synthetic) then the setter associated with it wi
ll be synthetic. | 8902 * does not have a corresponding setter.) If this variable was explicitly |
| 9528 * | 8903 * defined (is not synthetic) then the setter associated with it will be |
| 9529 * @return the setter associated with this variable | 8904 * synthetic. |
| 9530 */ | 8905 */ |
| 9531 PropertyAccessorElement get setter; | 8906 PropertyAccessorElement get setter; |
| 9532 } | 8907 } |
| 9533 | 8908 |
| 9534 /** | 8909 /** |
| 9535 * Instances of the class `PropertyInducingElementImpl` implement a | 8910 * A concrete implementation of a [PropertyInducingElement]. |
| 9536 * `PropertyInducingElement`. | |
| 9537 */ | 8911 */ |
| 9538 abstract class PropertyInducingElementImpl extends VariableElementImpl | 8912 abstract class PropertyInducingElementImpl extends VariableElementImpl |
| 9539 implements PropertyInducingElement { | 8913 implements PropertyInducingElement { |
| 9540 /** | 8914 /** |
| 9541 * An empty list of elements. | 8915 * An empty list of elements. |
| 9542 */ | 8916 */ |
| 9543 static const List<PropertyInducingElement> EMPTY_ARRAY = | 8917 static const List<PropertyInducingElement> EMPTY_ARRAY = |
| 9544 const <PropertyInducingElement>[]; | 8918 const <PropertyInducingElement>[]; |
| 9545 | 8919 |
| 9546 /** | 8920 /** |
| 9547 * The getter associated with this element. | 8921 * The getter associated with this element. |
| 9548 */ | 8922 */ |
| 9549 PropertyAccessorElement getter; | 8923 PropertyAccessorElement getter; |
| 9550 | 8924 |
| 9551 /** | 8925 /** |
| 9552 * The setter associated with this element, or `null` if the element is effect
ively | 8926 * The setter associated with this element, or `null` if the element is |
| 9553 * `final` and therefore does not have a setter associated with it. | 8927 * effectively `final` and therefore does not have a setter associated with |
| 8928 * it. |
| 9554 */ | 8929 */ |
| 9555 PropertyAccessorElement setter; | 8930 PropertyAccessorElement setter; |
| 9556 | 8931 |
| 9557 /** | 8932 /** |
| 9558 * The propagated type of this variable, or `null` if type propagation has not
been | 8933 * The propagated type of this variable, or `null` if type propagation has not |
| 9559 * performed. | 8934 * been performed. |
| 9560 */ | 8935 */ |
| 9561 DartType propagatedType; | 8936 DartType propagatedType; |
| 9562 | 8937 |
| 9563 /** | 8938 /** |
| 9564 * Initialize a newly created synthetic element to have the given name. | 8939 * Initialize a newly created synthetic element to have the given [name] and |
| 9565 * | 8940 * [offset]. |
| 9566 * @param name the name of this element | |
| 9567 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
| 9568 * declaration of this element | |
| 9569 */ | 8941 */ |
| 9570 PropertyInducingElementImpl(String name, int nameOffset) | 8942 PropertyInducingElementImpl(String name, int offset) |
| 9571 : super(name, nameOffset); | 8943 : super(name, offset); |
| 9572 | 8944 |
| 9573 /** | 8945 /** |
| 9574 * Initialize a newly created element to have the given name. | 8946 * Initialize a newly created element to have the given [name]. |
| 9575 * | |
| 9576 * @param name the name of this element | |
| 9577 */ | 8947 */ |
| 9578 PropertyInducingElementImpl.forNode(Identifier name) : super.forNode(name); | 8948 PropertyInducingElementImpl.forNode(Identifier name) : super.forNode(name); |
| 9579 } | 8949 } |
| 9580 | 8950 |
| 9581 /** | 8951 /** |
| 9582 * Instances of the class `RecursiveElementVisitor` implement an element visitor
that will | 8952 * A visitor that will recursively visit all of the element in an element model. |
| 9583 * recursively visit all of the element in an element model. For example, using
an instance of this | 8953 * For example, using an instance of this class to visit a |
| 9584 * class to visit a [CompilationUnitElement] will also cause all of the types in
the | 8954 * [CompilationUnitElement] will also cause all of the types in the compilation |
| 9585 * compilation unit to be visited. | 8955 * unit to be visited. |
| 9586 * | 8956 * |
| 9587 * Subclasses that override a visit method must either invoke the overridden vis
it method or must | 8957 * Subclasses that override a visit method must either invoke the overridden |
| 9588 * explicitly ask the visited element to visit its children. Failure to do so wi
ll cause the | 8958 * visit method or must explicitly ask the visited element to visit its |
| 9589 * children of the visited element to not be visited. | 8959 * children. Failure to do so will cause the children of the visited element to |
| 8960 * not be visited. |
| 9590 */ | 8961 */ |
| 9591 class RecursiveElementVisitor<R> implements ElementVisitor<R> { | 8962 class RecursiveElementVisitor<R> implements ElementVisitor<R> { |
| 9592 @override | 8963 @override |
| 9593 R visitClassElement(ClassElement element) { | 8964 R visitClassElement(ClassElement element) { |
| 9594 element.visitChildren(this); | 8965 element.visitChildren(this); |
| 9595 return null; | 8966 return null; |
| 9596 } | 8967 } |
| 9597 | 8968 |
| 9598 @override | 8969 @override |
| 9599 R visitCompilationUnitElement(CompilationUnitElement element) { | 8970 R visitCompilationUnitElement(CompilationUnitElement element) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9716 } | 9087 } |
| 9717 | 9088 |
| 9718 @override | 9089 @override |
| 9719 R visitTypeParameterElement(TypeParameterElement element) { | 9090 R visitTypeParameterElement(TypeParameterElement element) { |
| 9720 element.visitChildren(this); | 9091 element.visitChildren(this); |
| 9721 return null; | 9092 return null; |
| 9722 } | 9093 } |
| 9723 } | 9094 } |
| 9724 | 9095 |
| 9725 /** | 9096 /** |
| 9726 * The interface `ShowElementCombinator` defines the behavior of combinators tha
t cause some | 9097 * A combinator that cause some of the names in a namespace to be visible (and |
| 9727 * of the names in a namespace to be visible (and the rest hidden) when being im
ported. | 9098 * the rest hidden) when being imported. |
| 9728 */ | 9099 */ |
| 9729 abstract class ShowElementCombinator implements NamespaceCombinator { | 9100 abstract class ShowElementCombinator implements NamespaceCombinator { |
| 9730 /** | 9101 /** |
| 9731 * Return the offset of the character immediately following the last character
of this node. | 9102 * Return the offset of the character immediately following the last character |
| 9732 * | 9103 * of this node. |
| 9733 * @return the offset of the character just past this node | |
| 9734 */ | 9104 */ |
| 9735 int get end; | 9105 int get end; |
| 9736 | 9106 |
| 9737 /** | 9107 /** |
| 9738 * Return the offset of the 'show' keyword of this element. | 9108 * Return the offset of the 'show' keyword of this element. |
| 9739 * | |
| 9740 * @return the offset of the 'show' keyword of this element | |
| 9741 */ | 9109 */ |
| 9742 int get offset; | 9110 int get offset; |
| 9743 | 9111 |
| 9744 /** | 9112 /** |
| 9745 * Return an array containing the names that are to be made visible in the imp
orting library if | 9113 * Return a list containing the names that are to be made visible in the |
| 9746 * they are defined in the imported library. | 9114 * importing library if they are defined in the imported library. |
| 9747 * | |
| 9748 * @return the names from the imported library that are visible in the importi
ng library | |
| 9749 */ | 9115 */ |
| 9750 List<String> get shownNames; | 9116 List<String> get shownNames; |
| 9751 } | 9117 } |
| 9752 | 9118 |
| 9753 /** | 9119 /** |
| 9754 * Instances of the class `ShowElementCombinatorImpl` implement a | 9120 * A concrete implementation of a [ShowElementCombinator]. |
| 9755 * [ShowElementCombinator]. | |
| 9756 */ | 9121 */ |
| 9757 class ShowElementCombinatorImpl implements ShowElementCombinator { | 9122 class ShowElementCombinatorImpl implements ShowElementCombinator { |
| 9758 /** | 9123 /** |
| 9759 * The names that are to be made visible in the importing library if they are
defined in the | 9124 * The names that are to be made visible in the importing library if they are |
| 9760 * imported library. | 9125 * defined in the imported library. |
| 9761 */ | 9126 */ |
| 9762 List<String> shownNames = StringUtilities.EMPTY_ARRAY; | 9127 List<String> shownNames = StringUtilities.EMPTY_ARRAY; |
| 9763 | 9128 |
| 9764 /** | 9129 /** |
| 9765 * The offset of the character immediately following the last character of thi
s node. | 9130 * The offset of the character immediately following the last character of |
| 9131 * this node. |
| 9766 */ | 9132 */ |
| 9767 int end = -1; | 9133 int end = -1; |
| 9768 | 9134 |
| 9769 /** | 9135 /** |
| 9770 * The offset of the 'show' keyword of this element. | 9136 * The offset of the 'show' keyword of this element. |
| 9771 */ | 9137 */ |
| 9772 int offset = 0; | 9138 int offset = 0; |
| 9773 | 9139 |
| 9774 @override | 9140 @override |
| 9775 String toString() { | 9141 String toString() { |
| 9776 StringBuffer buffer = new StringBuffer(); | 9142 StringBuffer buffer = new StringBuffer(); |
| 9777 buffer.write("show "); | 9143 buffer.write("show "); |
| 9778 int count = shownNames.length; | 9144 int count = shownNames.length; |
| 9779 for (int i = 0; i < count; i++) { | 9145 for (int i = 0; i < count; i++) { |
| 9780 if (i > 0) { | 9146 if (i > 0) { |
| 9781 buffer.write(", "); | 9147 buffer.write(", "); |
| 9782 } | 9148 } |
| 9783 buffer.write(shownNames[i]); | 9149 buffer.write(shownNames[i]); |
| 9784 } | 9150 } |
| 9785 return buffer.toString(); | 9151 return buffer.toString(); |
| 9786 } | 9152 } |
| 9787 } | 9153 } |
| 9788 | 9154 |
| 9789 /** | 9155 /** |
| 9790 * Instances of the class `SimpleElementVisitor` implement an element visitor th
at will do | 9156 * A visitor that will do nothing when visiting an element. It is intended to be |
| 9791 * nothing when visiting an element. It is intended to be a superclass for class
es that use the | 9157 * a superclass for classes that use the visitor pattern primarily as a dispatch |
| 9792 * visitor pattern primarily as a dispatch mechanism (and hence don't need to re
cursively visit a | 9158 * mechanism (and hence don't need to recursively visit a whole structure) and |
| 9793 * whole structure) and that only need to visit a small number of element types. | 9159 * that only need to visit a small number of element types. |
| 9794 */ | 9160 */ |
| 9795 class SimpleElementVisitor<R> implements ElementVisitor<R> { | 9161 class SimpleElementVisitor<R> implements ElementVisitor<R> { |
| 9796 @override | 9162 @override |
| 9797 R visitClassElement(ClassElement element) => null; | 9163 R visitClassElement(ClassElement element) => null; |
| 9798 | 9164 |
| 9799 @override | 9165 @override |
| 9800 R visitCompilationUnitElement(CompilationUnitElement element) => null; | 9166 R visitCompilationUnitElement(CompilationUnitElement element) => null; |
| 9801 | 9167 |
| 9802 @override | 9168 @override |
| 9803 R visitConstructorElement(ConstructorElement element) => null; | 9169 R visitConstructorElement(ConstructorElement element) => null; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9855 R visitPropertyAccessorElement(PropertyAccessorElement element) => null; | 9221 R visitPropertyAccessorElement(PropertyAccessorElement element) => null; |
| 9856 | 9222 |
| 9857 @override | 9223 @override |
| 9858 R visitTopLevelVariableElement(TopLevelVariableElement element) => null; | 9224 R visitTopLevelVariableElement(TopLevelVariableElement element) => null; |
| 9859 | 9225 |
| 9860 @override | 9226 @override |
| 9861 R visitTypeParameterElement(TypeParameterElement element) => null; | 9227 R visitTypeParameterElement(TypeParameterElement element) => null; |
| 9862 } | 9228 } |
| 9863 | 9229 |
| 9864 /** | 9230 /** |
| 9865 * The interface `TopLevelVariableElement` defines the behavior of elements repr
esenting a | 9231 * A top-level variable. |
| 9866 * top-level variable. | |
| 9867 */ | 9232 */ |
| 9868 abstract class TopLevelVariableElement implements PropertyInducingElement {} | 9233 abstract class TopLevelVariableElement implements PropertyInducingElement {} |
| 9869 | 9234 |
| 9870 /** | 9235 /** |
| 9871 * Instances of the class `TopLevelVariableElementImpl` implement a | 9236 * A concrete implementation of a [TopLevelVariableElement]. |
| 9872 * `TopLevelVariableElement`. | |
| 9873 */ | 9237 */ |
| 9874 class TopLevelVariableElementImpl extends PropertyInducingElementImpl | 9238 class TopLevelVariableElementImpl extends PropertyInducingElementImpl |
| 9875 implements TopLevelVariableElement { | 9239 implements TopLevelVariableElement { |
| 9876 /** | 9240 /** |
| 9877 * An empty list of top-level variable elements. | 9241 * An empty list of top-level variable elements. |
| 9878 */ | 9242 */ |
| 9879 static const List<TopLevelVariableElement> EMPTY_ARRAY = | 9243 static const List<TopLevelVariableElement> EMPTY_ARRAY = |
| 9880 const <TopLevelVariableElement>[]; | 9244 const <TopLevelVariableElement>[]; |
| 9881 | 9245 |
| 9882 /** | 9246 /** |
| 9883 * Initialize a newly created synthetic top-level variable element to have the
given name. | 9247 * Initialize a newly created synthetic top-level variable element to have the |
| 9884 * | 9248 * given [name] and [offset]. |
| 9885 * @param name the name of this element | |
| 9886 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
| 9887 * declaration of this element | |
| 9888 */ | 9249 */ |
| 9889 TopLevelVariableElementImpl(String name, int nameOffset) | 9250 TopLevelVariableElementImpl(String name, int offset) |
| 9890 : super(name, nameOffset); | 9251 : super(name, offset); |
| 9891 | 9252 |
| 9892 /** | 9253 /** |
| 9893 * Initialize a newly created top-level variable element to have the given nam
e. | 9254 * Initialize a newly created top-level variable element to have the given |
| 9894 * | 9255 * [name]. |
| 9895 * @param name the name of this element | |
| 9896 */ | 9256 */ |
| 9897 TopLevelVariableElementImpl.forNode(Identifier name) : super.forNode(name); | 9257 TopLevelVariableElementImpl.forNode(Identifier name) : super.forNode(name); |
| 9898 | 9258 |
| 9899 @override | 9259 @override |
| 9900 bool get isStatic => true; | 9260 bool get isStatic => true; |
| 9901 | 9261 |
| 9902 @override | 9262 @override |
| 9903 ElementKind get kind => ElementKind.TOP_LEVEL_VARIABLE; | 9263 ElementKind get kind => ElementKind.TOP_LEVEL_VARIABLE; |
| 9904 | 9264 |
| 9905 @override | 9265 @override |
| 9906 accept(ElementVisitor visitor) => visitor.visitTopLevelVariableElement(this); | 9266 accept(ElementVisitor visitor) => visitor.visitTopLevelVariableElement(this); |
| 9907 } | 9267 } |
| 9908 | 9268 |
| 9909 /** | 9269 /** |
| 9910 * The abstract class `TypeImpl` implements the behavior common to objects | 9270 * The abstract class `TypeImpl` implements the behavior common to objects |
| 9911 * representing the declared type of elements in the element model. | 9271 * representing the declared type of elements in the element model. |
| 9912 */ | 9272 */ |
| 9913 abstract class TypeImpl implements DartType { | 9273 abstract class TypeImpl implements DartType { |
| 9914 /** | 9274 /** |
| 9915 * An empty list of types. | 9275 * An empty list of types. |
| 9916 */ | 9276 */ |
| 9917 static const List<DartType> EMPTY_ARRAY = const <DartType>[]; | 9277 static const List<DartType> EMPTY_ARRAY = const <DartType>[]; |
| 9918 | 9278 |
| 9919 /** | 9279 /** |
| 9920 * The element representing the declaration of this type, or `null` if the typ
e has not, or | 9280 * The element representing the declaration of this type, or `null` if the |
| 9921 * cannot, be associated with an element. | 9281 * type has not, or cannot, be associated with an element. |
| 9922 */ | 9282 */ |
| 9923 final Element _element; | 9283 final Element _element; |
| 9924 | 9284 |
| 9925 /** | 9285 /** |
| 9926 * The name of this type, or `null` if the type does not have a name. | 9286 * The name of this type, or `null` if the type does not have a name. |
| 9927 */ | 9287 */ |
| 9928 final String name; | 9288 final String name; |
| 9929 | 9289 |
| 9930 /** | 9290 /** |
| 9931 * Initialize a newly created type to be declared by the given element and to
have the given name. | 9291 * Initialize a newly created type to be declared by the given [element] and |
| 9932 * | 9292 * to have the given [name]. |
| 9933 * @param element the element representing the declaration of the type | |
| 9934 * @param name the name of the type | |
| 9935 */ | 9293 */ |
| 9936 TypeImpl(this._element, this.name); | 9294 TypeImpl(this._element, this.name); |
| 9937 | 9295 |
| 9938 @override | 9296 @override |
| 9939 String get displayName => name; | 9297 String get displayName => name; |
| 9940 | 9298 |
| 9941 @override | 9299 @override |
| 9942 Element get element => _element; | 9300 Element get element => _element; |
| 9943 | 9301 |
| 9944 @override | 9302 @override |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9986 DartType type, bool withDynamic, Set<TypeImpl_TypePair> visitedTypePairs); | 9344 DartType type, bool withDynamic, Set<TypeImpl_TypePair> visitedTypePairs); |
| 9987 | 9345 |
| 9988 bool internalIsSubtypeOf( | 9346 bool internalIsSubtypeOf( |
| 9989 DartType type, Set<TypeImpl_TypePair> visitedTypePairs); | 9347 DartType type, Set<TypeImpl_TypePair> visitedTypePairs); |
| 9990 | 9348 |
| 9991 @override | 9349 @override |
| 9992 bool isAssignableTo(DartType type) => | 9350 bool isAssignableTo(DartType type) => |
| 9993 isAssignableTo2(type, new HashSet<TypeImpl_TypePair>()); | 9351 isAssignableTo2(type, new HashSet<TypeImpl_TypePair>()); |
| 9994 | 9352 |
| 9995 /** | 9353 /** |
| 9996 * Return `true` if this type is assignable to the given type. A type <i>T</i>
may be | 9354 * Return `true` if this type is assignable to the given [type]. A type |
| 9997 * assigned to a type <i>S</i>, written <i>T</i> ⇔ <i>S</i>, iff either <
i>T</i> <: <i>S</i> | 9355 * <i>T</i> may be assigned to a type <i>S</i>, written <i>T</i> ⇔ |
| 9998 * or <i>S</i> <: <i>T</i> (Interface Types section of spec). | 9356 * <i>S</i>, iff either <i>T</i> <: <i>S</i> or <i>S</i> <: <i>T</i> |
| 9357 * (Interface Types section of spec). |
| 9999 * | 9358 * |
| 10000 * The given set of pairs of types (T1, T2), where each pair indicates that we
invoked this method | 9359 * The given set of [visitedTypePairs] of types (T1, T2), where each pair |
| 10001 * because we are in the process of answering the question of whether T1 is a
subtype of T2, is | 9360 * indicates that we invoked this method because we are in the process of |
| 10002 * used to prevent infinite loops. | 9361 * answering the question of whether T1 is a subtype of T2, is used to prevent |
| 10003 * | 9362 * infinite loops. |
| 10004 * @param type the type being compared with this type | |
| 10005 * @param visitedTypePairs the set of pairs of types used to prevent infinite
loops | |
| 10006 * @return `true` if this type is assignable to the given type | |
| 10007 */ | 9363 */ |
| 10008 bool isAssignableTo2(DartType type, Set<TypeImpl_TypePair> visitedTypePairs) { | 9364 bool isAssignableTo2(DartType type, Set<TypeImpl_TypePair> visitedTypePairs) { |
| 10009 // Strictness matters for union types on the LHS, but not for union types | 9365 // Strictness matters for union types on the LHS, but not for union types |
| 10010 // on the RHS. | 9366 // on the RHS. |
| 10011 if (this is UnionType) { | 9367 if (this is UnionType) { |
| 10012 if (AnalysisEngine.instance.strictUnionTypes) { | 9368 if (AnalysisEngine.instance.strictUnionTypes) { |
| 10013 // *Every* element on the LHS must be assignable to the RHS. | 9369 // *Every* element on the LHS must be assignable to the RHS. |
| 10014 // We recursively fall into the next case when the RHS is also a union: | 9370 // We recursively fall into the next case when the RHS is also a union: |
| 10015 // the order here is important! | 9371 // the order here is important! |
| 10016 for (DartType left in (this as UnionType).elements) { | 9372 for (DartType left in (this as UnionType).elements) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 10046 return isSubtypeOf2(type, visitedTypePairs) || | 9402 return isSubtypeOf2(type, visitedTypePairs) || |
| 10047 (type as TypeImpl).isSubtypeOf2(this, visitedTypePairs); | 9403 (type as TypeImpl).isSubtypeOf2(this, visitedTypePairs); |
| 10048 } | 9404 } |
| 10049 } | 9405 } |
| 10050 | 9406 |
| 10051 @override | 9407 @override |
| 10052 bool isMoreSpecificThan(DartType type) => | 9408 bool isMoreSpecificThan(DartType type) => |
| 10053 isMoreSpecificThan2(type, false, new HashSet<TypeImpl_TypePair>()); | 9409 isMoreSpecificThan2(type, false, new HashSet<TypeImpl_TypePair>()); |
| 10054 | 9410 |
| 10055 /** | 9411 /** |
| 10056 * Return `true` if this type is more specific than the given type. | 9412 * Return `true` if this type is more specific than the given [type]. If |
| 9413 * [withDynamic] is `true`, then "dynamic" should be considered as a subtype |
| 9414 * of any type. |
| 10057 * | 9415 * |
| 10058 * The given set of pairs of types (T1, T2), where each pair indicates that we
invoked this method | 9416 * The given set of [visitedTypePairs] of types (T1, T2), where each pair |
| 10059 * because we are in the process of answering the question of whether T1 is a
subtype of T2, is | 9417 * indicates that we invoked this method because we are in the process of |
| 10060 * used to prevent infinite loops. | 9418 * answering the question of whether T1 is a subtype of T2, is used to prevent |
| 10061 * | 9419 * infinite loops. |
| 10062 * @param type the type being compared with this type | |
| 10063 * @param withDynamic `true` if "dynamic" should be considered as a subtype of
any type | |
| 10064 * @param visitedTypePairs the set of pairs of types used to prevent infinite
loops | |
| 10065 * @return `true` if this type is more specific than the given type | |
| 10066 */ | 9420 */ |
| 10067 bool isMoreSpecificThan2(DartType type, bool withDynamic, | 9421 bool isMoreSpecificThan2(DartType type, bool withDynamic, |
| 10068 Set<TypeImpl_TypePair> visitedTypePairs) { | 9422 Set<TypeImpl_TypePair> visitedTypePairs) { |
| 10069 // If the visitedTypePairs already has the pair (this, type), return false | 9423 // If the visitedTypePairs already has the pair (this, type), return false |
| 10070 TypeImpl_TypePair typePair = new TypeImpl_TypePair(this, type); | 9424 TypeImpl_TypePair typePair = new TypeImpl_TypePair(this, type); |
| 10071 if (!visitedTypePairs.add(typePair)) { | 9425 if (!visitedTypePairs.add(typePair)) { |
| 10072 return false; | 9426 return false; |
| 10073 } | 9427 } |
| 10074 bool result = | 9428 bool result = |
| 10075 internalIsMoreSpecificThan(type, withDynamic, visitedTypePairs); | 9429 internalIsMoreSpecificThan(type, withDynamic, visitedTypePairs); |
| 10076 visitedTypePairs.remove(typePair); | 9430 visitedTypePairs.remove(typePair); |
| 10077 return result; | 9431 return result; |
| 10078 } | 9432 } |
| 10079 | 9433 |
| 10080 @override | 9434 @override |
| 10081 bool isSubtypeOf(DartType type) => | 9435 bool isSubtypeOf(DartType type) => |
| 10082 isSubtypeOf2(type, new HashSet<TypeImpl_TypePair>()); | 9436 isSubtypeOf2(type, new HashSet<TypeImpl_TypePair>()); |
| 10083 | 9437 |
| 10084 /** | 9438 /** |
| 10085 * Return `true` if this type is a subtype of the given type. | 9439 * Return `true` if this type is a subtype of the given [type]. |
| 10086 * | 9440 * |
| 10087 * The given set of pairs of types (T1, T2), where each pair indicates that we
invoked this method | 9441 * The given set of [visitedTypePairs] of types (T1, T2), where each pair |
| 10088 * because we are in the process of answering the question of whether T1 is a
subtype of T2, is | 9442 * indicates that we invoked this method because we are in the process of |
| 10089 * used to prevent infinite loops. | 9443 * answering the question of whether T1 is a subtype of T2, is used to prevent |
| 10090 * | 9444 * infinite loops. |
| 10091 * @param type the type being compared with this type | |
| 10092 * @param visitedTypePairs the set of pairs of types used to prevent infinite
loops | |
| 10093 * @return `true` if this type is a subtype of the given type | |
| 10094 */ | 9445 */ |
| 10095 bool isSubtypeOf2(DartType type, Set<TypeImpl_TypePair> visitedTypePairs) { | 9446 bool isSubtypeOf2(DartType type, Set<TypeImpl_TypePair> visitedTypePairs) { |
| 10096 // If the visitedTypePairs already has the pair (this, type), return false | 9447 // If the visitedTypePairs already has the pair (this, type), return false |
| 10097 TypeImpl_TypePair typePair = new TypeImpl_TypePair(this, type); | 9448 TypeImpl_TypePair typePair = new TypeImpl_TypePair(this, type); |
| 10098 if (!visitedTypePairs.add(typePair)) { | 9449 if (!visitedTypePairs.add(typePair)) { |
| 10099 return false; | 9450 return false; |
| 10100 } | 9451 } |
| 10101 bool result = internalIsSubtypeOf(type, visitedTypePairs); | 9452 bool result = internalIsSubtypeOf(type, visitedTypePairs); |
| 10102 visitedTypePairs.remove(typePair); | 9453 visitedTypePairs.remove(typePair); |
| 10103 return result; | 9454 return result; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10135 } | 9486 } |
| 10136 if (!(first[i] as TypeImpl).internalEquals( | 9487 if (!(first[i] as TypeImpl).internalEquals( |
| 10137 second[i], visitedElementPairs)) { | 9488 second[i], visitedElementPairs)) { |
| 10138 return false; | 9489 return false; |
| 10139 } | 9490 } |
| 10140 } | 9491 } |
| 10141 return true; | 9492 return true; |
| 10142 } | 9493 } |
| 10143 | 9494 |
| 10144 /** | 9495 /** |
| 10145 * Return an array containing the results of using the given argument types an
d parameter types to | 9496 * Return a list containing the results of using the given [argumentTypes] and |
| 10146 * perform a substitution on all of the given types. | 9497 * [parameterTypes] to perform a substitution on all of the given [types]. |
| 10147 * | |
| 10148 * @param types the types on which a substitution is to be performed | |
| 10149 * @param argumentTypes the argument types for the substitution | |
| 10150 * @param parameterTypes the parameter types for the substitution | |
| 10151 * @return the result of performing the substitution on each of the types | |
| 10152 */ | 9498 */ |
| 10153 static List<DartType> substitute(List<DartType> types, | 9499 static List<DartType> substitute(List<DartType> types, |
| 10154 List<DartType> argumentTypes, List<DartType> parameterTypes) { | 9500 List<DartType> argumentTypes, List<DartType> parameterTypes) { |
| 10155 int length = types.length; | 9501 int length = types.length; |
| 10156 if (length == 0) { | 9502 if (length == 0) { |
| 10157 return types; | 9503 return types; |
| 10158 } | 9504 } |
| 10159 List<DartType> newTypes = new List<DartType>(length); | 9505 List<DartType> newTypes = new List<DartType>(length); |
| 10160 for (int i = 0; i < length; i++) { | 9506 for (int i = 0; i < length; i++) { |
| 10161 newTypes[i] = types[i].substitute2(argumentTypes, parameterTypes); | 9507 newTypes[i] = types[i].substitute2(argumentTypes, parameterTypes); |
| 10162 } | 9508 } |
| 10163 return newTypes; | 9509 return newTypes; |
| 10164 } | 9510 } |
| 10165 } | 9511 } |
| 10166 | 9512 |
| 9513 /** |
| 9514 * A pair of types, used to prevent infinite recursion when performing certain |
| 9515 * computations. |
| 9516 */ |
| 10167 class TypeImpl_TypePair { | 9517 class TypeImpl_TypePair { |
| 9518 /** |
| 9519 * The first type in the pair. |
| 9520 */ |
| 10168 final DartType _firstType; | 9521 final DartType _firstType; |
| 10169 | 9522 |
| 9523 /** |
| 9524 * The second type in the pair. |
| 9525 */ |
| 10170 final DartType _secondType; | 9526 final DartType _secondType; |
| 10171 | 9527 |
| 9528 /** |
| 9529 * The hash code of the pair. This is cached on first access in order to |
| 9530 * improve performance. |
| 9531 */ |
| 10172 int _cachedHashCode; | 9532 int _cachedHashCode; |
| 10173 | 9533 |
| 9534 /** |
| 9535 * Initialize a newly created pair of types to have the given [_firstType] and |
| 9536 * [_secondType]. |
| 9537 */ |
| 10174 TypeImpl_TypePair(this._firstType, this._secondType); | 9538 TypeImpl_TypePair(this._firstType, this._secondType); |
| 10175 | 9539 |
| 10176 @override | 9540 @override |
| 10177 int get hashCode { | 9541 int get hashCode { |
| 10178 if (_cachedHashCode == null) { | 9542 if (_cachedHashCode == null) { |
| 10179 int firstHashCode = 0; | 9543 int firstHashCode = 0; |
| 10180 if (_firstType != null) { | 9544 if (_firstType != null) { |
| 10181 Element firstElement = _firstType.element; | 9545 Element firstElement = _firstType.element; |
| 10182 firstHashCode = firstElement == null ? 0 : firstElement.hashCode; | 9546 firstHashCode = firstElement == null ? 0 : firstElement.hashCode; |
| 10183 } | 9547 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 10200 TypeImpl_TypePair typePair = object; | 9564 TypeImpl_TypePair typePair = object; |
| 10201 return _firstType == typePair._firstType && | 9565 return _firstType == typePair._firstType && |
| 10202 _secondType != null && | 9566 _secondType != null && |
| 10203 _secondType == typePair._secondType; | 9567 _secondType == typePair._secondType; |
| 10204 } | 9568 } |
| 10205 return false; | 9569 return false; |
| 10206 } | 9570 } |
| 10207 } | 9571 } |
| 10208 | 9572 |
| 10209 /** | 9573 /** |
| 10210 * The interface `TypeParameterElement` defines the behavior of elements represe
nting a type | 9574 * A type parameter. |
| 10211 * parameter. | |
| 10212 */ | 9575 */ |
| 10213 abstract class TypeParameterElement implements Element { | 9576 abstract class TypeParameterElement implements Element { |
| 10214 /** | 9577 /** |
| 10215 * Return the type representing the bound associated with this parameter, or `
null` if this | 9578 * Return the type representing the bound associated with this parameter, or |
| 10216 * parameter does not have an explicit bound. | 9579 * `null` if this parameter does not have an explicit bound. |
| 10217 * | |
| 10218 * @return the type representing the bound associated with this parameter | |
| 10219 */ | 9580 */ |
| 10220 DartType get bound; | 9581 DartType get bound; |
| 10221 | 9582 |
| 10222 /** | 9583 /** |
| 10223 * Return the type defined by this type parameter. | 9584 * Return the type defined by this type parameter. |
| 10224 * | |
| 10225 * @return the type defined by this type parameter | |
| 10226 */ | 9585 */ |
| 10227 TypeParameterType get type; | 9586 TypeParameterType get type; |
| 10228 } | 9587 } |
| 10229 | 9588 |
| 10230 /** | 9589 /** |
| 10231 * Instances of the class `TypeParameterElementImpl` implement a [TypeParameterE
lement]. | 9590 * A concrete implementation of a [TypeParameterElement]. |
| 10232 */ | 9591 */ |
| 10233 class TypeParameterElementImpl extends ElementImpl | 9592 class TypeParameterElementImpl extends ElementImpl |
| 10234 implements TypeParameterElement { | 9593 implements TypeParameterElement { |
| 10235 /** | 9594 /** |
| 10236 * An empty list of type parameter elements. | 9595 * An empty list of type parameter elements. |
| 10237 */ | 9596 */ |
| 10238 static const List<TypeParameterElement> EMPTY_ARRAY = | 9597 static const List<TypeParameterElement> EMPTY_ARRAY = |
| 10239 const <TypeParameterElement>[]; | 9598 const <TypeParameterElement>[]; |
| 10240 | 9599 |
| 10241 /** | 9600 /** |
| 10242 * The type defined by this type parameter. | 9601 * The type defined by this type parameter. |
| 10243 */ | 9602 */ |
| 10244 TypeParameterType type; | 9603 TypeParameterType type; |
| 10245 | 9604 |
| 10246 /** | 9605 /** |
| 10247 * The type representing the bound associated with this parameter, or `null` i
f this | 9606 * The type representing the bound associated with this parameter, or `null` |
| 10248 * parameter does not have an explicit bound. | 9607 * if this parameter does not have an explicit bound. |
| 10249 */ | 9608 */ |
| 10250 DartType bound; | 9609 DartType bound; |
| 10251 | 9610 |
| 10252 /** | 9611 /** |
| 10253 * Initialize a newly created method element to have the given name. | 9612 * Initialize a newly created method element to have the given [name] and |
| 10254 * | 9613 * [offset]. |
| 10255 * @param name the name of this element | |
| 10256 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
| 10257 * declaration of this element | |
| 10258 */ | 9614 */ |
| 10259 TypeParameterElementImpl(String name, int nameOffset) | 9615 TypeParameterElementImpl(String name, int offset) |
| 10260 : super(name, nameOffset); | 9616 : super(name, offset); |
| 10261 | 9617 |
| 10262 /** | 9618 /** |
| 10263 * Initialize a newly created type parameter element to have the given name. | 9619 * Initialize a newly created type parameter element to have the given [name]. |
| 10264 * | |
| 10265 * @param name the name of this element | |
| 10266 */ | 9620 */ |
| 10267 TypeParameterElementImpl.forNode(Identifier name) : super.forNode(name); | 9621 TypeParameterElementImpl.forNode(Identifier name) : super.forNode(name); |
| 10268 | 9622 |
| 10269 @override | 9623 @override |
| 10270 ElementKind get kind => ElementKind.TYPE_PARAMETER; | 9624 ElementKind get kind => ElementKind.TYPE_PARAMETER; |
| 10271 | 9625 |
| 10272 @override | 9626 @override |
| 10273 accept(ElementVisitor visitor) => visitor.visitTypeParameterElement(this); | 9627 accept(ElementVisitor visitor) => visitor.visitTypeParameterElement(this); |
| 10274 | 9628 |
| 10275 @override | 9629 @override |
| 10276 void appendTo(StringBuffer buffer) { | 9630 void appendTo(StringBuffer buffer) { |
| 10277 buffer.write(displayName); | 9631 buffer.write(displayName); |
| 10278 if (bound != null) { | 9632 if (bound != null) { |
| 10279 buffer.write(" extends "); | 9633 buffer.write(" extends "); |
| 10280 buffer.write(bound); | 9634 buffer.write(bound); |
| 10281 } | 9635 } |
| 10282 } | 9636 } |
| 10283 } | 9637 } |
| 10284 | 9638 |
| 10285 /** | 9639 /** |
| 10286 * The interface `TypeParameterType` defines the behavior of objects representin
g the type | 9640 * The type introduced by a type parameter. |
| 10287 * introduced by a type parameter. | |
| 10288 */ | 9641 */ |
| 10289 abstract class TypeParameterType implements DartType { | 9642 abstract class TypeParameterType implements DartType { |
| 10290 @override | 9643 @override |
| 10291 TypeParameterElement get element; | 9644 TypeParameterElement get element; |
| 10292 } | 9645 } |
| 10293 | 9646 |
| 10294 /** | 9647 /** |
| 10295 * Instances of the class `TypeParameterTypeImpl` defines the behavior of object
s representing | 9648 * A concrete implementation of a [TypeParameterType]. |
| 10296 * the type introduced by a type parameter. | |
| 10297 */ | 9649 */ |
| 10298 class TypeParameterTypeImpl extends TypeImpl implements TypeParameterType { | 9650 class TypeParameterTypeImpl extends TypeImpl implements TypeParameterType { |
| 10299 /** | 9651 /** |
| 10300 * An empty list of type parameter types. | 9652 * An empty list of type parameter types. |
| 10301 */ | 9653 */ |
| 10302 static const List<TypeParameterType> EMPTY_ARRAY = const <TypeParameterType>[ | 9654 static const List<TypeParameterType> EMPTY_ARRAY = const <TypeParameterType>[ |
| 10303 ]; | 9655 ]; |
| 10304 | 9656 |
| 10305 /** | 9657 /** |
| 10306 * Initialize a newly created type parameter type to be declared by the given
element and to have | 9658 * Initialize a newly created type parameter type to be declared by the given |
| 10307 * the given name. | 9659 * [element] and to have the given name. |
| 10308 * | |
| 10309 * @param element the element representing the declaration of the type paramet
er | |
| 10310 */ | 9660 */ |
| 10311 TypeParameterTypeImpl(TypeParameterElement element) | 9661 TypeParameterTypeImpl(TypeParameterElement element) |
| 10312 : super(element, element.name); | 9662 : super(element, element.name); |
| 10313 | 9663 |
| 10314 @override | 9664 @override |
| 10315 TypeParameterElement get element => super.element as TypeParameterElement; | 9665 TypeParameterElement get element => super.element as TypeParameterElement; |
| 10316 | 9666 |
| 10317 @override | 9667 @override |
| 10318 int get hashCode => element.hashCode; | 9668 int get hashCode => element.hashCode; |
| 10319 | 9669 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10398 // Then check upper bound. | 9748 // Then check upper bound. |
| 10399 return boundTypeParameter._isMoreSpecificThan( | 9749 return boundTypeParameter._isMoreSpecificThan( |
| 10400 s, visitedTypes, withDynamic, visitedTypePairs); | 9750 s, visitedTypes, withDynamic, visitedTypePairs); |
| 10401 } | 9751 } |
| 10402 // Check interface type. | 9752 // Check interface type. |
| 10403 return (bound as TypeImpl).isMoreSpecificThan2( | 9753 return (bound as TypeImpl).isMoreSpecificThan2( |
| 10404 s, withDynamic, visitedTypePairs); | 9754 s, withDynamic, visitedTypePairs); |
| 10405 } | 9755 } |
| 10406 | 9756 |
| 10407 /** | 9757 /** |
| 10408 * Return an array containing the type parameter types defined by the given ar
ray of type | 9758 * Return a list containing the type parameter types defined by the given |
| 10409 * parameter elements. | 9759 * array of type parameter elements ([typeParameters]). |
| 10410 * | |
| 10411 * @param typeParameters the type parameter elements defining the type paramet
er types to be | |
| 10412 * returned | |
| 10413 * @return the type parameter types defined by the type parameter elements | |
| 10414 */ | 9760 */ |
| 10415 static List<TypeParameterType> getTypes( | 9761 static List<TypeParameterType> getTypes( |
| 10416 List<TypeParameterElement> typeParameters) { | 9762 List<TypeParameterElement> typeParameters) { |
| 10417 int count = typeParameters.length; | 9763 int count = typeParameters.length; |
| 10418 if (count == 0) { | 9764 if (count == 0) { |
| 10419 return EMPTY_ARRAY; | 9765 return EMPTY_ARRAY; |
| 10420 } | 9766 } |
| 10421 List<TypeParameterType> types = new List<TypeParameterType>(count); | 9767 List<TypeParameterType> types = new List<TypeParameterType>(count); |
| 10422 for (int i = 0; i < count; i++) { | 9768 for (int i = 0; i < count; i++) { |
| 10423 types[i] = typeParameters[i].type; | 9769 types[i] = typeParameters[i].type; |
| 10424 } | 9770 } |
| 10425 return types; | 9771 return types; |
| 10426 } | 9772 } |
| 10427 } | 9773 } |
| 10428 | 9774 |
| 10429 /** | 9775 /** |
| 10430 * The interface `UndefinedElement` defines the behavior of pseudo-elements that
represent | 9776 * A pseudo-elements that represents names that are undefined. This situation is |
| 10431 * names that are undefined. This situation is not allowed by the language, so o
bjects implementing | 9777 * not allowed by the language, so objects implementing this interface always |
| 10432 * this interface always represent an error. As a result, most of the normal ope
rations on elements | 9778 * represent an error. As a result, most of the normal operations on elements do |
| 10433 * do not make sense and will return useless results. | 9779 * not make sense and will return useless results. |
| 10434 */ | 9780 */ |
| 10435 abstract class UndefinedElement implements Element {} | 9781 abstract class UndefinedElement implements Element {} |
| 10436 | 9782 |
| 10437 /** | 9783 /** |
| 10438 * The unique instance of the class `UndefinedTypeImpl` implements the type of | 9784 * The unique instance of the class `UndefinedTypeImpl` implements the type of |
| 10439 * typenames that couldn't be resolved. | 9785 * typenames that couldn't be resolved. |
| 10440 * | 9786 * |
| 10441 * This class behaves like DynamicTypeImpl in almost every respect, to reduce | 9787 * This class behaves like DynamicTypeImpl in almost every respect, to reduce |
| 10442 * cascading errors. | 9788 * cascading errors. |
| 10443 */ | 9789 */ |
| 10444 class UndefinedTypeImpl extends TypeImpl { | 9790 class UndefinedTypeImpl extends TypeImpl { |
| 10445 /** | 9791 /** |
| 10446 * The unique instance of this class. | 9792 * The unique instance of this class. |
| 10447 */ | 9793 */ |
| 10448 static UndefinedTypeImpl _INSTANCE = new UndefinedTypeImpl._(); | 9794 static UndefinedTypeImpl _INSTANCE = new UndefinedTypeImpl._(); |
| 10449 | 9795 |
| 10450 /** | 9796 /** |
| 10451 * Return the unique instance of this class. | 9797 * Return the unique instance of this class. |
| 10452 * | |
| 10453 * @return the unique instance of this class | |
| 10454 */ | 9798 */ |
| 10455 static UndefinedTypeImpl get instance => _INSTANCE; | 9799 static UndefinedTypeImpl get instance => _INSTANCE; |
| 10456 | 9800 |
| 10457 /** | 9801 /** |
| 10458 * Prevent the creation of instances of this class. | 9802 * Prevent the creation of instances of this class. |
| 10459 */ | 9803 */ |
| 10460 UndefinedTypeImpl._() | 9804 UndefinedTypeImpl._() |
| 10461 : super(DynamicElementImpl.instance, Keyword.DYNAMIC.syntax); | 9805 : super(DynamicElementImpl.instance, Keyword.DYNAMIC.syntax); |
| 10462 | 9806 |
| 10463 @override | 9807 @override |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10504 for (int i = 0; i < length; i++) { | 9848 for (int i = 0; i < length; i++) { |
| 10505 if (parameterTypes[i] == this) { | 9849 if (parameterTypes[i] == this) { |
| 10506 return argumentTypes[i]; | 9850 return argumentTypes[i]; |
| 10507 } | 9851 } |
| 10508 } | 9852 } |
| 10509 return this; | 9853 return this; |
| 10510 } | 9854 } |
| 10511 } | 9855 } |
| 10512 | 9856 |
| 10513 /** | 9857 /** |
| 10514 * A flat immutable union of `Type`s. Here "flat" means a union type never conta
ins another | 9858 * A union of other types. Union types are "flattened" in the sense that a union |
| 10515 * union type. | 9859 * type never contains another union type. |
| 10516 */ | 9860 */ |
| 10517 abstract class UnionType implements DartType { | 9861 abstract class UnionType implements DartType { |
| 10518 /** | 9862 /** |
| 10519 * @return an immutable view of the types in this union type. | 9863 * Return an immutable view of the types in this union type. |
| 10520 */ | 9864 */ |
| 10521 Set<DartType> get elements; | 9865 Set<DartType> get elements; |
| 10522 } | 9866 } |
| 10523 | 9867 |
| 10524 /** | 9868 /** |
| 10525 * In addition to the methods of the `UnionType` interface we add a factory meth
od | 9869 * In addition to the methods of the `UnionType` interface we add a factory |
| 10526 * `union` for building unions. | 9870 * method `union` for building unions. |
| 10527 */ | 9871 */ |
| 10528 class UnionTypeImpl extends TypeImpl implements UnionType { | 9872 class UnionTypeImpl extends TypeImpl implements UnionType { |
| 10529 /** | 9873 /** |
| 10530 * The types in this union. | 9874 * The types in this union. |
| 10531 */ | 9875 */ |
| 10532 final Set<DartType> _types; | 9876 final Set<DartType> _types; |
| 10533 | 9877 |
| 10534 /** | 9878 /** |
| 10535 * This constructor should only be called by the `union` factory: it does not
check that its | 9879 * This constructor should only be called by the `union` factory: it does not |
| 10536 * argument `types` contains no union types. | 9880 * check that its argument [types] contains no union types. |
| 10537 * | |
| 10538 * @param types | |
| 10539 */ | 9881 */ |
| 10540 UnionTypeImpl(this._types) : super(null, null); | 9882 UnionTypeImpl(this._types) : super(null, null); |
| 10541 | 9883 |
| 10542 @override | 9884 @override |
| 10543 String get displayName { | 9885 String get displayName { |
| 10544 StringBuffer buffer = new StringBuffer(); | 9886 StringBuffer buffer = new StringBuffer(); |
| 10545 String prefix = "{"; | 9887 String prefix = "{"; |
| 10546 for (DartType t in _types) { | 9888 for (DartType t in _types) { |
| 10547 buffer.write(prefix); | 9889 buffer.write(prefix); |
| 10548 buffer.write(t.displayName); | 9890 buffer.write(t.displayName); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10637 for (DartType t in _types) { | 9979 for (DartType t in _types) { |
| 10638 if ((t as TypeImpl).internalIsSubtypeOf(type, visitedTypePairs)) { | 9980 if ((t as TypeImpl).internalIsSubtypeOf(type, visitedTypePairs)) { |
| 10639 return true; | 9981 return true; |
| 10640 } | 9982 } |
| 10641 } | 9983 } |
| 10642 return false; | 9984 return false; |
| 10643 } | 9985 } |
| 10644 } | 9986 } |
| 10645 | 9987 |
| 10646 /** | 9988 /** |
| 10647 * The more-specific-than test for union types on the RHS is uniform in non-un
ion LHSs. So, other | 9989 * The more-specific-than test for union types on the RHS is uniform in |
| 10648 * `TypeImpl`s can call this method to implement `internalIsMoreSpecificThan`
for | 9990 * non-union LHSs. So, other `TypeImpl`s can call this method to implement |
| 10649 * union types. | 9991 * [internalIsMoreSpecificThan] for union types. |
| 10650 * | |
| 10651 * @param type | |
| 10652 * @param visitedTypePairs | |
| 10653 * @return true if `type` is more specific than this union type | |
| 10654 */ | 9992 */ |
| 10655 bool internalUnionTypeIsLessSpecificThan(DartType type, bool withDynamic, | 9993 bool internalUnionTypeIsLessSpecificThan(DartType type, bool withDynamic, |
| 10656 Set<TypeImpl_TypePair> visitedTypePairs) { | 9994 Set<TypeImpl_TypePair> visitedTypePairs) { |
| 10657 // This implementation does not make sense when [type] is a union type, | 9995 // This implementation does not make sense when [type] is a union type, |
| 10658 // at least for the "less unsound" version of [internalIsMoreSpecificThan] | 9996 // at least for the "less unsound" version of [internalIsMoreSpecificThan] |
| 10659 // above. | 9997 // above. |
| 10660 if (type is UnionType) { | 9998 if (type is UnionType) { |
| 10661 throw new IllegalArgumentException("Only non-union types are supported."); | 9999 throw new IllegalArgumentException("Only non-union types are supported."); |
| 10662 } | 10000 } |
| 10663 for (DartType t in _types) { | 10001 for (DartType t in _types) { |
| 10664 if ((type as TypeImpl).internalIsMoreSpecificThan( | 10002 if ((type as TypeImpl).internalIsMoreSpecificThan( |
| 10665 t, withDynamic, visitedTypePairs)) { | 10003 t, withDynamic, visitedTypePairs)) { |
| 10666 return true; | 10004 return true; |
| 10667 } | 10005 } |
| 10668 } | 10006 } |
| 10669 return false; | 10007 return false; |
| 10670 } | 10008 } |
| 10671 | 10009 |
| 10672 /** | 10010 /** |
| 10673 * The supertype test for union types is uniform in non-union subtypes. So, ot
her `TypeImpl` | 10011 * The supertype test for union types is uniform in non-union subtypes. So, |
| 10674 * s can call this method to implement `internalIsSubtypeOf` for union types. | 10012 * other `TypeImpl`s can call this method to implement `internalIsSubtypeOf` |
| 10675 * | 10013 * for union types. |
| 10676 * @param type | |
| 10677 * @param visitedTypePairs | |
| 10678 * @return true if this union type is a super type of `type` | |
| 10679 */ | 10014 */ |
| 10680 bool internalUnionTypeIsSuperTypeOf( | 10015 bool internalUnionTypeIsSuperTypeOf( |
| 10681 DartType type, Set<TypeImpl_TypePair> visitedTypePairs) { | 10016 DartType type, Set<TypeImpl_TypePair> visitedTypePairs) { |
| 10682 // This implementation does not make sense when [type] is a union type, | 10017 // This implementation does not make sense when [type] is a union type, |
| 10683 // at least for the "less unsound" version of [internalIsSubtypeOf] above. | 10018 // at least for the "less unsound" version of [internalIsSubtypeOf] above. |
| 10684 if (type is UnionType) { | 10019 if (type is UnionType) { |
| 10685 throw new IllegalArgumentException("Only non-union types are supported."); | 10020 throw new IllegalArgumentException("Only non-union types are supported."); |
| 10686 } | 10021 } |
| 10687 for (DartType t in _types) { | 10022 for (DartType t in _types) { |
| 10688 if ((type as TypeImpl).internalIsSubtypeOf(t, visitedTypePairs)) { | 10023 if ((type as TypeImpl).internalIsSubtypeOf(t, visitedTypePairs)) { |
| 10689 return true; | 10024 return true; |
| 10690 } | 10025 } |
| 10691 } | 10026 } |
| 10692 return false; | 10027 return false; |
| 10693 } | 10028 } |
| 10694 | 10029 |
| 10695 @override | 10030 @override |
| 10696 DartType substitute2( | 10031 DartType substitute2( |
| 10697 List<DartType> argumentTypes, List<DartType> parameterTypes) { | 10032 List<DartType> argumentTypes, List<DartType> parameterTypes) { |
| 10698 List<DartType> out = new List<DartType>(); | 10033 List<DartType> out = new List<DartType>(); |
| 10699 for (DartType t in _types) { | 10034 for (DartType t in _types) { |
| 10700 out.add(t.substitute2(argumentTypes, parameterTypes)); | 10035 out.add(t.substitute2(argumentTypes, parameterTypes)); |
| 10701 } | 10036 } |
| 10702 return union(out); | 10037 return union(out); |
| 10703 } | 10038 } |
| 10704 | 10039 |
| 10705 /** | 10040 /** |
| 10706 * Any unions in the `types` will be flattened in the returned union. If there
is only one | 10041 * Return the union of the given [types]. Any unions in the [types] will be |
| 10707 * type after flattening then it will be returned directly, instead of a singl
eton union. Nulls | 10042 * flattened in the returned union. If there is only one type after flattening |
| 10708 * are discarded, unless all types are null, in which case an exception is rai
sed. | 10043 * then it will be returned directly, instead of a singleton union. Nulls are |
| 10709 * | 10044 * discarded, unless all types are null, in which case an exception is raised. |
| 10710 * @param types the `Type`s to union | |
| 10711 * @return a `Type` comprising the `Type`s in `types` | |
| 10712 */ | 10045 */ |
| 10713 static DartType union(List<DartType> types) { | 10046 static DartType union(List<DartType> types) { |
| 10714 Set<DartType> set = new HashSet<DartType>(); | 10047 Set<DartType> set = new HashSet<DartType>(); |
| 10715 for (DartType t in types) { | 10048 for (DartType t in types) { |
| 10716 if (t is UnionType) { | 10049 if (t is UnionType) { |
| 10717 set.addAll(t.elements); | 10050 set.addAll(t.elements); |
| 10718 } else { | 10051 } else { |
| 10719 if (t != null) { | 10052 if (t != null) { |
| 10720 set.add(t); | 10053 set.add(t); |
| 10721 } | 10054 } |
| 10722 } | 10055 } |
| 10723 } | 10056 } |
| 10724 if (set.length == 0) { | 10057 if (set.length == 0) { |
| 10725 // TODO(collinsn): better to return [null] here? The use case is e.g. | 10058 // TODO(collinsn): better to return [null] here? The use case is e.g. |
| 10726 // | 10059 // |
| 10727 // union(null, null) ==> null; | 10060 // union(null, null) ==> null; |
| 10728 // | 10061 // |
| 10729 // instead of raising an exception. | 10062 // instead of raising an exception. |
| 10730 throw new IllegalArgumentException("No known use case for empty unions."); | 10063 throw new IllegalArgumentException("No known use case for empty unions."); |
| 10731 } else if (set.length == 1) { | 10064 } else if (set.length == 1) { |
| 10732 return set.first; | 10065 return set.first; |
| 10733 } else { | 10066 } else { |
| 10734 return new UnionTypeImpl(set); | 10067 return new UnionTypeImpl(set); |
| 10735 } | 10068 } |
| 10736 } | 10069 } |
| 10737 } | 10070 } |
| 10738 | 10071 |
| 10739 /** | 10072 /** |
| 10740 * The interface `UriReferencedElement` defines the behavior of objects included
into a | 10073 * An element included into a library using some URI. |
| 10741 * library using some URI. | |
| 10742 */ | 10074 */ |
| 10743 abstract class UriReferencedElement implements Element { | 10075 abstract class UriReferencedElement implements Element { |
| 10744 /** | 10076 /** |
| 10745 * Return the URI that is used to include this element into the enclosing libr
ary, or `null` | 10077 * Return the URI that is used to include this element into the enclosing |
| 10746 * if this is the defining compilation unit of a library. | 10078 * library, or `null` if this is the defining compilation unit of a library. |
| 10747 * | |
| 10748 * @return the URI that is used to include this element into the enclosing lib
rary | |
| 10749 */ | 10079 */ |
| 10750 String get uri; | 10080 String get uri; |
| 10751 | 10081 |
| 10752 /** | 10082 /** |
| 10753 * Return the offset of the character immediately following the last character
of this node's URI, | 10083 * Return the offset of the character immediately following the last character |
| 10754 * or `-1` for synthetic import. | 10084 * of this node's URI, or `-1` for synthetic import. |
| 10755 * | |
| 10756 * @return the offset of the character just past the node's URI | |
| 10757 */ | 10085 */ |
| 10758 int get uriEnd; | 10086 int get uriEnd; |
| 10759 | 10087 |
| 10760 /** | 10088 /** |
| 10761 * Return the offset of the URI in the file, or `-1` if this element is synthe
tic. | 10089 * Return the offset of the URI in the file, or `-1` if this element is |
| 10762 * | 10090 * synthetic. |
| 10763 * @return the offset of the URI | |
| 10764 */ | 10091 */ |
| 10765 int get uriOffset; | 10092 int get uriOffset; |
| 10766 } | 10093 } |
| 10767 | 10094 |
| 10768 /** | 10095 /** |
| 10769 * Instances of the class `UriReferencedElementImpl` implement an [UriReferenced
Element] | 10096 * A concrete implementation of a [UriReferencedElement]. |
| 10770 * . | |
| 10771 */ | 10097 */ |
| 10772 abstract class UriReferencedElementImpl extends ElementImpl | 10098 abstract class UriReferencedElementImpl extends ElementImpl |
| 10773 implements UriReferencedElement { | 10099 implements UriReferencedElement { |
| 10774 /** | 10100 /** |
| 10775 * The offset of the URI in the file, may be `-1` if synthetic. | 10101 * The offset of the URI in the file, may be `-1` if synthetic. |
| 10776 */ | 10102 */ |
| 10777 int uriOffset = -1; | 10103 int uriOffset = -1; |
| 10778 | 10104 |
| 10779 /** | 10105 /** |
| 10780 * The offset of the character immediately following the last character of thi
s node's URI, may be | 10106 * The offset of the character immediately following the last character of |
| 10781 * `-1` if synthetic. | 10107 * this node's URI, may be `-1` if synthetic. |
| 10782 */ | 10108 */ |
| 10783 int uriEnd = -1; | 10109 int uriEnd = -1; |
| 10784 | 10110 |
| 10785 /** | 10111 /** |
| 10786 * The URI that is specified by this directive. | 10112 * The URI that is specified by this directive. |
| 10787 */ | 10113 */ |
| 10788 String uri; | 10114 String uri; |
| 10789 | 10115 |
| 10790 /** | 10116 /** |
| 10791 * Initialize a newly created import element. | 10117 * Initialize a newly created import element to heve the given [name] and |
| 10792 * | 10118 * [offset]. The offset may be `-1` if the element is synthetic. |
| 10793 * @param name the name of this element | |
| 10794 * @param offset the directive offset, may be `-1` if synthetic. | |
| 10795 */ | 10119 */ |
| 10796 UriReferencedElementImpl(String name, int offset) : super(name, offset); | 10120 UriReferencedElementImpl(String name, int offset) : super(name, offset); |
| 10797 } | 10121 } |
| 10798 | 10122 |
| 10799 /** | 10123 /** |
| 10800 * The interface `VariableElement` defines the behavior common to elements that
represent a | 10124 * A variable. There are concrete subclasses for different kinds of variables. |
| 10801 * variable. | |
| 10802 */ | 10125 */ |
| 10803 abstract class VariableElement implements Element { | 10126 abstract class VariableElement implements Element { |
| 10804 /** | 10127 /** |
| 10805 * Return a synthetic function representing this variable's initializer, or `n
ull` if this | 10128 * Return a synthetic function representing this variable's initializer, or |
| 10806 * variable does not have an initializer. The function will have no parameters
. The return type of | 10129 * `null` if this variable does not have an initializer. The function will |
| 10807 * the function will be the compile-time type of the initialization expression
. | 10130 * have no parameters. The return type of the function will be the |
| 10808 * | 10131 * compile-time type of the initialization expression. |
| 10809 * @return a synthetic function representing this variable's initializer | |
| 10810 */ | 10132 */ |
| 10811 FunctionElement get initializer; | 10133 FunctionElement get initializer; |
| 10812 | 10134 |
| 10813 /** | 10135 /** |
| 10814 * Return `true` if this variable was declared with the 'const' modifier. | 10136 * Return `true` if this variable was declared with the 'const' modifier. |
| 10815 * | |
| 10816 * @return `true` if this variable was declared with the 'const' modifier | |
| 10817 */ | 10137 */ |
| 10818 bool get isConst; | 10138 bool get isConst; |
| 10819 | 10139 |
| 10820 /** | 10140 /** |
| 10821 * Return `true` if this variable was declared with the 'final' modifier. Vari
ables that are | 10141 * Return `true` if this variable was declared with the 'final' modifier. |
| 10822 * declared with the 'const' modifier will return `false` even though they are
implicitly | 10142 * Variables that are declared with the 'const' modifier will return `false` |
| 10823 * final. | 10143 * even though they are implicitly final. |
| 10824 * | |
| 10825 * @return `true` if this variable was declared with the 'final' modifier | |
| 10826 */ | 10144 */ |
| 10827 bool get isFinal; | 10145 bool get isFinal; |
| 10828 | 10146 |
| 10829 /** | 10147 /** |
| 10830 * Return the resolved [VariableDeclaration] node that declares this [Variable
Element] | 10148 * Return the resolved [VariableDeclaration] node that declares this |
| 10831 * . | 10149 * [VariableElement]. |
| 10832 * | 10150 * |
| 10833 * This method is expensive, because resolved AST might be evicted from cache,
so parsing and | 10151 * This method is expensive, because resolved AST might be evicted from cache, |
| 10834 * resolving will be performed. | 10152 * so parsing and resolving will be performed. |
| 10835 * | |
| 10836 * @return the resolved [VariableDeclaration], not `null`. | |
| 10837 */ | 10153 */ |
| 10838 @override | 10154 @override |
| 10839 VariableDeclaration get node; | 10155 VariableDeclaration get node; |
| 10840 | 10156 |
| 10841 /** | 10157 /** |
| 10842 * Return the declared type of this variable, or `null` if the variable did no
t have a | 10158 * Return the declared type of this variable, or `null` if the variable did |
| 10843 * declared type (such as if it was declared using the keyword 'var'). | 10159 * not have a declared type (such as if it was declared using the keyword |
| 10844 * | 10160 * 'var'). |
| 10845 * @return the declared type of this variable | |
| 10846 */ | 10161 */ |
| 10847 DartType get type; | 10162 DartType get type; |
| 10848 } | 10163 } |
| 10849 | 10164 |
| 10850 /** | 10165 /** |
| 10851 * Instances of the class `VariableElementImpl` implement a `VariableElement`. | 10166 * A concrete implementation of a [VariableElement]. |
| 10852 */ | 10167 */ |
| 10853 abstract class VariableElementImpl extends ElementImpl | 10168 abstract class VariableElementImpl extends ElementImpl |
| 10854 implements VariableElement { | 10169 implements VariableElement { |
| 10855 /** | 10170 /** |
| 10856 * An empty list of variable elements. | 10171 * An empty list of variable elements. |
| 10857 */ | 10172 */ |
| 10858 static const List<VariableElement> EMPTY_ARRAY = const <VariableElement>[]; | 10173 static const List<VariableElement> EMPTY_ARRAY = const <VariableElement>[]; |
| 10859 | 10174 |
| 10860 /** | 10175 /** |
| 10861 * The declared type of this variable. | 10176 * The declared type of this variable. |
| 10862 */ | 10177 */ |
| 10863 DartType type; | 10178 DartType type; |
| 10864 | 10179 |
| 10865 /** | 10180 /** |
| 10866 * A synthetic function representing this variable's initializer, or `null` if
this variable | 10181 * A synthetic function representing this variable's initializer, or `null` if |
| 10867 * does not have an initializer. | 10182 * this variable does not have an initializer. |
| 10868 */ | 10183 */ |
| 10869 FunctionElement _initializer; | 10184 FunctionElement _initializer; |
| 10870 | 10185 |
| 10871 /** | 10186 /** |
| 10872 * Initialize a newly created variable element to have the given name. | 10187 * Initialize a newly created variable element to have the given [name] and |
| 10873 * | 10188 * [offset]. |
| 10874 * @param name the name of this element | |
| 10875 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
| 10876 * declaration of this element | |
| 10877 */ | 10189 */ |
| 10878 VariableElementImpl(String name, int nameOffset) : super(name, nameOffset); | 10190 VariableElementImpl(String name, int offset) : super(name, offset); |
| 10879 | 10191 |
| 10880 /** | 10192 /** |
| 10881 * Initialize a newly created variable element to have the given name. | 10193 * Initialize a newly created variable element to have the given [name]. |
| 10882 * | |
| 10883 * @param name the name of this element | |
| 10884 */ | 10194 */ |
| 10885 VariableElementImpl.forNode(Identifier name) : super.forNode(name); | 10195 VariableElementImpl.forNode(Identifier name) : super.forNode(name); |
| 10886 | 10196 |
| 10887 /** | 10197 /** |
| 10888 * Set whether this variable is const to correspond to the given value. | 10198 * Set whether this variable is const. |
| 10889 * | |
| 10890 * @param isConst `true` if the variable is const | |
| 10891 */ | 10199 */ |
| 10892 void set const3(bool isConst) { | 10200 void set const3(bool isConst) { |
| 10893 setModifier(Modifier.CONST, isConst); | 10201 setModifier(Modifier.CONST, isConst); |
| 10894 } | 10202 } |
| 10895 | 10203 |
| 10896 /** | 10204 /** |
| 10897 * Return the result of evaluating this variable's initializer as a compile-ti
me constant | 10205 * Return the result of evaluating this variable's initializer as a |
| 10898 * expression, or `null` if this variable is not a 'const' variable, if it doe
s not have an | 10206 * compile-time constant expression, or `null` if this variable is not a |
| 10899 * initializer, or if the compilation unit containing the variable has not bee
n resolved. | 10207 * 'const' variable, if it does not have an initializer, or if the compilation |
| 10900 * | 10208 * unit containing the variable has not been resolved. |
| 10901 * @return the result of evaluating this variable's initializer | |
| 10902 */ | 10209 */ |
| 10903 EvaluationResultImpl get evaluationResult => null; | 10210 EvaluationResultImpl get evaluationResult => null; |
| 10904 | 10211 |
| 10905 /** | 10212 /** |
| 10906 * Set the result of evaluating this variable's initializer as a compile-time
constant expression | 10213 * Set the result of evaluating this variable's initializer as a compile-time |
| 10907 * to the given result. | 10214 * constant expression to the given [result]. |
| 10908 * | |
| 10909 * @param result the result of evaluating this variable's initializer | |
| 10910 */ | 10215 */ |
| 10911 void set evaluationResult(EvaluationResultImpl result) { | 10216 void set evaluationResult(EvaluationResultImpl result) { |
| 10912 throw new IllegalStateException( | 10217 throw new IllegalStateException( |
| 10913 "Invalid attempt to set a compile-time constant result"); | 10218 "Invalid attempt to set a compile-time constant result"); |
| 10914 } | 10219 } |
| 10915 | 10220 |
| 10916 /** | 10221 /** |
| 10917 * Set whether this variable is final to correspond to the given value. | 10222 * Set whether this variable is final. |
| 10918 * | |
| 10919 * @param isFinal `true` if the variable is final | |
| 10920 */ | 10223 */ |
| 10921 void set final2(bool isFinal) { | 10224 void set final2(bool isFinal) { |
| 10922 setModifier(Modifier.FINAL, isFinal); | 10225 setModifier(Modifier.FINAL, isFinal); |
| 10923 } | 10226 } |
| 10924 | 10227 |
| 10925 @override | 10228 @override |
| 10926 FunctionElement get initializer => _initializer; | 10229 FunctionElement get initializer => _initializer; |
| 10927 | 10230 |
| 10928 /** | 10231 /** |
| 10929 * Set the function representing this variable's initializer to the given func
tion. | 10232 * Set the function representing this variable's initializer to the given |
| 10930 * | 10233 * [function]. |
| 10931 * @param initializer the function representing this variable's initializer | |
| 10932 */ | 10234 */ |
| 10933 void set initializer(FunctionElement initializer) { | 10235 void set initializer(FunctionElement function) { |
| 10934 if (initializer != null) { | 10236 if (function != null) { |
| 10935 (initializer as FunctionElementImpl).enclosingElement = this; | 10237 (function as FunctionElementImpl).enclosingElement = this; |
| 10936 } | 10238 } |
| 10937 this._initializer = initializer; | 10239 this._initializer = function; |
| 10938 } | 10240 } |
| 10939 | 10241 |
| 10940 @override | 10242 @override |
| 10941 bool get isConst => hasModifier(Modifier.CONST); | 10243 bool get isConst => hasModifier(Modifier.CONST); |
| 10942 | 10244 |
| 10943 @override | 10245 @override |
| 10944 bool get isFinal => hasModifier(Modifier.FINAL); | 10246 bool get isFinal => hasModifier(Modifier.FINAL); |
| 10945 | 10247 |
| 10946 /** | 10248 /** |
| 10947 * Return `true` if this variable is potentially mutated somewhere in a closur
e. This | 10249 * Return `true` if this variable is potentially mutated somewhere in a |
| 10948 * information is only available for local variables (including parameters) an
d only after the | 10250 * closure. This information is only available for local variables (including |
| 10949 * compilation unit containing the variable has been resolved. | 10251 * parameters) and only after the compilation unit containing the variable has |
| 10950 * | 10252 * been resolved. |
| 10951 * @return `true` if this variable is potentially mutated somewhere in closure | |
| 10952 */ | 10253 */ |
| 10953 bool get isPotentiallyMutatedInClosure => false; | 10254 bool get isPotentiallyMutatedInClosure => false; |
| 10954 | 10255 |
| 10955 /** | 10256 /** |
| 10956 * Return `true` if this variable is potentially mutated somewhere in its scop
e. This | 10257 * Return `true` if this variable is potentially mutated somewhere in its |
| 10957 * information is only available for local variables (including parameters) an
d only after the | 10258 * scope. This information is only available for local variables (including |
| 10958 * compilation unit containing the variable has been resolved. | 10259 * parameters) and only after the compilation unit containing the variable has |
| 10959 * | 10260 * been resolved. |
| 10960 * @return `true` if this variable is potentially mutated somewhere in its sco
pe | |
| 10961 */ | 10261 */ |
| 10962 bool get isPotentiallyMutatedInScope => false; | 10262 bool get isPotentiallyMutatedInScope => false; |
| 10963 | 10263 |
| 10964 @override | 10264 @override |
| 10965 VariableDeclaration get node => | 10265 VariableDeclaration get node => |
| 10966 getNodeMatching((node) => node is VariableDeclaration); | 10266 getNodeMatching((node) => node is VariableDeclaration); |
| 10967 | 10267 |
| 10968 @override | 10268 @override |
| 10969 void appendTo(StringBuffer buffer) { | 10269 void appendTo(StringBuffer buffer) { |
| 10970 buffer.write(type); | 10270 buffer.write(type); |
| 10971 buffer.write(" "); | 10271 buffer.write(" "); |
| 10972 buffer.write(displayName); | 10272 buffer.write(displayName); |
| 10973 } | 10273 } |
| 10974 | 10274 |
| 10975 @override | 10275 @override |
| 10976 void visitChildren(ElementVisitor visitor) { | 10276 void visitChildren(ElementVisitor visitor) { |
| 10977 super.visitChildren(visitor); | 10277 super.visitChildren(visitor); |
| 10978 safelyVisitChild(_initializer, visitor); | 10278 safelyVisitChild(_initializer, visitor); |
| 10979 } | 10279 } |
| 10980 } | 10280 } |
| 10981 | 10281 |
| 10982 /** | 10282 /** |
| 10983 * The abstract class `VariableMember` defines the behavior common to members th
at represent a | 10283 * A variable element defined in a parameterized type where the values of the |
| 10984 * variable element defined in a parameterized type where the values of the type
parameters are | 10284 * type parameters are known. |
| 10985 * known. | |
| 10986 */ | 10285 */ |
| 10987 abstract class VariableMember extends Member implements VariableElement { | 10286 abstract class VariableMember extends Member implements VariableElement { |
| 10988 /** | 10287 /** |
| 10989 * Initialize a newly created element to represent an executable element of th
e given | 10288 * Initialize a newly created element to represent a constructor, based on the |
| 10990 * parameterized type. | 10289 * [baseElement], defined by the [definingType]. |
| 10991 * | |
| 10992 * @param baseElement the element on which the parameterized element was creat
ed | |
| 10993 * @param definingType the type in which the element is defined | |
| 10994 */ | 10290 */ |
| 10995 VariableMember(VariableElement baseElement, ParameterizedType definingType) | 10291 VariableMember(VariableElement baseElement, ParameterizedType definingType) |
| 10996 : super(baseElement, definingType); | 10292 : super(baseElement, definingType); |
| 10997 | 10293 |
| 10998 @override | 10294 @override |
| 10999 VariableElement get baseElement => super.baseElement as VariableElement; | 10295 VariableElement get baseElement => super.baseElement as VariableElement; |
| 11000 | 10296 |
| 11001 @override | 10297 @override |
| 11002 FunctionElement get initializer { | 10298 FunctionElement get initializer { |
| 11003 // | 10299 // |
| (...skipping 19 matching lines...) Expand all Loading... |
| 11023 @override | 10319 @override |
| 11024 void visitChildren(ElementVisitor visitor) { | 10320 void visitChildren(ElementVisitor visitor) { |
| 11025 // TODO(brianwilkerson) We need to finish implementing the accessors used | 10321 // TODO(brianwilkerson) We need to finish implementing the accessors used |
| 11026 // below so that we can safely invoke them. | 10322 // below so that we can safely invoke them. |
| 11027 super.visitChildren(visitor); | 10323 super.visitChildren(visitor); |
| 11028 safelyVisitChild(baseElement.initializer, visitor); | 10324 safelyVisitChild(baseElement.initializer, visitor); |
| 11029 } | 10325 } |
| 11030 } | 10326 } |
| 11031 | 10327 |
| 11032 /** | 10328 /** |
| 11033 * The interface `VoidType` defines the behavior of the unique object representi
ng the type | 10329 * The type `void`. |
| 11034 * `void`. | |
| 11035 */ | 10330 */ |
| 11036 abstract class VoidType implements DartType { | 10331 abstract class VoidType implements DartType { |
| 11037 @override | 10332 @override |
| 11038 VoidType substitute2( | 10333 VoidType substitute2( |
| 11039 List<DartType> argumentTypes, List<DartType> parameterTypes); | 10334 List<DartType> argumentTypes, List<DartType> parameterTypes); |
| 11040 } | 10335 } |
| 11041 | 10336 |
| 11042 /** | 10337 /** |
| 11043 * The unique instance of the class `VoidTypeImpl` implements the type `void`. | 10338 * A concrete implementation of a [VoidType]. |
| 11044 */ | 10339 */ |
| 11045 class VoidTypeImpl extends TypeImpl implements VoidType { | 10340 class VoidTypeImpl extends TypeImpl implements VoidType { |
| 11046 /** | 10341 /** |
| 11047 * The unique instance of this class. | 10342 * The unique instance of this class. |
| 11048 */ | 10343 */ |
| 11049 static VoidTypeImpl _INSTANCE = new VoidTypeImpl(); | 10344 static VoidTypeImpl _INSTANCE = new VoidTypeImpl(); |
| 11050 | 10345 |
| 11051 /** | 10346 /** |
| 11052 * Return the unique instance of this class. | 10347 * Return the unique instance of this class. |
| 11053 * | |
| 11054 * @return the unique instance of this class | |
| 11055 */ | 10348 */ |
| 11056 static VoidTypeImpl get instance => _INSTANCE; | 10349 static VoidTypeImpl get instance => _INSTANCE; |
| 11057 | 10350 |
| 11058 /** | 10351 /** |
| 11059 * Prevent the creation of instances of this class. | 10352 * Prevent the creation of instances of this class. |
| 11060 */ | 10353 */ |
| 11061 VoidTypeImpl() : super(null, Keyword.VOID.syntax); | 10354 VoidTypeImpl() : super(null, Keyword.VOID.syntax); |
| 11062 | 10355 |
| 11063 @override | 10356 @override |
| 11064 int get hashCode => 2; | 10357 int get hashCode => 2; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 11091 // void <: void (by reflexivity) | 10384 // void <: void (by reflexivity) |
| 11092 // bottom <: void (as bottom is a subtype of all types). | 10385 // bottom <: void (as bottom is a subtype of all types). |
| 11093 // void <: dynamic (as dynamic is a supertype of all types) | 10386 // void <: dynamic (as dynamic is a supertype of all types) |
| 11094 return identical(type, this) || type.isDynamic; | 10387 return identical(type, this) || type.isDynamic; |
| 11095 } | 10388 } |
| 11096 | 10389 |
| 11097 @override | 10390 @override |
| 11098 VoidTypeImpl substitute2( | 10391 VoidTypeImpl substitute2( |
| 11099 List<DartType> argumentTypes, List<DartType> parameterTypes) => this; | 10392 List<DartType> argumentTypes, List<DartType> parameterTypes) => this; |
| 11100 } | 10393 } |
| OLD | NEW |