| OLD | NEW |
| (Empty) | |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. |
| 3 |
| 4 library engine.element; |
| 5 |
| 6 import 'dart:collection'; |
| 7 import 'java_core.dart'; |
| 8 import 'java_engine.dart'; |
| 9 import 'source.dart'; |
| 10 import 'scanner.dart' show Keyword; |
| 11 import 'ast.dart'; |
| 12 import 'package:analyzer-experimental/src/generated/utilities_dart.dart'; |
| 13 |
| 14 /** |
| 15 * The interface {@code Annotation} defines the behavior of objects representing
a single annotation |
| 16 * associated with an element. |
| 17 */ |
| 18 abstract class Annotation { |
| 19 /** |
| 20 * Return the element representing the field, variable, or const constructor b
eing used as an |
| 21 * annotation. |
| 22 * @return the field, variable, or constructor being used as an annotation |
| 23 */ |
| 24 Element get element; |
| 25 } |
| 26 /** |
| 27 * The interface {@code ClassElement} defines the behavior of elements that repr
esent a class. |
| 28 */ |
| 29 abstract class ClassElement implements Element { |
| 30 /** |
| 31 * Return an array containing all of the accessors (getters and setters) conta
ined in this class. |
| 32 * @return the accessors contained in this class |
| 33 */ |
| 34 List<PropertyAccessorElement> get accessors; |
| 35 /** |
| 36 * Return an array containing all of the constructors contained in this class. |
| 37 * @return the constructors contained in this class |
| 38 */ |
| 39 List<ConstructorElement> get constructors; |
| 40 /** |
| 41 * Return an array containing all of the fields contained in this class. |
| 42 * @return the fields contained in this class |
| 43 */ |
| 44 List<FieldElement> get fields; |
| 45 /** |
| 46 * Return an array containing all of the interfaces that are implemented by th
is class. |
| 47 * @return the interfaces that are implemented by this class |
| 48 */ |
| 49 List<InterfaceType> get interfaces; |
| 50 /** |
| 51 * Return an array containing all of the methods contained in this class. |
| 52 * @return the methods contained in this class |
| 53 */ |
| 54 List<MethodElement> get methods; |
| 55 /** |
| 56 * Return an array containing all of the mixins that are applied to the class
being extended in |
| 57 * order to derive the superclass of this class. |
| 58 * @return the mixins that are applied to derive the superclass of this class |
| 59 */ |
| 60 List<InterfaceType> get mixins; |
| 61 /** |
| 62 * Return the superclass of this class, or {@code null} if the class represent
s the class |
| 63 * 'Object'. All other classes will have a non-{@code null} superclass. If the
superclass was not |
| 64 * explicitly declared then the implicit superclass 'Object' will be returned. |
| 65 * @return the superclass of this class |
| 66 */ |
| 67 InterfaceType get supertype; |
| 68 /** |
| 69 * Return the type defined by the class. |
| 70 * @return the type defined by the class |
| 71 */ |
| 72 InterfaceType get type; |
| 73 /** |
| 74 * Return an array containing all of the type variables defined for this class
. |
| 75 * @return the type variables defined for this class |
| 76 */ |
| 77 List<TypeVariableElement> get typeVariables; |
| 78 /** |
| 79 * Return {@code true} if this class is abstract. A class is abstract if it ha
s an explicit{@code abstract} modifier. Note, that this definition of <i>abstrac
t</i> is different from |
| 80 * <i>has unimplemented members</i>. |
| 81 * @return {@code true} if this class is abstract |
| 82 */ |
| 83 bool isAbstract(); |
| 84 } |
| 85 /** |
| 86 * The interface {@code CompilationUnitElement} defines the behavior of elements
representing a |
| 87 * compilation unit. |
| 88 */ |
| 89 abstract class CompilationUnitElement implements Element { |
| 90 /** |
| 91 * Return an array containing all of the top-level accessors (getters and sett
ers) contained in |
| 92 * this compilation unit. |
| 93 * @return the top-level accessors contained in this compilation unit |
| 94 */ |
| 95 List<PropertyAccessorElement> get accessors; |
| 96 /** |
| 97 * Return the library in which this compilation unit is defined. |
| 98 * @return the library in which this compilation unit is defined |
| 99 */ |
| 100 LibraryElement get enclosingElement; |
| 101 /** |
| 102 * Return an array containing all of the fields contained in this compilation
unit. |
| 103 * @return the fields contained in this compilation unit |
| 104 */ |
| 105 List<FieldElement> get fields; |
| 106 /** |
| 107 * Return an array containing all of the top-level functions contained in this
compilation unit. |
| 108 * @return the top-level functions contained in this compilation unit |
| 109 */ |
| 110 List<FunctionElement> get functions; |
| 111 /** |
| 112 * Return the source that corresponds to this compilation unit. |
| 113 * @return the source that corresponds to this compilation unit |
| 114 */ |
| 115 Source get source; |
| 116 /** |
| 117 * Return an array containing all of the type aliases contained in this compil
ation unit. |
| 118 * @return the type aliases contained in this compilation unit |
| 119 */ |
| 120 List<TypeAliasElement> get typeAliases; |
| 121 /** |
| 122 * Return an array containing all of the classes contained in this compilation
unit. |
| 123 * @return the classes contained in this compilation unit |
| 124 */ |
| 125 List<ClassElement> get types; |
| 126 } |
| 127 /** |
| 128 * The interface {@code ConstructorElement} defines the behavior of elements rep
resenting a |
| 129 * constructor or a factory method defined within a type. |
| 130 */ |
| 131 abstract class ConstructorElement implements ExecutableElement { |
| 132 /** |
| 133 * Return the type in which this constructor is defined. |
| 134 * @return the type in which this constructor is defined |
| 135 */ |
| 136 ClassElement get enclosingElement; |
| 137 /** |
| 138 * Return {@code true} if this constructor is a const constructor. |
| 139 * @return {@code true} if this constructor is a const constructor |
| 140 */ |
| 141 bool isConst(); |
| 142 /** |
| 143 * Return {@code true} if this constructor represents a factory constructor. |
| 144 * @return {@code true} if this constructor represents a factory constructor |
| 145 */ |
| 146 bool isFactory(); |
| 147 } |
| 148 /** |
| 149 * The interface {@code Element} defines the behavior common to all of the eleme
nts in the element |
| 150 * model. Generally speaking, the element model is a semantic model of the progr
am that represents |
| 151 * things that are declared with a name and hence can be referenced elsewhere in
the code. |
| 152 * <p> |
| 153 * There are two exceptions to the general case. First, there are elements in th
e element model that |
| 154 * are created for the convenience of various kinds of analysis but that do not
have any |
| 155 * corresponding declaration within the source code. Such elements are marked as
being |
| 156 * <i>synthetic</i>. Examples of synthetic elements include |
| 157 * <ul> |
| 158 * <li>default constructors in classes that do not define any explicit construct
ors, |
| 159 * <li>getters and setters that are induced by explicit field declarations, |
| 160 * <li>fields that are induced by explicit declarations of getters and setters,
and |
| 161 * <li>functions representing the initialization expression for a variable. |
| 162 * </ul> |
| 163 * <p> |
| 164 * Second, there are elements in the element model that do not have a name. Thes
e correspond to |
| 165 * unnamed functions and exist in order to more accurately represent the semanti
c structure of the |
| 166 * program. |
| 167 */ |
| 168 abstract class Element { |
| 169 /** |
| 170 * Return the element of the given class that most immediately encloses this e
lement, or{@code null} if there is no enclosing element of the given class. |
| 171 * @param elementClass the class of the element to be returned |
| 172 * @return the element that encloses this element |
| 173 */ |
| 174 Element getAncestor(Type elementClass); |
| 175 /** |
| 176 * Return the analysis context in which this element is defined. |
| 177 * @return the analysis context in which this element is defined |
| 178 */ |
| 179 AnalysisContext get context; |
| 180 /** |
| 181 * Return the element that either physically or logically encloses this elemen
t. This will be{@code null} if this element is a library because libraries are t
he top-level elements in the |
| 182 * model. |
| 183 * @return the element that encloses this element |
| 184 */ |
| 185 Element get enclosingElement; |
| 186 /** |
| 187 * Return the kind of element that this is. |
| 188 * @return the kind of this element |
| 189 */ |
| 190 ElementKind get kind; |
| 191 /** |
| 192 * Return the library that contains this element. This will be {@code null} if
this element is a |
| 193 * library or HTML file because libraries and HTML files are not contained in
other libraries. |
| 194 * @return the library that contains this element |
| 195 */ |
| 196 LibraryElement get library; |
| 197 /** |
| 198 * Return an object representing the location of this element in the element m
odel. The object can |
| 199 * be used to locate this element at a later time. |
| 200 * @return the location of this element in the element model |
| 201 */ |
| 202 ElementLocation get location; |
| 203 /** |
| 204 * Return an array containing all of the metadata associated with this element
. |
| 205 * @return the metadata associated with this element |
| 206 */ |
| 207 List<Annotation> get metadata; |
| 208 /** |
| 209 * Return the name of this element, or {@code null} if this element does not h
ave a name. |
| 210 * @return the name of this element |
| 211 */ |
| 212 String get name; |
| 213 /** |
| 214 * Return the offset of the name of this element in the file that contains the
declaration of this |
| 215 * element, or {@code -1} if this element is synthetic, does not have a name,
or otherwise does |
| 216 * not have an offset. |
| 217 * @return the offset of the name of this element |
| 218 */ |
| 219 int get nameOffset; |
| 220 /** |
| 221 * Return {@code true} if this element is synthetic. A synthetic element is an
element that is not |
| 222 * represented in the source code explicitly, but is implied by the source cod
e, such as the |
| 223 * default constructor for a class that does not explicitly define any constru
ctors. |
| 224 * @return {@code true} if this element is synthetic |
| 225 */ |
| 226 bool isSynthetic(); |
| 227 } |
| 228 /** |
| 229 * The enumeration {@code ElementKind} defines the various kinds of elements in
the element model. |
| 230 */ |
| 231 class ElementKind { |
| 232 static final ElementKind CLASS = new ElementKind('CLASS', 0); |
| 233 static final ElementKind COMPILATION_UNIT = new ElementKind('COMPILATION_UNIT'
, 1); |
| 234 static final ElementKind CONSTRUCTOR = new ElementKind('CONSTRUCTOR', 2); |
| 235 static final ElementKind DYNAMIC = new ElementKind('DYNAMIC', 3); |
| 236 static final ElementKind ERROR = new ElementKind('ERROR', 4); |
| 237 static final ElementKind EXPORT = new ElementKind('EXPORT', 5); |
| 238 static final ElementKind FIELD = new ElementKind('FIELD', 6); |
| 239 static final ElementKind FUNCTION = new ElementKind('FUNCTION', 7); |
| 240 static final ElementKind GETTER = new ElementKind('GETTER', 8); |
| 241 static final ElementKind HTML = new ElementKind('HTML', 9); |
| 242 static final ElementKind IMPORT = new ElementKind('IMPORT', 10); |
| 243 static final ElementKind LABEL = new ElementKind('LABEL', 11); |
| 244 static final ElementKind LIBRARY = new ElementKind('LIBRARY', 12); |
| 245 static final ElementKind METHOD = new ElementKind('METHOD', 13); |
| 246 static final ElementKind NAME = new ElementKind('NAME', 14); |
| 247 static final ElementKind PARAMETER = new ElementKind('PARAMETER', 15); |
| 248 static final ElementKind PREFIX = new ElementKind('PREFIX', 16); |
| 249 static final ElementKind SETTER = new ElementKind('SETTER', 17); |
| 250 static final ElementKind TYPE_ALIAS = new ElementKind('TYPE_ALIAS', 18); |
| 251 static final ElementKind TYPE_VARIABLE = new ElementKind('TYPE_VARIABLE', 19); |
| 252 static final ElementKind UNIVERSE = new ElementKind('UNIVERSE', 20); |
| 253 static final ElementKind VARIABLE = new ElementKind('VARIABLE', 21); |
| 254 static final List<ElementKind> values = [CLASS, COMPILATION_UNIT, CONSTRUCTOR,
DYNAMIC, ERROR, EXPORT, FIELD, FUNCTION, GETTER, HTML, IMPORT, LABEL, LIBRARY,
METHOD, NAME, PARAMETER, PREFIX, SETTER, TYPE_ALIAS, TYPE_VARIABLE, UNIVERSE, VA
RIABLE]; |
| 255 final String __name; |
| 256 final int __ordinal; |
| 257 ElementKind(this.__name, this.__ordinal) { |
| 258 } |
| 259 String toString() => __name; |
| 260 } |
| 261 /** |
| 262 * The interface {@code ElementLocation} defines the behavior of objects that re
present the location |
| 263 * of an element within the element model. |
| 264 */ |
| 265 abstract class ElementLocation { |
| 266 /** |
| 267 * Return an encoded representation of this location that can be used to creat
e a location that is |
| 268 * equal to this location. |
| 269 * @return an encoded representation of this location |
| 270 */ |
| 271 String get encoding; |
| 272 } |
| 273 /** |
| 274 * The interface {@code ExecutableElement} defines the behavior of elements repr
esenting an |
| 275 * executable object, including functions, methods, constructors, getters, and s
etters. |
| 276 */ |
| 277 abstract class ExecutableElement implements Element { |
| 278 /** |
| 279 * Return an array containing all of the functions defined within this executa
ble element. |
| 280 * @return the functions defined within this executable element |
| 281 */ |
| 282 List<ExecutableElement> get functions; |
| 283 /** |
| 284 * Return an array containing all of the labels defined within this executable
element. |
| 285 * @return the labels defined within this executable element |
| 286 */ |
| 287 List<LabelElement> get labels; |
| 288 /** |
| 289 * Return an array containing all of the local variables defined within this e
xecutable element. |
| 290 * @return the local variables defined within this executable element |
| 291 */ |
| 292 List<VariableElement> get localVariables; |
| 293 /** |
| 294 * Return an array containing all of the parameters defined by this executable
element. |
| 295 * @return the parameters defined by this executable element |
| 296 */ |
| 297 List<ParameterElement> get parameters; |
| 298 /** |
| 299 * Return the type of function defined by this executable element. |
| 300 * @return the type of function defined by this executable element |
| 301 */ |
| 302 FunctionType get type; |
| 303 } |
| 304 /** |
| 305 * The interface {@code ExportElement} defines the behavior of objects represent
ing information |
| 306 * about a single export directive within a library. |
| 307 */ |
| 308 abstract class ExportElement implements Element { |
| 309 /** |
| 310 * An empty array of export elements. |
| 311 */ |
| 312 static List<ExportElement> EMPTY_ARRAY = new List<ExportElement>.fixedLength(0
); |
| 313 /** |
| 314 * Return an array containing the combinators that were specified as part of t
he export directive |
| 315 * in the order in which they were specified. |
| 316 * @return the combinators specified in the export directive |
| 317 */ |
| 318 List<NamespaceCombinator> get combinators; |
| 319 /** |
| 320 * Return the library that is exported from this library by this export direct
ive. |
| 321 * @return the library that is exported from this library |
| 322 */ |
| 323 LibraryElement get exportedLibrary; |
| 324 } |
| 325 /** |
| 326 * The interface {@code FieldElement} defines the behavior of elements represent
ing a field defined |
| 327 * within a type. Note that explicitly defined fields implicitly define a synthe
tic getter and that |
| 328 * non-{@code final} explicitly defined fields implicitly define a synthetic set
ter. Symmetrically, |
| 329 * synthetic fields are implicitly created for explicitly defined getters and se
tters. The following |
| 330 * rules apply: |
| 331 * <ul> |
| 332 * <li>Every explicit field is represented by a non-synthetic {@link FieldElemen
t}. |
| 333 * <li>Every explicit field induces a getter and possibly a setter, both of whic
h are represented by |
| 334 * synthetic {@link PropertyAccessorElement}s. |
| 335 * <li>Every explicit getter or setter is represented by a non-synthetic{@link P
ropertyAccessorElement}. |
| 336 * <li>Every explicit getter or setter (or pair thereof if they have the same na
me) induces a field |
| 337 * that is represented by a synthetic {@link FieldElement}. |
| 338 * </ul> |
| 339 */ |
| 340 abstract class FieldElement implements VariableElement { |
| 341 /** |
| 342 * Return the getter associated with this field. If this field was explicitly
defined (is not |
| 343 * synthetic) then the getter associated with it will be synthetic. |
| 344 * @return the getter associated with this field |
| 345 */ |
| 346 PropertyAccessorElement get getter; |
| 347 /** |
| 348 * Return the setter associated with this field, or {@code null} if the field
is effectively{@code final} and therefore does not have a setter associated with
it. (This can happen either |
| 349 * because the field is explicitly defined as being {@code final} or because t
he field is induced |
| 350 * by an explicit getter that does not have a corresponding setter.) If this f
ield was explicitly |
| 351 * defined (is not synthetic) then the setter associated with it will be synth
etic. |
| 352 * @return the setter associated with this field |
| 353 */ |
| 354 PropertyAccessorElement get setter; |
| 355 /** |
| 356 * Return {@code true} if this field is a static field. |
| 357 * @return {@code true} if this field is a static field |
| 358 */ |
| 359 bool isStatic(); |
| 360 } |
| 361 /** |
| 362 * The interface {@code FunctionElement} defines the behavior of elements repres
enting a function. |
| 363 */ |
| 364 abstract class FunctionElement implements ExecutableElement { |
| 365 } |
| 366 /** |
| 367 * The interface {@code HideCombinator} defines the behavior of combinators that
cause some of the |
| 368 * names in a namespace to be hidden when being imported. |
| 369 */ |
| 370 abstract class HideCombinator implements NamespaceCombinator { |
| 371 /** |
| 372 * Return an array containing the names that are not to be made visible in the
importing library |
| 373 * even if they are defined in the imported library. |
| 374 * @return the names from the imported library that are hidden from the import
ing library |
| 375 */ |
| 376 List<String> get hiddenNames; |
| 377 } |
| 378 /** |
| 379 * The interface {@code HtmlElement} defines the behavior of elements representi
ng an HTML file. |
| 380 */ |
| 381 abstract class HtmlElement implements Element { |
| 382 /** |
| 383 * Return an array containing all of the libraries contained in or referenced
from script tags in |
| 384 * the HTML file. This includes libraries that are defined by the content of a
script file as well |
| 385 * as libraries that are referenced in the {@core src} attribute of a script t
ag. |
| 386 * @return the libraries referenced from script tags in the HTML file |
| 387 */ |
| 388 List<LibraryElement> get libraries; |
| 389 /** |
| 390 * Return the source that corresponds to this HTML file. |
| 391 * @return the source that corresponds to this HTML file |
| 392 */ |
| 393 Source get source; |
| 394 } |
| 395 /** |
| 396 * The interface {@code ImportElement} defines the behavior of objects represent
ing information |
| 397 * about a single import directive within a library. |
| 398 */ |
| 399 abstract class ImportElement implements Element { |
| 400 /** |
| 401 * An empty array of import elements. |
| 402 */ |
| 403 static List<ImportElement> EMPTY_ARRAY = new List<ImportElement>.fixedLength(0
); |
| 404 /** |
| 405 * Return an array containing the combinators that were specified as part of t
he import directive |
| 406 * in the order in which they were specified. |
| 407 * @return the combinators specified in the import directive |
| 408 */ |
| 409 List<NamespaceCombinator> get combinators; |
| 410 /** |
| 411 * Return the library that is imported into this library by this import direct
ive. |
| 412 * @return the library that is imported into this library |
| 413 */ |
| 414 LibraryElement get importedLibrary; |
| 415 /** |
| 416 * Return the prefix that was specified as part of the import directive, or {@
code null} if there |
| 417 * was no prefix specified. |
| 418 * @return the prefix that was specified as part of the import directive |
| 419 */ |
| 420 PrefixElement get prefix; |
| 421 } |
| 422 /** |
| 423 * The interface {@code LabelElement} defines the behavior of elements represent
ing a label |
| 424 * associated with a statement. |
| 425 */ |
| 426 abstract class LabelElement implements Element { |
| 427 /** |
| 428 * Return the executable element in which this label is defined. |
| 429 * @return the executable element in which this label is defined |
| 430 */ |
| 431 ExecutableElement get enclosingElement; |
| 432 } |
| 433 /** |
| 434 * The interface {@code LibraryElement} defines the behavior of elements represe
nting a library. |
| 435 */ |
| 436 abstract class LibraryElement implements Element { |
| 437 /** |
| 438 * Return the compilation unit that defines this library. |
| 439 * @return the compilation unit that defines this library |
| 440 */ |
| 441 CompilationUnitElement get definingCompilationUnit; |
| 442 /** |
| 443 * Return the entry point for this library, or {@code null} if this library do
es not have an entry |
| 444 * point. The entry point is defined to be a zero argument top-level function
whose name is{@code main}. |
| 445 * @return the entry point for this library |
| 446 */ |
| 447 FunctionElement get entryPoint; |
| 448 /** |
| 449 * Return an array containing all of the exports defined in this library. |
| 450 * @return the exports defined in this library |
| 451 */ |
| 452 List<ExportElement> get exports; |
| 453 /** |
| 454 * Return an array containing all of the libraries that are imported into this
library. This |
| 455 * includes all of the libraries that are imported using a prefix (also availa
ble through the |
| 456 * prefixes returned by {@link #getPrefixes()}) and those that are imported wi
thout a prefix. |
| 457 * @return an array containing all of the libraries that are imported into thi
s library |
| 458 */ |
| 459 List<LibraryElement> get importedLibraries; |
| 460 /** |
| 461 * Return an array containing all of the imports defined in this library. |
| 462 * @return the imports defined in this library |
| 463 */ |
| 464 List<ImportElement> get imports; |
| 465 /** |
| 466 * Return an array containing all of the compilation units that are included i
n this library using |
| 467 * a {@code part} directive. This does not include the defining compilation un
it that contains the{@code part} directives. |
| 468 * @return the compilation units that are included in this library |
| 469 */ |
| 470 List<CompilationUnitElement> get parts; |
| 471 /** |
| 472 * Return an array containing elements for each of the prefixes used to {@code
import} libraries |
| 473 * into this library. Each prefix can be used in more than one {@code import}
directive. |
| 474 * @return the prefixes used to {@code import} libraries into this library |
| 475 */ |
| 476 List<PrefixElement> get prefixes; |
| 477 } |
| 478 /** |
| 479 * The interface {@code MethodElement} defines the behavior of elements that rep
resent a method |
| 480 * defined within a type. |
| 481 */ |
| 482 abstract class MethodElement implements ExecutableElement { |
| 483 /** |
| 484 * Return the type in which this method is defined. |
| 485 * @return the type in which this method is defined |
| 486 */ |
| 487 ClassElement get enclosingElement; |
| 488 /** |
| 489 * Return {@code true} if this method is abstract. Methods are abstract if the
y are not external |
| 490 * and have no body. |
| 491 * @return {@code true} if this method is abstract |
| 492 */ |
| 493 bool isAbstract(); |
| 494 /** |
| 495 * Return {@code true} if this method is static. Methods are static if they ha
ve been marked as |
| 496 * being static using the {@code static} modifier. |
| 497 * @return {@code true} if this method is static |
| 498 */ |
| 499 bool isStatic(); |
| 500 } |
| 501 /** |
| 502 * The interface {@code MultiplyDefinedElement} defines the behavior of pseudo-e
lements that |
| 503 * represent multiple elements defined within a single scope that have the same
name. This situation |
| 504 * is not allowed by the language, so objects implementing this interface always
represent an error. |
| 505 * As a result, most of the normal operations on elements do not make sense and
will return useless |
| 506 * results. |
| 507 */ |
| 508 abstract class MultiplyDefinedElement implements Element { |
| 509 /** |
| 510 * Return an array containing all of the elements that were defined within the
scope to have the |
| 511 * same name. |
| 512 * @return the elements that were defined with the same name |
| 513 */ |
| 514 List<Element> get conflictingElements; |
| 515 } |
| 516 /** |
| 517 * The interface {@code NamespaceCombinator} defines the behavior common to obje
cts that control how |
| 518 * namespaces are combined. |
| 519 */ |
| 520 abstract class NamespaceCombinator { |
| 521 /** |
| 522 * An empty array of namespace combinators. |
| 523 */ |
| 524 static List<NamespaceCombinator> EMPTY_ARRAY = new List<NamespaceCombinator>.f
ixedLength(0); |
| 525 } |
| 526 /** |
| 527 * The interface {@code ParameterElement} defines the behavior of elements repre
senting a parameter |
| 528 * defined within an executable element. |
| 529 */ |
| 530 abstract class ParameterElement implements VariableElement { |
| 531 /** |
| 532 * Return the kind of this parameter. |
| 533 * @return the kind of this parameter |
| 534 */ |
| 535 ParameterKind get parameterKind; |
| 536 } |
| 537 /** |
| 538 * The interface {@code PrefixElement} defines the behavior common to elements t
hat represent a |
| 539 * prefix used to import one or more libraries into another library. |
| 540 */ |
| 541 abstract class PrefixElement implements Element { |
| 542 /** |
| 543 * Return the library into which other libraries are imported using this prefi
x. |
| 544 * @return the library into which other libraries are imported using this pref
ix |
| 545 */ |
| 546 LibraryElement get enclosingElement; |
| 547 /** |
| 548 * Return an array containing all of the libraries that are imported using thi
s prefix. |
| 549 * @return the libraries that are imported using this prefix |
| 550 */ |
| 551 List<LibraryElement> get importedLibraries; |
| 552 } |
| 553 /** |
| 554 * The interface {@code PropertyAccessorElement} defines the behavior of element
s representing a |
| 555 * getter or a setter. Note that explicitly defined property accessors implicitl
y define a synthetic |
| 556 * field. Symmetrically, synthetic accessors are implicitly created for explicit
ly defined fields. |
| 557 * The following rules apply: |
| 558 * <ul> |
| 559 * <li>Every explicit field is represented by a non-synthetic {@link FieldElemen
t}. |
| 560 * <li>Every explicit field induces a getter and possibly a setter, both of whic
h are represented by |
| 561 * synthetic {@link PropertyAccessorElement}s. |
| 562 * <li>Every explicit getter or setter is represented by a non-synthetic{@link P
ropertyAccessorElement}. |
| 563 * <li>Every explicit getter or setter (or pair thereof if they have the same na
me) induces a field |
| 564 * that is represented by a synthetic {@link FieldElement}. |
| 565 * </ul> |
| 566 */ |
| 567 abstract class PropertyAccessorElement implements ExecutableElement { |
| 568 /** |
| 569 * Return the field associated with this accessor. If this accessor was explic
itly defined (is not |
| 570 * synthetic) then the field associated with it will be synthetic. |
| 571 * @return the field associated with this accessor |
| 572 */ |
| 573 FieldElement get field; |
| 574 /** |
| 575 * Return {@code true} if this accessor represents a getter. |
| 576 * @return {@code true} if this accessor represents a getter |
| 577 */ |
| 578 bool isGetter(); |
| 579 /** |
| 580 * Return {@code true} if this accessor represents a setter. |
| 581 * @return {@code true} if this accessor represents a setter |
| 582 */ |
| 583 bool isSetter(); |
| 584 } |
| 585 /** |
| 586 * The interface {@code ShowCombinator} defines the behavior of combinators that
cause some of the |
| 587 * names in a namespace to be visible (and the rest hidden) when being imported. |
| 588 */ |
| 589 abstract class ShowCombinator implements NamespaceCombinator { |
| 590 /** |
| 591 * Return an array containing the names that are to be made visible in the imp
orting library if |
| 592 * they are defined in the imported library. |
| 593 * @return the names from the imported library that are visible in the importi
ng library |
| 594 */ |
| 595 List<String> get shownNames; |
| 596 } |
| 597 /** |
| 598 * The interface {@code TypeAliasElement} defines the behavior of elements repre
senting a type alias |
| 599 * ({@code typedef}). |
| 600 */ |
| 601 abstract class TypeAliasElement implements Element { |
| 602 /** |
| 603 * Return the compilation unit in which this type alias is defined. |
| 604 * @return the compilation unit in which this type alias is defined |
| 605 */ |
| 606 CompilationUnitElement get enclosingElement; |
| 607 /** |
| 608 * Return an array containing all of the parameters defined by this type alias
. |
| 609 * @return the parameters defined by this type alias |
| 610 */ |
| 611 List<ParameterElement> get parameters; |
| 612 /** |
| 613 * Return the type of function defined by this type alias. |
| 614 * @return the type of function defined by this type alias |
| 615 */ |
| 616 FunctionType get type; |
| 617 /** |
| 618 * Return an array containing all of the type variables defined for this type. |
| 619 * @return the type variables defined for this type |
| 620 */ |
| 621 List<TypeVariableElement> get typeVariables; |
| 622 } |
| 623 /** |
| 624 * The interface {@code TypeVariableElement} defines the behavior of elements re
presenting a type |
| 625 * variable. |
| 626 */ |
| 627 abstract class TypeVariableElement implements Element { |
| 628 /** |
| 629 * Return the type representing the bound associated with this variable, or {@
code null} if this |
| 630 * variable does not have an explicit bound. |
| 631 * @return the type representing the bound associated with this variable |
| 632 */ |
| 633 Type2 get bound; |
| 634 /** |
| 635 * Return the type defined by this type variable. |
| 636 * @return the type defined by this type variable |
| 637 */ |
| 638 TypeVariableType get type; |
| 639 } |
| 640 /** |
| 641 * The interface {@code UndefinedElement} defines the behavior of pseudo-element
s that represent |
| 642 * names that are undefined. This situation is not allowed by the language, so o
bjects implementing |
| 643 * this interface always represent an error. As a result, most of the normal ope
rations on elements |
| 644 * do not make sense and will return useless results. |
| 645 */ |
| 646 abstract class UndefinedElement implements Element { |
| 647 } |
| 648 /** |
| 649 * The interface {@code VariableElement} defines the behavior common to elements
that represent a |
| 650 * variable. |
| 651 */ |
| 652 abstract class VariableElement implements Element { |
| 653 /** |
| 654 * Return a synthetic function representing this variable's initializer, or {@
code null} if this |
| 655 * variable does not have an initializer. The function will have no parameters
. The return type of |
| 656 * the function will be the compile-time type of the initialization expression
. |
| 657 * @return a synthetic function representing this variable's initializer |
| 658 */ |
| 659 FunctionElement get initializer; |
| 660 /** |
| 661 * Return the declared type of this variable, or {@code null} if the variable
did not have a |
| 662 * declared type (such as if it was declared using the keyword 'var'). |
| 663 * @return the declared type of this variable |
| 664 */ |
| 665 Type2 get type; |
| 666 /** |
| 667 * Return {@code true} if this variable is a const variable. Variables are con
st if they have been |
| 668 * marked as being const using the {@code const} modifier. |
| 669 * @return {@code true} if this variable is a const variable |
| 670 */ |
| 671 bool isConst(); |
| 672 /** |
| 673 * Return {@code true} if this variable is a final variable. Variables are fin
al if they have been |
| 674 * marked as being final using either the {@code final} or {@code const} modif
iers. |
| 675 * @return {@code true} if this variable is a final variable |
| 676 */ |
| 677 bool isFinal(); |
| 678 } |
| 679 /** |
| 680 * Instances of the class {@code AnnotationImpl} implement an {@link Annotation}
. |
| 681 */ |
| 682 class AnnotationImpl implements Annotation { |
| 683 /** |
| 684 * The element representing the field, variable, or constructor being used as
an annotation. |
| 685 */ |
| 686 Element _element; |
| 687 /** |
| 688 * An empty array of annotations. |
| 689 */ |
| 690 static List<AnnotationImpl> EMPTY_ARRAY = new List<AnnotationImpl>.fixedLength
(0); |
| 691 /** |
| 692 * Initialize a newly created annotation. |
| 693 * @param element the element representing the field, variable, or constructor
being used as an |
| 694 * annotation |
| 695 */ |
| 696 AnnotationImpl(Element element) { |
| 697 this._element = element; |
| 698 } |
| 699 Element get element => _element; |
| 700 } |
| 701 /** |
| 702 * Instances of the class {@code ClassElementImpl} implement a {@code ClassEleme
nt}. |
| 703 */ |
| 704 class ClassElementImpl extends ElementImpl implements ClassElement { |
| 705 /** |
| 706 * An array containing all of the accessors (getters and setters) contained in
this class. |
| 707 */ |
| 708 List<PropertyAccessorElement> _accessors = PropertyAccessorElementImpl.EMPTY_A
RRAY; |
| 709 /** |
| 710 * An array containing all of the constructors contained in this class. |
| 711 */ |
| 712 List<ConstructorElement> _constructors = ConstructorElementImpl.EMPTY_ARRAY; |
| 713 /** |
| 714 * An array containing all of the fields contained in this class. |
| 715 */ |
| 716 List<FieldElement> _fields = FieldElementImpl.EMPTY_ARRAY; |
| 717 /** |
| 718 * An array containing all of the mixins that are applied to the class being e
xtended in order to |
| 719 * derive the superclass of this class. |
| 720 */ |
| 721 List<InterfaceType> _mixins = InterfaceTypeImpl.EMPTY_ARRAY; |
| 722 /** |
| 723 * An array containing all of the interfaces that are implemented by this clas
s. |
| 724 */ |
| 725 List<InterfaceType> _interfaces = InterfaceTypeImpl.EMPTY_ARRAY; |
| 726 /** |
| 727 * An array containing all of the methods contained in this class. |
| 728 */ |
| 729 List<MethodElement> _methods = MethodElementImpl.EMPTY_ARRAY; |
| 730 /** |
| 731 * The superclass of the class, or {@code null} if the class does not have an
explicit superclass. |
| 732 */ |
| 733 InterfaceType _supertype; |
| 734 /** |
| 735 * The type defined by the class. |
| 736 */ |
| 737 InterfaceType _type; |
| 738 /** |
| 739 * An array containing all of the type variables defined for this class. |
| 740 */ |
| 741 List<TypeVariableElement> _typeVariables = TypeVariableElementImpl.EMPTY_ARRAY
; |
| 742 /** |
| 743 * An empty array of type elements. |
| 744 */ |
| 745 static List<ClassElement> EMPTY_ARRAY = new List<ClassElement>.fixedLength(0); |
| 746 /** |
| 747 * Initialize a newly created class element to have the given name. |
| 748 * @param name the name of this element |
| 749 */ |
| 750 ClassElementImpl(Identifier name) : super.con1(name) { |
| 751 } |
| 752 List<PropertyAccessorElement> get accessors => _accessors; |
| 753 ElementImpl getChild(String identifier) { |
| 754 for (PropertyAccessorElement accessor in _accessors) { |
| 755 if ((accessor as PropertyAccessorElementImpl).identifier == identifier) { |
| 756 return accessor as PropertyAccessorElementImpl; |
| 757 } |
| 758 } |
| 759 for (ConstructorElement constructor in _constructors) { |
| 760 if ((constructor as ConstructorElementImpl).identifier == identifier) { |
| 761 return constructor as ConstructorElementImpl; |
| 762 } |
| 763 } |
| 764 for (FieldElement field in _fields) { |
| 765 if ((field as FieldElementImpl).identifier == identifier) { |
| 766 return field as FieldElementImpl; |
| 767 } |
| 768 } |
| 769 for (MethodElement method in _methods) { |
| 770 if ((method as MethodElementImpl).identifier == identifier) { |
| 771 return method as MethodElementImpl; |
| 772 } |
| 773 } |
| 774 for (TypeVariableElement typeVariable in _typeVariables) { |
| 775 if ((typeVariable as TypeVariableElementImpl).identifier == identifier) { |
| 776 return typeVariable as TypeVariableElementImpl; |
| 777 } |
| 778 } |
| 779 return null; |
| 780 } |
| 781 List<ConstructorElement> get constructors => _constructors; |
| 782 List<FieldElement> get fields => _fields; |
| 783 List<InterfaceType> get interfaces => _interfaces; |
| 784 ElementKind get kind => ElementKind.CLASS; |
| 785 List<MethodElement> get methods => _methods; |
| 786 List<InterfaceType> get mixins => _mixins; |
| 787 InterfaceType get supertype => _supertype; |
| 788 InterfaceType get type => _type; |
| 789 List<TypeVariableElement> get typeVariables => _typeVariables; |
| 790 bool isAbstract() => hasModifier(Modifier.ABSTRACT); |
| 791 /** |
| 792 * Set whether this class is abstract to correspond to the given value. |
| 793 * @param isAbstract {@code true} if the class is abstract |
| 794 */ |
| 795 void set abstract(bool isAbstract) { |
| 796 setModifier(Modifier.ABSTRACT, isAbstract); |
| 797 } |
| 798 /** |
| 799 * Set the accessors contained in this class to the given accessors. |
| 800 * @param accessors the accessors contained in this class |
| 801 */ |
| 802 void set accessors2(List<PropertyAccessorElement> accessors) { |
| 803 for (PropertyAccessorElement accessor in accessors) { |
| 804 (accessor as PropertyAccessorElementImpl).enclosingElement2 = this; |
| 805 } |
| 806 this._accessors = accessors; |
| 807 } |
| 808 /** |
| 809 * Set the constructors contained in this class to the given constructors. |
| 810 * @param constructors the constructors contained in this class |
| 811 */ |
| 812 void set constructors2(List<ConstructorElement> constructors) { |
| 813 for (ConstructorElement constructor in constructors) { |
| 814 (constructor as ConstructorElementImpl).enclosingElement2 = this; |
| 815 } |
| 816 this._constructors = constructors; |
| 817 } |
| 818 /** |
| 819 * Set the fields contained in this class to the given fields. |
| 820 * @param fields the fields contained in this class |
| 821 */ |
| 822 void set fields3(List<FieldElement> fields) { |
| 823 for (FieldElement field in fields) { |
| 824 (field as FieldElementImpl).enclosingElement2 = this; |
| 825 } |
| 826 this._fields = fields; |
| 827 } |
| 828 /** |
| 829 * Set the interfaces that are implemented by this class to the given types. |
| 830 * @param the interfaces that are implemented by this class |
| 831 */ |
| 832 void set interfaces2(List<InterfaceType> interfaces) { |
| 833 this._interfaces = interfaces; |
| 834 } |
| 835 /** |
| 836 * Set the methods contained in this class to the given methods. |
| 837 * @param methods the methods contained in this class |
| 838 */ |
| 839 void set methods2(List<MethodElement> methods) { |
| 840 for (MethodElement method in methods) { |
| 841 (method as MethodElementImpl).enclosingElement2 = this; |
| 842 } |
| 843 this._methods = methods; |
| 844 } |
| 845 /** |
| 846 * Set the mixins that are applied to the class being extended in order to der
ive the superclass |
| 847 * of this class to the given types. |
| 848 * @param mixins the mixins that are applied to derive the superclass of this
class |
| 849 */ |
| 850 void set mixins2(List<InterfaceType> mixins) { |
| 851 this._mixins = mixins; |
| 852 } |
| 853 /** |
| 854 * Set the superclass of the class to the given type. |
| 855 * @param supertype the superclass of the class |
| 856 */ |
| 857 void set supertype2(InterfaceType supertype) { |
| 858 this._supertype = supertype; |
| 859 } |
| 860 /** |
| 861 * Set the type defined by the class to the given type. |
| 862 * @param type the type defined by the class |
| 863 */ |
| 864 void set type9(InterfaceType type) { |
| 865 this._type = type; |
| 866 } |
| 867 /** |
| 868 * Set the type variables defined for this class to the given type variables. |
| 869 * @param typeVariables the type variables defined for this class |
| 870 */ |
| 871 void set typeVariables2(List<TypeVariableElement> typeVariables) { |
| 872 for (TypeVariableElement typeVariable in typeVariables) { |
| 873 (typeVariable as TypeVariableElementImpl).enclosingElement2 = this; |
| 874 } |
| 875 this._typeVariables = typeVariables; |
| 876 } |
| 877 String toString() { |
| 878 String name15 = name; |
| 879 return name15 == null ? "<unnamed class>" : "class ${name15}"; |
| 880 } |
| 881 } |
| 882 /** |
| 883 * Instances of the class {@code CompilationUnitElementImpl} implement a{@link C
ompilationUnitElement}. |
| 884 */ |
| 885 class CompilationUnitElementImpl extends ElementImpl implements CompilationUnitE
lement { |
| 886 /** |
| 887 * An array containing all of the top-level accessors (getters and setters) co
ntained in this |
| 888 * compilation unit. |
| 889 */ |
| 890 List<PropertyAccessorElement> _accessors = PropertyAccessorElementImpl.EMPTY_A
RRAY; |
| 891 /** |
| 892 * An array containing all of the fields contained in this compilation unit. |
| 893 */ |
| 894 List<FieldElement> _fields = FieldElementImpl.EMPTY_ARRAY; |
| 895 /** |
| 896 * An array containing all of the top-level functions contained in this compil
ation unit. |
| 897 */ |
| 898 List<FunctionElement> _functions = FunctionElementImpl.EMPTY_ARRAY; |
| 899 /** |
| 900 * The source that corresponds to this compilation unit. |
| 901 */ |
| 902 Source _source; |
| 903 /** |
| 904 * An array containing all of the type aliases contained in this compilation u
nit. |
| 905 */ |
| 906 List<TypeAliasElement> _typeAliases = TypeAliasElementImpl.EMPTY_ARRAY; |
| 907 /** |
| 908 * An array containing all of the types contained in this compilation unit. |
| 909 */ |
| 910 List<ClassElement> _types = ClassElementImpl.EMPTY_ARRAY; |
| 911 /** |
| 912 * An empty array of compilation unit elements. |
| 913 */ |
| 914 static List<CompilationUnitElement> EMPTY_ARRAY = new List<CompilationUnitElem
ent>.fixedLength(0); |
| 915 /** |
| 916 * Initialize a newly created compilation unit element to have the given name. |
| 917 * @param name the name of this element |
| 918 */ |
| 919 CompilationUnitElementImpl(String name) : super.con2(name, -1) { |
| 920 } |
| 921 bool operator ==(Object object) => this.runtimeType == object.runtimeType && _
source == (object as CompilationUnitElementImpl).source; |
| 922 List<PropertyAccessorElement> get accessors => _accessors; |
| 923 ElementImpl getChild(String identifier) { |
| 924 for (PropertyAccessorElement accessor in _accessors) { |
| 925 if ((accessor as PropertyAccessorElementImpl).identifier == identifier) { |
| 926 return accessor as PropertyAccessorElementImpl; |
| 927 } |
| 928 } |
| 929 for (FieldElement field in _fields) { |
| 930 if ((field as FieldElementImpl).identifier == identifier) { |
| 931 return field as FieldElementImpl; |
| 932 } |
| 933 } |
| 934 for (ExecutableElement function in _functions) { |
| 935 if ((function as ExecutableElementImpl).identifier == identifier) { |
| 936 return function as ExecutableElementImpl; |
| 937 } |
| 938 } |
| 939 for (TypeAliasElement typeAlias in _typeAliases) { |
| 940 if ((typeAlias as TypeAliasElementImpl).identifier == identifier) { |
| 941 return typeAlias as TypeAliasElementImpl; |
| 942 } |
| 943 } |
| 944 for (ClassElement type in _types) { |
| 945 if ((type as ClassElementImpl).identifier == identifier) { |
| 946 return type as ClassElementImpl; |
| 947 } |
| 948 } |
| 949 return null; |
| 950 } |
| 951 LibraryElement get enclosingElement => super.enclosingElement as LibraryElemen
t; |
| 952 List<FieldElement> get fields => _fields; |
| 953 List<FunctionElement> get functions => _functions; |
| 954 String get identifier => source.fullName; |
| 955 ElementKind get kind => ElementKind.COMPILATION_UNIT; |
| 956 Source get source => _source; |
| 957 List<TypeAliasElement> get typeAliases => _typeAliases; |
| 958 List<ClassElement> get types => _types; |
| 959 int get hashCode => _source.hashCode; |
| 960 /** |
| 961 * Set the top-level accessors (getters and setters) contained in this compila
tion unit to the |
| 962 * given accessors. |
| 963 * @param the top-level accessors (getters and setters) contained in this comp
ilation unit |
| 964 */ |
| 965 void set accessors3(List<PropertyAccessorElement> accessors) { |
| 966 for (PropertyAccessorElement accessor in accessors) { |
| 967 (accessor as PropertyAccessorElementImpl).enclosingElement2 = this; |
| 968 } |
| 969 this._accessors = accessors; |
| 970 } |
| 971 /** |
| 972 * Set the fields contained in this compilation unit to the given fields. |
| 973 * @param fields the fields contained in this compilation unit |
| 974 */ |
| 975 void set fields4(List<FieldElement> fields) { |
| 976 for (FieldElement field in fields) { |
| 977 (field as FieldElementImpl).enclosingElement2 = this; |
| 978 } |
| 979 this._fields = fields; |
| 980 } |
| 981 /** |
| 982 * Set the top-level functions contained in this compilation unit to the given
functions. |
| 983 * @param functions the top-level functions contained in this compilation unit |
| 984 */ |
| 985 void set functions2(List<FunctionElement> functions) { |
| 986 for (FunctionElement function in functions) { |
| 987 (function as FunctionElementImpl).enclosingElement2 = this; |
| 988 } |
| 989 this._functions = functions; |
| 990 } |
| 991 /** |
| 992 * Set the source that corresponds to this compilation unit to the given sourc
e. |
| 993 * @param source the source that corresponds to this compilation unit |
| 994 */ |
| 995 void set source3(Source source) { |
| 996 this._source = source; |
| 997 } |
| 998 /** |
| 999 * Set the type aliases contained in this compilation unit to the given type a
liases. |
| 1000 * @param typeAliases the type aliases contained in this compilation unit |
| 1001 */ |
| 1002 void set typeAliases2(List<TypeAliasElement> typeAliases) { |
| 1003 for (TypeAliasElement typeAlias in typeAliases) { |
| 1004 (typeAlias as TypeAliasElementImpl).enclosingElement2 = this; |
| 1005 } |
| 1006 this._typeAliases = typeAliases; |
| 1007 } |
| 1008 /** |
| 1009 * Set the types contained in this compilation unit to the given types. |
| 1010 * @param types types contained in this compilation unit |
| 1011 */ |
| 1012 void set types2(List<ClassElement> types) { |
| 1013 for (ClassElement type in types) { |
| 1014 (type as ClassElementImpl).enclosingElement2 = this; |
| 1015 } |
| 1016 this._types = types; |
| 1017 } |
| 1018 } |
| 1019 /** |
| 1020 * Instances of the class {@code ConstructorElementImpl} implement a {@code Cons
tructorElement}. |
| 1021 */ |
| 1022 class ConstructorElementImpl extends ExecutableElementImpl implements Constructo
rElement { |
| 1023 /** |
| 1024 * An empty array of constructor elements. |
| 1025 */ |
| 1026 static List<ConstructorElement> EMPTY_ARRAY = new List<ConstructorElement>.fix
edLength(0); |
| 1027 /** |
| 1028 * Initialize a newly created constructor element to have the given name. |
| 1029 * @param name the name of this element |
| 1030 */ |
| 1031 ConstructorElementImpl(Identifier name) : super.con1(name) { |
| 1032 } |
| 1033 ClassElement get enclosingElement => super.enclosingElement as ClassElement; |
| 1034 ElementKind get kind => ElementKind.CONSTRUCTOR; |
| 1035 bool isConst() => hasModifier(Modifier.CONST); |
| 1036 bool isFactory() => hasModifier(Modifier.FACTORY); |
| 1037 /** |
| 1038 * Set whether this constructor represents a factory method to the given value
. |
| 1039 * @param isFactory {@code true} if this constructor represents a factory meth
od |
| 1040 */ |
| 1041 void set factory(bool isFactory) { |
| 1042 setModifier(Modifier.FACTORY, isFactory); |
| 1043 } |
| 1044 } |
| 1045 /** |
| 1046 * Instances of the class {@code DynamicElementImpl} represent the synthetic ele
ment representing |
| 1047 * the declaration of the type {@code dynamic}. |
| 1048 */ |
| 1049 class DynamicElementImpl extends ElementImpl { |
| 1050 /** |
| 1051 * The type defined by this element. |
| 1052 */ |
| 1053 DynamicTypeImpl _type; |
| 1054 /** |
| 1055 * Initialize a newly created instance of this class. Instances of this class
should <b>not</b> be |
| 1056 * created except as part of creating the type associated with this element. T
he single instance |
| 1057 * of this class should be accessed through the single instance of the class{@
link DynamicTypeImpl}. |
| 1058 */ |
| 1059 DynamicElementImpl() : super.con2(Keyword.DYNAMIC.syntax, -1) { |
| 1060 setModifier(Modifier.SYNTHETIC, true); |
| 1061 } |
| 1062 ElementKind get kind => ElementKind.DYNAMIC; |
| 1063 /** |
| 1064 * Return the type defined by this element. |
| 1065 * @return the type defined by this element |
| 1066 */ |
| 1067 DynamicTypeImpl get type => _type; |
| 1068 /** |
| 1069 * Set the type defined by this element to the given type. |
| 1070 * @param type the type defined by this element |
| 1071 */ |
| 1072 void set type10(DynamicTypeImpl type) { |
| 1073 this._type = type; |
| 1074 } |
| 1075 } |
| 1076 /** |
| 1077 * The abstract class {@code ElementImpl} implements the behavior common to obje
cts that implement |
| 1078 * an {@link Element}. |
| 1079 */ |
| 1080 abstract class ElementImpl implements Element { |
| 1081 /** |
| 1082 * The enclosing element of this element, or {@code null} if this element is a
t the root of the |
| 1083 * element structure. |
| 1084 */ |
| 1085 ElementImpl _enclosingElement; |
| 1086 /** |
| 1087 * The name of this element. |
| 1088 */ |
| 1089 String _name; |
| 1090 /** |
| 1091 * The offset of the name of this element in the file that contains the declar
ation of this |
| 1092 * element. |
| 1093 */ |
| 1094 int _nameOffset = 0; |
| 1095 /** |
| 1096 * A bit-encoded form of the modifiers associated with this element. |
| 1097 */ |
| 1098 Set<Modifier> _modifiers; |
| 1099 /** |
| 1100 * An array containing all of the metadata associated with this element. |
| 1101 */ |
| 1102 List<Annotation> _metadata = AnnotationImpl.EMPTY_ARRAY; |
| 1103 /** |
| 1104 * Initialize a newly created element to have the given name. |
| 1105 * @param name the name of this element |
| 1106 */ |
| 1107 ElementImpl.con1(Identifier name) { |
| 1108 _jtd_constructor_129_impl(name); |
| 1109 } |
| 1110 _jtd_constructor_129_impl(Identifier name) { |
| 1111 _jtd_constructor_130_impl(name == null ? "" : name.name, name == null ? -1 :
name.offset); |
| 1112 } |
| 1113 /** |
| 1114 * Initialize a newly created element to have the given name. |
| 1115 * @param name the name of this element |
| 1116 * @param nameOffset the offset of the name of this element in the file that c
ontains the |
| 1117 * declaration of this element |
| 1118 */ |
| 1119 ElementImpl.con2(String name, int nameOffset) { |
| 1120 _jtd_constructor_130_impl(name, nameOffset); |
| 1121 } |
| 1122 _jtd_constructor_130_impl(String name, int nameOffset) { |
| 1123 this._name = name; |
| 1124 this._nameOffset = nameOffset; |
| 1125 this._modifiers = new Set(); |
| 1126 } |
| 1127 bool operator ==(Object object) => object is Element && (object as Element).lo
cation == location; |
| 1128 Element getAncestor(Type elementClass) { |
| 1129 Element ancestor = _enclosingElement; |
| 1130 while (ancestor != null && !isInstanceOf(ancestor, elementClass)) { |
| 1131 ancestor = ancestor.enclosingElement; |
| 1132 } |
| 1133 return ancestor as Element; |
| 1134 } |
| 1135 /** |
| 1136 * Return the child of this element that is uniquely identified by the given i
dentifier, or{@code null} if there is no such child. |
| 1137 * @param identifier the identifier used to select a child |
| 1138 * @return the child of this element with the given identifier |
| 1139 */ |
| 1140 ElementImpl getChild(String identifier) => null; |
| 1141 AnalysisContext get context { |
| 1142 if (_enclosingElement == null) { |
| 1143 return null; |
| 1144 } |
| 1145 return _enclosingElement.context; |
| 1146 } |
| 1147 Element get enclosingElement => _enclosingElement; |
| 1148 LibraryElement get library => getAncestor(LibraryElement); |
| 1149 ElementLocation get location => new ElementLocationImpl.con1(this); |
| 1150 List<Annotation> get metadata => _metadata; |
| 1151 String get name => _name; |
| 1152 int get nameOffset => _nameOffset; |
| 1153 int get hashCode => location.hashCode; |
| 1154 bool isSynthetic() => hasModifier(Modifier.SYNTHETIC); |
| 1155 /** |
| 1156 * Set the metadata associate with this element to the given array of annotati
ons. |
| 1157 * @param metadata the metadata to be associated with this element |
| 1158 */ |
| 1159 void set metadata2(List<Annotation> metadata) { |
| 1160 this._metadata = metadata; |
| 1161 } |
| 1162 /** |
| 1163 * Set whether this element is synthetic to correspond to the given value. |
| 1164 * @param isSynthetic {@code true} if the element is synthetic |
| 1165 */ |
| 1166 void set synthetic(bool isSynthetic) { |
| 1167 setModifier(Modifier.SYNTHETIC, isSynthetic); |
| 1168 } |
| 1169 /** |
| 1170 * Return an identifier that uniquely identifies this element among the childr
en of this element's |
| 1171 * parent. |
| 1172 * @return an identifier that uniquely identifies this element relative to its
parent |
| 1173 */ |
| 1174 String get identifier => name; |
| 1175 /** |
| 1176 * Return {@code true} if this element has the given modifier associated with
it. |
| 1177 * @param modifier the modifier being tested for |
| 1178 * @return {@code true} if this element has the given modifier associated with
it |
| 1179 */ |
| 1180 bool hasModifier(Modifier modifier) => _modifiers.contains(modifier); |
| 1181 /** |
| 1182 * Set the enclosing element of this element to the given element. |
| 1183 * @param element the enclosing element of this element |
| 1184 */ |
| 1185 void set enclosingElement2(ElementImpl element) { |
| 1186 _enclosingElement = element; |
| 1187 } |
| 1188 /** |
| 1189 * Set whether the given modifier is associated with this element to correspon
d to the given |
| 1190 * value. |
| 1191 * @param modifier the modifier to be set |
| 1192 * @param value {@code true} if the modifier is to be associated with this ele
ment |
| 1193 */ |
| 1194 void setModifier(Modifier modifier, bool value) { |
| 1195 if (value) { |
| 1196 _modifiers.add(modifier); |
| 1197 } else { |
| 1198 _modifiers.remove(modifier); |
| 1199 } |
| 1200 } |
| 1201 } |
| 1202 /** |
| 1203 * Instances of the class {@code ElementLocationImpl} implement an {@link Elemen
tLocation}. |
| 1204 */ |
| 1205 class ElementLocationImpl implements ElementLocation { |
| 1206 /** |
| 1207 * The path to the element whose location is represented by this object. |
| 1208 */ |
| 1209 List<String> _components; |
| 1210 /** |
| 1211 * The character used to separate components in the encoded form. |
| 1212 */ |
| 1213 static int _SEPARATOR_CHAR = 0x3b; |
| 1214 /** |
| 1215 * Initialize a newly created location to represent the given element. |
| 1216 * @param element the element whose location is being represented |
| 1217 */ |
| 1218 ElementLocationImpl.con1(Element element) { |
| 1219 _jtd_constructor_131_impl(element); |
| 1220 } |
| 1221 _jtd_constructor_131_impl(Element element) { |
| 1222 List<String> components = new List<String>(); |
| 1223 Element ancestor = element; |
| 1224 while (ancestor != null) { |
| 1225 components.insertRange(0, 1, (ancestor as ElementImpl).identifier); |
| 1226 ancestor = ancestor.enclosingElement; |
| 1227 } |
| 1228 this._components = new List.from(components); |
| 1229 } |
| 1230 /** |
| 1231 * Initialize a newly created location from the given encoded form. |
| 1232 * @param encoding the encoded form of a location |
| 1233 */ |
| 1234 ElementLocationImpl.con2(String encoding) { |
| 1235 _jtd_constructor_132_impl(encoding); |
| 1236 } |
| 1237 _jtd_constructor_132_impl(String encoding) { |
| 1238 this._components = decode(encoding); |
| 1239 } |
| 1240 bool operator ==(Object object) { |
| 1241 if (object is! ElementLocationImpl) { |
| 1242 return false; |
| 1243 } |
| 1244 ElementLocationImpl location = object as ElementLocationImpl; |
| 1245 return JavaArrays.equals(_components, location._components); |
| 1246 } |
| 1247 /** |
| 1248 * Return the path to the element whose location is represented by this object
. |
| 1249 * @return the path to the element whose location is represented by this objec
t |
| 1250 */ |
| 1251 List<String> get components => _components; |
| 1252 String get encoding { |
| 1253 StringBuffer builder = new StringBuffer(); |
| 1254 int length2 = _components.length; |
| 1255 for (int i = 0; i < length2; i++) { |
| 1256 if (i > 0) { |
| 1257 builder.addCharCode(ElementLocationImpl._SEPARATOR_CHAR); |
| 1258 } |
| 1259 encode(builder, _components[i]); |
| 1260 } |
| 1261 return builder.toString(); |
| 1262 } |
| 1263 int get hashCode => JavaArrays.makeHashCode(_components); |
| 1264 /** |
| 1265 * Decode the encoded form of a location into an array of components. |
| 1266 * @param encoding the encoded form of a location |
| 1267 * @return the components that were encoded |
| 1268 */ |
| 1269 List<String> decode(String encoding) { |
| 1270 List<String> components = new List<String>(); |
| 1271 StringBuffer builder = new StringBuffer(); |
| 1272 int index = 0; |
| 1273 int length3 = encoding.length; |
| 1274 while (index < length3) { |
| 1275 int currentChar = encoding.charCodeAt(index); |
| 1276 if (currentChar == ElementLocationImpl._SEPARATOR_CHAR) { |
| 1277 if (index + 1 < length3 && encoding.charCodeAt(index + 1) == ElementLoca
tionImpl._SEPARATOR_CHAR) { |
| 1278 builder.addCharCode(ElementLocationImpl._SEPARATOR_CHAR); |
| 1279 index += 2; |
| 1280 } else { |
| 1281 components.add(builder.toString()); |
| 1282 builder.clear(); |
| 1283 index++; |
| 1284 } |
| 1285 } else { |
| 1286 builder.addCharCode(currentChar); |
| 1287 index++; |
| 1288 } |
| 1289 } |
| 1290 if (builder.length > 0) { |
| 1291 components.add(builder.toString()); |
| 1292 } |
| 1293 return new List.from(components); |
| 1294 } |
| 1295 /** |
| 1296 * Append an encoded form of the given component to the given builder. |
| 1297 * @param builder the builder to which the encoded component is to be appended |
| 1298 * @param component the component to be appended to the builder |
| 1299 */ |
| 1300 void encode(StringBuffer builder, String component) { |
| 1301 int length4 = component.length; |
| 1302 for (int i = 0; i < length4; i++) { |
| 1303 int currentChar = component.charCodeAt(i); |
| 1304 if (currentChar == ElementLocationImpl._SEPARATOR_CHAR) { |
| 1305 builder.addCharCode(ElementLocationImpl._SEPARATOR_CHAR); |
| 1306 } |
| 1307 builder.addCharCode(currentChar); |
| 1308 } |
| 1309 } |
| 1310 } |
| 1311 /** |
| 1312 * The abstract class {@code ExecutableElementImpl} implements the behavior comm
on to{@code ExecutableElement}s. |
| 1313 */ |
| 1314 abstract class ExecutableElementImpl extends ElementImpl implements ExecutableEl
ement { |
| 1315 /** |
| 1316 * An array containing all of the functions defined within this executable ele
ment. |
| 1317 */ |
| 1318 List<ExecutableElement> _functions = EMPTY_ARRAY; |
| 1319 /** |
| 1320 * An array containing all of the labels defined within this executable elemen
t. |
| 1321 */ |
| 1322 List<LabelElement> _labels = LabelElementImpl.EMPTY_ARRAY; |
| 1323 /** |
| 1324 * An array containing all of the local variables defined within this executab
le element. |
| 1325 */ |
| 1326 List<VariableElement> _localVariables = VariableElementImpl.EMPTY_ARRAY; |
| 1327 /** |
| 1328 * An array containing all of the parameters defined by this executable elemen
t. |
| 1329 */ |
| 1330 List<ParameterElement> _parameters = ParameterElementImpl.EMPTY_ARRAY; |
| 1331 /** |
| 1332 * The type of function defined by this executable element. |
| 1333 */ |
| 1334 FunctionType _type; |
| 1335 /** |
| 1336 * An empty array of executable elements. |
| 1337 */ |
| 1338 static List<ExecutableElement> EMPTY_ARRAY = new List<ExecutableElement>.fixed
Length(0); |
| 1339 /** |
| 1340 * Initialize a newly created executable element to have the given name. |
| 1341 * @param name the name of this element |
| 1342 */ |
| 1343 ExecutableElementImpl.con1(Identifier name) : super.con1(name) { |
| 1344 _jtd_constructor_133_impl(name); |
| 1345 } |
| 1346 _jtd_constructor_133_impl(Identifier name) { |
| 1347 } |
| 1348 /** |
| 1349 * Initialize a newly created executable element to have the given name. |
| 1350 * @param name the name of this element |
| 1351 * @param nameOffset the offset of the name of this element in the file that c
ontains the |
| 1352 * declaration of this element |
| 1353 */ |
| 1354 ExecutableElementImpl.con2(String name, int nameOffset) : super.con2(name, nam
eOffset) { |
| 1355 _jtd_constructor_134_impl(name, nameOffset); |
| 1356 } |
| 1357 _jtd_constructor_134_impl(String name, int nameOffset) { |
| 1358 } |
| 1359 ElementImpl getChild(String identifier) { |
| 1360 for (ExecutableElement function in _functions) { |
| 1361 if ((function as ExecutableElementImpl).identifier == identifier) { |
| 1362 return function as ExecutableElementImpl; |
| 1363 } |
| 1364 } |
| 1365 for (LabelElement label in _labels) { |
| 1366 if ((label as LabelElementImpl).identifier == identifier) { |
| 1367 return label as LabelElementImpl; |
| 1368 } |
| 1369 } |
| 1370 for (VariableElement variable in _localVariables) { |
| 1371 if ((variable as VariableElementImpl).identifier == identifier) { |
| 1372 return variable as VariableElementImpl; |
| 1373 } |
| 1374 } |
| 1375 for (ParameterElement parameter in _parameters) { |
| 1376 if ((parameter as ParameterElementImpl).identifier == identifier) { |
| 1377 return parameter as ParameterElementImpl; |
| 1378 } |
| 1379 } |
| 1380 return null; |
| 1381 } |
| 1382 List<ExecutableElement> get functions => _functions; |
| 1383 List<LabelElement> get labels => _labels; |
| 1384 List<VariableElement> get localVariables => _localVariables; |
| 1385 List<ParameterElement> get parameters => _parameters; |
| 1386 FunctionType get type => _type; |
| 1387 /** |
| 1388 * Set the functions defined within this executable element to the given funct
ions. |
| 1389 * @param functions the functions defined within this executable element |
| 1390 */ |
| 1391 void set functions3(List<ExecutableElement> functions) { |
| 1392 for (ExecutableElement function in functions) { |
| 1393 (function as ExecutableElementImpl).enclosingElement2 = this; |
| 1394 } |
| 1395 this._functions = functions; |
| 1396 } |
| 1397 /** |
| 1398 * Set the labels defined within this executable element to the given labels. |
| 1399 * @param labels the labels defined within this executable element |
| 1400 */ |
| 1401 void set labels2(List<LabelElement> labels) { |
| 1402 for (LabelElement label in labels) { |
| 1403 (label as LabelElementImpl).enclosingElement2 = this; |
| 1404 } |
| 1405 this._labels = labels; |
| 1406 } |
| 1407 /** |
| 1408 * Set the local variables defined within this executable element to the given
variables. |
| 1409 * @param localVariables the local variables defined within this executable el
ement |
| 1410 */ |
| 1411 void set localVariables2(List<VariableElement> localVariables) { |
| 1412 for (VariableElement variable in localVariables) { |
| 1413 (variable as VariableElementImpl).enclosingElement2 = this; |
| 1414 } |
| 1415 this._localVariables = localVariables; |
| 1416 } |
| 1417 /** |
| 1418 * Set the parameters defined by this executable element to the given paramete
rs. |
| 1419 * @param parameters the parameters defined by this executable element |
| 1420 */ |
| 1421 void set parameters7(List<ParameterElement> parameters) { |
| 1422 for (ParameterElement parameter in parameters) { |
| 1423 (parameter as ParameterElementImpl).enclosingElement2 = this; |
| 1424 } |
| 1425 this._parameters = parameters; |
| 1426 } |
| 1427 /** |
| 1428 * Set the type of function defined by this executable element to the given ty
pe. |
| 1429 * @param type the type of function defined by this executable element |
| 1430 */ |
| 1431 void set type11(FunctionType type) { |
| 1432 this._type = type; |
| 1433 } |
| 1434 } |
| 1435 /** |
| 1436 * Instances of the class {@code ExportElementImpl} implement an {@link ExportEl
ement}. |
| 1437 */ |
| 1438 class ExportElementImpl extends ElementImpl implements ExportElement { |
| 1439 /** |
| 1440 * The library that is exported from this library by this export directive. |
| 1441 */ |
| 1442 LibraryElement _exportedLibrary; |
| 1443 /** |
| 1444 * The combinators that were specified as part of the export directive in the
order in which they |
| 1445 * were specified. |
| 1446 */ |
| 1447 List<NamespaceCombinator> _combinators = NamespaceCombinator.EMPTY_ARRAY; |
| 1448 /** |
| 1449 * Initialize a newly created export element. |
| 1450 */ |
| 1451 ExportElementImpl() : super.con1(null) { |
| 1452 } |
| 1453 List<NamespaceCombinator> get combinators => _combinators; |
| 1454 LibraryElement get exportedLibrary => _exportedLibrary; |
| 1455 ElementKind get kind => ElementKind.EXPORT; |
| 1456 /** |
| 1457 * Set the combinators that were specified as part of the export directive to
the given array of |
| 1458 * combinators. |
| 1459 * @param combinators the combinators that were specified as part of the expor
t directive |
| 1460 */ |
| 1461 void set combinators2(List<NamespaceCombinator> combinators) { |
| 1462 this._combinators = combinators; |
| 1463 } |
| 1464 /** |
| 1465 * Set the library that is exported from this library by this import directive
to the given |
| 1466 * library. |
| 1467 * @param exportedLibrary the library that is exported from this library |
| 1468 */ |
| 1469 void set exportedLibrary2(LibraryElement exportedLibrary) { |
| 1470 this._exportedLibrary = exportedLibrary; |
| 1471 } |
| 1472 } |
| 1473 /** |
| 1474 * Instances of the class {@code FieldElementImpl} implement a {@code FieldEleme
nt}. |
| 1475 */ |
| 1476 class FieldElementImpl extends VariableElementImpl implements FieldElement { |
| 1477 /** |
| 1478 * The getter associated with this field. |
| 1479 */ |
| 1480 PropertyAccessorElement _getter; |
| 1481 /** |
| 1482 * The setter associated with this field, or {@code null} if the field is effe
ctively{@code final} and therefore does not have a setter associated with it. |
| 1483 */ |
| 1484 PropertyAccessorElement _setter; |
| 1485 /** |
| 1486 * An empty array of field elements. |
| 1487 */ |
| 1488 static List<FieldElement> EMPTY_ARRAY = new List<FieldElement>.fixedLength(0); |
| 1489 /** |
| 1490 * Initialize a newly created field element to have the given name. |
| 1491 * @param name the name of this element |
| 1492 */ |
| 1493 FieldElementImpl.con1(Identifier name) : super.con1(name) { |
| 1494 _jtd_constructor_136_impl(name); |
| 1495 } |
| 1496 _jtd_constructor_136_impl(Identifier name) { |
| 1497 } |
| 1498 /** |
| 1499 * Initialize a newly created synthetic field element to have the given name. |
| 1500 * @param name the name of this element |
| 1501 */ |
| 1502 FieldElementImpl.con2(String name) : super.con2(name, -1) { |
| 1503 _jtd_constructor_137_impl(name); |
| 1504 } |
| 1505 _jtd_constructor_137_impl(String name) { |
| 1506 synthetic = true; |
| 1507 } |
| 1508 PropertyAccessorElement get getter => _getter; |
| 1509 ElementKind get kind => ElementKind.FIELD; |
| 1510 PropertyAccessorElement get setter => _setter; |
| 1511 bool isStatic() => hasModifier(Modifier.STATIC); |
| 1512 /** |
| 1513 * Set the getter associated with this field to the given accessor. |
| 1514 * @param getter the getter associated with this field |
| 1515 */ |
| 1516 void set getter2(PropertyAccessorElement getter) { |
| 1517 this._getter = getter; |
| 1518 } |
| 1519 /** |
| 1520 * Set the setter associated with this field to the given accessor. |
| 1521 * @param setter the setter associated with this field |
| 1522 */ |
| 1523 void set setter2(PropertyAccessorElement setter) { |
| 1524 this._setter = setter; |
| 1525 } |
| 1526 /** |
| 1527 * Set whether this field is static to correspond to the given value. |
| 1528 * @param isStatic {@code true} if the field is static |
| 1529 */ |
| 1530 void set static(bool isStatic) { |
| 1531 setModifier(Modifier.STATIC, isStatic); |
| 1532 } |
| 1533 String toString() => "field ${type} ${name}"; |
| 1534 } |
| 1535 /** |
| 1536 * Instances of the class {@code FunctionElementImpl} implement a {@code Functio
nElement}. |
| 1537 */ |
| 1538 class FunctionElementImpl extends ExecutableElementImpl implements FunctionEleme
nt { |
| 1539 /** |
| 1540 * An empty array of function elements. |
| 1541 */ |
| 1542 static List<FunctionElement> EMPTY_ARRAY = new List<FunctionElement>.fixedLeng
th(0); |
| 1543 /** |
| 1544 * Initialize a newly created synthetic function element. |
| 1545 */ |
| 1546 FunctionElementImpl() : super.con2("", -1) { |
| 1547 _jtd_constructor_138_impl(); |
| 1548 } |
| 1549 _jtd_constructor_138_impl() { |
| 1550 synthetic = true; |
| 1551 } |
| 1552 /** |
| 1553 * Initialize a newly created function element to have the given name. |
| 1554 * @param name the name of this element |
| 1555 */ |
| 1556 FunctionElementImpl.con1(Identifier name) : super.con1(name) { |
| 1557 _jtd_constructor_139_impl(name); |
| 1558 } |
| 1559 _jtd_constructor_139_impl(Identifier name) { |
| 1560 } |
| 1561 String get identifier => name; |
| 1562 ElementKind get kind => ElementKind.FUNCTION; |
| 1563 } |
| 1564 /** |
| 1565 * Instances of the class {@code ShowCombinatorImpl} implement a {@link ShowComb
inator}. |
| 1566 */ |
| 1567 class HideCombinatorImpl implements HideCombinator { |
| 1568 /** |
| 1569 * The names that are not to be made visible in the importing library even if
they are defined in |
| 1570 * the imported library. |
| 1571 */ |
| 1572 List<String> _hiddenNames = StringUtilities.EMPTY_ARRAY; |
| 1573 /** |
| 1574 * Initialize a newly created combinator. |
| 1575 */ |
| 1576 HideCombinatorImpl() : super() { |
| 1577 } |
| 1578 List<String> get hiddenNames => _hiddenNames; |
| 1579 /** |
| 1580 * Set the names that are not to be made visible in the importing library even
if they are defined |
| 1581 * in the imported library to the given names. |
| 1582 * @param hiddenNames the names that are not to be made visible in the importi
ng library |
| 1583 */ |
| 1584 void set hiddenNames2(List<String> hiddenNames) { |
| 1585 this._hiddenNames = hiddenNames; |
| 1586 } |
| 1587 } |
| 1588 /** |
| 1589 * Instances of the class {@code HtmlElementImpl} implement an {@link HtmlElemen
t}. |
| 1590 */ |
| 1591 class HtmlElementImpl extends ElementImpl implements HtmlElement { |
| 1592 /** |
| 1593 * An empty array of HTML file elements. |
| 1594 */ |
| 1595 static List<HtmlElement> EMPTY_ARRAY = new List<HtmlElement>.fixedLength(0); |
| 1596 /** |
| 1597 * The analysis context in which this library is defined. |
| 1598 */ |
| 1599 AnalysisContext _context; |
| 1600 /** |
| 1601 * The libraries contained in or referenced from script tags in the HTML file. |
| 1602 */ |
| 1603 List<LibraryElement> _libraries = LibraryElementImpl.EMPTY_ARRAY; |
| 1604 /** |
| 1605 * The source that corresponds to this HTML file. |
| 1606 */ |
| 1607 Source _source; |
| 1608 /** |
| 1609 * Initialize a newly created HTML element to have the given name. |
| 1610 * @param context the analysis context in which the HTML file is defined |
| 1611 * @param name the name of this element |
| 1612 */ |
| 1613 HtmlElementImpl(AnalysisContext context, String name) : super.con2(name, -1) { |
| 1614 this._context = context; |
| 1615 } |
| 1616 bool operator ==(Object object) => this.runtimeType == object.runtimeType && _
source == (object as CompilationUnitElementImpl).source; |
| 1617 AnalysisContext get context => _context; |
| 1618 ElementKind get kind => ElementKind.HTML; |
| 1619 List<LibraryElement> get libraries => _libraries; |
| 1620 Source get source => _source; |
| 1621 int get hashCode => _source.hashCode; |
| 1622 /** |
| 1623 * Set the libraries contained in or referenced from script tags in the HTML f
ile to the given |
| 1624 * libraries. |
| 1625 * @param libraries the libraries contained in or referenced from script tags
in the HTML file |
| 1626 */ |
| 1627 void set libraries2(List<LibraryElement> libraries) { |
| 1628 this._libraries = libraries; |
| 1629 } |
| 1630 /** |
| 1631 * Set the source that corresponds to this HTML file to the given source. |
| 1632 * @param source the source that corresponds to this HTML file |
| 1633 */ |
| 1634 void set source4(Source source) { |
| 1635 this._source = source; |
| 1636 } |
| 1637 } |
| 1638 /** |
| 1639 * Instances of the class {@code ImportElementImpl} implement an {@link ImportEl
ement}. |
| 1640 */ |
| 1641 class ImportElementImpl extends ElementImpl implements ImportElement { |
| 1642 /** |
| 1643 * The library that is imported into this library by this import directive. |
| 1644 */ |
| 1645 LibraryElement _importedLibrary; |
| 1646 /** |
| 1647 * The combinators that were specified as part of the import directive in the
order in which they |
| 1648 * were specified. |
| 1649 */ |
| 1650 List<NamespaceCombinator> _combinators = NamespaceCombinator.EMPTY_ARRAY; |
| 1651 /** |
| 1652 * The prefix that was specified as part of the import directive, or {@code nu
ll} if there was no |
| 1653 * prefix specified. |
| 1654 */ |
| 1655 PrefixElement _prefix; |
| 1656 /** |
| 1657 * Initialize a newly created import element. |
| 1658 */ |
| 1659 ImportElementImpl() : super.con1(null) { |
| 1660 } |
| 1661 List<NamespaceCombinator> get combinators => _combinators; |
| 1662 LibraryElement get importedLibrary => _importedLibrary; |
| 1663 ElementKind get kind => ElementKind.IMPORT; |
| 1664 PrefixElement get prefix => _prefix; |
| 1665 /** |
| 1666 * Set the combinators that were specified as part of the import directive to
the given array of |
| 1667 * combinators. |
| 1668 * @param combinators the combinators that were specified as part of the impor
t directive |
| 1669 */ |
| 1670 void set combinators3(List<NamespaceCombinator> combinators) { |
| 1671 this._combinators = combinators; |
| 1672 } |
| 1673 /** |
| 1674 * Set the library that is imported into this library by this import directive
to the given |
| 1675 * library. |
| 1676 * @param importedLibrary the library that is imported into this library |
| 1677 */ |
| 1678 void set importedLibrary2(LibraryElement importedLibrary) { |
| 1679 this._importedLibrary = importedLibrary; |
| 1680 } |
| 1681 /** |
| 1682 * Set the prefix that was specified as part of the import directive to the gi
ven prefix. |
| 1683 * @param prefix the prefix that was specified as part of the import directive |
| 1684 */ |
| 1685 void set prefix4(PrefixElement prefix) { |
| 1686 this._prefix = prefix; |
| 1687 } |
| 1688 } |
| 1689 /** |
| 1690 * Instances of the class {@code LabelElementImpl} implement a {@code LabelEleme
nt}. |
| 1691 */ |
| 1692 class LabelElementImpl extends ElementImpl implements LabelElement { |
| 1693 /** |
| 1694 * A flag indicating whether this label is associated with a {@code switch} st
atement. |
| 1695 */ |
| 1696 bool _onSwitchStatement = false; |
| 1697 /** |
| 1698 * A flag indicating whether this label is associated with a {@code switch} me
mber ({@code case}or {@code default}). |
| 1699 */ |
| 1700 bool _onSwitchMember = false; |
| 1701 /** |
| 1702 * An empty array of label elements. |
| 1703 */ |
| 1704 static List<LabelElement> EMPTY_ARRAY = new List<LabelElement>.fixedLength(0); |
| 1705 /** |
| 1706 * Initialize a newly created label element to have the given name. |
| 1707 * @param name the name of this element |
| 1708 * @param onSwitchStatement {@code true} if this label is associated with a {@
code switch}statement |
| 1709 * @param onSwitchMember {@code true} if this label is associated with a {@cod
e switch} member |
| 1710 */ |
| 1711 LabelElementImpl(Identifier name, bool onSwitchStatement, bool onSwitchMember)
: super.con1(name) { |
| 1712 this._onSwitchStatement = onSwitchStatement; |
| 1713 this._onSwitchMember = onSwitchMember; |
| 1714 } |
| 1715 ExecutableElement get enclosingElement => super.enclosingElement as Executable
Element; |
| 1716 ElementKind get kind => ElementKind.LABEL; |
| 1717 /** |
| 1718 * Return {@code true} if this label is associated with a {@code switch} membe
r ({@code case} or{@code default}). |
| 1719 * @return {@code true} if this label is associated with a {@code switch} memb
er |
| 1720 */ |
| 1721 bool isOnSwitchMember() => _onSwitchMember; |
| 1722 /** |
| 1723 * Return {@code true} if this label is associated with a {@code switch} state
ment. |
| 1724 * @return {@code true} if this label is associated with a {@code switch} stat
ement |
| 1725 */ |
| 1726 bool isOnSwitchStatement() => _onSwitchStatement; |
| 1727 } |
| 1728 /** |
| 1729 * Instances of the class {@code LibraryElementImpl} implement a {@code LibraryE
lement}. |
| 1730 */ |
| 1731 class LibraryElementImpl extends ElementImpl implements LibraryElement { |
| 1732 /** |
| 1733 * An empty array of library elements. |
| 1734 */ |
| 1735 static List<LibraryElement> EMPTY_ARRAY = new List<LibraryElement>.fixedLength
(0); |
| 1736 /** |
| 1737 * The analysis context in which this library is defined. |
| 1738 */ |
| 1739 AnalysisContext _context; |
| 1740 /** |
| 1741 * The compilation unit that defines this library. |
| 1742 */ |
| 1743 CompilationUnitElement _definingCompilationUnit; |
| 1744 /** |
| 1745 * The entry point for this library, or {@code null} if this library does not
have an entry point. |
| 1746 */ |
| 1747 FunctionElement _entryPoint; |
| 1748 /** |
| 1749 * An array containing specifications of all of the imports defined in this li
brary. |
| 1750 */ |
| 1751 List<ImportElement> _imports = ImportElement.EMPTY_ARRAY; |
| 1752 /** |
| 1753 * An array containing specifications of all of the exports defined in this li
brary. |
| 1754 */ |
| 1755 List<ExportElement> _exports = ExportElement.EMPTY_ARRAY; |
| 1756 /** |
| 1757 * An array containing all of the compilation units that are included in this
library using a{@code part} directive. |
| 1758 */ |
| 1759 List<CompilationUnitElement> _parts = CompilationUnitElementImpl.EMPTY_ARRAY; |
| 1760 /** |
| 1761 * Initialize a newly created library element to have the given name. |
| 1762 * @param context the analysis context in which the library is defined |
| 1763 * @param name the name of this element |
| 1764 */ |
| 1765 LibraryElementImpl(AnalysisContext context, LibraryIdentifier name) : super.co
n1(name) { |
| 1766 this._context = context; |
| 1767 } |
| 1768 bool operator ==(Object object) => this.runtimeType == object.runtimeType && _
definingCompilationUnit == (object as LibraryElementImpl).definingCompilationUni
t; |
| 1769 ElementImpl getChild(String identifier) { |
| 1770 if ((_definingCompilationUnit as CompilationUnitElementImpl).identifier == i
dentifier) { |
| 1771 return _definingCompilationUnit as CompilationUnitElementImpl; |
| 1772 } |
| 1773 for (CompilationUnitElement part in _parts) { |
| 1774 if ((part as CompilationUnitElementImpl).identifier == identifier) { |
| 1775 return part as CompilationUnitElementImpl; |
| 1776 } |
| 1777 } |
| 1778 return null; |
| 1779 } |
| 1780 AnalysisContext get context => _context; |
| 1781 CompilationUnitElement get definingCompilationUnit => _definingCompilationUnit
; |
| 1782 FunctionElement get entryPoint => _entryPoint; |
| 1783 List<ExportElement> get exports => _exports; |
| 1784 String get identifier => _definingCompilationUnit.source.fullName; |
| 1785 List<LibraryElement> get importedLibraries { |
| 1786 Set<LibraryElement> libraries = new Set<LibraryElement>(); |
| 1787 for (ImportElement element in _imports) { |
| 1788 LibraryElement prefix = element.importedLibrary; |
| 1789 javaSetAdd(libraries, prefix); |
| 1790 } |
| 1791 return new List.from(libraries); |
| 1792 } |
| 1793 List<ImportElement> get imports => _imports; |
| 1794 ElementKind get kind => ElementKind.LIBRARY; |
| 1795 List<CompilationUnitElement> get parts => _parts; |
| 1796 List<PrefixElement> get prefixes { |
| 1797 Set<PrefixElement> prefixes = new Set<PrefixElement>(); |
| 1798 for (ImportElement element in _imports) { |
| 1799 PrefixElement prefix5 = element.prefix; |
| 1800 if (prefix5 != null) { |
| 1801 javaSetAdd(prefixes, prefix5); |
| 1802 } |
| 1803 } |
| 1804 return new List.from(prefixes); |
| 1805 } |
| 1806 int get hashCode => _definingCompilationUnit.hashCode; |
| 1807 /** |
| 1808 * Set the compilation unit that defines this library to the given compilation
unit. |
| 1809 * @param definingCompilationUnit the compilation unit that defines this libra
ry |
| 1810 */ |
| 1811 void set definingCompilationUnit2(CompilationUnitElement definingCompilationUn
it) { |
| 1812 (definingCompilationUnit as CompilationUnitElementImpl).enclosingElement2 =
this; |
| 1813 this._definingCompilationUnit = definingCompilationUnit; |
| 1814 } |
| 1815 /** |
| 1816 * Set the entry point for this library to the given function. |
| 1817 * @param entryPoint the entry point for this library |
| 1818 */ |
| 1819 void set entryPoint2(FunctionElement entryPoint) { |
| 1820 (entryPoint as FunctionElementImpl).enclosingElement2 = this; |
| 1821 this._entryPoint = entryPoint; |
| 1822 } |
| 1823 /** |
| 1824 * Set the specifications of all of the exports defined in this library to the
given array. |
| 1825 * @param exports the specifications of all of the exports defined in this lib
rary |
| 1826 */ |
| 1827 void set exports2(List<ExportElement> exports) { |
| 1828 this._exports = exports; |
| 1829 } |
| 1830 /** |
| 1831 * Set the specifications of all of the imports defined in this library to the
given array. |
| 1832 * @param imports the specifications of all of the imports defined in this lib
rary |
| 1833 */ |
| 1834 void set imports2(List<ImportElement> imports) { |
| 1835 this._imports = imports; |
| 1836 } |
| 1837 /** |
| 1838 * Set the compilation units that are included in this library using a {@code
part} directive. |
| 1839 * @param parts the compilation units that are included in this library using
a {@code part}directive |
| 1840 */ |
| 1841 void set parts2(List<CompilationUnitElement> parts) { |
| 1842 for (CompilationUnitElement compilationUnit in parts) { |
| 1843 (compilationUnit as CompilationUnitElementImpl).enclosingElement2 = this; |
| 1844 } |
| 1845 this._parts = parts; |
| 1846 } |
| 1847 } |
| 1848 /** |
| 1849 * Instances of the class {@code MethodElementImpl} implement a {@code MethodEle
ment}. |
| 1850 */ |
| 1851 class MethodElementImpl extends ExecutableElementImpl implements MethodElement { |
| 1852 /** |
| 1853 * An empty array of method elements. |
| 1854 */ |
| 1855 static List<MethodElement> EMPTY_ARRAY = new List<MethodElement>.fixedLength(0
); |
| 1856 /** |
| 1857 * Initialize a newly created method element to have the given name. |
| 1858 * @param name the name of this element |
| 1859 */ |
| 1860 MethodElementImpl(Identifier name) : super.con1(name) { |
| 1861 } |
| 1862 ClassElement get enclosingElement => super.enclosingElement as ClassElement; |
| 1863 ElementKind get kind => ElementKind.METHOD; |
| 1864 bool isAbstract() => hasModifier(Modifier.ABSTRACT); |
| 1865 bool isStatic() => hasModifier(Modifier.STATIC); |
| 1866 /** |
| 1867 * Set whether this method is abstract to correspond to the given value. |
| 1868 * @param isAbstract {@code true} if the method is abstract |
| 1869 */ |
| 1870 void set abstract(bool isAbstract) { |
| 1871 setModifier(Modifier.ABSTRACT, isAbstract); |
| 1872 } |
| 1873 /** |
| 1874 * Set whether this method is static to correspond to the given value. |
| 1875 * @param isStatic {@code true} if the method is static |
| 1876 */ |
| 1877 void set static(bool isStatic) { |
| 1878 setModifier(Modifier.STATIC, isStatic); |
| 1879 } |
| 1880 String toString() { |
| 1881 StringBuffer builder = new StringBuffer(); |
| 1882 builder.add("method "); |
| 1883 builder.add(enclosingElement.name); |
| 1884 builder.add("."); |
| 1885 builder.add(name); |
| 1886 builder.add(type); |
| 1887 return builder.toString(); |
| 1888 } |
| 1889 } |
| 1890 /** |
| 1891 * The enumeration {@code Modifier} defines constants for all of the modifiers d
efined by the Dart |
| 1892 * language. |
| 1893 */ |
| 1894 class Modifier { |
| 1895 static final Modifier ABSTRACT = new Modifier('ABSTRACT', 0); |
| 1896 static final Modifier CONST = new Modifier('CONST', 1); |
| 1897 static final Modifier FACTORY = new Modifier('FACTORY', 2); |
| 1898 static final Modifier FINAL = new Modifier('FINAL', 3); |
| 1899 static final Modifier GETTER = new Modifier('GETTER', 4); |
| 1900 static final Modifier SETTER = new Modifier('SETTER', 5); |
| 1901 static final Modifier STATIC = new Modifier('STATIC', 6); |
| 1902 static final Modifier SYNTHETIC = new Modifier('SYNTHETIC', 7); |
| 1903 static final List<Modifier> values = [ABSTRACT, CONST, FACTORY, FINAL, GETTER,
SETTER, STATIC, SYNTHETIC]; |
| 1904 final String __name; |
| 1905 final int __ordinal; |
| 1906 Modifier(this.__name, this.__ordinal) { |
| 1907 } |
| 1908 String toString() => __name; |
| 1909 } |
| 1910 /** |
| 1911 * Instances of the class {@code MultiplyDefinedElementImpl} represent a collect
ion of elements that |
| 1912 * have the same name within the same scope. |
| 1913 */ |
| 1914 class MultiplyDefinedElementImpl implements MultiplyDefinedElement { |
| 1915 /** |
| 1916 * The analysis context in which the multiply defined elements are defined. |
| 1917 */ |
| 1918 AnalysisContext _context; |
| 1919 /** |
| 1920 * The name of the conflicting elements. |
| 1921 */ |
| 1922 String _name; |
| 1923 /** |
| 1924 * A list containing all of the elements that conflict. |
| 1925 */ |
| 1926 List<Element> _conflictingElements; |
| 1927 /** |
| 1928 * Initialize a newly created element to represent a list of conflicting eleme
nts. |
| 1929 * @param context the analysis context in which the multiply defined elements
are defined |
| 1930 * @param firstElement the first element that conflicts |
| 1931 * @param secondElement the second element that conflicts |
| 1932 */ |
| 1933 MultiplyDefinedElementImpl(AnalysisContext context, Element firstElement, Elem
ent secondElement) { |
| 1934 _name = firstElement.name; |
| 1935 _conflictingElements = computeConflictingElements(firstElement, secondElemen
t); |
| 1936 } |
| 1937 Element getAncestor(Type elementClass) => null; |
| 1938 List<Element> get conflictingElements => _conflictingElements; |
| 1939 AnalysisContext get context => _context; |
| 1940 Element get enclosingElement => null; |
| 1941 ElementKind get kind => ElementKind.ERROR; |
| 1942 LibraryElement get library => null; |
| 1943 ElementLocation get location => null; |
| 1944 List<Annotation> get metadata => AnnotationImpl.EMPTY_ARRAY; |
| 1945 String get name => _name; |
| 1946 int get nameOffset => -1; |
| 1947 bool isSynthetic() => true; |
| 1948 /** |
| 1949 * Add the given element to the list of elements. If the element is a multiply
-defined element, |
| 1950 * add all of the conflicting elements that it represents. |
| 1951 * @param elements the list to which the element(s) are to be added |
| 1952 * @param element the element(s) to be added |
| 1953 */ |
| 1954 void add(List<Element> elements, Element element) { |
| 1955 if (element is MultiplyDefinedElementImpl) { |
| 1956 for (Element conflictingElement in (element as MultiplyDefinedElementImpl)
._conflictingElements) { |
| 1957 elements.add(conflictingElement); |
| 1958 } |
| 1959 } else { |
| 1960 elements.add(element); |
| 1961 } |
| 1962 } |
| 1963 /** |
| 1964 * Use the given elements to construct an array of conflicting elements. If ei
ther of the given |
| 1965 * elements are multiply-defined elements then the conflicting elements they r
epresent will be |
| 1966 * included in the array. Otherwise, the element itself will be included. |
| 1967 * @param firstElement the first element to be included |
| 1968 * @param secondElement the second element to be included |
| 1969 * @return an array containing all of the conflicting elements |
| 1970 */ |
| 1971 List<Element> computeConflictingElements(Element firstElement, Element secondE
lement) { |
| 1972 List<Element> elements = new List<Element>(); |
| 1973 add(elements, firstElement); |
| 1974 add(elements, secondElement); |
| 1975 return new List.from(elements); |
| 1976 } |
| 1977 } |
| 1978 /** |
| 1979 * Instances of the class {@code ParameterElementImpl} implement a {@code Parame
terElement}. |
| 1980 */ |
| 1981 class ParameterElementImpl extends VariableElementImpl implements ParameterEleme
nt { |
| 1982 /** |
| 1983 * The kind of this parameter. |
| 1984 */ |
| 1985 ParameterKind _parameterKind; |
| 1986 /** |
| 1987 * An empty array of field elements. |
| 1988 */ |
| 1989 static List<ParameterElement> EMPTY_ARRAY = new List<ParameterElement>.fixedLe
ngth(0); |
| 1990 /** |
| 1991 * Initialize a newly created parameter element to have the given name. |
| 1992 * @param name the name of this element |
| 1993 */ |
| 1994 ParameterElementImpl(Identifier name) : super.con1(name) { |
| 1995 } |
| 1996 ElementKind get kind => ElementKind.PARAMETER; |
| 1997 ParameterKind get parameterKind => _parameterKind; |
| 1998 /** |
| 1999 * Set the kind of this parameter to the given kind. |
| 2000 * @param parameterKind the new kind of this parameter |
| 2001 */ |
| 2002 void set parameterKind2(ParameterKind parameterKind) { |
| 2003 this._parameterKind = parameterKind; |
| 2004 } |
| 2005 String toString() => "parameter ${type} ${name} (${kind})"; |
| 2006 } |
| 2007 /** |
| 2008 * Instances of the class {@code PrefixElementImpl} implement a {@code PrefixEle
ment}. |
| 2009 */ |
| 2010 class PrefixElementImpl extends ElementImpl implements PrefixElement { |
| 2011 /** |
| 2012 * An array containing all of the libraries that are imported using this prefi
x. |
| 2013 */ |
| 2014 List<LibraryElement> _importedLibraries = LibraryElementImpl.EMPTY_ARRAY; |
| 2015 /** |
| 2016 * An empty array of prefix elements. |
| 2017 */ |
| 2018 static List<PrefixElement> EMPTY_ARRAY = new List<PrefixElement>.fixedLength(0
); |
| 2019 /** |
| 2020 * Initialize a newly created prefix element to have the given name. |
| 2021 * @param name the name of this element |
| 2022 */ |
| 2023 PrefixElementImpl(Identifier name) : super.con1(name) { |
| 2024 } |
| 2025 LibraryElement get enclosingElement => super.enclosingElement as LibraryElemen
t; |
| 2026 List<LibraryElement> get importedLibraries => _importedLibraries; |
| 2027 ElementKind get kind => ElementKind.PREFIX; |
| 2028 /** |
| 2029 * Set the libraries that are imported using this prefix to the given librarie
s. |
| 2030 * @param importedLibraries the libraries that are imported using this prefix |
| 2031 */ |
| 2032 void set importedLibraries2(List<LibraryElement> importedLibraries) { |
| 2033 for (LibraryElement library in importedLibraries) { |
| 2034 (library as LibraryElementImpl).enclosingElement2 = this; |
| 2035 } |
| 2036 this._importedLibraries = importedLibraries; |
| 2037 } |
| 2038 } |
| 2039 /** |
| 2040 * Instances of the class {@code PropertyAccessorElementImpl} implement a{@code
PropertyAccessorElement}. |
| 2041 */ |
| 2042 class PropertyAccessorElementImpl extends ExecutableElementImpl implements Prope
rtyAccessorElement { |
| 2043 /** |
| 2044 * The field associated with this accessor. |
| 2045 */ |
| 2046 FieldElement _field; |
| 2047 /** |
| 2048 * An empty array of property accessor elements. |
| 2049 */ |
| 2050 static List<PropertyAccessorElement> EMPTY_ARRAY = new List<PropertyAccessorEl
ement>.fixedLength(0); |
| 2051 /** |
| 2052 * Initialize a newly created synthetic property accessor element to be associ
ated with the given |
| 2053 * field. |
| 2054 * @param name the name of this element |
| 2055 */ |
| 2056 PropertyAccessorElementImpl.con1(FieldElementImpl field) : super.con2(field.na
me, -1) { |
| 2057 _jtd_constructor_150_impl(field); |
| 2058 } |
| 2059 _jtd_constructor_150_impl(FieldElementImpl field) { |
| 2060 this._field = field; |
| 2061 synthetic = true; |
| 2062 } |
| 2063 /** |
| 2064 * Initialize a newly created property accessor element to have the given name
. |
| 2065 * @param name the name of this element |
| 2066 */ |
| 2067 PropertyAccessorElementImpl.con2(Identifier name) : super.con1(name) { |
| 2068 _jtd_constructor_151_impl(name); |
| 2069 } |
| 2070 _jtd_constructor_151_impl(Identifier name) { |
| 2071 } |
| 2072 FieldElement get field => _field; |
| 2073 ElementKind get kind { |
| 2074 if (isGetter()) { |
| 2075 return ElementKind.GETTER; |
| 2076 } |
| 2077 return ElementKind.SETTER; |
| 2078 } |
| 2079 bool isGetter() => hasModifier(Modifier.GETTER); |
| 2080 bool isSetter() => hasModifier(Modifier.SETTER); |
| 2081 /** |
| 2082 * Set the field associated with this accessor to the given field. |
| 2083 * @param field the field associated with this accessor |
| 2084 */ |
| 2085 void set field2(FieldElement field) { |
| 2086 this._field = field; |
| 2087 } |
| 2088 /** |
| 2089 * Set whether this accessor is a getter to correspond to the given value. |
| 2090 * @param isGetter {@code true} if the accessor is a getter |
| 2091 */ |
| 2092 void set getter(bool isGetter) { |
| 2093 setModifier(Modifier.GETTER, isGetter); |
| 2094 } |
| 2095 /** |
| 2096 * Set whether this accessor is a setter to correspond to the given value. |
| 2097 * @param isSetter {@code true} if the accessor is a setter |
| 2098 */ |
| 2099 void set setter(bool isSetter) { |
| 2100 setModifier(Modifier.SETTER, isSetter); |
| 2101 } |
| 2102 } |
| 2103 /** |
| 2104 * Instances of the class {@code ShowCombinatorImpl} implement a {@link ShowComb
inator}. |
| 2105 */ |
| 2106 class ShowCombinatorImpl implements ShowCombinator { |
| 2107 /** |
| 2108 * The names that are to be made visible in the importing library if they are
defined in the |
| 2109 * imported library. |
| 2110 */ |
| 2111 List<String> _shownNames = StringUtilities.EMPTY_ARRAY; |
| 2112 /** |
| 2113 * Initialize a newly created combinator. |
| 2114 */ |
| 2115 ShowCombinatorImpl() : super() { |
| 2116 } |
| 2117 List<String> get shownNames => _shownNames; |
| 2118 /** |
| 2119 * Set the names that are to be made visible in the importing library if they
are defined in the |
| 2120 * imported library to the given names. |
| 2121 * @param shownNames the names that are to be made visible in the importing li
brary |
| 2122 */ |
| 2123 void set shownNames2(List<String> shownNames) { |
| 2124 this._shownNames = shownNames; |
| 2125 } |
| 2126 } |
| 2127 /** |
| 2128 * Instances of the class {@code TypeAliasElementImpl} implement a {@code TypeAl
iasElement}. |
| 2129 */ |
| 2130 class TypeAliasElementImpl extends ElementImpl implements TypeAliasElement { |
| 2131 /** |
| 2132 * An array containing all of the parameters defined by this type alias. |
| 2133 */ |
| 2134 List<ParameterElement> _parameters = ParameterElementImpl.EMPTY_ARRAY; |
| 2135 /** |
| 2136 * The type of function defined by this type alias. |
| 2137 */ |
| 2138 FunctionType _type; |
| 2139 /** |
| 2140 * An array containing all of the type variables defined for this type. |
| 2141 */ |
| 2142 List<TypeVariableElement> _typeVariables = TypeVariableElementImpl.EMPTY_ARRAY
; |
| 2143 /** |
| 2144 * An empty array of type alias elements. |
| 2145 */ |
| 2146 static List<TypeAliasElement> EMPTY_ARRAY = new List<TypeAliasElement>.fixedLe
ngth(0); |
| 2147 /** |
| 2148 * Initialize a newly created type alias element to have the given name. |
| 2149 * @param name the name of this element |
| 2150 */ |
| 2151 TypeAliasElementImpl(Identifier name) : super.con1(name) { |
| 2152 } |
| 2153 ElementImpl getChild(String identifier) { |
| 2154 for (VariableElement parameter in _parameters) { |
| 2155 if ((parameter as VariableElementImpl).identifier == identifier) { |
| 2156 return parameter as VariableElementImpl; |
| 2157 } |
| 2158 } |
| 2159 for (TypeVariableElement typeVariable in _typeVariables) { |
| 2160 if ((typeVariable as TypeVariableElementImpl).identifier == identifier) { |
| 2161 return typeVariable as TypeVariableElementImpl; |
| 2162 } |
| 2163 } |
| 2164 return null; |
| 2165 } |
| 2166 CompilationUnitElement get enclosingElement => super.enclosingElement as Compi
lationUnitElement; |
| 2167 ElementKind get kind => ElementKind.TYPE_ALIAS; |
| 2168 List<ParameterElement> get parameters => _parameters; |
| 2169 FunctionType get type => _type; |
| 2170 List<TypeVariableElement> get typeVariables => _typeVariables; |
| 2171 /** |
| 2172 * Set the parameters defined by this type alias to the given parameters. |
| 2173 * @param parameters the parameters defined by this type alias |
| 2174 */ |
| 2175 void set parameters8(List<ParameterElement> parameters) { |
| 2176 if (parameters != null) { |
| 2177 for (ParameterElement parameter in parameters) { |
| 2178 (parameter as ParameterElementImpl).enclosingElement2 = this; |
| 2179 } |
| 2180 } |
| 2181 this._parameters = parameters; |
| 2182 } |
| 2183 /** |
| 2184 * Set the type of function defined by this type alias to the given type. |
| 2185 * @param type the type of function defined by this type alias |
| 2186 */ |
| 2187 void set type12(FunctionType type) { |
| 2188 this._type = type; |
| 2189 } |
| 2190 /** |
| 2191 * Set the type variables defined for this type to the given variables. |
| 2192 * @param typeVariables the type variables defined for this type |
| 2193 */ |
| 2194 void set typeVariables3(List<TypeVariableElement> typeVariables) { |
| 2195 for (TypeVariableElement variable in typeVariables) { |
| 2196 (variable as TypeVariableElementImpl).enclosingElement2 = this; |
| 2197 } |
| 2198 this._typeVariables = typeVariables; |
| 2199 } |
| 2200 } |
| 2201 /** |
| 2202 * Instances of the class {@code TypeVariableElementImpl} implement a {@code Typ
eVariableElement}. |
| 2203 */ |
| 2204 class TypeVariableElementImpl extends ElementImpl implements TypeVariableElement
{ |
| 2205 /** |
| 2206 * The type defined by this type variable. |
| 2207 */ |
| 2208 TypeVariableType _type; |
| 2209 /** |
| 2210 * The type representing the bound associated with this variable, or {@code nu
ll} if this variable |
| 2211 * does not have an explicit bound. |
| 2212 */ |
| 2213 Type2 _bound; |
| 2214 /** |
| 2215 * An empty array of type variable elements. |
| 2216 */ |
| 2217 static List<TypeVariableElement> EMPTY_ARRAY = new List<TypeVariableElement>.f
ixedLength(0); |
| 2218 /** |
| 2219 * Initialize a newly created type variable element to have the given name. |
| 2220 * @param name the name of this element |
| 2221 */ |
| 2222 TypeVariableElementImpl(Identifier name) : super.con1(name) { |
| 2223 } |
| 2224 Type2 get bound => _bound; |
| 2225 ElementKind get kind => ElementKind.TYPE_VARIABLE; |
| 2226 TypeVariableType get type => _type; |
| 2227 /** |
| 2228 * Set the type representing the bound associated with this variable to the gi
ven type. |
| 2229 * @param bound the type representing the bound associated with this variable |
| 2230 */ |
| 2231 void set bound3(Type2 bound) { |
| 2232 this._bound = bound; |
| 2233 } |
| 2234 /** |
| 2235 * Set the type defined by this type variable to the given type |
| 2236 * @param type the type defined by this type variable |
| 2237 */ |
| 2238 void set type13(TypeVariableType type) { |
| 2239 this._type = type; |
| 2240 } |
| 2241 } |
| 2242 /** |
| 2243 * Instances of the class {@code VariableElementImpl} implement a {@code Variabl
eElement}. |
| 2244 */ |
| 2245 class VariableElementImpl extends ElementImpl implements VariableElement { |
| 2246 /** |
| 2247 * The declared type of this variable. |
| 2248 */ |
| 2249 Type2 _type; |
| 2250 /** |
| 2251 * A synthetic function representing this variable's initializer, or {@code nu
ll} if this variable |
| 2252 * does not have an initializer. |
| 2253 */ |
| 2254 FunctionElement _initializer; |
| 2255 /** |
| 2256 * An empty array of variable elements. |
| 2257 */ |
| 2258 static List<VariableElement> EMPTY_ARRAY = new List<VariableElement>.fixedLeng
th(0); |
| 2259 /** |
| 2260 * Initialize a newly created variable element to have the given name. |
| 2261 * @param name the name of this element |
| 2262 */ |
| 2263 VariableElementImpl.con1(Identifier name) : super.con1(name) { |
| 2264 _jtd_constructor_155_impl(name); |
| 2265 } |
| 2266 _jtd_constructor_155_impl(Identifier name) { |
| 2267 } |
| 2268 /** |
| 2269 * Initialize a newly created variable element to have the given name. |
| 2270 * @param name the name of this element |
| 2271 * @param nameOffset the offset of the name of this element in the file that c
ontains the |
| 2272 * declaration of this element |
| 2273 */ |
| 2274 VariableElementImpl.con2(String name, int nameOffset) : super.con2(name, nameO
ffset) { |
| 2275 _jtd_constructor_156_impl(name, nameOffset); |
| 2276 } |
| 2277 _jtd_constructor_156_impl(String name, int nameOffset) { |
| 2278 } |
| 2279 FunctionElement get initializer => _initializer; |
| 2280 ElementKind get kind => ElementKind.VARIABLE; |
| 2281 Type2 get type => _type; |
| 2282 bool isConst() => hasModifier(Modifier.CONST); |
| 2283 bool isFinal() => hasModifier(Modifier.FINAL); |
| 2284 /** |
| 2285 * Set whether this variable is const to correspond to the given value. |
| 2286 * @param isConst {@code true} if the variable is const |
| 2287 */ |
| 2288 void set const2(bool isConst) { |
| 2289 setModifier(Modifier.CONST, isConst); |
| 2290 } |
| 2291 /** |
| 2292 * Set whether this variable is final to correspond to the given value. |
| 2293 * @param isFinal {@code true} if the variable is final |
| 2294 */ |
| 2295 void set final2(bool isFinal) { |
| 2296 setModifier(Modifier.FINAL, isFinal); |
| 2297 } |
| 2298 /** |
| 2299 * Set the function representing this variable's initializer to the given func
tion. |
| 2300 * @param initializer the function representing this variable's initializer |
| 2301 */ |
| 2302 void set initializer3(FunctionElement initializer) { |
| 2303 if (initializer != null) { |
| 2304 (initializer as FunctionElementImpl).enclosingElement2 = this; |
| 2305 } |
| 2306 this._initializer = initializer; |
| 2307 } |
| 2308 /** |
| 2309 * Set the declared type of this variable to the given type. |
| 2310 * @param type the declared type of this variable |
| 2311 */ |
| 2312 void set type14(Type2 type) { |
| 2313 this._type = type; |
| 2314 } |
| 2315 String toString() => "variable ${type} ${name}"; |
| 2316 } |
| 2317 /** |
| 2318 * The unique instance of the class {@code BottomTypeImpl} implements the type {
@code bottom}. |
| 2319 */ |
| 2320 class BottomTypeImpl extends TypeImpl { |
| 2321 /** |
| 2322 * The unique instance of this class. |
| 2323 */ |
| 2324 static BottomTypeImpl _INSTANCE = new BottomTypeImpl(); |
| 2325 /** |
| 2326 * Return the unique instance of this class. |
| 2327 * @return the unique instance of this class |
| 2328 */ |
| 2329 static BottomTypeImpl get instance => _INSTANCE; |
| 2330 /** |
| 2331 * Prevent the creation of instances of this class. |
| 2332 */ |
| 2333 BottomTypeImpl() : super(null, "<bottom>") { |
| 2334 } |
| 2335 bool operator ==(Object object) => object == this; |
| 2336 bool isMoreSpecificThan(Type2 type) => true; |
| 2337 bool isSubtypeOf(Type2 type) => true; |
| 2338 bool isSupertypeOf(Type2 type) => false; |
| 2339 BottomTypeImpl substitute2(List<Type2> argumentTypes, List<Type2> parameterTyp
es) => this; |
| 2340 } |
| 2341 /** |
| 2342 * The unique instance of the class {@code DynamicTypeImpl} implements the type
{@code dynamic}. |
| 2343 */ |
| 2344 class DynamicTypeImpl extends TypeImpl { |
| 2345 /** |
| 2346 * The unique instance of this class. |
| 2347 */ |
| 2348 static DynamicTypeImpl _INSTANCE = new DynamicTypeImpl(); |
| 2349 /** |
| 2350 * Return the unique instance of this class. |
| 2351 * @return the unique instance of this class |
| 2352 */ |
| 2353 static DynamicTypeImpl get instance => _INSTANCE; |
| 2354 /** |
| 2355 * Prevent the creation of instances of this class. |
| 2356 */ |
| 2357 DynamicTypeImpl() : super(new DynamicElementImpl(), Keyword.DYNAMIC.syntax) { |
| 2358 (element as DynamicElementImpl).type10 = this; |
| 2359 } |
| 2360 bool operator ==(Object object) => object is DynamicTypeImpl; |
| 2361 bool isMoreSpecificThan(Type2 type) => false; |
| 2362 bool isSubtypeOf(Type2 type) => false; |
| 2363 bool isSupertypeOf(Type2 type) => true; |
| 2364 DynamicTypeImpl substitute2(List<Type2> argumentTypes, List<Type2> parameterTy
pes) => this; |
| 2365 } |
| 2366 /** |
| 2367 * Instances of the class {@code FunctionTypeImpl} defines the behavior common t
o objects |
| 2368 * representing the type of a function, method, constructor, getter, or setter. |
| 2369 */ |
| 2370 class FunctionTypeImpl extends TypeImpl implements FunctionType { |
| 2371 /** |
| 2372 * Return {@code true} if all of the types in the first array are equal to the
corresponding types |
| 2373 * in the second array. |
| 2374 * @param firstTypes the first array of types being compared |
| 2375 * @param secondTypes the second array of types being compared |
| 2376 * @return {@code true} if all of the types in the first array are equal to th
e corresponding |
| 2377 * types in the second array |
| 2378 */ |
| 2379 static bool equals2(LinkedHashMap<String, Type2> firstTypes, LinkedHashMap<Str
ing, Type2> secondTypes) { |
| 2380 if (secondTypes.length != firstTypes.length) { |
| 2381 return false; |
| 2382 } |
| 2383 HasNextIterator<MapEntry<String, Type2>> firstIterator = new HasNextIterator
(getMapEntrySet(firstTypes).iterator); |
| 2384 HasNextIterator<MapEntry<String, Type2>> secondIterator = new HasNextIterato
r(getMapEntrySet(firstTypes).iterator); |
| 2385 while (firstIterator.hasNext) { |
| 2386 MapEntry<String, Type2> firstEntry = firstIterator.next(); |
| 2387 MapEntry<String, Type2> secondEntry = secondIterator.next(); |
| 2388 if (firstEntry.getKey() != secondEntry.getKey() || firstEntry.getValue() !
= secondEntry.getValue()) { |
| 2389 return false; |
| 2390 } |
| 2391 } |
| 2392 return true; |
| 2393 } |
| 2394 /** |
| 2395 * Return a map containing the results of using the given argument types and p
arameter types to |
| 2396 * perform a substitution on all of the values in the given map. The order of
the entries will be |
| 2397 * preserved. |
| 2398 * @param types the types on which a substitution is to be performed |
| 2399 * @param argumentTypes the argument types for the substitution |
| 2400 * @param parameterTypes the parameter types for the substitution |
| 2401 * @return the result of performing the substitution on each of the types |
| 2402 */ |
| 2403 static LinkedHashMap<String, Type2> substitute3(LinkedHashMap<String, Type2> t
ypes, List<Type2> argumentTypes, List<Type2> parameterTypes) { |
| 2404 LinkedHashMap<String, Type2> newTypes = new LinkedHashMap<String, Type2>(); |
| 2405 for (MapEntry<String, Type2> entry in getMapEntrySet(types)) { |
| 2406 newTypes[entry.getKey()] = entry.getValue().substitute2(argumentTypes, par
ameterTypes); |
| 2407 } |
| 2408 return newTypes; |
| 2409 } |
| 2410 /** |
| 2411 * An array containing the actual types of the type arguments. |
| 2412 */ |
| 2413 List<Type2> _typeArguments = TypeImpl.EMPTY_ARRAY; |
| 2414 /** |
| 2415 * An array containing the types of the normal parameters of this type of func
tion. The parameter |
| 2416 * types are in the same order as they appear in the declaration of the functi
on. |
| 2417 * @return the types of the normal parameters of this type of function |
| 2418 */ |
| 2419 List<Type2> _normalParameterTypes = TypeImpl.EMPTY_ARRAY; |
| 2420 /** |
| 2421 * A table mapping the names of optional (positional) parameters to the types
of the optional |
| 2422 * parameters of this type of function. |
| 2423 */ |
| 2424 List<Type2> _optionalParameterTypes = TypeImpl.EMPTY_ARRAY; |
| 2425 /** |
| 2426 * A table mapping the names of named parameters to the types of the named par
ameters of this type |
| 2427 * of function. |
| 2428 */ |
| 2429 LinkedHashMap<String, Type2> _namedParameterTypes = new LinkedHashMap<String,
Type2>(); |
| 2430 /** |
| 2431 * The type of object returned by this type of function. |
| 2432 */ |
| 2433 Type2 _returnType = VoidTypeImpl.instance; |
| 2434 /** |
| 2435 * Initialize a newly created function type to be declared by the given elemen
t and to have the |
| 2436 * given name. |
| 2437 * @param element the element representing the declaration of the function typ
e |
| 2438 */ |
| 2439 FunctionTypeImpl.con1(ExecutableElement element) : super(element, element == n
ull ? null : element.name) { |
| 2440 _jtd_constructor_200_impl(element); |
| 2441 } |
| 2442 _jtd_constructor_200_impl(ExecutableElement element) { |
| 2443 } |
| 2444 /** |
| 2445 * Initialize a newly created function type to be declared by the given elemen
t and to have the |
| 2446 * given name. |
| 2447 * @param element the element representing the declaration of the function typ
e |
| 2448 */ |
| 2449 FunctionTypeImpl.con2(TypeAliasElement element) : super(element, element == nu
ll ? null : element.name) { |
| 2450 _jtd_constructor_201_impl(element); |
| 2451 } |
| 2452 _jtd_constructor_201_impl(TypeAliasElement element) { |
| 2453 } |
| 2454 bool operator ==(Object object) { |
| 2455 if (object is! FunctionTypeImpl) { |
| 2456 return false; |
| 2457 } |
| 2458 FunctionTypeImpl otherType = object as FunctionTypeImpl; |
| 2459 return element == otherType.element && JavaArrays.equals(_normalParameterTyp
es, otherType._normalParameterTypes) && JavaArrays.equals(_optionalParameterType
s, otherType._optionalParameterTypes) && equals2(_namedParameterTypes, otherType
._namedParameterTypes); |
| 2460 } |
| 2461 Map<String, Type2> get namedParameterTypes => _namedParameterTypes; |
| 2462 List<Type2> get normalParameterTypes => _normalParameterTypes; |
| 2463 List<Type2> get optionalParameterTypes => _optionalParameterTypes; |
| 2464 Type2 get returnType => _returnType; |
| 2465 List<Type2> get typeArguments => _typeArguments; |
| 2466 int get hashCode { |
| 2467 Element element29 = element; |
| 2468 if (element29 == null) { |
| 2469 return 0; |
| 2470 } |
| 2471 return element29.hashCode; |
| 2472 } |
| 2473 bool isSubtypeOf(Type2 type) { |
| 2474 if (type == null || type is! FunctionType) { |
| 2475 return false; |
| 2476 } else if (this == type || this == type) { |
| 2477 return true; |
| 2478 } |
| 2479 FunctionType t = this; |
| 2480 FunctionType s = type as FunctionType; |
| 2481 if (t.normalParameterTypes.length != s.normalParameterTypes.length) { |
| 2482 return false; |
| 2483 } else if (t.normalParameterTypes.length > 0) { |
| 2484 List<Type2> tTypes = t.normalParameterTypes; |
| 2485 List<Type2> sTypes = s.normalParameterTypes; |
| 2486 for (int i = 0; i < tTypes.length; i++) { |
| 2487 if (!tTypes[i].isAssignableTo(sTypes[i])) { |
| 2488 return false; |
| 2489 } |
| 2490 } |
| 2491 } |
| 2492 if (t.optionalParameterTypes.length > 0) { |
| 2493 List<Type2> tOpTypes = t.optionalParameterTypes; |
| 2494 List<Type2> sOpTypes = s.optionalParameterTypes; |
| 2495 if (tOpTypes.length < sOpTypes.length) { |
| 2496 return false; |
| 2497 } |
| 2498 for (int i = 0; i < sOpTypes.length; i++) { |
| 2499 if (!tOpTypes[i].isAssignableTo(sOpTypes[i])) { |
| 2500 return false; |
| 2501 } |
| 2502 } |
| 2503 if (t.namedParameterTypes.length > 0 || s.namedParameterTypes.length > 0)
{ |
| 2504 return false; |
| 2505 } |
| 2506 } else if (s.optionalParameterTypes.length > 0) { |
| 2507 return false; |
| 2508 } |
| 2509 if (t.namedParameterTypes.length > 0) { |
| 2510 Map<String, Type2> namedTypesT = t.namedParameterTypes; |
| 2511 Map<String, Type2> namedTypesS = s.namedParameterTypes; |
| 2512 if (namedTypesT.length < namedTypesS.length) { |
| 2513 return false; |
| 2514 } |
| 2515 HasNextIterator<MapEntry<String, Type2>> iteratorS = new HasNextIterator(g
etMapEntrySet(namedTypesS).iterator); |
| 2516 while (iteratorS.hasNext) { |
| 2517 MapEntry<String, Type2> entryS = iteratorS.next(); |
| 2518 Type2 typeT = namedTypesT[entryS.getKey()]; |
| 2519 if (typeT == null) { |
| 2520 return false; |
| 2521 } |
| 2522 if (!entryS.getValue().isAssignableTo(typeT)) { |
| 2523 return false; |
| 2524 } |
| 2525 } |
| 2526 } else if (s.namedParameterTypes.length > 0) { |
| 2527 return false; |
| 2528 } |
| 2529 return s.returnType == VoidTypeImpl.instance || t.returnType.isAssignableTo(
s.returnType); |
| 2530 } |
| 2531 /** |
| 2532 * Set the mapping of the names of named parameters to the types of the named
parameters of this |
| 2533 * type of function to the given mapping. |
| 2534 * @param namedParameterTypes the mapping of the names of named parameters to
the types of the |
| 2535 * named parameters of this type of function |
| 2536 */ |
| 2537 void set namedParameterTypes2(LinkedHashMap<String, Type2> namedParameterTypes
) { |
| 2538 this._namedParameterTypes = namedParameterTypes; |
| 2539 } |
| 2540 /** |
| 2541 * Set the types of the normal parameters of this type of function to the type
s in the given |
| 2542 * array. |
| 2543 * @param normalParameterTypes the types of the normal parameters of this type
of function |
| 2544 */ |
| 2545 void set normalParameterTypes2(List<Type2> normalParameterTypes) { |
| 2546 this._normalParameterTypes = normalParameterTypes; |
| 2547 } |
| 2548 /** |
| 2549 * Set the types of the optional parameters of this type of function to the ty
pes in the given |
| 2550 * array. |
| 2551 * @param optionalParameterTypes the types of the optional parameters of this
type of function |
| 2552 */ |
| 2553 void set optionalParameterTypes2(List<Type2> optionalParameterTypes) { |
| 2554 this._optionalParameterTypes = optionalParameterTypes; |
| 2555 } |
| 2556 /** |
| 2557 * Set the type of object returned by this type of function to the given type. |
| 2558 * @param returnType the type of object returned by this type of function |
| 2559 */ |
| 2560 void set returnType7(Type2 returnType) { |
| 2561 this._returnType = returnType; |
| 2562 } |
| 2563 /** |
| 2564 * Set the actual types of the type arguments to the given types. |
| 2565 * @param typeArguments the actual types of the type arguments |
| 2566 */ |
| 2567 void set typeArguments4(List<Type2> typeArguments) { |
| 2568 this._typeArguments = typeArguments; |
| 2569 } |
| 2570 FunctionTypeImpl substitute4(List<Type2> argumentTypes) => substitute2(argumen
tTypes, typeArguments); |
| 2571 FunctionTypeImpl substitute2(List<Type2> argumentTypes, List<Type2> parameterT
ypes) { |
| 2572 if (argumentTypes.length != parameterTypes.length) { |
| 2573 throw new IllegalArgumentException("argumentTypes.length (${argumentTypes.
length}) != parameterTypes.length (${parameterTypes.length})"); |
| 2574 } |
| 2575 if (argumentTypes.length == 0) { |
| 2576 return this; |
| 2577 } |
| 2578 Element element30 = element; |
| 2579 FunctionTypeImpl newType = (element30 is ExecutableElement) ? new FunctionTy
peImpl.con1(element30 as ExecutableElement) : new FunctionTypeImpl.con2(element3
0 as TypeAliasElement); |
| 2580 newType.returnType7 = _returnType.substitute2(argumentTypes, parameterTypes)
; |
| 2581 newType.normalParameterTypes2 = TypeImpl.substitute(_normalParameterTypes, a
rgumentTypes, parameterTypes); |
| 2582 newType.optionalParameterTypes2 = TypeImpl.substitute(_optionalParameterType
s, argumentTypes, parameterTypes); |
| 2583 newType.namedParameterTypes2 = substitute3(_namedParameterTypes, argumentTyp
es, parameterTypes); |
| 2584 return newType; |
| 2585 } |
| 2586 String toString() { |
| 2587 StringBuffer builder = new StringBuffer(); |
| 2588 builder.add("("); |
| 2589 bool needsComma = false; |
| 2590 if (_normalParameterTypes.length > 0) { |
| 2591 for (Type2 type in _normalParameterTypes) { |
| 2592 if (needsComma) { |
| 2593 builder.add(", "); |
| 2594 } else { |
| 2595 needsComma = true; |
| 2596 } |
| 2597 builder.add(type); |
| 2598 } |
| 2599 } |
| 2600 if (_optionalParameterTypes.length > 0) { |
| 2601 if (needsComma) { |
| 2602 builder.add(", "); |
| 2603 needsComma = false; |
| 2604 } |
| 2605 builder.add("["); |
| 2606 for (Type2 type in _optionalParameterTypes) { |
| 2607 if (needsComma) { |
| 2608 builder.add(", "); |
| 2609 } else { |
| 2610 needsComma = true; |
| 2611 } |
| 2612 builder.add(type); |
| 2613 } |
| 2614 builder.add("]"); |
| 2615 needsComma = true; |
| 2616 } |
| 2617 if (_namedParameterTypes.length > 0) { |
| 2618 if (needsComma) { |
| 2619 builder.add(", "); |
| 2620 needsComma = false; |
| 2621 } |
| 2622 builder.add("{"); |
| 2623 for (MapEntry<String, Type2> entry in getMapEntrySet(_namedParameterTypes)
) { |
| 2624 if (needsComma) { |
| 2625 builder.add(", "); |
| 2626 } else { |
| 2627 needsComma = true; |
| 2628 } |
| 2629 builder.add(entry.getKey()); |
| 2630 builder.add(": "); |
| 2631 builder.add(entry.getValue()); |
| 2632 } |
| 2633 builder.add("}"); |
| 2634 needsComma = true; |
| 2635 } |
| 2636 builder.add(") -> "); |
| 2637 builder.add(_returnType); |
| 2638 return builder.toString(); |
| 2639 } |
| 2640 } |
| 2641 /** |
| 2642 * Instances of the class {@code InterfaceTypeImpl} defines the behavior common
to objects |
| 2643 * representing the type introduced by either a class or an interface, or a refe
rence to such a |
| 2644 * type. |
| 2645 */ |
| 2646 class InterfaceTypeImpl extends TypeImpl implements InterfaceType { |
| 2647 /** |
| 2648 * An empty array of types. |
| 2649 */ |
| 2650 static List<InterfaceType> EMPTY_ARRAY = new List<InterfaceType>.fixedLength(0
); |
| 2651 /** |
| 2652 * This method computes the longest inheritance path from some passed {@link T
ype} to Object. |
| 2653 * @param type the {@link Type} to compute the longest inheritance path of fro
m the passed{@link Type} to Object |
| 2654 * @return the computed longest inheritance path to Object |
| 2655 * @see #computeLongestInheritancePathToObject(Type,int) |
| 2656 * @see InterfaceType#getLeastUpperBound(Type) |
| 2657 */ |
| 2658 static int computeLongestInheritancePathToObject(InterfaceType type) => comput
eLongestInheritancePathToObject2(type, 0); |
| 2659 /** |
| 2660 * Returns the set of all superinterfaces of the passed {@link Type}. |
| 2661 * @param type the {@link Type} to compute the set of superinterfaces of |
| 2662 * @return the {@link Set} of superinterfaces of the passed {@link Type} |
| 2663 * @see #computeSuperinterfaceSet(Type,HashSet) |
| 2664 * @see #getLeastUpperBound(Type) |
| 2665 */ |
| 2666 static Set<InterfaceType> computeSuperinterfaceSet(InterfaceType type) => comp
uteSuperinterfaceSet2(type, new Set<InterfaceType>()); |
| 2667 /** |
| 2668 * This method computes the longest inheritance path from some passed {@link T
ype} to Object. This |
| 2669 * method calls itself recursively, callers should use the public method{@link
#computeLongestInheritancePathToObject(Type)}. |
| 2670 * @param type the {@link Type} to compute the longest inheritance path of fro
m the passed{@link Type} to Object |
| 2671 * @param depth a field used recursively |
| 2672 * @return the computed longest inheritance path to Object |
| 2673 * @see #computeLongestInheritancePathToObject(Type) |
| 2674 * @see #getLeastUpperBound(Type) |
| 2675 */ |
| 2676 static int computeLongestInheritancePathToObject2(InterfaceType type, int dept
h) { |
| 2677 ClassElement classElement = type.element; |
| 2678 if (classElement.supertype == null) { |
| 2679 return depth; |
| 2680 } |
| 2681 List<InterfaceType> superinterfaces = classElement.interfaces; |
| 2682 int longestPath = 1; |
| 2683 int pathLength; |
| 2684 if (superinterfaces.length > 0) { |
| 2685 for (InterfaceType superinterface in superinterfaces) { |
| 2686 pathLength = computeLongestInheritancePathToObject2(superinterface, dept
h + 1); |
| 2687 if (pathLength > longestPath) { |
| 2688 longestPath = pathLength; |
| 2689 } |
| 2690 } |
| 2691 } |
| 2692 InterfaceType supertype3 = classElement.supertype; |
| 2693 pathLength = computeLongestInheritancePathToObject2(supertype3, depth + 1); |
| 2694 if (pathLength > longestPath) { |
| 2695 longestPath = pathLength; |
| 2696 } |
| 2697 return longestPath; |
| 2698 } |
| 2699 /** |
| 2700 * Returns the set of all superinterfaces of the passed {@link Type}. This is
a recursive method, |
| 2701 * callers should call the public {@link #computeSuperinterfaceSet(Type)}. |
| 2702 * @param type the {@link Type} to compute the set of superinterfaces of |
| 2703 * @param set a {@link HashSet} used recursively by this method |
| 2704 * @return the {@link Set} of superinterfaces of the passed {@link Type} |
| 2705 * @see #computeSuperinterfaceSet(Type) |
| 2706 * @see #getLeastUpperBound(Type) |
| 2707 */ |
| 2708 static Set<InterfaceType> computeSuperinterfaceSet2(InterfaceType type, Set<In
terfaceType> set) { |
| 2709 Element element31 = type.element; |
| 2710 if (element31 != null && element31 is ClassElement) { |
| 2711 ClassElement classElement = element31 as ClassElement; |
| 2712 List<InterfaceType> superinterfaces = classElement.interfaces; |
| 2713 for (InterfaceType superinterface in superinterfaces) { |
| 2714 javaSetAdd(set, superinterface); |
| 2715 computeSuperinterfaceSet2(superinterface, set); |
| 2716 } |
| 2717 InterfaceType supertype4 = classElement.supertype; |
| 2718 if (supertype4 != null) { |
| 2719 javaSetAdd(set, supertype4); |
| 2720 computeSuperinterfaceSet2(supertype4, set); |
| 2721 } |
| 2722 } |
| 2723 return set; |
| 2724 } |
| 2725 /** |
| 2726 * An array containing the actual types of the type arguments. |
| 2727 */ |
| 2728 List<Type2> _typeArguments = TypeImpl.EMPTY_ARRAY; |
| 2729 /** |
| 2730 * Initialize a newly created type to be declared by the given element. |
| 2731 * @param element the element representing the declaration of the type |
| 2732 */ |
| 2733 InterfaceTypeImpl.con1(ClassElement element) : super(element, element.name) { |
| 2734 _jtd_constructor_202_impl(element); |
| 2735 } |
| 2736 _jtd_constructor_202_impl(ClassElement element) { |
| 2737 } |
| 2738 /** |
| 2739 * Initialize a newly created type to have the given name. This constructor sh
ould only be used in |
| 2740 * cases where there is no declaration of the type. |
| 2741 * @param name the name of the type |
| 2742 */ |
| 2743 InterfaceTypeImpl.con2(String name) : super(null, name) { |
| 2744 _jtd_constructor_203_impl(name); |
| 2745 } |
| 2746 _jtd_constructor_203_impl(String name) { |
| 2747 } |
| 2748 bool operator ==(Object object) { |
| 2749 if (object is! InterfaceTypeImpl) { |
| 2750 return false; |
| 2751 } |
| 2752 InterfaceTypeImpl otherType = object as InterfaceTypeImpl; |
| 2753 return element == otherType.element && JavaArrays.equals(_typeArguments, oth
erType._typeArguments); |
| 2754 } |
| 2755 ClassElement get element => super.element as ClassElement; |
| 2756 Type2 getLeastUpperBound(Type2 type) { |
| 2757 Type2 dynamicType = DynamicTypeImpl.instance; |
| 2758 if (this == dynamicType || type == dynamicType) { |
| 2759 return dynamicType; |
| 2760 } |
| 2761 if (type == null || type is! InterfaceType) { |
| 2762 return null; |
| 2763 } |
| 2764 InterfaceType i = this; |
| 2765 InterfaceType j = type as InterfaceType; |
| 2766 Set<InterfaceType> si = computeSuperinterfaceSet(i); |
| 2767 Set<InterfaceType> sj = computeSuperinterfaceSet(j); |
| 2768 javaSetAdd(si, i); |
| 2769 javaSetAdd(sj, j); |
| 2770 si.retainAll(sj); |
| 2771 Set<InterfaceType> s = si; |
| 2772 List<InterfaceType> sn = new List.from(s); |
| 2773 List<int> depths = new List<int>.fixedLength(sn.length); |
| 2774 int maxDepth = 0; |
| 2775 for (int n = 0; n < sn.length; n++) { |
| 2776 depths[n] = computeLongestInheritancePathToObject(sn[n]); |
| 2777 if (depths[n] > maxDepth) { |
| 2778 maxDepth = depths[n]; |
| 2779 } |
| 2780 } |
| 2781 for (; maxDepth >= 0; maxDepth--) { |
| 2782 int indexOfLeastUpperBound = -1; |
| 2783 int numberOfTypesAtMaxDepth = 0; |
| 2784 for (int m = 0; m < depths.length; m++) { |
| 2785 if (depths[m] == maxDepth) { |
| 2786 numberOfTypesAtMaxDepth++; |
| 2787 indexOfLeastUpperBound = m; |
| 2788 } |
| 2789 } |
| 2790 if (numberOfTypesAtMaxDepth == 1) { |
| 2791 return sn[indexOfLeastUpperBound]; |
| 2792 } |
| 2793 } |
| 2794 return null; |
| 2795 } |
| 2796 Type2 get superclass { |
| 2797 ClassElement classElement = element; |
| 2798 return element.supertype.substitute2(_typeArguments, TypeVariableTypeImpl.ge
tTypes(classElement.typeVariables)); |
| 2799 } |
| 2800 List<Type2> get typeArguments => _typeArguments; |
| 2801 int get hashCode { |
| 2802 ClassElement element32 = element; |
| 2803 if (element32 == null) { |
| 2804 return 0; |
| 2805 } |
| 2806 return element32.hashCode; |
| 2807 } |
| 2808 bool isDirectSupertypeOf(InterfaceType type) { |
| 2809 ClassElement i = element; |
| 2810 ClassElement j = type.element; |
| 2811 Type2 supertype5 = j.supertype; |
| 2812 if (supertype5 == null) { |
| 2813 return false; |
| 2814 } |
| 2815 ClassElement supertypeElement = supertype5.element as ClassElement; |
| 2816 if (supertypeElement == i) { |
| 2817 return true; |
| 2818 } |
| 2819 for (Type2 interfaceType in j.interfaces) { |
| 2820 if (interfaceType == i) { |
| 2821 return true; |
| 2822 } |
| 2823 } |
| 2824 for (Type2 mixinType in j.mixins) { |
| 2825 if (mixinType == i) { |
| 2826 return true; |
| 2827 } |
| 2828 } |
| 2829 return false; |
| 2830 } |
| 2831 bool isMoreSpecificThan(Type2 type) { |
| 2832 if (type == DynamicTypeImpl.instance) { |
| 2833 return true; |
| 2834 } else if (type is! InterfaceType) { |
| 2835 return false; |
| 2836 } |
| 2837 InterfaceType s = type as InterfaceType; |
| 2838 if (this == s) { |
| 2839 return true; |
| 2840 } |
| 2841 if (s.isDirectSupertypeOf(this)) { |
| 2842 return true; |
| 2843 } |
| 2844 ClassElement tElement = element; |
| 2845 ClassElement sElement = s.element; |
| 2846 if (tElement == sElement) { |
| 2847 List<Type2> tArguments = typeArguments; |
| 2848 List<Type2> sArguments = s.typeArguments; |
| 2849 if (tArguments.length != sArguments.length) { |
| 2850 return false; |
| 2851 } |
| 2852 for (int i = 0; i < tArguments.length; i++) { |
| 2853 if (!tArguments[i].isMoreSpecificThan(sArguments[i])) { |
| 2854 return false; |
| 2855 } |
| 2856 } |
| 2857 return true; |
| 2858 } |
| 2859 if (element.supertype == null) { |
| 2860 return false; |
| 2861 } |
| 2862 return element.supertype.isMoreSpecificThan(type); |
| 2863 } |
| 2864 bool isSubtypeOf(Type2 type) { |
| 2865 if (type == DynamicTypeImpl.instance) { |
| 2866 return true; |
| 2867 } else if (type is TypeVariableType) { |
| 2868 return true; |
| 2869 } else if (type is! InterfaceType) { |
| 2870 return false; |
| 2871 } else if (this == type) { |
| 2872 return true; |
| 2873 } |
| 2874 InterfaceType typeT = this; |
| 2875 InterfaceType typeS = type as InterfaceType; |
| 2876 ClassElement elementT = element; |
| 2877 if (elementT == null) { |
| 2878 return false; |
| 2879 } |
| 2880 typeT = substitute2(_typeArguments, TypeVariableTypeImpl.getTypes(elementT.t
ypeVariables)); |
| 2881 if (typeT == typeS) { |
| 2882 return true; |
| 2883 } else if (elementT == typeS.element) { |
| 2884 List<Type2> typeTArgs = typeT.typeArguments; |
| 2885 List<Type2> typeSArgs = typeS.typeArguments; |
| 2886 if (typeTArgs.length != typeSArgs.length) { |
| 2887 return false; |
| 2888 } |
| 2889 for (int i = 0; i < typeTArgs.length; i++) { |
| 2890 if (!typeTArgs[i].isSubtypeOf(typeSArgs[i])) { |
| 2891 return false; |
| 2892 } |
| 2893 } |
| 2894 return true; |
| 2895 } |
| 2896 Type2 supertype6 = elementT.supertype; |
| 2897 if (supertype6 == null) { |
| 2898 return false; |
| 2899 } |
| 2900 List<Type2> interfaceTypes = elementT.interfaces; |
| 2901 for (Type2 interfaceType in interfaceTypes) { |
| 2902 if (interfaceType.isSubtypeOf(typeS)) { |
| 2903 return true; |
| 2904 } |
| 2905 } |
| 2906 List<Type2> mixinTypes = elementT.mixins; |
| 2907 for (Type2 mixinType in mixinTypes) { |
| 2908 if (mixinType == typeS) { |
| 2909 return true; |
| 2910 } |
| 2911 } |
| 2912 return supertype6.isSubtypeOf(typeS); |
| 2913 } |
| 2914 /** |
| 2915 * Set the actual types of the type arguments to those in the given array. |
| 2916 * @param typeArguments the actual types of the type arguments |
| 2917 */ |
| 2918 void set typeArguments5(List<Type2> typeArguments) { |
| 2919 this._typeArguments = typeArguments; |
| 2920 } |
| 2921 InterfaceTypeImpl substitute5(List<Type2> argumentTypes) => substitute2(argume
ntTypes, typeArguments); |
| 2922 InterfaceTypeImpl substitute2(List<Type2> argumentTypes, List<Type2> parameter
Types) { |
| 2923 if (argumentTypes.length != parameterTypes.length) { |
| 2924 throw new IllegalArgumentException("argumentTypes.length (${argumentTypes.
length}) != parameterTypes.length (${parameterTypes.length})"); |
| 2925 } |
| 2926 if (argumentTypes.length == 0) { |
| 2927 return this; |
| 2928 } |
| 2929 InterfaceTypeImpl newType = new InterfaceTypeImpl.con1(element); |
| 2930 newType.typeArguments5 = TypeImpl.substitute(_typeArguments, argumentTypes,
parameterTypes); |
| 2931 return newType; |
| 2932 } |
| 2933 } |
| 2934 /** |
| 2935 * The abstract class {@code TypeImpl} implements the behavior common to objects
representing the |
| 2936 * declared type of elements in the element model. |
| 2937 */ |
| 2938 abstract class TypeImpl implements Type2 { |
| 2939 /** |
| 2940 * Return an array containing the results of using the given argument types an
d parameter types to |
| 2941 * perform a substitution on all of the given types. |
| 2942 * @param types the types on which a substitution is to be performed |
| 2943 * @param argumentTypes the argument types for the substitution |
| 2944 * @param parameterTypes the parameter types for the substitution |
| 2945 * @return the result of performing the substitution on each of the types |
| 2946 */ |
| 2947 static List<Type2> substitute(List<Type2> types, List<Type2> argumentTypes, Li
st<Type2> parameterTypes) { |
| 2948 int length6 = types.length; |
| 2949 List<Type2> newTypes = new List<Type2>.fixedLength(length6); |
| 2950 for (int i = 0; i < length6; i++) { |
| 2951 newTypes[i] = types[i].substitute2(argumentTypes, parameterTypes); |
| 2952 } |
| 2953 return newTypes; |
| 2954 } |
| 2955 /** |
| 2956 * The element representing the declaration of this type, or {@code null} if t
he type has not, or |
| 2957 * cannot, be associated with an element. |
| 2958 */ |
| 2959 Element _element; |
| 2960 /** |
| 2961 * The name of this type, or {@code null} if the type does not have a name. |
| 2962 */ |
| 2963 String _name; |
| 2964 /** |
| 2965 * An empty array of types. |
| 2966 */ |
| 2967 static List<Type2> EMPTY_ARRAY = new List<Type2>.fixedLength(0); |
| 2968 /** |
| 2969 * Initialize a newly created type to be declared by the given element and to
have the given name. |
| 2970 * @param element the element representing the declaration of the type |
| 2971 * @param name the name of the type |
| 2972 */ |
| 2973 TypeImpl(Element element, String name) { |
| 2974 this._element = element; |
| 2975 this._name = name; |
| 2976 } |
| 2977 Element get element => _element; |
| 2978 Type2 getLeastUpperBound(Type2 type) => null; |
| 2979 String get name => _name; |
| 2980 bool isAssignableTo(Type2 type) => this.isSubtypeOf(type) || type.isSubtypeOf(
this); |
| 2981 bool isMoreSpecificThan(Type2 type) => false; |
| 2982 bool isSupertypeOf(Type2 type) => type.isSubtypeOf(this); |
| 2983 String toString() => _name == null ? "<unnamed type>" : "type ${_name}"; |
| 2984 } |
| 2985 /** |
| 2986 * Instances of the class {@code TypeVariableTypeImpl} defines the behavior of o
bjects representing |
| 2987 * the type introduced by a type variable. |
| 2988 */ |
| 2989 class TypeVariableTypeImpl extends TypeImpl implements TypeVariableType { |
| 2990 /** |
| 2991 * Return an array containing the type variable types defined by the given arr
ay of type variable |
| 2992 * elements. |
| 2993 * @param typeVariables the type variable elements defining the type variable
types to be returned |
| 2994 * @return the type variable types defined by the type variable elements |
| 2995 */ |
| 2996 static List<TypeVariableType> getTypes(List<TypeVariableElement> typeVariables
) { |
| 2997 int count = typeVariables.length; |
| 2998 List<TypeVariableType> types = new List<TypeVariableType>.fixedLength(count)
; |
| 2999 for (int i = 0; i < count; i++) { |
| 3000 types[i] = typeVariables[i].type; |
| 3001 } |
| 3002 return types; |
| 3003 } |
| 3004 /** |
| 3005 * Initialize a newly created type variable to be declared by the given elemen
t and to have the |
| 3006 * given name. |
| 3007 * @param element the element representing the declaration of the type variabl
e |
| 3008 */ |
| 3009 TypeVariableTypeImpl(TypeVariableElement element) : super(element, element.nam
e) { |
| 3010 } |
| 3011 bool operator ==(Object object) => object is TypeVariableTypeImpl && element =
= (object as TypeVariableTypeImpl).element; |
| 3012 TypeVariableElement get element => super.element as TypeVariableElement; |
| 3013 int get hashCode => element.hashCode; |
| 3014 bool isMoreSpecificThan(Type2 type) { |
| 3015 Type2 upperBound = element.bound; |
| 3016 return type == upperBound; |
| 3017 } |
| 3018 bool isSubtypeOf(Type2 type) => true; |
| 3019 Type2 substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes) { |
| 3020 int length7 = parameterTypes.length; |
| 3021 for (int i = 0; i < length7; i++) { |
| 3022 if (parameterTypes[i] == this) { |
| 3023 return argumentTypes[i]; |
| 3024 } |
| 3025 } |
| 3026 return this; |
| 3027 } |
| 3028 } |
| 3029 /** |
| 3030 * The unique instance of the class {@code VoidTypeImpl} implements the type {@c
ode void}. |
| 3031 */ |
| 3032 class VoidTypeImpl extends TypeImpl implements VoidType { |
| 3033 /** |
| 3034 * The unique instance of this class. |
| 3035 */ |
| 3036 static VoidTypeImpl _INSTANCE = new VoidTypeImpl(); |
| 3037 /** |
| 3038 * Return the unique instance of this class. |
| 3039 * @return the unique instance of this class |
| 3040 */ |
| 3041 static VoidTypeImpl get instance => _INSTANCE; |
| 3042 /** |
| 3043 * Prevent the creation of instances of this class. |
| 3044 */ |
| 3045 VoidTypeImpl() : super(null, Keyword.VOID.syntax) { |
| 3046 } |
| 3047 bool operator ==(Object object) => object == this; |
| 3048 bool isSubtypeOf(Type2 type) => type == this || type == DynamicTypeImpl.instan
ce; |
| 3049 VoidTypeImpl substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes
) => this; |
| 3050 } |
| 3051 /** |
| 3052 * The interface {@code FunctionType} defines the behavior common to objects rep
resenting the type |
| 3053 * of a function, method, constructor, getter, or setter. Function types come in
three variations: |
| 3054 * <ol> |
| 3055 * <li>The types of functions that only have required parameters. These have the
general form |
| 3056 * <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T</i>.</li> |
| 3057 * <li>The types of functions with optional positional parameters. These have th
e general form |
| 3058 * <i>(T<sub>1</sub>, …, T<sub>n</sub>, [T<sub>n+1</sub>, …, T<sub
>n+k</sub>]) → |
| 3059 * T</i>.</li> |
| 3060 * <li>The types of functions with named positional parameters. These have the g
eneral form |
| 3061 * <i>(T<sub>1</sub>, …, T<sub>n</sub>, {T<sub>x1</sub> x1, …, T<s
ub>xk</sub> xk}) |
| 3062 * → T</i>.</li> |
| 3063 * </ol> |
| 3064 */ |
| 3065 abstract class FunctionType implements Type2 { |
| 3066 /** |
| 3067 * Return a map from the names of named parameters to the types of the named p
arameters of this |
| 3068 * type of function. The entries in the map will be iterated in the same order
as the order in |
| 3069 * which the named parameters were defined. If there were no named parameters
declared then the |
| 3070 * map will be empty. |
| 3071 * @return a map from the name to the types of the named parameters of this ty
pe of function |
| 3072 */ |
| 3073 Map<String, Type2> get namedParameterTypes; |
| 3074 /** |
| 3075 * Return an array containing the types of the normal parameters of this type
of function. The |
| 3076 * parameter types are in the same order as they appear in the declaration of
the function. |
| 3077 * @return the types of the normal parameters of this type of function |
| 3078 */ |
| 3079 List<Type2> get normalParameterTypes; |
| 3080 /** |
| 3081 * Return a map from the names of optional (positional) parameters to the type
s of the optional |
| 3082 * parameters of this type of function. The entries in the map will be iterate
d in the same order |
| 3083 * as the order in which the optional parameters were defined. If there were n
o optional |
| 3084 * parameters declared then the map will be empty. |
| 3085 * @return a map from the name to the types of the optional parameters of this
type of function |
| 3086 */ |
| 3087 List<Type2> get optionalParameterTypes; |
| 3088 /** |
| 3089 * Return the type of object returned by this type of function. |
| 3090 * @return the type of object returned by this type of function |
| 3091 */ |
| 3092 Type2 get returnType; |
| 3093 /** |
| 3094 * Return an array containing the actual types of the type arguments. If this
type's element does |
| 3095 * not have type parameters, then the array should be empty (although it is po
ssible for type |
| 3096 * arguments to be erroneously declared). If the element has type parameters a
nd the actual type |
| 3097 * does not explicitly include argument values, then the type "dynamic" will b
e automatically |
| 3098 * provided. |
| 3099 * @return the actual types of the type arguments |
| 3100 */ |
| 3101 List<Type2> get typeArguments; |
| 3102 /** |
| 3103 * Return {@code true} if this type is a subtype of the given type. |
| 3104 * <p> |
| 3105 * A function type <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T</i> is
a subtype of the |
| 3106 * function type <i>(S<sub>1</sub>, …, S<sub>n</sub>) → S</i>, if
all of the following |
| 3107 * conditions are met: |
| 3108 * <ul> |
| 3109 * <li>Either |
| 3110 * <ul> |
| 3111 * <li><i>S</i> is void, or</li> |
| 3112 * <li><i>T ⇔ S</i>.</li> |
| 3113 * </ul> |
| 3114 * </li> |
| 3115 * <li>For all <i>i</i>, 1 <= <i>i</i> <= <i>n</i>, <i>T<sub>i</sub> ⇔ S<
sub>i</sub></i>.</li> |
| 3116 * </ul> |
| 3117 * A function type <i>(T<sub>1</sub>, …, T<sub>n</sub>, [T<sub>n+1</sub
>, …, |
| 3118 * T<sub>n+k</sub>]) → T</i> is a subtype of the function type <i>(S<sub>
1</sub>, …, |
| 3119 * S<sub>n</sub>, [S<sub>n+1</sub>, …, S<sub>n+m</sub>]) → S</i>,
if all of the |
| 3120 * following conditions are met: |
| 3121 * <ul> |
| 3122 * <li>Either |
| 3123 * <ul> |
| 3124 * <li><i>S</i> is void, or</li> |
| 3125 * <li><i>T ⇔ S</i>.</li> |
| 3126 * </ul> |
| 3127 * </li> |
| 3128 * <li><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> |
| 3129 * ⇔ S<sub>i</sub></i>.</li> |
| 3130 * </ul> |
| 3131 * A function type <i>(T<sub>1</sub>, …, T<sub>n</sub>, {T<sub>x1</sub>
x1, …, |
| 3132 * T<sub>xk</sub> xk}) → T</i> is a subtype of the function type <i>(S<su
b>1</sub>, …, |
| 3133 * S<sub>n</sub>, {S<sub>y1</sub> y1, …, S<sub>ym</sub> ym}) → S</
i>, if all of the |
| 3134 * following conditions are met: |
| 3135 * <ul> |
| 3136 * <li>Either |
| 3137 * <ul> |
| 3138 * <li><i>S</i> is void,</li> |
| 3139 * <li>or <i>T ⇔ S</i>.</li> |
| 3140 * </ul> |
| 3141 * </li> |
| 3142 * <li>For all <i>i</i>, 1 <= <i>i</i> <= <i>n</i>, <i>T<sub>i</sub> ⇔ S<
sub>i</sub></i>.</li> |
| 3143 * <li><i>k</i> >= <i>m</i> and <i>y<sub>i</sub></i> in <i>{x<sub>1</sub>, &he
llip;, |
| 3144 * x<sub>k</sub>}</i>, 1 <= <i>i</i> <= <i>m</i>.</li> |
| 3145 * <li>For all <i>y<sub>i</sub></i> in <i>{y<sub>1</sub>, …, y<sub>m</s
ub>}</i>, |
| 3146 * <i>y<sub>i</sub> = x<sub>j</sub> => Tj ⇔ Si</i>.</li> |
| 3147 * </ul> |
| 3148 * In addition, the following subtype rules apply: |
| 3149 * <p> |
| 3150 * <i>(T<sub>1</sub>, …, T<sub>n</sub>, []) → T <: (T<sub>1</sub>,
…, |
| 3151 * T<sub>n</sub>) → T.</i><br> |
| 3152 * <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T <: (T<sub>1</sub>, &he
llip;, |
| 3153 * T<sub>n</sub>, {}) → T.</i><br> |
| 3154 * <i>(T<sub>1</sub>, …, T<sub>n</sub>, {}) → T <: (T<sub>1</sub>,
…, |
| 3155 * T<sub>n</sub>) → T.</i><br> |
| 3156 * <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T <: (T<sub>1</sub>, &he
llip;, |
| 3157 * T<sub>n</sub>, []) → T.</i> |
| 3158 * <p> |
| 3159 * All functions implement the class {@code Function}. However not all functio
n types are a |
| 3160 * subtype of {@code Function}. If an interface type <i>I</i> includes a metho
d named{@code call()}, and the type of {@code call()} is the function type <i>F<
/i>, then <i>I</i> is |
| 3161 * considered to be a subtype of <i>F</i>. |
| 3162 * @param type the type being compared with this type |
| 3163 * @return {@code true} if this type is a subtype of the given type |
| 3164 */ |
| 3165 bool isSubtypeOf(Type2 type); |
| 3166 /** |
| 3167 * Return the type resulting from substituting the given arguments for this ty
pe's parameters. |
| 3168 * This is fully equivalent to {@code substitute(argumentTypes, getTypeArgumen
ts())}. |
| 3169 * @param argumentTypes the actual type arguments being substituted for the ty
pe parameters |
| 3170 * @return the result of performing the substitution |
| 3171 */ |
| 3172 FunctionType substitute4(List<Type2> argumentTypes); |
| 3173 FunctionType substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes
); |
| 3174 } |
| 3175 /** |
| 3176 * The interface {@code InterfaceType} defines the behavior common to objects re
presenting the type |
| 3177 * introduced by either a class or an interface, or a reference to such a type. |
| 3178 */ |
| 3179 abstract class InterfaceType implements Type2 { |
| 3180 ClassElement get element; |
| 3181 /** |
| 3182 * Return the least upper bound of this type and the given type, or {@code nul
l} if there is no |
| 3183 * least upper bound. |
| 3184 * <p> |
| 3185 * Given two interfaces <i>I</i> and <i>J</i>, let <i>S<sub>I</sub></i> be the
set of |
| 3186 * superinterfaces of <i>I<i>, let <i>S<sub>J</sub></i> be the set of superint
erfaces of <i>J</i> |
| 3187 * and let <i>S = (I ∪ S<sub>I</sub>) ∩ (J ∪ S<sub>J</sub>)</i>. F
urthermore, we |
| 3188 * define <i>S<sub>n</sub> = {T | T ∈ S ∧ depth(T) = n}</i> for any f
inite <i>n</i>, |
| 3189 * where <i>depth(T)</i> is the number of steps in the longest inheritance pat
h from <i>T</i> to |
| 3190 * <i>Object</i>. Let <i>q</i> be the largest number such that <i>S<sub>q</sub
></i> has |
| 3191 * cardinality one. The least upper bound of <i>I</i> and <i>J</i> is the sole
element of |
| 3192 * <i>S<sub>q</sub></i>. |
| 3193 * @param type the other type used to compute the least upper bound |
| 3194 * @return the least upper bound of this type and the given type |
| 3195 */ |
| 3196 Type2 getLeastUpperBound(Type2 type); |
| 3197 /** |
| 3198 * Return the type representing the superclass of this type. Note that this is
<b>not</b>, in |
| 3199 * general, equivalent to getting the superclass from this type's element beca
use the type |
| 3200 * returned by this method will have had it's type parameters replaced. |
| 3201 * @return the superclass of this type |
| 3202 */ |
| 3203 Type2 get superclass; |
| 3204 /** |
| 3205 * Return an array containing the actual types of the type arguments. If this
type's element does |
| 3206 * not have type parameters, then the array should be empty (although it is po
ssible for type |
| 3207 * arguments to be erroneously declared). If the element has type parameters a
nd the actual type |
| 3208 * does not explicitly include argument values, then the type "dynamic" will b
e automatically |
| 3209 * provided. |
| 3210 * @return the actual types of the type arguments |
| 3211 */ |
| 3212 List<Type2> get typeArguments; |
| 3213 /** |
| 3214 * Return {@code true} if this type is a direct supertype of the given type. T
he implicit |
| 3215 * interface of class <i>I</i> is a direct supertype of the implicit interface
of class <i>J</i> |
| 3216 * iff: |
| 3217 * <ul> |
| 3218 * <li><i>I</i> is Object, and <i>J</i> has no extends clause.</li> |
| 3219 * <li><i>I</i> is listed in the extends clause of <i>J</i>.</li> |
| 3220 * <li><i>I</i> is listed in the implements clause of <i>J</i>.</li> |
| 3221 * <li><i>I</i> is listed in the with clause of <i>J</i>.</li> |
| 3222 * <li><i>J</i> is a mixin application of the mixin of <i>I</i>.</li> |
| 3223 * </ul> |
| 3224 * @param type the type being compared with this type |
| 3225 * @return {@code true} if this type is a direct supertype of the given type |
| 3226 */ |
| 3227 bool isDirectSupertypeOf(InterfaceType type); |
| 3228 /** |
| 3229 * Return {@code true} if this type is more specific than the given type. An i
nterface type |
| 3230 * <i>T</i> is more specific than an interface type <i>S</i>, written <i>T &la
quo; S</i>, if one |
| 3231 * of the following conditions is met: |
| 3232 * <ul> |
| 3233 * <li>Reflexivity: <i>T</i> is <i>S</i>. |
| 3234 * <li><i>T</i> is bottom. |
| 3235 * <li><i>S</i> is dynamic. |
| 3236 * <li>Direct supertype: <i>S</i> is a direct supertype of <i>T</i>. |
| 3237 * <li><i>T</i> is a type variable and <i>S</i> is the upper bound of <i>T</i>
. |
| 3238 * <li>Covariance: <i>T</i> is of the form <i>I<T<sub>1</sub>, …, T<
sub>n</sub>></i> |
| 3239 * and S</i> is of the form <i>I<S<sub>1</sub>, …, S<sub>n</sub>>
</i> and |
| 3240 * <i>T<sub>i</sub> « S<sub>i</sub></i>, <i>1 <= i <= n</i>. |
| 3241 * <li>Transitivity: <i>T « U</i> and <i>U « S</i>. |
| 3242 * </ul> |
| 3243 * @param type the type being compared with this type |
| 3244 * @return {@code true} if this type is more specific than the given type |
| 3245 */ |
| 3246 bool isMoreSpecificThan(Type2 type); |
| 3247 /** |
| 3248 * Return {@code true} if this type is a subtype of the given type. An interfa
ce type <i>T</i> is |
| 3249 * a subtype of an interface type <i>S</i>, written <i>T</i> <: <i>S</i>, iff |
| 3250 * <i>[bottom/dynamic]T</i> « <i>S</i> (<i>T</i> is more specific than <
i>S</i>). If an |
| 3251 * interface type <i>I</i> includes a method named <i>call()</i>, and the type
of <i>call()</i> is |
| 3252 * the function type <i>F</i>, then <i>I</i> is considered to be a subtype of
<i>F</i>. |
| 3253 * @param type the type being compared with this type |
| 3254 * @return {@code true} if this type is a subtype of the given type |
| 3255 */ |
| 3256 bool isSubtypeOf(Type2 type); |
| 3257 /** |
| 3258 * Return the type resulting from substituting the given arguments for this ty
pe's parameters. |
| 3259 * This is fully equivalent to {@code substitute(argumentTypes, getTypeArgumen
ts())}. |
| 3260 * @param argumentTypes the actual type arguments being substituted for the ty
pe parameters |
| 3261 * @return the result of performing the substitution |
| 3262 */ |
| 3263 InterfaceType substitute5(List<Type2> argumentTypes); |
| 3264 InterfaceType substitute2(List<Type2> argumentTypes, List<Type2> parameterType
s); |
| 3265 } |
| 3266 /** |
| 3267 * The interface {@code Type} defines the behavior of objects representing the d
eclared type of |
| 3268 * elements in the element model. |
| 3269 */ |
| 3270 abstract class Type2 { |
| 3271 /** |
| 3272 * Return the element representing the declaration of this type, or {@code nul
l} if the type has |
| 3273 * not, or cannot, be associated with an element. The former case will occur i
f the element model |
| 3274 * is not yet complete; the latter case will occur if this object represents a
n undefined type. |
| 3275 * @return the element representing the declaration of this type |
| 3276 */ |
| 3277 Element get element; |
| 3278 /** |
| 3279 * Return the least upper bound of this type and the given type, or {@code nul
l} if there is no |
| 3280 * least upper bound. |
| 3281 * @param type the other type used to compute the least upper bound |
| 3282 * @return the least upper bound of this type and the given type |
| 3283 */ |
| 3284 Type2 getLeastUpperBound(Type2 type); |
| 3285 /** |
| 3286 * Return the name of this type, or {@code null} if the type does not have a n
ame, such as when |
| 3287 * the type represents the type of an unnamed function. |
| 3288 * @return the name of this type |
| 3289 */ |
| 3290 String get name; |
| 3291 /** |
| 3292 * Return {@code true} if this type is assignable to the given type. A type <i
>T</i> may be |
| 3293 * assigned to a type <i>S</i>, written <i>T</i> ⇔ <i>S</i>, iff either <
i>T</i> <: <i>S</i> |
| 3294 * or <i>S</i> <: <i>T</i>. |
| 3295 * @param type the type being compared with this type |
| 3296 * @return {@code true} if this type is assignable to the given type |
| 3297 */ |
| 3298 bool isAssignableTo(Type2 type); |
| 3299 /** |
| 3300 * Return {@code true} if this type is more specific than the given type. |
| 3301 * @param type the type being compared with this type |
| 3302 * @return {@code true} if this type is more specific than the given type |
| 3303 */ |
| 3304 bool isMoreSpecificThan(Type2 type); |
| 3305 /** |
| 3306 * Return {@code true} if this type is a subtype of the given type. |
| 3307 * @param type the type being compared with this type |
| 3308 * @return {@code true} if this type is a subtype of the given type |
| 3309 */ |
| 3310 bool isSubtypeOf(Type2 type); |
| 3311 /** |
| 3312 * Return {@code true} if this type is a supertype of the given type. A type <
i>S</i> is a |
| 3313 * supertype of <i>T</i>, written <i>S</i> :> <i>T</i>, iff <i>T</i> is a subt
ype of <i>S</i>. |
| 3314 * @param type the type being compared with this type |
| 3315 * @return {@code true} if this type is a supertype of the given type |
| 3316 */ |
| 3317 bool isSupertypeOf(Type2 type); |
| 3318 /** |
| 3319 * Return the type resulting from substituting the given arguments for the giv
en parameters in |
| 3320 * this type. The specification defines this operation in section 2: <blockquo
te> The notation |
| 3321 * <i>[x<sub>1</sub>, ..., x<sub>n</sub>/y<sub>1</sub>, ..., y<sub>n</sub>]E</
i> denotes a copy of |
| 3322 * <i>E</i> in which all occurrences of <i>y<sub>i</sub>, 1 <= i <= n</i> have
been replaced with |
| 3323 * <i>x<sub>i</sub></i>.</blockquote> Note that, contrary to the specification
, this method will |
| 3324 * not create a copy of this type if no substitutions were required, but will
return this type |
| 3325 * directly. |
| 3326 * @param argumentTypes the actual type arguments being substituted for the pa
rameters |
| 3327 * @param parameterTypes the parameters to be replaced |
| 3328 * @return the result of performing the substitution |
| 3329 */ |
| 3330 Type2 substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes); |
| 3331 } |
| 3332 /** |
| 3333 * The interface {@code TypeVariableType} defines the behavior of objects repres
enting the type |
| 3334 * introduced by a type variable. |
| 3335 */ |
| 3336 abstract class TypeVariableType implements Type2 { |
| 3337 TypeVariableElement get element; |
| 3338 } |
| 3339 /** |
| 3340 * The interface {@code VoidType} defines the behavior of the unique object repr
esenting the type{@code void}. |
| 3341 */ |
| 3342 abstract class VoidType implements Type2 { |
| 3343 VoidType substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes); |
| 3344 } |
| OLD | NEW |