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' show Identifier, LibraryIdentifier; | |
12 import 'html.dart' show XmlTagNode; | |
13 import 'engine.dart' show AnalysisContext; | |
14 import 'utilities_dart.dart'; | |
15 | |
16 /** | |
17 * The interface {@code Annotation} defines the behavior of objects representing
a single annotation | |
18 * associated with an element. | |
19 * @coverage dart.engine.element | |
20 */ | |
21 abstract class Annotation { | |
22 /** | |
23 * Return the element representing the field, variable, or const constructor b
eing used as an | |
24 * annotation. | |
25 * @return the field, variable, or constructor being used as an annotation | |
26 */ | |
27 Element get element; | |
28 } | |
29 /** | |
30 * The interface {@code ClassElement} defines the behavior of elements that repr
esent a class. | |
31 * @coverage dart.engine.element | |
32 */ | |
33 abstract class ClassElement implements Element { | |
34 /** | |
35 * Return an array containing all of the accessors (getters and setters) decla
red in this class. | |
36 * @return the accessors declared in this class | |
37 */ | |
38 List<PropertyAccessorElement> get accessors; | |
39 /** | |
40 * Return an array containing all the supertypes defined for this class and it
s supertypes. | |
41 * @return all the supertypes of this class, including mixins | |
42 */ | |
43 List<InterfaceType> get allSupertypes; | |
44 /** | |
45 * Return an array containing all of the constructors declared in this class. | |
46 * @return the constructors declared in this class | |
47 */ | |
48 List<ConstructorElement> get constructors; | |
49 /** | |
50 * Return an array containing all of the fields declared in this class. | |
51 * @return the fields declared in this class | |
52 */ | |
53 List<FieldElement> get fields; | |
54 /** | |
55 * Return an array containing all of the interfaces that are implemented by th
is class. | |
56 * @return the interfaces that are implemented by this class | |
57 */ | |
58 List<InterfaceType> get interfaces; | |
59 /** | |
60 * Return an array containing all of the methods declared in this class. | |
61 * @return the methods declared in this class | |
62 */ | |
63 List<MethodElement> get methods; | |
64 /** | |
65 * Return an array containing all of the mixins that are applied to the class
being extended in | |
66 * order to derive the superclass of this class. | |
67 * @return the mixins that are applied to derive the superclass of this class | |
68 */ | |
69 List<InterfaceType> get mixins; | |
70 /** | |
71 * Return the named constructor declared in this class with the given name, or
{@code null} if | |
72 * this class does not declare a named constructor with the given name. | |
73 * @param name the name of the constructor to be returned | |
74 * @return the element representing the specified constructor | |
75 */ | |
76 ConstructorElement getNamedConstructor(String name); | |
77 /** | |
78 * Return the superclass of this class, or {@code null} if the class represent
s the class | |
79 * 'Object'. All other classes will have a non-{@code null} superclass. If the
superclass was not | |
80 * explicitly declared then the implicit superclass 'Object' will be returned. | |
81 * @return the superclass of this class | |
82 */ | |
83 InterfaceType get supertype; | |
84 /** | |
85 * Return the type defined by the class. | |
86 * @return the type defined by the class | |
87 */ | |
88 InterfaceType get type; | |
89 /** | |
90 * Return an array containing all of the type variables declared for this clas
s. | |
91 * @return the type variables declared for this class | |
92 */ | |
93 List<TypeVariableElement> get typeVariables; | |
94 /** | |
95 * Return the unnamed constructor declared in this class, or {@code null} if t
his class does not | |
96 * declare an unnamed constructor but does declare named constructors. The ret
urned constructor | |
97 * will be synthetic if this class does not declare any constructors, in which
case it will | |
98 * represent the default constructor for the class. | |
99 * @return the unnamed constructor defined in this class | |
100 */ | |
101 ConstructorElement get unnamedConstructor; | |
102 /** | |
103 * 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 | |
104 * <i>has unimplemented members</i>. | |
105 * @return {@code true} if this class is abstract | |
106 */ | |
107 bool isAbstract(); | |
108 /** | |
109 * Return {@code true} if this class is defined by a typedef construct. | |
110 * @return {@code true} if this class is defined by a typedef construct | |
111 */ | |
112 bool isTypedef(); | |
113 /** | |
114 * Return {@code true} if this class can validly be used as a mixin when defin
ing another class. | |
115 * The behavior of this method is defined by the Dart Language Specification i
n section 9: | |
116 * <blockquote>It is a compile-time error if a declared or derived mixin refer
s to super. It is a | |
117 * compile-time error if a declared or derived mixin explicitly declares a con
structor. It is a | |
118 * compile-time error if a mixin is derived from a class whose superclass is n
ot | |
119 * Object.</blockquote> | |
120 * @return {@code true} if this class can validly be used as a mixin | |
121 */ | |
122 bool isValidMixin(); | |
123 /** | |
124 * Return the element representing the getter that results from looking up the
given getter in | |
125 * this class with respect to the given library, or {@code null} if the look u
p fails. The | |
126 * behavior of this method is defined by the Dart Language Specification in se
ction 12.15.1: | |
127 * <blockquote>The result of looking up getter (respectively setter) <i>m</i>
in class <i>C</i> | |
128 * with respect to library <i>L</i> is: | |
129 * <ul> | |
130 * <li>If <i>C</i> declares an instance getter (respectively setter) named <i>
m</i> that is | |
131 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. | |
132 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result | |
133 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. | |
134 * Otherwise, we say that the lookup has failed.</li> | |
135 * </ul> | |
136 * </blockquote> | |
137 * @param getterName the name of the getter being looked up | |
138 * @param library the library with respect to which the lookup is being perfor
med | |
139 * @return the result of looking up the given getter in this class with respec
t to the given | |
140 * library | |
141 */ | |
142 PropertyAccessorElement lookUpGetter(String getterName, LibraryElement library
); | |
143 /** | |
144 * Return the element representing the method that results from looking up the
given method in | |
145 * this class with respect to the given library, or {@code null} if the look u
p fails. The | |
146 * behavior of this method is defined by the Dart Language Specification in se
ction 12.15.1: | |
147 * <blockquote> The result of looking up method <i>m</i> in class <i>C</i> wit
h respect to library | |
148 * <i>L</i> is: | |
149 * <ul> | |
150 * <li>If <i>C</i> declares an instance method named <i>m</i> that is accessib
le to <i>L</i>, then | |
151 * that method is the result of the lookup. Otherwise, if <i>C</i> has a super
class <i>S</i>, then | |
152 * the result of the lookup is the result of looking up method <i>m</i> in <i>
S</i> with respect | |
153 * to <i>L</i>. Otherwise, we say that the lookup has failed.</li> | |
154 * </ul> | |
155 * </blockquote> | |
156 * @param methodName the name of the method being looked up | |
157 * @param library the library with respect to which the lookup is being perfor
med | |
158 * @return the result of looking up the given method in this class with respec
t to the given | |
159 * library | |
160 */ | |
161 MethodElement lookUpMethod(String methodName, LibraryElement library); | |
162 /** | |
163 * Return the element representing the setter that results from looking up the
given setter in | |
164 * this class with respect to the given library, or {@code null} if the look u
p fails. The | |
165 * behavior of this method is defined by the Dart Language Specification in se
ction 12.16: | |
166 * <blockquote> The result of looking up getter (respectively setter) <i>m</i>
in class <i>C</i> | |
167 * with respect to library <i>L</i> is: | |
168 * <ul> | |
169 * <li>If <i>C</i> declares an instance getter (respectively setter) named <i>
m</i> that is | |
170 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. | |
171 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result | |
172 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. | |
173 * Otherwise, we say that the lookup has failed.</li> | |
174 * </ul> | |
175 * </blockquote> | |
176 * @param setterName the name of the setter being looked up | |
177 * @param library the library with respect to which the lookup is being perfor
med | |
178 * @return the result of looking up the given setter in this class with respec
t to the given | |
179 * library | |
180 */ | |
181 PropertyAccessorElement lookUpSetter(String setterName, LibraryElement library
); | |
182 } | |
183 /** | |
184 * The interface {@code CompilationUnitElement} defines the behavior of elements
representing a | |
185 * compilation unit. | |
186 * @coverage dart.engine.element | |
187 */ | |
188 abstract class CompilationUnitElement implements Element { | |
189 /** | |
190 * Return an array containing all of the top-level accessors (getters and sett
ers) contained in | |
191 * this compilation unit. | |
192 * @return the top-level accessors contained in this compilation unit | |
193 */ | |
194 List<PropertyAccessorElement> get accessors; | |
195 /** | |
196 * Return the library in which this compilation unit is defined. | |
197 * @return the library in which this compilation unit is defined | |
198 */ | |
199 LibraryElement get enclosingElement; | |
200 /** | |
201 * Return an array containing all of the top-level functions contained in this
compilation unit. | |
202 * @return the top-level functions contained in this compilation unit | |
203 */ | |
204 List<FunctionElement> get functions; | |
205 /** | |
206 * Return an array containing all of the top-level variables contained in this
compilation unit. | |
207 * @return the top-level variables contained in this compilation unit | |
208 */ | |
209 List<TopLevelVariableElement> get topLevelVariables; | |
210 /** | |
211 * Return an array containing all of the type aliases contained in this compil
ation unit. | |
212 * @return the type aliases contained in this compilation unit | |
213 */ | |
214 List<TypeAliasElement> get typeAliases; | |
215 /** | |
216 * Return an array containing all of the classes contained in this compilation
unit. | |
217 * @return the classes contained in this compilation unit | |
218 */ | |
219 List<ClassElement> get types; | |
220 } | |
221 /** | |
222 * The interface {@code ConstructorElement} defines the behavior of elements rep
resenting a | |
223 * constructor or a factory method defined within a type. | |
224 * @coverage dart.engine.element | |
225 */ | |
226 abstract class ConstructorElement implements ExecutableElement { | |
227 /** | |
228 * Return the type in which this constructor is defined. | |
229 * @return the type in which this constructor is defined | |
230 */ | |
231 ClassElement get enclosingElement; | |
232 /** | |
233 * Return {@code true} if this constructor is a const constructor. | |
234 * @return {@code true} if this constructor is a const constructor | |
235 */ | |
236 bool isConst(); | |
237 /** | |
238 * Return {@code true} if this constructor represents a factory constructor. | |
239 * @return {@code true} if this constructor represents a factory constructor | |
240 */ | |
241 bool isFactory(); | |
242 } | |
243 /** | |
244 * The interface {@code Element} defines the behavior common to all of the eleme
nts in the element | |
245 * model. Generally speaking, the element model is a semantic model of the progr
am that represents | |
246 * things that are declared with a name and hence can be referenced elsewhere in
the code. | |
247 * <p> | |
248 * There are two exceptions to the general case. First, there are elements in th
e element model that | |
249 * are created for the convenience of various kinds of analysis but that do not
have any | |
250 * corresponding declaration within the source code. Such elements are marked as
being | |
251 * <i>synthetic</i>. Examples of synthetic elements include | |
252 * <ul> | |
253 * <li>default constructors in classes that do not define any explicit construct
ors, | |
254 * <li>getters and setters that are induced by explicit field declarations, | |
255 * <li>fields that are induced by explicit declarations of getters and setters,
and | |
256 * <li>functions representing the initialization expression for a variable. | |
257 * </ul> | |
258 * <p> | |
259 * Second, there are elements in the element model that do not have a name. Thes
e correspond to | |
260 * unnamed functions and exist in order to more accurately represent the semanti
c structure of the | |
261 * program. | |
262 * @coverage dart.engine.element | |
263 */ | |
264 abstract class Element { | |
265 /** | |
266 * A comparator that can be used to sort elements by their name offset. Elemen
ts with a smaller | |
267 * offset will be sorted to be before elements with a larger name offset. | |
268 */ | |
269 static Comparator<Element> SORT_BY_OFFSET = (Element firstElement, Element sec
ondElement) => firstElement.nameOffset - secondElement.nameOffset; | |
270 /** | |
271 * Use the given visitor to visit this element. | |
272 * @param visitor the visitor that will visit this element | |
273 * @return the value returned by the visitor as a result of visiting this elem
ent | |
274 */ | |
275 accept(ElementVisitor visitor); | |
276 /** | |
277 * 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. | |
278 * @param elementClass the class of the element to be returned | |
279 * @return the element that encloses this element | |
280 */ | |
281 Element getAncestor(Type elementClass); | |
282 /** | |
283 * Return the analysis context in which this element is defined. | |
284 * @return the analysis context in which this element is defined | |
285 */ | |
286 AnalysisContext get context; | |
287 /** | |
288 * 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 | |
289 * model. | |
290 * @return the element that encloses this element | |
291 */ | |
292 Element get enclosingElement; | |
293 /** | |
294 * Return the kind of element that this is. | |
295 * @return the kind of this element | |
296 */ | |
297 ElementKind get kind; | |
298 /** | |
299 * Return the library that contains this element. This will be {@code null} if
this element is a | |
300 * library or HTML file because libraries and HTML files are not contained in
other libraries. | |
301 * @return the library that contains this element | |
302 */ | |
303 LibraryElement get library; | |
304 /** | |
305 * Return an object representing the location of this element in the element m
odel. The object can | |
306 * be used to locate this element at a later time. | |
307 * @return the location of this element in the element model | |
308 */ | |
309 ElementLocation get location; | |
310 /** | |
311 * Return an array containing all of the metadata associated with this element
. | |
312 * @return the metadata associated with this element | |
313 */ | |
314 List<Annotation> get metadata; | |
315 /** | |
316 * Return the name of this element, or {@code null} if this element does not h
ave a name. | |
317 * @return the name of this element | |
318 */ | |
319 String get name; | |
320 /** | |
321 * Return the offset of the name of this element in the file that contains the
declaration of this | |
322 * element, or {@code -1} if this element is synthetic, does not have a name,
or otherwise does | |
323 * not have an offset. | |
324 * @return the offset of the name of this element | |
325 */ | |
326 int get nameOffset; | |
327 /** | |
328 * Return the source that contains this element, or {@code null} if this eleme
nt is not contained | |
329 * in a source. | |
330 * @return the source that contains this element | |
331 */ | |
332 Source get source; | |
333 /** | |
334 * Return {@code true} if this element, assuming that it is within scope, is a
ccessible to code in | |
335 * the given library. This is defined by the Dart Language Specification in se
ction 3.2: | |
336 * <blockquote> A declaration <i>m</i> is accessible to library <i>L</i> if <i
>m</i> is declared | |
337 * in <i>L</i> or if <i>m</i> is public. </blockquote> | |
338 * @param library the library in which a possible reference to this element wo
uld occur | |
339 * @return {@code true} if this element is accessible to code in the given lib
rary | |
340 */ | |
341 bool isAccessibleIn(LibraryElement library); | |
342 /** | |
343 * Return {@code true} if this element is synthetic. A synthetic element is an
element that is not | |
344 * represented in the source code explicitly, but is implied by the source cod
e, such as the | |
345 * default constructor for a class that does not explicitly define any constru
ctors. | |
346 * @return {@code true} if this element is synthetic | |
347 */ | |
348 bool isSynthetic(); | |
349 /** | |
350 * Use the given visitor to visit all of the children of this element. There i
s no guarantee of | |
351 * the order in which the children will be visited. | |
352 * @param visitor the visitor that will be used to visit the children of this
element | |
353 */ | |
354 void visitChildren(ElementVisitor<Object> visitor); | |
355 } | |
356 /** | |
357 * The enumeration {@code ElementKind} defines the various kinds of elements in
the element model. | |
358 * @coverage dart.engine.element | |
359 */ | |
360 class ElementKind { | |
361 static final ElementKind CLASS = new ElementKind('CLASS', 0, "class"); | |
362 static final ElementKind COMPILATION_UNIT = new ElementKind('COMPILATION_UNIT'
, 1, "compilation unit"); | |
363 static final ElementKind CONSTRUCTOR = new ElementKind('CONSTRUCTOR', 2, "cons
tructor"); | |
364 static final ElementKind DYNAMIC = new ElementKind('DYNAMIC', 3, "<dynamic>"); | |
365 static final ElementKind EMBEDDED_HTML_SCRIPT = new ElementKind('EMBEDDED_HTML
_SCRIPT', 4, "embedded html script"); | |
366 static final ElementKind ERROR = new ElementKind('ERROR', 5, "<error>"); | |
367 static final ElementKind EXPORT = new ElementKind('EXPORT', 6, "export directi
ve"); | |
368 static final ElementKind EXTERNAL_HTML_SCRIPT = new ElementKind('EXTERNAL_HTML
_SCRIPT', 7, "external html script"); | |
369 static final ElementKind FIELD = new ElementKind('FIELD', 8, "field"); | |
370 static final ElementKind FUNCTION = new ElementKind('FUNCTION', 9, "function")
; | |
371 static final ElementKind GETTER = new ElementKind('GETTER', 10, "getter"); | |
372 static final ElementKind HTML = new ElementKind('HTML', 11, "html"); | |
373 static final ElementKind IMPORT = new ElementKind('IMPORT', 12, "import direct
ive"); | |
374 static final ElementKind LABEL = new ElementKind('LABEL', 13, "label"); | |
375 static final ElementKind LIBRARY = new ElementKind('LIBRARY', 14, "library"); | |
376 static final ElementKind LOCAL_VARIABLE = new ElementKind('LOCAL_VARIABLE', 15
, "local variable"); | |
377 static final ElementKind METHOD = new ElementKind('METHOD', 16, "method"); | |
378 static final ElementKind NAME = new ElementKind('NAME', 17, "<name>"); | |
379 static final ElementKind PARAMETER = new ElementKind('PARAMETER', 18, "paramet
er"); | |
380 static final ElementKind PREFIX = new ElementKind('PREFIX', 19, "import prefix
"); | |
381 static final ElementKind SETTER = new ElementKind('SETTER', 20, "setter"); | |
382 static final ElementKind TOP_LEVEL_VARIABLE = new ElementKind('TOP_LEVEL_VARIA
BLE', 21, "top level variable"); | |
383 static final ElementKind TYPE_ALIAS = new ElementKind('TYPE_ALIAS', 22, "funct
ion type alias"); | |
384 static final ElementKind TYPE_VARIABLE = new ElementKind('TYPE_VARIABLE', 23,
"type variable"); | |
385 static final ElementKind UNIVERSE = new ElementKind('UNIVERSE', 24, "<universe
>"); | |
386 static final List<ElementKind> values = [CLASS, COMPILATION_UNIT, CONSTRUCTOR,
DYNAMIC, EMBEDDED_HTML_SCRIPT, ERROR, EXPORT, EXTERNAL_HTML_SCRIPT, FIELD, FUNC
TION, GETTER, HTML, IMPORT, LABEL, LIBRARY, LOCAL_VARIABLE, METHOD, NAME, PARAME
TER, PREFIX, SETTER, TOP_LEVEL_VARIABLE, TYPE_ALIAS, TYPE_VARIABLE, UNIVERSE]; | |
387 final String __name; | |
388 final int __ordinal; | |
389 int get ordinal => __ordinal; | |
390 String _displayName; | |
391 ElementKind(this.__name, this.__ordinal, String displayName) { | |
392 this._displayName = displayName; | |
393 } | |
394 /** | |
395 * @return the name of this {@link ElementKind} to display in UI. | |
396 */ | |
397 String get displayName => _displayName; | |
398 String toString() => __name; | |
399 } | |
400 /** | |
401 * The interface {@code ElementLocation} defines the behavior of objects that re
present the location | |
402 * of an element within the element model. | |
403 * @coverage dart.engine.element | |
404 */ | |
405 abstract class ElementLocation { | |
406 /** | |
407 * Return an encoded representation of this location that can be used to creat
e a location that is | |
408 * equal to this location. | |
409 * @return an encoded representation of this location | |
410 */ | |
411 String get encoding; | |
412 } | |
413 /** | |
414 * The interface {@code ElementVisitor} defines the behavior of objects that can
be used to visit an | |
415 * element structure. | |
416 * @coverage dart.engine.element | |
417 */ | |
418 abstract class ElementVisitor<R> { | |
419 R visitClassElement(ClassElement element); | |
420 R visitCompilationUnitElement(CompilationUnitElement element); | |
421 R visitConstructorElement(ConstructorElement element); | |
422 R visitEmbeddedHtmlScriptElement(EmbeddedHtmlScriptElement element); | |
423 R visitExportElement(ExportElement element); | |
424 R visitExternalHtmlScriptElement(ExternalHtmlScriptElement element); | |
425 R visitFieldElement(FieldElement element); | |
426 R visitFunctionElement(FunctionElement element); | |
427 R visitHtmlElement(HtmlElement element); | |
428 R visitImportElement(ImportElement element); | |
429 R visitLabelElement(LabelElement element); | |
430 R visitLibraryElement(LibraryElement element); | |
431 R visitLocalVariableElement(LocalVariableElement element); | |
432 R visitMethodElement(MethodElement element); | |
433 R visitMultiplyDefinedElement(MultiplyDefinedElement element); | |
434 R visitParameterElement(ParameterElement element); | |
435 R visitPrefixElement(PrefixElement element); | |
436 R visitPropertyAccessorElement(PropertyAccessorElement element); | |
437 R visitTopLevelVariableElement(TopLevelVariableElement element); | |
438 R visitTypeAliasElement(TypeAliasElement element); | |
439 R visitTypeVariableElement(TypeVariableElement element); | |
440 } | |
441 /** | |
442 * The interface {@code EmbeddedHtmlScriptElement} defines the behavior of eleme
nts representing a | |
443 * script tag in an HTML file having content that defines a Dart library. | |
444 * @coverage dart.engine.element | |
445 */ | |
446 abstract class EmbeddedHtmlScriptElement implements HtmlScriptElement { | |
447 /** | |
448 * Return the library element defined by the content of the script tag. | |
449 * @return the library element (not {@code null}) | |
450 */ | |
451 LibraryElement get scriptLibrary; | |
452 } | |
453 /** | |
454 * The interface {@code ExecutableElement} defines the behavior of elements repr
esenting an | |
455 * executable object, including functions, methods, constructors, getters, and s
etters. | |
456 * @coverage dart.engine.element | |
457 */ | |
458 abstract class ExecutableElement implements Element { | |
459 /** | |
460 * Return an array containing all of the functions defined within this executa
ble element. | |
461 * @return the functions defined within this executable element | |
462 */ | |
463 List<FunctionElement> get functions; | |
464 /** | |
465 * Return an array containing all of the labels defined within this executable
element. | |
466 * @return the labels defined within this executable element | |
467 */ | |
468 List<LabelElement> get labels; | |
469 /** | |
470 * Return an array containing all of the local variables defined within this e
xecutable element. | |
471 * @return the local variables defined within this executable element | |
472 */ | |
473 List<LocalVariableElement> get localVariables; | |
474 /** | |
475 * Return an array containing all of the parameters defined by this executable
element. | |
476 * @return the parameters defined by this executable element | |
477 */ | |
478 List<ParameterElement> get parameters; | |
479 /** | |
480 * Return the type of function defined by this executable element. | |
481 * @return the type of function defined by this executable element | |
482 */ | |
483 FunctionType get type; | |
484 /** | |
485 * Return {@code true} if this element is a static element. A static element i
s an element that is | |
486 * not associated with a particular instance, but rather with an entire librar
y or class. | |
487 * @return {@code true} if this executable element is a static element | |
488 */ | |
489 bool isStatic(); | |
490 } | |
491 /** | |
492 * The interface {@code ExportElement} defines the behavior of objects represent
ing information | |
493 * about a single export directive within a library. | |
494 * @coverage dart.engine.element | |
495 */ | |
496 abstract class ExportElement implements Element { | |
497 /** | |
498 * An empty array of export elements. | |
499 */ | |
500 static List<ExportElement> EMPTY_ARRAY = new List<ExportElement>(0); | |
501 /** | |
502 * Return an array containing the combinators that were specified as part of t
he export directive | |
503 * in the order in which they were specified. | |
504 * @return the combinators specified in the export directive | |
505 */ | |
506 List<NamespaceCombinator> get combinators; | |
507 /** | |
508 * Return the library that is exported from this library by this export direct
ive. | |
509 * @return the library that is exported from this library | |
510 */ | |
511 LibraryElement get exportedLibrary; | |
512 } | |
513 /** | |
514 * The interface {@code ExternalHtmlScriptElement} defines the behavior of eleme
nts representing a | |
515 * script tag in an HTML file having a {@code source} attribute that references
a Dart library | |
516 * source file. | |
517 * @coverage dart.engine.element | |
518 */ | |
519 abstract class ExternalHtmlScriptElement implements HtmlScriptElement { | |
520 /** | |
521 * Return the source referenced by this element, or {@code null} if this eleme
nt does not | |
522 * reference a Dart library source file. | |
523 * @return the source for the external Dart library | |
524 */ | |
525 Source get scriptSource; | |
526 } | |
527 /** | |
528 * The interface {@code FieldElement} defines the behavior of elements represent
ing a field defined | |
529 * within a type. | |
530 * @coverage dart.engine.element | |
531 */ | |
532 abstract class FieldElement implements PropertyInducingElement { | |
533 /** | |
534 * Return the type in which this field is defined. | |
535 * @return the type in which this field is defined | |
536 */ | |
537 ClassElement get enclosingElement; | |
538 } | |
539 /** | |
540 * The interface {@code FunctionElement} defines the behavior of elements repres
enting a function. | |
541 * @coverage dart.engine.element | |
542 */ | |
543 abstract class FunctionElement implements ExecutableElement, LocalElement { | |
544 } | |
545 /** | |
546 * The interface {@code HideCombinator} defines the behavior of combinators that
cause some of the | |
547 * names in a namespace to be hidden when being imported. | |
548 * @coverage dart.engine.element | |
549 */ | |
550 abstract class HideCombinator implements NamespaceCombinator { | |
551 /** | |
552 * Return an array containing the names that are not to be made visible in the
importing library | |
553 * even if they are defined in the imported library. | |
554 * @return the names from the imported library that are hidden from the import
ing library | |
555 */ | |
556 List<String> get hiddenNames; | |
557 } | |
558 /** | |
559 * The interface {@code HtmlElement} defines the behavior of elements representi
ng an HTML file. | |
560 * @coverage dart.engine.element | |
561 */ | |
562 abstract class HtmlElement implements Element { | |
563 /** | |
564 * Return an array containing all of the script elements contained in the HTML
file. This includes | |
565 * scripts with libraries that are defined by the content of a script tag as w
ell as libraries | |
566 * that are referenced in the {@core source} attribute of a script tag. | |
567 * @return the script elements in the HTML file (not {@code null}, contains no
{@code null}s) | |
568 */ | |
569 List<HtmlScriptElement> get scripts; | |
570 } | |
571 /** | |
572 * The interface {@code HtmlScriptElement} defines the behavior of elements repr
esenting a script | |
573 * tag in an HTML file. | |
574 * @see EmbeddedHtmlScriptElement | |
575 * @see ExternalHtmlScriptElement | |
576 * @coverage dart.engine.element | |
577 */ | |
578 abstract class HtmlScriptElement implements Element { | |
579 } | |
580 /** | |
581 * The interface {@code ImportElement} defines the behavior of objects represent
ing information | |
582 * about a single import directive within a library. | |
583 * @coverage dart.engine.element | |
584 */ | |
585 abstract class ImportElement implements Element { | |
586 /** | |
587 * An empty array of import elements. | |
588 */ | |
589 static List<ImportElement> EMPTY_ARRAY = new List<ImportElement>(0); | |
590 /** | |
591 * Return an array containing the combinators that were specified as part of t
he import directive | |
592 * in the order in which they were specified. | |
593 * @return the combinators specified in the import directive | |
594 */ | |
595 List<NamespaceCombinator> get combinators; | |
596 /** | |
597 * Return the library that is imported into this library by this import direct
ive. | |
598 * @return the library that is imported into this library | |
599 */ | |
600 LibraryElement get importedLibrary; | |
601 /** | |
602 * Return the prefix that was specified as part of the import directive, or {@
code null} if there | |
603 * was no prefix specified. | |
604 * @return the prefix that was specified as part of the import directive | |
605 */ | |
606 PrefixElement get prefix; | |
607 } | |
608 /** | |
609 * The interface {@code LabelElement} defines the behavior of elements represent
ing a label | |
610 * associated with a statement. | |
611 * @coverage dart.engine.element | |
612 */ | |
613 abstract class LabelElement implements Element { | |
614 /** | |
615 * Return the executable element in which this label is defined. | |
616 * @return the executable element in which this label is defined | |
617 */ | |
618 ExecutableElement get enclosingElement; | |
619 } | |
620 /** | |
621 * The interface {@code LibraryElement} defines the behavior of elements represe
nting a library. | |
622 * @coverage dart.engine.element | |
623 */ | |
624 abstract class LibraryElement implements Element { | |
625 /** | |
626 * Return the compilation unit that defines this library. | |
627 * @return the compilation unit that defines this library | |
628 */ | |
629 CompilationUnitElement get definingCompilationUnit; | |
630 /** | |
631 * Return the entry point for this library, or {@code null} if this library do
es not have an entry | |
632 * point. The entry point is defined to be a zero argument top-level function
whose name is{@code main}. | |
633 * @return the entry point for this library | |
634 */ | |
635 FunctionElement get entryPoint; | |
636 /** | |
637 * Return an array containing all of the libraries that are exported from this
library. | |
638 * @return an array containing all of the libraries that are exported from thi
s library | |
639 */ | |
640 List<LibraryElement> get exportedLibraries; | |
641 /** | |
642 * Return an array containing all of the exports defined in this library. | |
643 * @return the exports defined in this library | |
644 */ | |
645 List<ExportElement> get exports; | |
646 /** | |
647 * Return an array containing all of the libraries that are imported into this
library. This | |
648 * includes all of the libraries that are imported using a prefix (also availa
ble through the | |
649 * prefixes returned by {@link #getPrefixes()}) and those that are imported wi
thout a prefix. | |
650 * @return an array containing all of the libraries that are imported into thi
s library | |
651 */ | |
652 List<LibraryElement> get importedLibraries; | |
653 /** | |
654 * Return an array containing all of the imports defined in this library. | |
655 * @return the imports defined in this library | |
656 */ | |
657 List<ImportElement> get imports; | |
658 /** | |
659 * Return an array containing all of the compilation units that are included i
n this library using | |
660 * a {@code part} directive. This does not include the defining compilation un
it that contains the{@code part} directives. | |
661 * @return the compilation units that are included in this library | |
662 */ | |
663 List<CompilationUnitElement> get parts; | |
664 /** | |
665 * Return an array containing elements for each of the prefixes used to {@code
import} libraries | |
666 * into this library. Each prefix can be used in more than one {@code import}
directive. | |
667 * @return the prefixes used to {@code import} libraries into this library | |
668 */ | |
669 List<PrefixElement> get prefixes; | |
670 /** | |
671 * Answer {@code true} if this library is an application that can be run in th
e browser. | |
672 * @return {@code true} if this library is an application that can be run in t
he browser | |
673 */ | |
674 bool isBrowserApplication(); | |
675 /** | |
676 * Return {@code true} if this library is the dart:core library. | |
677 * @return {@code true} if this library is the dart:core library | |
678 */ | |
679 bool isDartCore(); | |
680 /** | |
681 * Return {@code true} if this library is up to date with respect to the given
time stamp. If any | |
682 * transitively referenced Source is newer than the time stamp, this method re
turns false. | |
683 * @param timeStamp the time stamp to compare against | |
684 * @return {@code true} if this library is up to date with respect to the give
n time stamp | |
685 */ | |
686 bool isUpToDate2(int timeStamp); | |
687 } | |
688 /** | |
689 * The interface {@code LocalElement} defines the behavior of elements that can
be (but are not | |
690 * required to be) defined within a method or function (an {@link ExecutableElem
ent}). | |
691 * @coverage dart.engine.element | |
692 */ | |
693 abstract class LocalElement implements Element { | |
694 /** | |
695 * Return a source range that covers the approximate portion of the source in
which the name of | |
696 * this element is visible, or {@code null} if there is no single range of cha
racters within which | |
697 * the element name is visible. | |
698 * <ul> | |
699 * <li>For a local variable, this includes everything from the end of the vari
able's initializer | |
700 * to the end of the block that encloses the variable declaration.</li> | |
701 * <li>For a parameter, this includes the body of the method or function that
declares the | |
702 * parameter.</li> | |
703 * <li>For a local function, this includes everything from the beginning of th
e function's body to | |
704 * the end of the block that encloses the function declaration.</li> | |
705 * <li>For top-level functions, {@code null} will be returned because they are
potentially visible | |
706 * in multiple sources.</li> | |
707 * </ul> | |
708 * @return the range of characters in which the name of this element is visibl
e | |
709 */ | |
710 SourceRange get visibleRange; | |
711 } | |
712 /** | |
713 * The interface {@code LocalVariableElement} defines the behavior common to ele
ments that represent | |
714 * a local variable. | |
715 * @coverage dart.engine.element | |
716 */ | |
717 abstract class LocalVariableElement implements LocalElement, VariableElement { | |
718 } | |
719 /** | |
720 * The interface {@code MethodElement} defines the behavior of elements that rep
resent a method | |
721 * defined within a type. | |
722 * @coverage dart.engine.element | |
723 */ | |
724 abstract class MethodElement implements ExecutableElement { | |
725 /** | |
726 * Return the type in which this method is defined. | |
727 * @return the type in which this method is defined | |
728 */ | |
729 ClassElement get enclosingElement; | |
730 /** | |
731 * Return {@code true} if this method is abstract. Methods are abstract if the
y are not external | |
732 * and have no body. | |
733 * @return {@code true} if this method is abstract | |
734 */ | |
735 bool isAbstract(); | |
736 } | |
737 /** | |
738 * The interface {@code MultiplyDefinedElement} defines the behavior of pseudo-e
lements that | |
739 * represent multiple elements defined within a single scope that have the same
name. This situation | |
740 * is not allowed by the language, so objects implementing this interface always
represent an error. | |
741 * As a result, most of the normal operations on elements do not make sense and
will return useless | |
742 * results. | |
743 * @coverage dart.engine.element | |
744 */ | |
745 abstract class MultiplyDefinedElement implements Element { | |
746 /** | |
747 * Return an array containing all of the elements that were defined within the
scope to have the | |
748 * same name. | |
749 * @return the elements that were defined with the same name | |
750 */ | |
751 List<Element> get conflictingElements; | |
752 } | |
753 /** | |
754 * The interface {@code NamespaceCombinator} defines the behavior common to obje
cts that control how | |
755 * namespaces are combined. | |
756 * @coverage dart.engine.element | |
757 */ | |
758 abstract class NamespaceCombinator { | |
759 /** | |
760 * An empty array of namespace combinators. | |
761 */ | |
762 static List<NamespaceCombinator> EMPTY_ARRAY = new List<NamespaceCombinator>(0
); | |
763 } | |
764 /** | |
765 * The interface {@code ParameterElement} defines the behavior of elements repre
senting a parameter | |
766 * defined within an executable element. | |
767 * @coverage dart.engine.element | |
768 */ | |
769 abstract class ParameterElement implements LocalElement, VariableElement { | |
770 /** | |
771 * Return the kind of this parameter. | |
772 * @return the kind of this parameter | |
773 */ | |
774 ParameterKind get parameterKind; | |
775 /** | |
776 * Return {@code true} if this parameter is an initializing formal parameter. | |
777 * @return {@code true} if this parameter is an initializing formal parameter | |
778 */ | |
779 bool isInitializingFormal(); | |
780 } | |
781 /** | |
782 * The interface {@code PrefixElement} defines the behavior common to elements t
hat represent a | |
783 * prefix used to import one or more libraries into another library. | |
784 * @coverage dart.engine.element | |
785 */ | |
786 abstract class PrefixElement implements Element { | |
787 /** | |
788 * Return the library into which other libraries are imported using this prefi
x. | |
789 * @return the library into which other libraries are imported using this pref
ix | |
790 */ | |
791 LibraryElement get enclosingElement; | |
792 /** | |
793 * Return an array containing all of the libraries that are imported using thi
s prefix. | |
794 * @return the libraries that are imported using this prefix | |
795 */ | |
796 List<LibraryElement> get importedLibraries; | |
797 } | |
798 /** | |
799 * The interface {@code PropertyAccessorElement} defines the behavior of element
s representing a | |
800 * getter or a setter. Note that explicitly defined property accessors implicitl
y define a synthetic | |
801 * field. Symmetrically, synthetic accessors are implicitly created for explicit
ly defined fields. | |
802 * The following rules apply: | |
803 * <ul> | |
804 * <li>Every explicit field is represented by a non-synthetic {@link FieldElemen
t}. | |
805 * <li>Every explicit field induces a getter and possibly a setter, both of whic
h are represented by | |
806 * synthetic {@link PropertyAccessorElement}s. | |
807 * <li>Every explicit getter or setter is represented by a non-synthetic{@link P
ropertyAccessorElement}. | |
808 * <li>Every explicit getter or setter (or pair thereof if they have the same na
me) induces a field | |
809 * that is represented by a synthetic {@link FieldElement}. | |
810 * </ul> | |
811 * @coverage dart.engine.element | |
812 */ | |
813 abstract class PropertyAccessorElement implements ExecutableElement { | |
814 /** | |
815 * Return the field or top-level variable associated with this accessor. If th
is accessor was | |
816 * explicitly defined (is not synthetic) then the variable associated with it
will be synthetic. | |
817 * @return the variable associated with this accessor | |
818 */ | |
819 PropertyInducingElement get variable; | |
820 /** | |
821 * Return {@code true} if this accessor represents a getter. | |
822 * @return {@code true} if this accessor represents a getter | |
823 */ | |
824 bool isGetter(); | |
825 /** | |
826 * Return {@code true} if this accessor represents a setter. | |
827 * @return {@code true} if this accessor represents a setter | |
828 */ | |
829 bool isSetter(); | |
830 } | |
831 /** | |
832 * The interface {@code PropertyInducingElement} defines the behavior of element
s representing a | |
833 * variable that has an associated getter and possibly a setter. Note that expli
citly defined | |
834 * variables implicitly define a synthetic getter and that non-{@code final} exp
licitly defined | |
835 * variables implicitly define a synthetic setter. Symmetrically, synthetic fiel
ds are implicitly | |
836 * created for explicitly defined getters and setters. The following rules apply
: | |
837 * <ul> | |
838 * <li>Every explicit variable is represented by a non-synthetic {@link Property
InducingElement}. | |
839 * <li>Every explicit variable induces a getter and possibly a setter, both of w
hich are represented | |
840 * by synthetic {@link PropertyAccessorElement}s. | |
841 * <li>Every explicit getter or setter is represented by a non-synthetic{@link P
ropertyAccessorElement}. | |
842 * <li>Every explicit getter or setter (or pair thereof if they have the same na
me) induces a | |
843 * variable that is represented by a synthetic {@link PropertyInducingElement}. | |
844 * </ul> | |
845 * @coverage dart.engine.element | |
846 */ | |
847 abstract class PropertyInducingElement implements VariableElement { | |
848 /** | |
849 * Return the getter associated with this variable. If this variable was expli
citly defined (is | |
850 * not synthetic) then the getter associated with it will be synthetic. | |
851 * @return the getter associated with this variable | |
852 */ | |
853 PropertyAccessorElement get getter; | |
854 /** | |
855 * Return the setter associated with this variable, or {@code null} if the var
iable is effectively{@code final} and therefore does not have a setter associate
d with it. (This can happen either | |
856 * because the variable is explicitly defined as being {@code final} or becaus
e the variable is | |
857 * induced by an explicit getter that does not have a corresponding setter.) I
f this variable was | |
858 * explicitly defined (is not synthetic) then the setter associated with it wi
ll be synthetic. | |
859 * @return the setter associated with this variable | |
860 */ | |
861 PropertyAccessorElement get setter; | |
862 /** | |
863 * Return {@code true} if this element is a static element. A static element i
s an element that is | |
864 * not associated with a particular instance, but rather with an entire librar
y or class. | |
865 * @return {@code true} if this executable element is a static element | |
866 */ | |
867 bool isStatic(); | |
868 } | |
869 /** | |
870 * The interface {@code ShowCombinator} defines the behavior of combinators that
cause some of the | |
871 * names in a namespace to be visible (and the rest hidden) when being imported. | |
872 * @coverage dart.engine.element | |
873 */ | |
874 abstract class ShowCombinator implements NamespaceCombinator { | |
875 /** | |
876 * Return an array containing the names that are to be made visible in the imp
orting library if | |
877 * they are defined in the imported library. | |
878 * @return the names from the imported library that are visible in the importi
ng library | |
879 */ | |
880 List<String> get shownNames; | |
881 } | |
882 /** | |
883 * The interface {@code TopLevelVariableElement} defines the behavior of element
s representing a | |
884 * top-level variable. | |
885 * @coverage dart.engine.element | |
886 */ | |
887 abstract class TopLevelVariableElement implements PropertyInducingElement { | |
888 } | |
889 /** | |
890 * The interface {@code TypeAliasElement} defines the behavior of elements repre
senting a type alias | |
891 * ({@code typedef}). | |
892 * @coverage dart.engine.element | |
893 */ | |
894 abstract class TypeAliasElement implements Element { | |
895 /** | |
896 * Return the compilation unit in which this type alias is defined. | |
897 * @return the compilation unit in which this type alias is defined | |
898 */ | |
899 CompilationUnitElement get enclosingElement; | |
900 /** | |
901 * Return an array containing all of the parameters defined by this type alias
. | |
902 * @return the parameters defined by this type alias | |
903 */ | |
904 List<ParameterElement> get parameters; | |
905 /** | |
906 * Return the type of function defined by this type alias. | |
907 * @return the type of function defined by this type alias | |
908 */ | |
909 FunctionType get type; | |
910 /** | |
911 * Return an array containing all of the type variables defined for this type. | |
912 * @return the type variables defined for this type | |
913 */ | |
914 List<TypeVariableElement> get typeVariables; | |
915 } | |
916 /** | |
917 * The interface {@code TypeVariableElement} defines the behavior of elements re
presenting a type | |
918 * variable. | |
919 * @coverage dart.engine.element | |
920 */ | |
921 abstract class TypeVariableElement implements Element { | |
922 /** | |
923 * Return the type representing the bound associated with this variable, or {@
code null} if this | |
924 * variable does not have an explicit bound. | |
925 * @return the type representing the bound associated with this variable | |
926 */ | |
927 Type2 get bound; | |
928 /** | |
929 * Return the type defined by this type variable. | |
930 * @return the type defined by this type variable | |
931 */ | |
932 TypeVariableType get type; | |
933 } | |
934 /** | |
935 * The interface {@code UndefinedElement} defines the behavior of pseudo-element
s that represent | |
936 * names that are undefined. This situation is not allowed by the language, so o
bjects implementing | |
937 * this interface always represent an error. As a result, most of the normal ope
rations on elements | |
938 * do not make sense and will return useless results. | |
939 * @coverage dart.engine.element | |
940 */ | |
941 abstract class UndefinedElement implements Element { | |
942 } | |
943 /** | |
944 * The interface {@code VariableElement} defines the behavior common to elements
that represent a | |
945 * variable. | |
946 * @coverage dart.engine.element | |
947 */ | |
948 abstract class VariableElement implements Element { | |
949 /** | |
950 * Return a synthetic function representing this variable's initializer, or {@
code null} if this | |
951 * variable does not have an initializer. The function will have no parameters
. The return type of | |
952 * the function will be the compile-time type of the initialization expression
. | |
953 * @return a synthetic function representing this variable's initializer | |
954 */ | |
955 FunctionElement get initializer; | |
956 /** | |
957 * Return the declared type of this variable, or {@code null} if the variable
did not have a | |
958 * declared type (such as if it was declared using the keyword 'var'). | |
959 * @return the declared type of this variable | |
960 */ | |
961 Type2 get type; | |
962 /** | |
963 * Return {@code true} if this variable was declared with the 'const' modifier
. | |
964 * @return {@code true} if this variable was declared with the 'const' modifie
r | |
965 */ | |
966 bool isConst(); | |
967 /** | |
968 * Return {@code true} if this variable was declared with the 'final' modifier
. Variables that are | |
969 * declared with the 'const' modifier will return {@code false} even though th
ey are implicitly | |
970 * final. | |
971 * @return {@code true} if this variable was declared with the 'final' modifie
r | |
972 */ | |
973 bool isFinal(); | |
974 } | |
975 /** | |
976 * Instances of the class {@code GeneralizingElementVisitor} implement an elemen
t visitor that will | |
977 * recursively visit all of the elements in an element model (like instances of
the class{@link RecursiveElementVisitor}). In addition, when an element of a spe
cific type is visited not | |
978 * only will the visit method for that specific type of element be invoked, but
additional methods | |
979 * for the supertypes of that element will also be invoked. For example, using a
n instance of this | |
980 * class to visit a {@link MethodElement} will cause the method{@link #visitMeth
odElement(MethodElement)} to be invoked but will also cause the methods{@link #v
isitExecutableElement(ExecutableElement)} and {@link #visitElement(Element)} to
be | |
981 * subsequently invoked. This allows visitors to be written that visit all execu
table elements | |
982 * without needing to override the visit method for each of the specific subclas
ses of{@link ExecutableElement}. | |
983 * <p> | |
984 * Note, however, that unlike many visitors, element visitors visit objects base
d on the interfaces | |
985 * implemented by those elements. Because interfaces form a graph structure rath
er than a tree | |
986 * structure the way classes do, and because it is generally undesirable for an
object to be visited | |
987 * more than once, this class flattens the interface graph into a pseudo-tree. I
n particular, this | |
988 * class treats elements as if the element types were structured in the followin
g way: | |
989 * <p> | |
990 * <pre> | |
991 * Element | |
992 * ClassElement | |
993 * CompilationUnitElement | |
994 * ExecutableElement | |
995 * ConstructorElement | |
996 * LocalElement | |
997 * FunctionElement | |
998 * MethodElement | |
999 * PropertyAccessorElement | |
1000 * ExportElement | |
1001 * HtmlElement | |
1002 * ImportElement | |
1003 * LabelElement | |
1004 * LibraryElement | |
1005 * MultiplyDefinedElement | |
1006 * PrefixElement | |
1007 * TypeAliasElement | |
1008 * TypeVariableElement | |
1009 * UndefinedElement | |
1010 * VariableElement | |
1011 * PropertyInducingElement | |
1012 * FieldElement | |
1013 * TopLevelVariableElement | |
1014 * LocalElement | |
1015 * LocalVariableElement | |
1016 * ParameterElement | |
1017 * </pre> | |
1018 * <p> | |
1019 * Subclasses that override a visit method must either invoke the overridden vis
it method or | |
1020 * explicitly invoke the more general visit method. Failure to do so will cause
the visit methods | |
1021 * for superclasses of the element to not be invoked and will cause the children
of the visited node | |
1022 * to not be visited. | |
1023 * @coverage dart.engine.element | |
1024 */ | |
1025 class GeneralizingElementVisitor<R> implements ElementVisitor<R> { | |
1026 R visitClassElement(ClassElement element) => visitElement(element); | |
1027 R visitCompilationUnitElement(CompilationUnitElement element) => visitElement(
element); | |
1028 R visitConstructorElement(ConstructorElement element) => visitExecutableElemen
t(element); | |
1029 R visitElement(Element element) { | |
1030 element.visitChildren(this); | |
1031 return null; | |
1032 } | |
1033 R visitEmbeddedHtmlScriptElement(EmbeddedHtmlScriptElement element) => visitHt
mlScriptElement(element); | |
1034 R visitExecutableElement(ExecutableElement element) => visitElement(element); | |
1035 R visitExportElement(ExportElement element) => visitElement(element); | |
1036 R visitExternalHtmlScriptElement(ExternalHtmlScriptElement element) => visitHt
mlScriptElement(element); | |
1037 R visitFieldElement(FieldElement element) => visitPropertyInducingElement(elem
ent); | |
1038 R visitFunctionElement(FunctionElement element) => visitLocalElement(element); | |
1039 R visitHtmlElement(HtmlElement element) => visitElement(element); | |
1040 R visitHtmlScriptElement(HtmlScriptElement element) => visitElement(element); | |
1041 R visitImportElement(ImportElement element) => visitElement(element); | |
1042 R visitLabelElement(LabelElement element) => visitElement(element); | |
1043 R visitLibraryElement(LibraryElement element) => visitElement(element); | |
1044 R visitLocalElement(LocalElement element) { | |
1045 if (element is LocalVariableElement) { | |
1046 return visitVariableElement((element as LocalVariableElement)); | |
1047 } else if (element is ParameterElement) { | |
1048 return visitVariableElement((element as ParameterElement)); | |
1049 } else if (element is FunctionElement) { | |
1050 return visitExecutableElement((element as FunctionElement)); | |
1051 } | |
1052 return null; | |
1053 } | |
1054 R visitLocalVariableElement(LocalVariableElement element) => visitLocalElement
(element); | |
1055 R visitMethodElement(MethodElement element) => visitExecutableElement(element)
; | |
1056 R visitMultiplyDefinedElement(MultiplyDefinedElement element) => visitElement(
element); | |
1057 R visitParameterElement(ParameterElement element) => visitLocalElement(element
); | |
1058 R visitPrefixElement(PrefixElement element) => visitElement(element); | |
1059 R visitPropertyAccessorElement(PropertyAccessorElement element) => visitExecut
ableElement(element); | |
1060 R visitPropertyInducingElement(PropertyInducingElement element) => visitVariab
leElement(element); | |
1061 R visitTopLevelVariableElement(TopLevelVariableElement element) => visitProper
tyInducingElement(element); | |
1062 R visitTypeAliasElement(TypeAliasElement element) => visitElement(element); | |
1063 R visitTypeVariableElement(TypeVariableElement element) => visitElement(elemen
t); | |
1064 R visitVariableElement(VariableElement element) => visitElement(element); | |
1065 } | |
1066 /** | |
1067 * Instances of the class {@code RecursiveElementVisitor} implement an element v
isitor that will | |
1068 * recursively visit all of the element in an element model. For example, using
an instance of this | |
1069 * class to visit a {@link CompilationUnitElement} will also cause all of the ty
pes in the | |
1070 * compilation unit to be visited. | |
1071 * <p> | |
1072 * Subclasses that override a visit method must either invoke the overridden vis
it method or must | |
1073 * explicitly ask the visited element to visit its children. Failure to do so wi
ll cause the | |
1074 * children of the visited element to not be visited. | |
1075 * @coverage dart.engine.element | |
1076 */ | |
1077 class RecursiveElementVisitor<R> implements ElementVisitor<R> { | |
1078 R visitClassElement(ClassElement element) { | |
1079 element.visitChildren(this); | |
1080 return null; | |
1081 } | |
1082 R visitCompilationUnitElement(CompilationUnitElement element) { | |
1083 element.visitChildren(this); | |
1084 return null; | |
1085 } | |
1086 R visitConstructorElement(ConstructorElement element) { | |
1087 element.visitChildren(this); | |
1088 return null; | |
1089 } | |
1090 R visitEmbeddedHtmlScriptElement(EmbeddedHtmlScriptElement element) { | |
1091 element.visitChildren(this); | |
1092 return null; | |
1093 } | |
1094 R visitExportElement(ExportElement element) { | |
1095 element.visitChildren(this); | |
1096 return null; | |
1097 } | |
1098 R visitExternalHtmlScriptElement(ExternalHtmlScriptElement element) { | |
1099 element.visitChildren(this); | |
1100 return null; | |
1101 } | |
1102 R visitFieldElement(FieldElement element) { | |
1103 element.visitChildren(this); | |
1104 return null; | |
1105 } | |
1106 R visitFunctionElement(FunctionElement element) { | |
1107 element.visitChildren(this); | |
1108 return null; | |
1109 } | |
1110 R visitHtmlElement(HtmlElement element) { | |
1111 element.visitChildren(this); | |
1112 return null; | |
1113 } | |
1114 R visitImportElement(ImportElement element) { | |
1115 element.visitChildren(this); | |
1116 return null; | |
1117 } | |
1118 R visitLabelElement(LabelElement element) { | |
1119 element.visitChildren(this); | |
1120 return null; | |
1121 } | |
1122 R visitLibraryElement(LibraryElement element) { | |
1123 element.visitChildren(this); | |
1124 return null; | |
1125 } | |
1126 R visitLocalVariableElement(LocalVariableElement element) { | |
1127 element.visitChildren(this); | |
1128 return null; | |
1129 } | |
1130 R visitMethodElement(MethodElement element) { | |
1131 element.visitChildren(this); | |
1132 return null; | |
1133 } | |
1134 R visitMultiplyDefinedElement(MultiplyDefinedElement element) { | |
1135 element.visitChildren(this); | |
1136 return null; | |
1137 } | |
1138 R visitParameterElement(ParameterElement element) { | |
1139 element.visitChildren(this); | |
1140 return null; | |
1141 } | |
1142 R visitPrefixElement(PrefixElement element) { | |
1143 element.visitChildren(this); | |
1144 return null; | |
1145 } | |
1146 R visitPropertyAccessorElement(PropertyAccessorElement element) { | |
1147 element.visitChildren(this); | |
1148 return null; | |
1149 } | |
1150 R visitTopLevelVariableElement(TopLevelVariableElement element) { | |
1151 element.visitChildren(this); | |
1152 return null; | |
1153 } | |
1154 R visitTypeAliasElement(TypeAliasElement element) { | |
1155 element.visitChildren(this); | |
1156 return null; | |
1157 } | |
1158 R visitTypeVariableElement(TypeVariableElement element) { | |
1159 element.visitChildren(this); | |
1160 return null; | |
1161 } | |
1162 } | |
1163 /** | |
1164 * Instances of the class {@code SimpleElementVisitor} implement an element visi
tor that will do | |
1165 * nothing when visiting an element. It is intended to be a superclass for class
es that use the | |
1166 * visitor pattern primarily as a dispatch mechanism (and hence don't need to re
cursively visit a | |
1167 * whole structure) and that only need to visit a small number of element types. | |
1168 * @coverage dart.engine.element | |
1169 */ | |
1170 class SimpleElementVisitor<R> implements ElementVisitor<R> { | |
1171 R visitClassElement(ClassElement element) => null; | |
1172 R visitCompilationUnitElement(CompilationUnitElement element) => null; | |
1173 R visitConstructorElement(ConstructorElement element) => null; | |
1174 R visitEmbeddedHtmlScriptElement(EmbeddedHtmlScriptElement element) => null; | |
1175 R visitExportElement(ExportElement element) => null; | |
1176 R visitExternalHtmlScriptElement(ExternalHtmlScriptElement element) => null; | |
1177 R visitFieldElement(FieldElement element) => null; | |
1178 R visitFunctionElement(FunctionElement element) => null; | |
1179 R visitHtmlElement(HtmlElement element) => null; | |
1180 R visitImportElement(ImportElement element) => null; | |
1181 R visitLabelElement(LabelElement element) => null; | |
1182 R visitLibraryElement(LibraryElement element) => null; | |
1183 R visitLocalVariableElement(LocalVariableElement element) => null; | |
1184 R visitMethodElement(MethodElement element) => null; | |
1185 R visitMultiplyDefinedElement(MultiplyDefinedElement element) => null; | |
1186 R visitParameterElement(ParameterElement element) => null; | |
1187 R visitPrefixElement(PrefixElement element) => null; | |
1188 R visitPropertyAccessorElement(PropertyAccessorElement element) => null; | |
1189 R visitTopLevelVariableElement(TopLevelVariableElement element) => null; | |
1190 R visitTypeAliasElement(TypeAliasElement element) => null; | |
1191 R visitTypeVariableElement(TypeVariableElement element) => null; | |
1192 } | |
1193 /** | |
1194 * Instances of the class {@code AnnotationImpl} implement an {@link Annotation}
. | |
1195 * @coverage dart.engine.element | |
1196 */ | |
1197 class AnnotationImpl implements Annotation { | |
1198 /** | |
1199 * The element representing the field, variable, or constructor being used as
an annotation. | |
1200 */ | |
1201 Element _element; | |
1202 /** | |
1203 * An empty array of annotations. | |
1204 */ | |
1205 static List<AnnotationImpl> EMPTY_ARRAY = new List<AnnotationImpl>(0); | |
1206 /** | |
1207 * Initialize a newly created annotation. | |
1208 * @param element the element representing the field, variable, or constructor
being used as an | |
1209 * annotation | |
1210 */ | |
1211 AnnotationImpl(Element element) { | |
1212 this._element = element; | |
1213 } | |
1214 Element get element => _element; | |
1215 String toString() => "@${_element.toString()}"; | |
1216 } | |
1217 /** | |
1218 * Instances of the class {@code ClassElementImpl} implement a {@code ClassEleme
nt}. | |
1219 * @coverage dart.engine.element | |
1220 */ | |
1221 class ClassElementImpl extends ElementImpl implements ClassElement { | |
1222 /** | |
1223 * An array containing all of the accessors (getters and setters) contained in
this class. | |
1224 */ | |
1225 List<PropertyAccessorElement> _accessors = PropertyAccessorElementImpl.EMPTY_A
RRAY; | |
1226 /** | |
1227 * An array containing all of the constructors contained in this class. | |
1228 */ | |
1229 List<ConstructorElement> _constructors = ConstructorElementImpl.EMPTY_ARRAY; | |
1230 /** | |
1231 * An array containing all of the fields contained in this class. | |
1232 */ | |
1233 List<FieldElement> _fields = FieldElementImpl.EMPTY_ARRAY; | |
1234 /** | |
1235 * An array containing all of the mixins that are applied to the class being e
xtended in order to | |
1236 * derive the superclass of this class. | |
1237 */ | |
1238 List<InterfaceType> _mixins = InterfaceTypeImpl.EMPTY_ARRAY; | |
1239 /** | |
1240 * An array containing all of the interfaces that are implemented by this clas
s. | |
1241 */ | |
1242 List<InterfaceType> _interfaces = InterfaceTypeImpl.EMPTY_ARRAY; | |
1243 /** | |
1244 * An array containing all of the methods contained in this class. | |
1245 */ | |
1246 List<MethodElement> _methods = MethodElementImpl.EMPTY_ARRAY; | |
1247 /** | |
1248 * The superclass of the class, or {@code null} if the class does not have an
explicit superclass. | |
1249 */ | |
1250 InterfaceType _supertype; | |
1251 /** | |
1252 * The type defined by the class. | |
1253 */ | |
1254 InterfaceType _type; | |
1255 /** | |
1256 * An array containing all of the type variables defined for this class. | |
1257 */ | |
1258 List<TypeVariableElement> _typeVariables = TypeVariableElementImpl.EMPTY_ARRAY
; | |
1259 /** | |
1260 * An empty array of type elements. | |
1261 */ | |
1262 static List<ClassElement> EMPTY_ARRAY = new List<ClassElement>(0); | |
1263 /** | |
1264 * Initialize a newly created class element to have the given name. | |
1265 * @param name the name of this element | |
1266 */ | |
1267 ClassElementImpl(Identifier name) : super.con1(name) { | |
1268 } | |
1269 accept(ElementVisitor visitor) => visitor.visitClassElement(this); | |
1270 List<PropertyAccessorElement> get accessors => _accessors; | |
1271 List<InterfaceType> get allSupertypes { | |
1272 Collection<InterfaceType> list = new Set<InterfaceType>(); | |
1273 collectAllSupertypes(list); | |
1274 return new List.from(list); | |
1275 } | |
1276 ElementImpl getChild(String identifier25) { | |
1277 for (PropertyAccessorElement accessor in _accessors) { | |
1278 if (((accessor as PropertyAccessorElementImpl)).identifier == identifier25
) { | |
1279 return accessor as PropertyAccessorElementImpl; | |
1280 } | |
1281 } | |
1282 for (ConstructorElement constructor in _constructors) { | |
1283 if (((constructor as ConstructorElementImpl)).identifier == identifier25)
{ | |
1284 return constructor as ConstructorElementImpl; | |
1285 } | |
1286 } | |
1287 for (FieldElement field in _fields) { | |
1288 if (((field as FieldElementImpl)).identifier == identifier25) { | |
1289 return field as FieldElementImpl; | |
1290 } | |
1291 } | |
1292 for (MethodElement method in _methods) { | |
1293 if (((method as MethodElementImpl)).identifier == identifier25) { | |
1294 return method as MethodElementImpl; | |
1295 } | |
1296 } | |
1297 for (TypeVariableElement typeVariable in _typeVariables) { | |
1298 if (((typeVariable as TypeVariableElementImpl)).identifier == identifier25
) { | |
1299 return typeVariable as TypeVariableElementImpl; | |
1300 } | |
1301 } | |
1302 return null; | |
1303 } | |
1304 List<ConstructorElement> get constructors => _constructors; | |
1305 List<FieldElement> get fields => _fields; | |
1306 List<InterfaceType> get interfaces => _interfaces; | |
1307 ElementKind get kind => ElementKind.CLASS; | |
1308 List<MethodElement> get methods => _methods; | |
1309 List<InterfaceType> get mixins => _mixins; | |
1310 ConstructorElement getNamedConstructor(String name23) { | |
1311 for (ConstructorElement element in constructors) { | |
1312 String elementName = element.name; | |
1313 if (elementName != null && elementName == name23) { | |
1314 return element; | |
1315 } | |
1316 } | |
1317 return null; | |
1318 } | |
1319 InterfaceType get supertype => _supertype; | |
1320 InterfaceType get type => _type; | |
1321 List<TypeVariableElement> get typeVariables => _typeVariables; | |
1322 ConstructorElement get unnamedConstructor { | |
1323 for (ConstructorElement element in constructors) { | |
1324 String name10 = element.name; | |
1325 if (name10 == null || name10.isEmpty) { | |
1326 return element; | |
1327 } | |
1328 } | |
1329 return null; | |
1330 } | |
1331 bool isAbstract() => hasModifier(Modifier.ABSTRACT); | |
1332 bool isTypedef() => hasModifier(Modifier.TYPEDEF); | |
1333 bool isValidMixin() => hasModifier(Modifier.MIXIN); | |
1334 PropertyAccessorElement lookUpGetter(String getterName, LibraryElement library
) { | |
1335 PropertyAccessorElement element = getGetter(getterName); | |
1336 if (element != null && element.isAccessibleIn(library)) { | |
1337 return element; | |
1338 } | |
1339 for (InterfaceType mixin in _mixins) { | |
1340 ClassElement mixinElement = mixin.element; | |
1341 if (mixinElement != null) { | |
1342 element = ((mixinElement as ClassElementImpl)).getGetter(getterName); | |
1343 if (element != null && element.isAccessibleIn(library)) { | |
1344 return element; | |
1345 } | |
1346 } | |
1347 } | |
1348 if (_supertype != null) { | |
1349 ClassElement supertypeElement = _supertype.element; | |
1350 if (supertypeElement != null) { | |
1351 element = supertypeElement.lookUpGetter(getterName, library); | |
1352 if (element != null && element.isAccessibleIn(library)) { | |
1353 return element; | |
1354 } | |
1355 } | |
1356 } | |
1357 return null; | |
1358 } | |
1359 MethodElement lookUpMethod(String methodName, LibraryElement library) { | |
1360 MethodElement element = getMethod(methodName); | |
1361 if (element != null && element.isAccessibleIn(library)) { | |
1362 return element; | |
1363 } | |
1364 for (InterfaceType mixin in _mixins) { | |
1365 ClassElement mixinElement = mixin.element; | |
1366 if (mixinElement != null) { | |
1367 element = ((mixinElement as ClassElementImpl)).getMethod(methodName); | |
1368 if (element != null && element.isAccessibleIn(library)) { | |
1369 return element; | |
1370 } | |
1371 } | |
1372 } | |
1373 if (_supertype != null) { | |
1374 ClassElement supertypeElement = _supertype.element; | |
1375 if (supertypeElement != null) { | |
1376 element = supertypeElement.lookUpMethod(methodName, library); | |
1377 if (element != null && element.isAccessibleIn(library)) { | |
1378 return element; | |
1379 } | |
1380 } | |
1381 } | |
1382 return null; | |
1383 } | |
1384 PropertyAccessorElement lookUpSetter(String setterName, LibraryElement library
) { | |
1385 PropertyAccessorElement element = getSetter(setterName); | |
1386 if (element != null && element.isAccessibleIn(library)) { | |
1387 return element; | |
1388 } | |
1389 for (InterfaceType mixin in _mixins) { | |
1390 ClassElement mixinElement = mixin.element; | |
1391 if (mixinElement != null) { | |
1392 element = ((mixinElement as ClassElementImpl)).getSetter(setterName); | |
1393 if (element != null && element.isAccessibleIn(library)) { | |
1394 return element; | |
1395 } | |
1396 } | |
1397 } | |
1398 if (_supertype != null) { | |
1399 ClassElement supertypeElement = _supertype.element; | |
1400 if (supertypeElement != null) { | |
1401 element = supertypeElement.lookUpSetter(setterName, library); | |
1402 if (element != null && element.isAccessibleIn(library)) { | |
1403 return element; | |
1404 } | |
1405 } | |
1406 } | |
1407 return null; | |
1408 } | |
1409 /** | |
1410 * Set whether this class is abstract to correspond to the given value. | |
1411 * @param isAbstract {@code true} if the class is abstract | |
1412 */ | |
1413 void set abstract(bool isAbstract) { | |
1414 setModifier(Modifier.ABSTRACT, isAbstract); | |
1415 } | |
1416 /** | |
1417 * Set the accessors contained in this class to the given accessors. | |
1418 * @param accessors the accessors contained in this class | |
1419 */ | |
1420 void set accessors(List<PropertyAccessorElement> accessors2) { | |
1421 for (PropertyAccessorElement accessor in accessors2) { | |
1422 ((accessor as PropertyAccessorElementImpl)).enclosingElement = this; | |
1423 } | |
1424 this._accessors = accessors2; | |
1425 } | |
1426 /** | |
1427 * Set the constructors contained in this class to the given constructors. | |
1428 * @param constructors the constructors contained in this class | |
1429 */ | |
1430 void set constructors(List<ConstructorElement> constructors2) { | |
1431 for (ConstructorElement constructor in constructors2) { | |
1432 ((constructor as ConstructorElementImpl)).enclosingElement = this; | |
1433 } | |
1434 this._constructors = constructors2; | |
1435 } | |
1436 /** | |
1437 * Set the fields contained in this class to the given fields. | |
1438 * @param fields the fields contained in this class | |
1439 */ | |
1440 void set fields(List<FieldElement> fields2) { | |
1441 for (FieldElement field in fields2) { | |
1442 ((field as FieldElementImpl)).enclosingElement = this; | |
1443 } | |
1444 this._fields = fields2; | |
1445 } | |
1446 /** | |
1447 * Set the interfaces that are implemented by this class to the given types. | |
1448 * @param the interfaces that are implemented by this class | |
1449 */ | |
1450 void set interfaces(List<InterfaceType> interfaces2) { | |
1451 this._interfaces = interfaces2; | |
1452 } | |
1453 /** | |
1454 * Set the methods contained in this class to the given methods. | |
1455 * @param methods the methods contained in this class | |
1456 */ | |
1457 void set methods(List<MethodElement> methods2) { | |
1458 for (MethodElement method in methods2) { | |
1459 ((method as MethodElementImpl)).enclosingElement = this; | |
1460 } | |
1461 this._methods = methods2; | |
1462 } | |
1463 /** | |
1464 * Set the mixins that are applied to the class being extended in order to der
ive the superclass | |
1465 * of this class to the given types. | |
1466 * @param mixins the mixins that are applied to derive the superclass of this
class | |
1467 */ | |
1468 void set mixins(List<InterfaceType> mixins2) { | |
1469 this._mixins = mixins2; | |
1470 } | |
1471 /** | |
1472 * Set the superclass of the class to the given type. | |
1473 * @param supertype the superclass of the class | |
1474 */ | |
1475 void set supertype(InterfaceType supertype2) { | |
1476 this._supertype = supertype2; | |
1477 } | |
1478 /** | |
1479 * Set the type defined by the class to the given type. | |
1480 * @param type the type defined by the class | |
1481 */ | |
1482 void set type(InterfaceType type5) { | |
1483 this._type = type5; | |
1484 } | |
1485 /** | |
1486 * Set whether this class is defined by a typedef construct to correspond to t
he given value. | |
1487 * @param isTypedef {@code true} if the class is defined by a typedef construc
t | |
1488 */ | |
1489 void set typedef(bool isTypedef) { | |
1490 setModifier(Modifier.TYPEDEF, isTypedef); | |
1491 } | |
1492 /** | |
1493 * Set the type variables defined for this class to the given type variables. | |
1494 * @param typeVariables the type variables defined for this class | |
1495 */ | |
1496 void set typeVariables(List<TypeVariableElement> typeVariables2) { | |
1497 for (TypeVariableElement typeVariable in typeVariables2) { | |
1498 ((typeVariable as TypeVariableElementImpl)).enclosingElement = this; | |
1499 } | |
1500 this._typeVariables = typeVariables2; | |
1501 } | |
1502 /** | |
1503 * Set whether this class is a valid mixin to correspond to the given value. | |
1504 * @param isValidMixin {@code true} if this class can be used as a mixin | |
1505 */ | |
1506 void set validMixin(bool isValidMixin) { | |
1507 setModifier(Modifier.MIXIN, isValidMixin); | |
1508 } | |
1509 void visitChildren(ElementVisitor<Object> visitor) { | |
1510 super.visitChildren(visitor); | |
1511 safelyVisitChildren(_accessors, visitor); | |
1512 safelyVisitChildren(_constructors, visitor); | |
1513 safelyVisitChildren(_fields, visitor); | |
1514 safelyVisitChildren(_methods, visitor); | |
1515 safelyVisitChildren(_typeVariables, visitor); | |
1516 } | |
1517 void appendTo(JavaStringBuilder builder) { | |
1518 String name11 = name; | |
1519 if (name11 == null) { | |
1520 builder.append("{unnamed class}"); | |
1521 } else { | |
1522 builder.append(name11); | |
1523 } | |
1524 int variableCount = _typeVariables.length; | |
1525 if (variableCount > 0) { | |
1526 builder.append("<"); | |
1527 for (int i = 0; i < variableCount; i++) { | |
1528 if (i > 0) { | |
1529 builder.append(", "); | |
1530 } | |
1531 ((_typeVariables[i] as TypeVariableElementImpl)).appendTo(builder); | |
1532 } | |
1533 builder.append(">"); | |
1534 } | |
1535 } | |
1536 void collectAllSupertypes(Collection<InterfaceType> list) { | |
1537 if (_supertype == null || list.contains(_supertype)) { | |
1538 return; | |
1539 } | |
1540 list.add(_supertype); | |
1541 ((_supertype.element as ClassElementImpl)).collectAllSupertypes(list); | |
1542 for (InterfaceType type in interfaces) { | |
1543 if (!list.contains(type)) { | |
1544 list.add(type); | |
1545 ((type.element as ClassElementImpl)).collectAllSupertypes(list); | |
1546 } | |
1547 } | |
1548 for (InterfaceType type in mixins) { | |
1549 if (!list.contains(type)) { | |
1550 list.add(type); | |
1551 } | |
1552 } | |
1553 } | |
1554 /** | |
1555 * Return the element representing the getter with the given name that is decl
ared in this class, | |
1556 * or {@code null} if this class does not declare a getter with the given name
. | |
1557 * @param getterName the name of the getter to be returned | |
1558 * @return the getter declared in this class with the given name | |
1559 */ | |
1560 PropertyAccessorElement getGetter(String getterName) { | |
1561 for (PropertyAccessorElement accessor in _accessors) { | |
1562 if (accessor.isGetter() && accessor.name == getterName) { | |
1563 return accessor; | |
1564 } | |
1565 } | |
1566 return null; | |
1567 } | |
1568 /** | |
1569 * Return the element representing the method with the given name that is decl
ared in this class, | |
1570 * or {@code null} if this class does not declare a method with the given name
. | |
1571 * @param methodName the name of the method to be returned | |
1572 * @return the method declared in this class with the given name | |
1573 */ | |
1574 MethodElement getMethod(String methodName) { | |
1575 for (MethodElement method in _methods) { | |
1576 if (method.name == methodName) { | |
1577 return method; | |
1578 } | |
1579 } | |
1580 return null; | |
1581 } | |
1582 /** | |
1583 * Return the element representing the setter with the given name that is decl
ared in this class, | |
1584 * or {@code null} if this class does not declare a setter with the given name
. | |
1585 * @param setterName the name of the getter to be returned | |
1586 * @return the getter declared in this class with the given name | |
1587 */ | |
1588 PropertyAccessorElement getSetter(String setterName) { | |
1589 for (PropertyAccessorElement accessor in _accessors) { | |
1590 if (accessor.isSetter() && accessor.name == setterName) { | |
1591 return accessor; | |
1592 } | |
1593 } | |
1594 return null; | |
1595 } | |
1596 } | |
1597 /** | |
1598 * Instances of the class {@code CompilationUnitElementImpl} implement a{@link C
ompilationUnitElement}. | |
1599 * @coverage dart.engine.element | |
1600 */ | |
1601 class CompilationUnitElementImpl extends ElementImpl implements CompilationUnitE
lement { | |
1602 /** | |
1603 * An array containing all of the top-level accessors (getters and setters) co
ntained in this | |
1604 * compilation unit. | |
1605 */ | |
1606 List<PropertyAccessorElement> _accessors = PropertyAccessorElementImpl.EMPTY_A
RRAY; | |
1607 /** | |
1608 * An array containing all of the top-level functions contained in this compil
ation unit. | |
1609 */ | |
1610 List<FunctionElement> _functions = FunctionElementImpl.EMPTY_ARRAY; | |
1611 /** | |
1612 * An array containing all of the variables contained in this compilation unit
. | |
1613 */ | |
1614 List<TopLevelVariableElement> _variables = TopLevelVariableElementImpl.EMPTY_A
RRAY; | |
1615 /** | |
1616 * The source that corresponds to this compilation unit. | |
1617 */ | |
1618 Source _source; | |
1619 /** | |
1620 * An array containing all of the type aliases contained in this compilation u
nit. | |
1621 */ | |
1622 List<TypeAliasElement> _typeAliases = TypeAliasElementImpl.EMPTY_ARRAY; | |
1623 /** | |
1624 * An array containing all of the types contained in this compilation unit. | |
1625 */ | |
1626 List<ClassElement> _types = ClassElementImpl.EMPTY_ARRAY; | |
1627 /** | |
1628 * An empty array of compilation unit elements. | |
1629 */ | |
1630 static List<CompilationUnitElement> EMPTY_ARRAY = new List<CompilationUnitElem
ent>(0); | |
1631 /** | |
1632 * Initialize a newly created compilation unit element to have the given name. | |
1633 * @param name the name of this element | |
1634 */ | |
1635 CompilationUnitElementImpl(String name) : super.con2(name, -1) { | |
1636 } | |
1637 accept(ElementVisitor visitor) => visitor.visitCompilationUnitElement(this); | |
1638 bool operator ==(Object object) => identical(runtimeType, object.runtimeType)
&& _source == ((object as CompilationUnitElementImpl)).source; | |
1639 List<PropertyAccessorElement> get accessors => _accessors; | |
1640 ElementImpl getChild(String identifier26) { | |
1641 for (PropertyAccessorElement accessor in _accessors) { | |
1642 if (((accessor as PropertyAccessorElementImpl)).identifier == identifier26
) { | |
1643 return accessor as PropertyAccessorElementImpl; | |
1644 } | |
1645 } | |
1646 for (VariableElement variable in _variables) { | |
1647 if (((variable as VariableElementImpl)).identifier == identifier26) { | |
1648 return variable as VariableElementImpl; | |
1649 } | |
1650 } | |
1651 for (ExecutableElement function in _functions) { | |
1652 if (((function as ExecutableElementImpl)).identifier == identifier26) { | |
1653 return function as ExecutableElementImpl; | |
1654 } | |
1655 } | |
1656 for (TypeAliasElement typeAlias in _typeAliases) { | |
1657 if (((typeAlias as TypeAliasElementImpl)).identifier == identifier26) { | |
1658 return typeAlias as TypeAliasElementImpl; | |
1659 } | |
1660 } | |
1661 for (ClassElement type in _types) { | |
1662 if (((type as ClassElementImpl)).identifier == identifier26) { | |
1663 return type as ClassElementImpl; | |
1664 } | |
1665 } | |
1666 return null; | |
1667 } | |
1668 LibraryElement get enclosingElement => super.enclosingElement as LibraryElemen
t; | |
1669 List<FunctionElement> get functions => _functions; | |
1670 String get identifier => source.fullName; | |
1671 ElementKind get kind => ElementKind.COMPILATION_UNIT; | |
1672 Source get source => _source; | |
1673 List<TopLevelVariableElement> get topLevelVariables => _variables; | |
1674 List<TypeAliasElement> get typeAliases => _typeAliases; | |
1675 List<ClassElement> get types => _types; | |
1676 int get hashCode => _source.hashCode; | |
1677 /** | |
1678 * Set the top-level accessors (getters and setters) contained in this compila
tion unit to the | |
1679 * given accessors. | |
1680 * @param the top-level accessors (getters and setters) contained in this comp
ilation unit | |
1681 */ | |
1682 void set accessors(List<PropertyAccessorElement> accessors3) { | |
1683 for (PropertyAccessorElement accessor in accessors3) { | |
1684 ((accessor as PropertyAccessorElementImpl)).enclosingElement = this; | |
1685 } | |
1686 this._accessors = accessors3; | |
1687 } | |
1688 /** | |
1689 * Set the top-level functions contained in this compilation unit to the given
functions. | |
1690 * @param functions the top-level functions contained in this compilation unit | |
1691 */ | |
1692 void set functions(List<FunctionElement> functions2) { | |
1693 for (FunctionElement function in functions2) { | |
1694 ((function as FunctionElementImpl)).enclosingElement = this; | |
1695 } | |
1696 this._functions = functions2; | |
1697 } | |
1698 /** | |
1699 * Set the source that corresponds to this compilation unit to the given sourc
e. | |
1700 * @param source the source that corresponds to this compilation unit | |
1701 */ | |
1702 void set source(Source source5) { | |
1703 this._source = source5; | |
1704 } | |
1705 /** | |
1706 * Set the top-level variables contained in this compilation unit to the given
variables. | |
1707 * @param variables the top-level variables contained in this compilation unit | |
1708 */ | |
1709 void set topLevelVariables(List<TopLevelVariableElement> variables2) { | |
1710 for (TopLevelVariableElement field in variables2) { | |
1711 ((field as TopLevelVariableElementImpl)).enclosingElement = this; | |
1712 } | |
1713 this._variables = variables2; | |
1714 } | |
1715 /** | |
1716 * Set the type aliases contained in this compilation unit to the given type a
liases. | |
1717 * @param typeAliases the type aliases contained in this compilation unit | |
1718 */ | |
1719 void set typeAliases(List<TypeAliasElement> typeAliases2) { | |
1720 for (TypeAliasElement typeAlias in typeAliases2) { | |
1721 ((typeAlias as TypeAliasElementImpl)).enclosingElement = this; | |
1722 } | |
1723 this._typeAliases = typeAliases2; | |
1724 } | |
1725 /** | |
1726 * Set the types contained in this compilation unit to the given types. | |
1727 * @param types types contained in this compilation unit | |
1728 */ | |
1729 void set types(List<ClassElement> types2) { | |
1730 for (ClassElement type in types2) { | |
1731 ((type as ClassElementImpl)).enclosingElement = this; | |
1732 } | |
1733 this._types = types2; | |
1734 } | |
1735 void visitChildren(ElementVisitor<Object> visitor) { | |
1736 super.visitChildren(visitor); | |
1737 safelyVisitChildren(_accessors, visitor); | |
1738 safelyVisitChildren(_functions, visitor); | |
1739 safelyVisitChildren(_typeAliases, visitor); | |
1740 safelyVisitChildren(_types, visitor); | |
1741 safelyVisitChildren(_variables, visitor); | |
1742 } | |
1743 void appendTo(JavaStringBuilder builder) { | |
1744 if (_source == null) { | |
1745 builder.append("{compilation unit}"); | |
1746 } else { | |
1747 builder.append(_source.fullName); | |
1748 } | |
1749 } | |
1750 } | |
1751 /** | |
1752 * Instances of the class {@code ConstructorElementImpl} implement a {@code Cons
tructorElement}. | |
1753 * @coverage dart.engine.element | |
1754 */ | |
1755 class ConstructorElementImpl extends ExecutableElementImpl implements Constructo
rElement { | |
1756 /** | |
1757 * An empty array of constructor elements. | |
1758 */ | |
1759 static List<ConstructorElement> EMPTY_ARRAY = new List<ConstructorElement>(0); | |
1760 /** | |
1761 * Initialize a newly created constructor element to have the given name. | |
1762 * @param name the name of this element | |
1763 */ | |
1764 ConstructorElementImpl(Identifier name) : super.con1(name) { | |
1765 } | |
1766 accept(ElementVisitor visitor) => visitor.visitConstructorElement(this); | |
1767 ClassElement get enclosingElement => super.enclosingElement as ClassElement; | |
1768 ElementKind get kind => ElementKind.CONSTRUCTOR; | |
1769 bool isConst() => hasModifier(Modifier.CONST); | |
1770 bool isFactory() => hasModifier(Modifier.FACTORY); | |
1771 bool isStatic() => false; | |
1772 /** | |
1773 * Set whether this constructor represents a factory method to the given value
. | |
1774 * @param isFactory {@code true} if this constructor represents a factory meth
od | |
1775 */ | |
1776 void set factory(bool isFactory) { | |
1777 setModifier(Modifier.FACTORY, isFactory); | |
1778 } | |
1779 void appendTo(JavaStringBuilder builder) { | |
1780 builder.append(enclosingElement.name); | |
1781 String name12 = name; | |
1782 if (name12 != null && !name12.isEmpty) { | |
1783 builder.append("."); | |
1784 builder.append(name12); | |
1785 } | |
1786 super.appendTo(builder); | |
1787 } | |
1788 } | |
1789 /** | |
1790 * Instances of the class {@code DynamicElementImpl} represent the synthetic ele
ment representing | |
1791 * the declaration of the type {@code dynamic}. | |
1792 * @coverage dart.engine.element | |
1793 */ | |
1794 class DynamicElementImpl extends ElementImpl { | |
1795 /** | |
1796 * Return the unique instance of this class. | |
1797 * @return the unique instance of this class | |
1798 */ | |
1799 static DynamicElementImpl get instance => DynamicTypeImpl.instance.element as
DynamicElementImpl; | |
1800 /** | |
1801 * The type defined by this element. | |
1802 */ | |
1803 DynamicTypeImpl _type; | |
1804 /** | |
1805 * Initialize a newly created instance of this class. Instances of this class
should <b>not</b> be | |
1806 * created except as part of creating the type associated with this element. T
he single instance | |
1807 * of this class should be accessed through the method {@link #getInstance()}. | |
1808 */ | |
1809 DynamicElementImpl() : super.con2(Keyword.DYNAMIC.syntax, -1) { | |
1810 setModifier(Modifier.SYNTHETIC, true); | |
1811 } | |
1812 accept(ElementVisitor visitor) => null; | |
1813 ElementKind get kind => ElementKind.DYNAMIC; | |
1814 /** | |
1815 * Return the type defined by this element. | |
1816 * @return the type defined by this element | |
1817 */ | |
1818 DynamicTypeImpl get type => _type; | |
1819 /** | |
1820 * Set the type defined by this element to the given type. | |
1821 * @param type the type defined by this element | |
1822 */ | |
1823 void set type(DynamicTypeImpl type6) { | |
1824 this._type = type6; | |
1825 } | |
1826 } | |
1827 /** | |
1828 * The abstract class {@code ElementImpl} implements the behavior common to obje
cts that implement | |
1829 * an {@link Element}. | |
1830 * @coverage dart.engine.element | |
1831 */ | |
1832 abstract class ElementImpl implements Element { | |
1833 /** | |
1834 * The enclosing element of this element, or {@code null} if this element is a
t the root of the | |
1835 * element structure. | |
1836 */ | |
1837 ElementImpl _enclosingElement; | |
1838 /** | |
1839 * The name of this element. | |
1840 */ | |
1841 String _name; | |
1842 /** | |
1843 * The offset of the name of this element in the file that contains the declar
ation of this | |
1844 * element. | |
1845 */ | |
1846 int _nameOffset = 0; | |
1847 /** | |
1848 * A bit-encoded form of the modifiers associated with this element. | |
1849 */ | |
1850 Set<Modifier> _modifiers; | |
1851 /** | |
1852 * An array containing all of the metadata associated with this element. | |
1853 */ | |
1854 List<Annotation> _metadata = AnnotationImpl.EMPTY_ARRAY; | |
1855 /** | |
1856 * Initialize a newly created element to have the given name. | |
1857 * @param name the name of this element | |
1858 */ | |
1859 ElementImpl.con1(Identifier name24) { | |
1860 _jtd_constructor_161_impl(name24); | |
1861 } | |
1862 _jtd_constructor_161_impl(Identifier name24) { | |
1863 _jtd_constructor_162_impl(name24 == null ? "" : name24.name, name24 == null
? -1 : name24.offset); | |
1864 } | |
1865 /** | |
1866 * Initialize a newly created element to have the given name. | |
1867 * @param name the name of this element | |
1868 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
1869 * declaration of this element | |
1870 */ | |
1871 ElementImpl.con2(String name8, int nameOffset2) { | |
1872 _jtd_constructor_162_impl(name8, nameOffset2); | |
1873 } | |
1874 _jtd_constructor_162_impl(String name8, int nameOffset2) { | |
1875 this._name = name8; | |
1876 this._nameOffset = nameOffset2; | |
1877 this._modifiers = new Set(); | |
1878 } | |
1879 bool operator ==(Object object) => object != null && identical(object.runtimeT
ype, runtimeType) && ((object as Element)).location == location; | |
1880 Element getAncestor(Type elementClass) { | |
1881 Element ancestor = _enclosingElement; | |
1882 while (ancestor != null && !isInstanceOf(ancestor, elementClass)) { | |
1883 ancestor = ancestor.enclosingElement; | |
1884 } | |
1885 return ancestor as Element; | |
1886 } | |
1887 /** | |
1888 * Return the child of this element that is uniquely identified by the given i
dentifier, or{@code null} if there is no such child. | |
1889 * @param identifier the identifier used to select a child | |
1890 * @return the child of this element with the given identifier | |
1891 */ | |
1892 ElementImpl getChild(String identifier) => null; | |
1893 AnalysisContext get context { | |
1894 if (_enclosingElement == null) { | |
1895 return null; | |
1896 } | |
1897 return _enclosingElement.context; | |
1898 } | |
1899 Element get enclosingElement => _enclosingElement; | |
1900 LibraryElement get library => getAncestor(LibraryElement); | |
1901 ElementLocation get location => new ElementLocationImpl.con1(this); | |
1902 List<Annotation> get metadata => _metadata; | |
1903 String get name => _name; | |
1904 int get nameOffset => _nameOffset; | |
1905 Source get source { | |
1906 if (_enclosingElement == null) { | |
1907 return null; | |
1908 } | |
1909 return _enclosingElement.source; | |
1910 } | |
1911 int get hashCode => location.hashCode; | |
1912 bool isAccessibleIn(LibraryElement library20) { | |
1913 if (Identifier.isPrivateName(_name)) { | |
1914 return library20 == library; | |
1915 } | |
1916 return true; | |
1917 } | |
1918 bool isSynthetic() => hasModifier(Modifier.SYNTHETIC); | |
1919 /** | |
1920 * Set the metadata associate with this element to the given array of annotati
ons. | |
1921 * @param metadata the metadata to be associated with this element | |
1922 */ | |
1923 void set metadata(List<Annotation> metadata2) { | |
1924 this._metadata = metadata2; | |
1925 } | |
1926 /** | |
1927 * Set whether this element is synthetic to correspond to the given value. | |
1928 * @param isSynthetic {@code true} if the element is synthetic | |
1929 */ | |
1930 void set synthetic(bool isSynthetic) { | |
1931 setModifier(Modifier.SYNTHETIC, isSynthetic); | |
1932 } | |
1933 String toString() { | |
1934 JavaStringBuilder builder = new JavaStringBuilder(); | |
1935 appendTo(builder); | |
1936 return builder.toString(); | |
1937 } | |
1938 void visitChildren(ElementVisitor<Object> visitor) { | |
1939 } | |
1940 /** | |
1941 * Append a textual representation of this type to the given builder. | |
1942 * @param builder the builder to which the text is to be appended | |
1943 */ | |
1944 void appendTo(JavaStringBuilder builder) { | |
1945 if (_name == null) { | |
1946 builder.append("<unnamed "); | |
1947 builder.append(runtimeType.toString()); | |
1948 builder.append(">"); | |
1949 } else { | |
1950 builder.append(_name); | |
1951 } | |
1952 } | |
1953 /** | |
1954 * Return an identifier that uniquely identifies this element among the childr
en of this element's | |
1955 * parent. | |
1956 * @return an identifier that uniquely identifies this element relative to its
parent | |
1957 */ | |
1958 String get identifier => name; | |
1959 /** | |
1960 * Return {@code true} if this element has the given modifier associated with
it. | |
1961 * @param modifier the modifier being tested for | |
1962 * @return {@code true} if this element has the given modifier associated with
it | |
1963 */ | |
1964 bool hasModifier(Modifier modifier) => _modifiers.contains(modifier); | |
1965 /** | |
1966 * If the given child is not {@code null}, use the given visitor to visit it. | |
1967 * @param child the child to be visited | |
1968 * @param visitor the visitor to be used to visit the child | |
1969 */ | |
1970 void safelyVisitChild(Element child, ElementVisitor<Object> visitor) { | |
1971 if (child != null) { | |
1972 child.accept(visitor); | |
1973 } | |
1974 } | |
1975 /** | |
1976 * Use the given visitor to visit all of the children in the given array. | |
1977 * @param children the children to be visited | |
1978 * @param visitor the visitor being used to visit the children | |
1979 */ | |
1980 void safelyVisitChildren(List<Element> children, ElementVisitor<Object> visito
r) { | |
1981 if (children != null) { | |
1982 for (Element child in children) { | |
1983 child.accept(visitor); | |
1984 } | |
1985 } | |
1986 } | |
1987 /** | |
1988 * Set the enclosing element of this element to the given element. | |
1989 * @param element the enclosing element of this element | |
1990 */ | |
1991 void set enclosingElement(ElementImpl element) { | |
1992 _enclosingElement = element; | |
1993 } | |
1994 /** | |
1995 * Set whether the given modifier is associated with this element to correspon
d to the given | |
1996 * value. | |
1997 * @param modifier the modifier to be set | |
1998 * @param value {@code true} if the modifier is to be associated with this ele
ment | |
1999 */ | |
2000 void setModifier(Modifier modifier, bool value) { | |
2001 if (value) { | |
2002 _modifiers.add(modifier); | |
2003 } else { | |
2004 _modifiers.remove(modifier); | |
2005 } | |
2006 } | |
2007 } | |
2008 /** | |
2009 * Instances of the class {@code ElementLocationImpl} implement an {@link Elemen
tLocation}. | |
2010 * @coverage dart.engine.element | |
2011 */ | |
2012 class ElementLocationImpl implements ElementLocation { | |
2013 /** | |
2014 * The path to the element whose location is represented by this object. | |
2015 */ | |
2016 List<String> _components; | |
2017 /** | |
2018 * The character used to separate components in the encoded form. | |
2019 */ | |
2020 static int _SEPARATOR_CHAR = 0x3B; | |
2021 /** | |
2022 * Initialize a newly created location to represent the given element. | |
2023 * @param element the element whose location is being represented | |
2024 */ | |
2025 ElementLocationImpl.con1(Element element) { | |
2026 _jtd_constructor_163_impl(element); | |
2027 } | |
2028 _jtd_constructor_163_impl(Element element) { | |
2029 List<String> components = new List<String>(); | |
2030 Element ancestor = element; | |
2031 while (ancestor != null) { | |
2032 components.insertRange(0, 1, ((ancestor as ElementImpl)).identifier); | |
2033 ancestor = ancestor.enclosingElement; | |
2034 } | |
2035 this._components = new List.from(components); | |
2036 } | |
2037 /** | |
2038 * Initialize a newly created location from the given encoded form. | |
2039 * @param encoding the encoded form of a location | |
2040 */ | |
2041 ElementLocationImpl.con2(String encoding) { | |
2042 _jtd_constructor_164_impl(encoding); | |
2043 } | |
2044 _jtd_constructor_164_impl(String encoding) { | |
2045 this._components = decode(encoding); | |
2046 } | |
2047 bool operator ==(Object object) { | |
2048 if (object is! ElementLocationImpl) { | |
2049 return false; | |
2050 } | |
2051 ElementLocationImpl location = object as ElementLocationImpl; | |
2052 return JavaArrays.equals(_components, location._components); | |
2053 } | |
2054 /** | |
2055 * Return the path to the element whose location is represented by this object
. | |
2056 * @return the path to the element whose location is represented by this objec
t | |
2057 */ | |
2058 List<String> get components => _components; | |
2059 String get encoding { | |
2060 JavaStringBuilder builder = new JavaStringBuilder(); | |
2061 int length2 = _components.length; | |
2062 for (int i = 0; i < length2; i++) { | |
2063 if (i > 0) { | |
2064 builder.appendChar(_SEPARATOR_CHAR); | |
2065 } | |
2066 encode(builder, _components[i]); | |
2067 } | |
2068 return builder.toString(); | |
2069 } | |
2070 int get hashCode => JavaArrays.makeHashCode(_components); | |
2071 String toString() => encoding; | |
2072 /** | |
2073 * Decode the encoded form of a location into an array of components. | |
2074 * @param encoding the encoded form of a location | |
2075 * @return the components that were encoded | |
2076 */ | |
2077 List<String> decode(String encoding) { | |
2078 List<String> components = new List<String>(); | |
2079 JavaStringBuilder builder = new JavaStringBuilder(); | |
2080 int index = 0; | |
2081 int length3 = encoding.length; | |
2082 while (index < length3) { | |
2083 int currentChar = encoding.codeUnitAt(index); | |
2084 if (currentChar == _SEPARATOR_CHAR) { | |
2085 if (index + 1 < length3 && encoding.codeUnitAt(index + 1) == _SEPARATOR_
CHAR) { | |
2086 builder.appendChar(_SEPARATOR_CHAR); | |
2087 index += 2; | |
2088 } else { | |
2089 components.add(builder.toString()); | |
2090 builder.length = 0; | |
2091 index++; | |
2092 } | |
2093 } else { | |
2094 builder.appendChar(currentChar); | |
2095 index++; | |
2096 } | |
2097 } | |
2098 if (builder.length > 0) { | |
2099 components.add(builder.toString()); | |
2100 } | |
2101 return new List.from(components); | |
2102 } | |
2103 /** | |
2104 * Append an encoded form of the given component to the given builder. | |
2105 * @param builder the builder to which the encoded component is to be appended | |
2106 * @param component the component to be appended to the builder | |
2107 */ | |
2108 void encode(JavaStringBuilder builder, String component) { | |
2109 int length4 = component.length; | |
2110 for (int i = 0; i < length4; i++) { | |
2111 int currentChar = component.codeUnitAt(i); | |
2112 if (currentChar == _SEPARATOR_CHAR) { | |
2113 builder.appendChar(_SEPARATOR_CHAR); | |
2114 } | |
2115 builder.appendChar(currentChar); | |
2116 } | |
2117 } | |
2118 } | |
2119 /** | |
2120 * Instances of the class {@code EmbeddedHtmlScriptElementImpl} implement an{@li
nk EmbeddedHtmlScriptElement}. | |
2121 * @coverage dart.engine.element | |
2122 */ | |
2123 class EmbeddedHtmlScriptElementImpl extends HtmlScriptElementImpl implements Emb
eddedHtmlScriptElement { | |
2124 /** | |
2125 * The library defined by the script tag's content. | |
2126 */ | |
2127 LibraryElement _scriptLibrary; | |
2128 /** | |
2129 * Initialize a newly created script element to have the specified tag name an
d offset. | |
2130 * @param node the XML node from which this element is derived (not {@code nul
l}) | |
2131 */ | |
2132 EmbeddedHtmlScriptElementImpl(XmlTagNode node) : super(node) { | |
2133 } | |
2134 accept(ElementVisitor visitor) => visitor.visitEmbeddedHtmlScriptElement(this)
; | |
2135 ElementKind get kind => ElementKind.EMBEDDED_HTML_SCRIPT; | |
2136 LibraryElement get scriptLibrary => _scriptLibrary; | |
2137 /** | |
2138 * Set the script library defined by the script tag's content. | |
2139 * @param scriptLibrary the library or {@code null} if none | |
2140 */ | |
2141 void set scriptLibrary(LibraryElementImpl scriptLibrary2) { | |
2142 scriptLibrary2.enclosingElement = this; | |
2143 this._scriptLibrary = scriptLibrary2; | |
2144 } | |
2145 void visitChildren(ElementVisitor<Object> visitor) { | |
2146 safelyVisitChild(_scriptLibrary, visitor); | |
2147 } | |
2148 } | |
2149 /** | |
2150 * The abstract class {@code ExecutableElementImpl} implements the behavior comm
on to{@code ExecutableElement}s. | |
2151 * @coverage dart.engine.element | |
2152 */ | |
2153 abstract class ExecutableElementImpl extends ElementImpl implements ExecutableEl
ement { | |
2154 /** | |
2155 * An array containing all of the functions defined within this executable ele
ment. | |
2156 */ | |
2157 List<FunctionElement> _functions = FunctionElementImpl.EMPTY_ARRAY; | |
2158 /** | |
2159 * An array containing all of the labels defined within this executable elemen
t. | |
2160 */ | |
2161 List<LabelElement> _labels = LabelElementImpl.EMPTY_ARRAY; | |
2162 /** | |
2163 * An array containing all of the local variables defined within this executab
le element. | |
2164 */ | |
2165 List<LocalVariableElement> _localVariables = LocalVariableElementImpl.EMPTY_AR
RAY; | |
2166 /** | |
2167 * An array containing all of the parameters defined by this executable elemen
t. | |
2168 */ | |
2169 List<ParameterElement> _parameters = ParameterElementImpl.EMPTY_ARRAY; | |
2170 /** | |
2171 * The type of function defined by this executable element. | |
2172 */ | |
2173 FunctionType _type; | |
2174 /** | |
2175 * An empty array of executable elements. | |
2176 */ | |
2177 static List<ExecutableElement> EMPTY_ARRAY = new List<ExecutableElement>(0); | |
2178 /** | |
2179 * Initialize a newly created executable element to have the given name. | |
2180 * @param name the name of this element | |
2181 */ | |
2182 ExecutableElementImpl.con1(Identifier name) : super.con1(name) { | |
2183 _jtd_constructor_166_impl(name); | |
2184 } | |
2185 _jtd_constructor_166_impl(Identifier name) { | |
2186 } | |
2187 /** | |
2188 * Initialize a newly created executable element to have the given name. | |
2189 * @param name the name of this element | |
2190 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
2191 * declaration of this element | |
2192 */ | |
2193 ExecutableElementImpl.con2(String name, int nameOffset) : super.con2(name, nam
eOffset) { | |
2194 _jtd_constructor_167_impl(name, nameOffset); | |
2195 } | |
2196 _jtd_constructor_167_impl(String name, int nameOffset) { | |
2197 } | |
2198 ElementImpl getChild(String identifier27) { | |
2199 for (ExecutableElement function in _functions) { | |
2200 if (((function as ExecutableElementImpl)).identifier == identifier27) { | |
2201 return function as ExecutableElementImpl; | |
2202 } | |
2203 } | |
2204 for (LabelElement label in _labels) { | |
2205 if (((label as LabelElementImpl)).identifier == identifier27) { | |
2206 return label as LabelElementImpl; | |
2207 } | |
2208 } | |
2209 for (VariableElement variable in _localVariables) { | |
2210 if (((variable as VariableElementImpl)).identifier == identifier27) { | |
2211 return variable as VariableElementImpl; | |
2212 } | |
2213 } | |
2214 for (ParameterElement parameter in _parameters) { | |
2215 if (((parameter as ParameterElementImpl)).identifier == identifier27) { | |
2216 return parameter as ParameterElementImpl; | |
2217 } | |
2218 } | |
2219 return null; | |
2220 } | |
2221 List<FunctionElement> get functions => _functions; | |
2222 List<LabelElement> get labels => _labels; | |
2223 List<LocalVariableElement> get localVariables => _localVariables; | |
2224 List<ParameterElement> get parameters => _parameters; | |
2225 FunctionType get type => _type; | |
2226 /** | |
2227 * Set the functions defined within this executable element to the given funct
ions. | |
2228 * @param functions the functions defined within this executable element | |
2229 */ | |
2230 void set functions(List<FunctionElement> functions3) { | |
2231 for (FunctionElement function in functions3) { | |
2232 ((function as FunctionElementImpl)).enclosingElement = this; | |
2233 } | |
2234 this._functions = functions3; | |
2235 } | |
2236 /** | |
2237 * Set the labels defined within this executable element to the given labels. | |
2238 * @param labels the labels defined within this executable element | |
2239 */ | |
2240 void set labels(List<LabelElement> labels2) { | |
2241 for (LabelElement label in labels2) { | |
2242 ((label as LabelElementImpl)).enclosingElement = this; | |
2243 } | |
2244 this._labels = labels2; | |
2245 } | |
2246 /** | |
2247 * Set the local variables defined within this executable element to the given
variables. | |
2248 * @param localVariables the local variables defined within this executable el
ement | |
2249 */ | |
2250 void set localVariables(List<LocalVariableElement> localVariables2) { | |
2251 for (LocalVariableElement variable in localVariables2) { | |
2252 ((variable as LocalVariableElementImpl)).enclosingElement = this; | |
2253 } | |
2254 this._localVariables = localVariables2; | |
2255 } | |
2256 /** | |
2257 * Set the parameters defined by this executable element to the given paramete
rs. | |
2258 * @param parameters the parameters defined by this executable element | |
2259 */ | |
2260 void set parameters(List<ParameterElement> parameters7) { | |
2261 for (ParameterElement parameter in parameters7) { | |
2262 ((parameter as ParameterElementImpl)).enclosingElement = this; | |
2263 } | |
2264 this._parameters = parameters7; | |
2265 } | |
2266 /** | |
2267 * Set the type of function defined by this executable element to the given ty
pe. | |
2268 * @param type the type of function defined by this executable element | |
2269 */ | |
2270 void set type(FunctionType type7) { | |
2271 this._type = type7; | |
2272 } | |
2273 void visitChildren(ElementVisitor<Object> visitor) { | |
2274 super.visitChildren(visitor); | |
2275 safelyVisitChildren(_functions, visitor); | |
2276 safelyVisitChildren(_labels, visitor); | |
2277 safelyVisitChildren(_localVariables, visitor); | |
2278 safelyVisitChildren(_parameters, visitor); | |
2279 } | |
2280 void appendTo(JavaStringBuilder builder) { | |
2281 builder.append("("); | |
2282 int parameterCount = _parameters.length; | |
2283 for (int i = 0; i < parameterCount; i++) { | |
2284 if (i > 0) { | |
2285 builder.append(", "); | |
2286 } | |
2287 ((_parameters[i] as ParameterElementImpl)).appendTo(builder); | |
2288 } | |
2289 builder.append(")"); | |
2290 if (_type != null) { | |
2291 builder.append(" -> "); | |
2292 builder.append(_type.returnType); | |
2293 } | |
2294 } | |
2295 } | |
2296 /** | |
2297 * Instances of the class {@code ExportElementImpl} implement an {@link ExportEl
ement}. | |
2298 * @coverage dart.engine.element | |
2299 */ | |
2300 class ExportElementImpl extends ElementImpl implements ExportElement { | |
2301 /** | |
2302 * The library that is exported from this library by this export directive. | |
2303 */ | |
2304 LibraryElement _exportedLibrary; | |
2305 /** | |
2306 * The combinators that were specified as part of the export directive in the
order in which they | |
2307 * were specified. | |
2308 */ | |
2309 List<NamespaceCombinator> _combinators = NamespaceCombinator.EMPTY_ARRAY; | |
2310 /** | |
2311 * Initialize a newly created export element. | |
2312 */ | |
2313 ExportElementImpl() : super.con1(null) { | |
2314 } | |
2315 accept(ElementVisitor visitor) => visitor.visitExportElement(this); | |
2316 List<NamespaceCombinator> get combinators => _combinators; | |
2317 LibraryElement get exportedLibrary => _exportedLibrary; | |
2318 ElementKind get kind => ElementKind.EXPORT; | |
2319 /** | |
2320 * Set the combinators that were specified as part of the export directive to
the given array of | |
2321 * combinators. | |
2322 * @param combinators the combinators that were specified as part of the expor
t directive | |
2323 */ | |
2324 void set combinators(List<NamespaceCombinator> combinators2) { | |
2325 this._combinators = combinators2; | |
2326 } | |
2327 /** | |
2328 * Set the library that is exported from this library by this import directive
to the given | |
2329 * library. | |
2330 * @param exportedLibrary the library that is exported from this library | |
2331 */ | |
2332 void set exportedLibrary(LibraryElement exportedLibrary2) { | |
2333 this._exportedLibrary = exportedLibrary2; | |
2334 } | |
2335 void appendTo(JavaStringBuilder builder) { | |
2336 builder.append("export "); | |
2337 ((_exportedLibrary as LibraryElementImpl)).appendTo(builder); | |
2338 } | |
2339 } | |
2340 /** | |
2341 * Instances of the class {@code ExternalHtmlScriptElementImpl} implement an{@li
nk ExternalHtmlScriptElement}. | |
2342 * @coverage dart.engine.element | |
2343 */ | |
2344 class ExternalHtmlScriptElementImpl extends HtmlScriptElementImpl implements Ext
ernalHtmlScriptElement { | |
2345 /** | |
2346 * The source specified in the {@code source} attribute or {@code null} if uns
pecified. | |
2347 */ | |
2348 Source _scriptSource; | |
2349 /** | |
2350 * Initialize a newly created script element to have the specified tag name an
d offset. | |
2351 * @param node the XML node from which this element is derived (not {@code nul
l}) | |
2352 */ | |
2353 ExternalHtmlScriptElementImpl(XmlTagNode node) : super(node) { | |
2354 } | |
2355 accept(ElementVisitor visitor) => visitor.visitExternalHtmlScriptElement(this)
; | |
2356 ElementKind get kind => ElementKind.EXTERNAL_HTML_SCRIPT; | |
2357 Source get scriptSource => _scriptSource; | |
2358 /** | |
2359 * Set the source specified in the {@code source} attribute. | |
2360 * @param scriptSource the script source or {@code null} if unspecified | |
2361 */ | |
2362 void set scriptSource(Source scriptSource2) { | |
2363 this._scriptSource = scriptSource2; | |
2364 } | |
2365 } | |
2366 /** | |
2367 * Instances of the class {@code FieldElementImpl} implement a {@code FieldEleme
nt}. | |
2368 * @coverage dart.engine.element | |
2369 */ | |
2370 class FieldElementImpl extends PropertyInducingElementImpl implements FieldEleme
nt { | |
2371 /** | |
2372 * An empty array of field elements. | |
2373 */ | |
2374 static List<FieldElement> EMPTY_ARRAY = new List<FieldElement>(0); | |
2375 /** | |
2376 * Initialize a newly created field element to have the given name. | |
2377 * @param name the name of this element | |
2378 */ | |
2379 FieldElementImpl.con1(Identifier name) : super.con1(name) { | |
2380 _jtd_constructor_170_impl(name); | |
2381 } | |
2382 _jtd_constructor_170_impl(Identifier name) { | |
2383 } | |
2384 /** | |
2385 * Initialize a newly created synthetic field element to have the given name. | |
2386 * @param name the name of this element | |
2387 */ | |
2388 FieldElementImpl.con2(String name) : super.con2(name) { | |
2389 _jtd_constructor_171_impl(name); | |
2390 } | |
2391 _jtd_constructor_171_impl(String name) { | |
2392 } | |
2393 accept(ElementVisitor visitor) => visitor.visitFieldElement(this); | |
2394 ClassElement get enclosingElement => super.enclosingElement as ClassElement; | |
2395 ElementKind get kind => ElementKind.FIELD; | |
2396 bool isStatic() => hasModifier(Modifier.STATIC); | |
2397 /** | |
2398 * Set whether this field is static to correspond to the given value. | |
2399 * @param isStatic {@code true} if the field is static | |
2400 */ | |
2401 void set static(bool isStatic) { | |
2402 setModifier(Modifier.STATIC, isStatic); | |
2403 } | |
2404 } | |
2405 /** | |
2406 * Instances of the class {@code FunctionElementImpl} implement a {@code Functio
nElement}. | |
2407 * @coverage dart.engine.element | |
2408 */ | |
2409 class FunctionElementImpl extends ExecutableElementImpl implements FunctionEleme
nt { | |
2410 /** | |
2411 * The offset to the beginning of the visible range for this element. | |
2412 */ | |
2413 int _visibleRangeOffset = 0; | |
2414 /** | |
2415 * The length of the visible range for this element, or {@code -1} if this ele
ment does not have a | |
2416 * visible range. | |
2417 */ | |
2418 int _visibleRangeLength = -1; | |
2419 /** | |
2420 * An empty array of function elements. | |
2421 */ | |
2422 static List<FunctionElement> EMPTY_ARRAY = new List<FunctionElement>(0); | |
2423 /** | |
2424 * Initialize a newly created synthetic function element. | |
2425 */ | |
2426 FunctionElementImpl() : super.con2("", -1) { | |
2427 _jtd_constructor_172_impl(); | |
2428 } | |
2429 _jtd_constructor_172_impl() { | |
2430 synthetic = true; | |
2431 } | |
2432 /** | |
2433 * Initialize a newly created function element to have the given name. | |
2434 * @param name the name of this element | |
2435 */ | |
2436 FunctionElementImpl.con1(Identifier name) : super.con1(name) { | |
2437 _jtd_constructor_173_impl(name); | |
2438 } | |
2439 _jtd_constructor_173_impl(Identifier name) { | |
2440 } | |
2441 accept(ElementVisitor visitor) => visitor.visitFunctionElement(this); | |
2442 String get identifier => name; | |
2443 ElementKind get kind => ElementKind.FUNCTION; | |
2444 SourceRange get visibleRange { | |
2445 if (_visibleRangeLength < 0) { | |
2446 return null; | |
2447 } | |
2448 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); | |
2449 } | |
2450 bool isStatic() => enclosingElement is CompilationUnitElement; | |
2451 /** | |
2452 * Set the visible range for this element to the range starting at the given o
ffset with the given | |
2453 * length. | |
2454 * @param offset the offset to the beginning of the visible range for this ele
ment | |
2455 * @param length the length of the visible range for this element, or {@code -
1} if this element | |
2456 * does not have a visible range | |
2457 */ | |
2458 void setVisibleRange(int offset, int length) { | |
2459 _visibleRangeOffset = offset; | |
2460 _visibleRangeLength = length; | |
2461 } | |
2462 void appendTo(JavaStringBuilder builder) { | |
2463 String name13 = name; | |
2464 if (name13 != null) { | |
2465 builder.append(name13); | |
2466 } | |
2467 super.appendTo(builder); | |
2468 } | |
2469 } | |
2470 /** | |
2471 * Instances of the class {@code ShowCombinatorImpl} implement a {@link ShowComb
inator}. | |
2472 * @coverage dart.engine.element | |
2473 */ | |
2474 class HideCombinatorImpl implements HideCombinator { | |
2475 /** | |
2476 * The names that are not to be made visible in the importing library even if
they are defined in | |
2477 * the imported library. | |
2478 */ | |
2479 List<String> _hiddenNames = StringUtilities.EMPTY_ARRAY; | |
2480 /** | |
2481 * Initialize a newly created combinator. | |
2482 */ | |
2483 HideCombinatorImpl() : super() { | |
2484 } | |
2485 List<String> get hiddenNames => _hiddenNames; | |
2486 /** | |
2487 * Set the names that are not to be made visible in the importing library even
if they are defined | |
2488 * in the imported library to the given names. | |
2489 * @param hiddenNames the names that are not to be made visible in the importi
ng library | |
2490 */ | |
2491 void set hiddenNames(List<String> hiddenNames2) { | |
2492 this._hiddenNames = hiddenNames2; | |
2493 } | |
2494 String toString() { | |
2495 JavaStringBuilder builder = new JavaStringBuilder(); | |
2496 builder.append("show "); | |
2497 int count = _hiddenNames.length; | |
2498 for (int i = 0; i < count; i++) { | |
2499 if (i > 0) { | |
2500 builder.append(", "); | |
2501 } | |
2502 builder.append(_hiddenNames[i]); | |
2503 } | |
2504 return builder.toString(); | |
2505 } | |
2506 } | |
2507 /** | |
2508 * Instances of the class {@code HtmlElementImpl} implement an {@link HtmlElemen
t}. | |
2509 * @coverage dart.engine.element | |
2510 */ | |
2511 class HtmlElementImpl extends ElementImpl implements HtmlElement { | |
2512 /** | |
2513 * An empty array of HTML file elements. | |
2514 */ | |
2515 static List<HtmlElement> EMPTY_ARRAY = new List<HtmlElement>(0); | |
2516 /** | |
2517 * The analysis context in which this library is defined. | |
2518 */ | |
2519 AnalysisContext _context; | |
2520 /** | |
2521 * The scripts contained in or referenced from script tags in the HTML file. | |
2522 */ | |
2523 List<HtmlScriptElement> _scripts = HtmlScriptElementImpl.EMPTY_ARRAY; | |
2524 /** | |
2525 * The source that corresponds to this HTML file. | |
2526 */ | |
2527 Source _source; | |
2528 /** | |
2529 * Initialize a newly created HTML element to have the given name. | |
2530 * @param context the analysis context in which the HTML file is defined | |
2531 * @param name the name of this element | |
2532 */ | |
2533 HtmlElementImpl(AnalysisContext context, String name) : super.con2(name, -1) { | |
2534 this._context = context; | |
2535 } | |
2536 accept(ElementVisitor visitor) => visitor.visitHtmlElement(this); | |
2537 bool operator ==(Object object) => identical(runtimeType, object.runtimeType)
&& _source == ((object as CompilationUnitElementImpl)).source; | |
2538 AnalysisContext get context => _context; | |
2539 ElementKind get kind => ElementKind.HTML; | |
2540 List<HtmlScriptElement> get scripts => _scripts; | |
2541 Source get source => _source; | |
2542 int get hashCode => _source.hashCode; | |
2543 /** | |
2544 * Set the scripts contained in the HTML file to the given scripts. | |
2545 * @param scripts the scripts | |
2546 */ | |
2547 void set scripts(List<HtmlScriptElement> scripts2) { | |
2548 for (HtmlScriptElement script in scripts2) { | |
2549 ((script as HtmlScriptElementImpl)).enclosingElement = this; | |
2550 } | |
2551 this._scripts = scripts2; | |
2552 } | |
2553 /** | |
2554 * Set the source that corresponds to this HTML file to the given source. | |
2555 * @param source the source that corresponds to this HTML file | |
2556 */ | |
2557 void set source(Source source6) { | |
2558 this._source = source6; | |
2559 } | |
2560 void visitChildren(ElementVisitor<Object> visitor) { | |
2561 super.visitChildren(visitor); | |
2562 safelyVisitChildren(_scripts, visitor); | |
2563 } | |
2564 void appendTo(JavaStringBuilder builder) { | |
2565 if (_source == null) { | |
2566 builder.append("{HTML file}"); | |
2567 } else { | |
2568 builder.append(_source.fullName); | |
2569 } | |
2570 } | |
2571 } | |
2572 /** | |
2573 * Instances of the class {@code HtmlScriptElementImpl} implement an {@link Html
ScriptElement}. | |
2574 * @coverage dart.engine.element | |
2575 */ | |
2576 abstract class HtmlScriptElementImpl extends ElementImpl implements HtmlScriptEl
ement { | |
2577 /** | |
2578 * An empty array of HTML script elements. | |
2579 */ | |
2580 static List<HtmlScriptElement> EMPTY_ARRAY = new List<HtmlScriptElement>(0); | |
2581 /** | |
2582 * Initialize a newly created script element to have the specified tag name an
d offset. | |
2583 * @param node the XML node from which this element is derived (not {@code nul
l}) | |
2584 */ | |
2585 HtmlScriptElementImpl(XmlTagNode node) : super.con2(node.tag.lexeme, node.tag.
offset) { | |
2586 } | |
2587 } | |
2588 /** | |
2589 * Instances of the class {@code ImportElementImpl} implement an {@link ImportEl
ement}. | |
2590 * @coverage dart.engine.element | |
2591 */ | |
2592 class ImportElementImpl extends ElementImpl implements ImportElement { | |
2593 /** | |
2594 * The library that is imported into this library by this import directive. | |
2595 */ | |
2596 LibraryElement _importedLibrary; | |
2597 /** | |
2598 * The combinators that were specified as part of the import directive in the
order in which they | |
2599 * were specified. | |
2600 */ | |
2601 List<NamespaceCombinator> _combinators = NamespaceCombinator.EMPTY_ARRAY; | |
2602 /** | |
2603 * The prefix that was specified as part of the import directive, or {@code nu
ll} if there was no | |
2604 * prefix specified. | |
2605 */ | |
2606 PrefixElement _prefix; | |
2607 /** | |
2608 * Initialize a newly created import element. | |
2609 */ | |
2610 ImportElementImpl() : super.con1(null) { | |
2611 } | |
2612 accept(ElementVisitor visitor) => visitor.visitImportElement(this); | |
2613 List<NamespaceCombinator> get combinators => _combinators; | |
2614 LibraryElement get importedLibrary => _importedLibrary; | |
2615 ElementKind get kind => ElementKind.IMPORT; | |
2616 PrefixElement get prefix => _prefix; | |
2617 /** | |
2618 * Set the combinators that were specified as part of the import directive to
the given array of | |
2619 * combinators. | |
2620 * @param combinators the combinators that were specified as part of the impor
t directive | |
2621 */ | |
2622 void set combinators(List<NamespaceCombinator> combinators3) { | |
2623 this._combinators = combinators3; | |
2624 } | |
2625 /** | |
2626 * Set the library that is imported into this library by this import directive
to the given | |
2627 * library. | |
2628 * @param importedLibrary the library that is imported into this library | |
2629 */ | |
2630 void set importedLibrary(LibraryElement importedLibrary3) { | |
2631 this._importedLibrary = importedLibrary3; | |
2632 } | |
2633 /** | |
2634 * Set the prefix that was specified as part of the import directive to the gi
ven prefix. | |
2635 * @param prefix the prefix that was specified as part of the import directive | |
2636 */ | |
2637 void set prefix(PrefixElement prefix3) { | |
2638 this._prefix = prefix3; | |
2639 } | |
2640 void visitChildren(ElementVisitor<Object> visitor) { | |
2641 super.visitChildren(visitor); | |
2642 safelyVisitChild(_prefix, visitor); | |
2643 } | |
2644 void appendTo(JavaStringBuilder builder) { | |
2645 builder.append("import "); | |
2646 ((_importedLibrary as LibraryElementImpl)).appendTo(builder); | |
2647 } | |
2648 } | |
2649 /** | |
2650 * Instances of the class {@code LabelElementImpl} implement a {@code LabelEleme
nt}. | |
2651 * @coverage dart.engine.element | |
2652 */ | |
2653 class LabelElementImpl extends ElementImpl implements LabelElement { | |
2654 /** | |
2655 * A flag indicating whether this label is associated with a {@code switch} st
atement. | |
2656 */ | |
2657 bool _onSwitchStatement = false; | |
2658 /** | |
2659 * A flag indicating whether this label is associated with a {@code switch} me
mber ({@code case}or {@code default}). | |
2660 */ | |
2661 bool _onSwitchMember = false; | |
2662 /** | |
2663 * An empty array of label elements. | |
2664 */ | |
2665 static List<LabelElement> EMPTY_ARRAY = new List<LabelElement>(0); | |
2666 /** | |
2667 * Initialize a newly created label element to have the given name. | |
2668 * @param name the name of this element | |
2669 * @param onSwitchStatement {@code true} if this label is associated with a {@
code switch}statement | |
2670 * @param onSwitchMember {@code true} if this label is associated with a {@cod
e switch} member | |
2671 */ | |
2672 LabelElementImpl(Identifier name, bool onSwitchStatement, bool onSwitchMember)
: super.con1(name) { | |
2673 this._onSwitchStatement = onSwitchStatement; | |
2674 this._onSwitchMember = onSwitchMember; | |
2675 } | |
2676 accept(ElementVisitor visitor) => visitor.visitLabelElement(this); | |
2677 ExecutableElement get enclosingElement => super.enclosingElement as Executable
Element; | |
2678 ElementKind get kind => ElementKind.LABEL; | |
2679 /** | |
2680 * Return {@code true} if this label is associated with a {@code switch} membe
r ({@code case} or{@code default}). | |
2681 * @return {@code true} if this label is associated with a {@code switch} memb
er | |
2682 */ | |
2683 bool isOnSwitchMember() => _onSwitchMember; | |
2684 /** | |
2685 * Return {@code true} if this label is associated with a {@code switch} state
ment. | |
2686 * @return {@code true} if this label is associated with a {@code switch} stat
ement | |
2687 */ | |
2688 bool isOnSwitchStatement() => _onSwitchStatement; | |
2689 } | |
2690 /** | |
2691 * Instances of the class {@code LibraryElementImpl} implement a {@code LibraryE
lement}. | |
2692 * @coverage dart.engine.element | |
2693 */ | |
2694 class LibraryElementImpl extends ElementImpl implements LibraryElement { | |
2695 /** | |
2696 * An empty array of library elements. | |
2697 */ | |
2698 static List<LibraryElement> EMPTY_ARRAY = new List<LibraryElement>(0); | |
2699 /** | |
2700 * Determine if the given library is up to date with respect to the given time
stamp. | |
2701 * @param library the library to process | |
2702 * @param timeStamp the time stamp to check against | |
2703 * @param visitedLibraries the set of visited libraries | |
2704 */ | |
2705 static bool isUpToDate(LibraryElement library, int timeStamp, Set<LibraryEleme
nt> visitedLibraries) { | |
2706 if (!visitedLibraries.contains(library)) { | |
2707 javaSetAdd(visitedLibraries, library); | |
2708 if (timeStamp < library.definingCompilationUnit.source.modificationStamp)
{ | |
2709 return false; | |
2710 } | |
2711 for (CompilationUnitElement element in library.parts) { | |
2712 if (timeStamp < element.source.modificationStamp) { | |
2713 return false; | |
2714 } | |
2715 } | |
2716 for (LibraryElement importedLibrary in library.importedLibraries) { | |
2717 if (!isUpToDate(importedLibrary, timeStamp, visitedLibraries)) { | |
2718 return false; | |
2719 } | |
2720 } | |
2721 for (LibraryElement exportedLibrary in library.exportedLibraries) { | |
2722 if (!isUpToDate(exportedLibrary, timeStamp, visitedLibraries)) { | |
2723 return false; | |
2724 } | |
2725 } | |
2726 } | |
2727 return true; | |
2728 } | |
2729 /** | |
2730 * The analysis context in which this library is defined. | |
2731 */ | |
2732 AnalysisContext _context; | |
2733 /** | |
2734 * The compilation unit that defines this library. | |
2735 */ | |
2736 CompilationUnitElement _definingCompilationUnit; | |
2737 /** | |
2738 * The entry point for this library, or {@code null} if this library does not
have an entry point. | |
2739 */ | |
2740 FunctionElement _entryPoint; | |
2741 /** | |
2742 * An array containing specifications of all of the imports defined in this li
brary. | |
2743 */ | |
2744 List<ImportElement> _imports = ImportElement.EMPTY_ARRAY; | |
2745 /** | |
2746 * An array containing specifications of all of the exports defined in this li
brary. | |
2747 */ | |
2748 List<ExportElement> _exports = ExportElement.EMPTY_ARRAY; | |
2749 /** | |
2750 * An array containing all of the compilation units that are included in this
library using a{@code part} directive. | |
2751 */ | |
2752 List<CompilationUnitElement> _parts = CompilationUnitElementImpl.EMPTY_ARRAY; | |
2753 /** | |
2754 * Initialize a newly created library element to have the given name. | |
2755 * @param context the analysis context in which the library is defined | |
2756 * @param name the name of this element | |
2757 */ | |
2758 LibraryElementImpl(AnalysisContext context, LibraryIdentifier name) : super.co
n1(name) { | |
2759 this._context = context; | |
2760 } | |
2761 accept(ElementVisitor visitor) => visitor.visitLibraryElement(this); | |
2762 bool operator ==(Object object) => identical(runtimeType, object.runtimeType)
&& _definingCompilationUnit == ((object as LibraryElementImpl)).definingCompilat
ionUnit; | |
2763 ElementImpl getChild(String identifier28) { | |
2764 if (((_definingCompilationUnit as CompilationUnitElementImpl)).identifier ==
identifier28) { | |
2765 return _definingCompilationUnit as CompilationUnitElementImpl; | |
2766 } | |
2767 for (CompilationUnitElement part in _parts) { | |
2768 if (((part as CompilationUnitElementImpl)).identifier == identifier28) { | |
2769 return part as CompilationUnitElementImpl; | |
2770 } | |
2771 } | |
2772 return null; | |
2773 } | |
2774 AnalysisContext get context => _context; | |
2775 CompilationUnitElement get definingCompilationUnit => _definingCompilationUnit
; | |
2776 FunctionElement get entryPoint => _entryPoint; | |
2777 List<LibraryElement> get exportedLibraries { | |
2778 Set<LibraryElement> libraries = new Set<LibraryElement>(); | |
2779 for (ExportElement element in _exports) { | |
2780 LibraryElement library = element.exportedLibrary; | |
2781 javaSetAdd(libraries, library); | |
2782 } | |
2783 return new List.from(libraries); | |
2784 } | |
2785 List<ExportElement> get exports => _exports; | |
2786 String get identifier => _definingCompilationUnit.source.fullName; | |
2787 List<LibraryElement> get importedLibraries { | |
2788 Set<LibraryElement> libraries = new Set<LibraryElement>(); | |
2789 for (ImportElement element in _imports) { | |
2790 LibraryElement prefix = element.importedLibrary; | |
2791 javaSetAdd(libraries, prefix); | |
2792 } | |
2793 return new List.from(libraries); | |
2794 } | |
2795 List<ImportElement> get imports => _imports; | |
2796 ElementKind get kind => ElementKind.LIBRARY; | |
2797 List<CompilationUnitElement> get parts => _parts; | |
2798 List<PrefixElement> get prefixes { | |
2799 Set<PrefixElement> prefixes = new Set<PrefixElement>(); | |
2800 for (ImportElement element in _imports) { | |
2801 PrefixElement prefix4 = element.prefix; | |
2802 if (prefix4 != null) { | |
2803 javaSetAdd(prefixes, prefix4); | |
2804 } | |
2805 } | |
2806 return new List.from(prefixes); | |
2807 } | |
2808 int get hashCode => _definingCompilationUnit.hashCode; | |
2809 bool isBrowserApplication() => _entryPoint != null && isOrImportsBrowserLibrar
y(); | |
2810 bool isDartCore() => name == "dart.core"; | |
2811 bool isUpToDate2(int timeStamp) { | |
2812 Set<LibraryElement> visitedLibraries = new Set(); | |
2813 return isUpToDate(this, timeStamp, visitedLibraries); | |
2814 } | |
2815 /** | |
2816 * Set the compilation unit that defines this library to the given compilation
unit. | |
2817 * @param definingCompilationUnit the compilation unit that defines this libra
ry | |
2818 */ | |
2819 void set definingCompilationUnit(CompilationUnitElement definingCompilationUni
t2) { | |
2820 ((definingCompilationUnit2 as CompilationUnitElementImpl)).enclosingElement
= this; | |
2821 this._definingCompilationUnit = definingCompilationUnit2; | |
2822 } | |
2823 /** | |
2824 * Set the entry point for this library to the given function. | |
2825 * @param entryPoint the entry point for this library | |
2826 */ | |
2827 void set entryPoint(FunctionElement entryPoint2) { | |
2828 this._entryPoint = entryPoint2; | |
2829 } | |
2830 /** | |
2831 * Set the specifications of all of the exports defined in this library to the
given array. | |
2832 * @param exports the specifications of all of the exports defined in this lib
rary | |
2833 */ | |
2834 void set exports(List<ExportElement> exports2) { | |
2835 for (ExportElement exportElement in exports2) { | |
2836 ((exportElement as ExportElementImpl)).enclosingElement = this; | |
2837 } | |
2838 this._exports = exports2; | |
2839 } | |
2840 /** | |
2841 * Set the specifications of all of the imports defined in this library to the
given array. | |
2842 * @param imports the specifications of all of the imports defined in this lib
rary | |
2843 */ | |
2844 void set imports(List<ImportElement> imports2) { | |
2845 for (ImportElement importElement in imports2) { | |
2846 ((importElement as ImportElementImpl)).enclosingElement = this; | |
2847 PrefixElementImpl prefix5 = importElement.prefix as PrefixElementImpl; | |
2848 if (prefix5 != null) { | |
2849 prefix5.enclosingElement = this; | |
2850 } | |
2851 } | |
2852 this._imports = imports2; | |
2853 } | |
2854 /** | |
2855 * Set the compilation units that are included in this library using a {@code
part} directive. | |
2856 * @param parts the compilation units that are included in this library using
a {@code part}directive | |
2857 */ | |
2858 void set parts(List<CompilationUnitElement> parts2) { | |
2859 for (CompilationUnitElement compilationUnit in parts2) { | |
2860 ((compilationUnit as CompilationUnitElementImpl)).enclosingElement = this; | |
2861 } | |
2862 this._parts = parts2; | |
2863 } | |
2864 void visitChildren(ElementVisitor<Object> visitor) { | |
2865 super.visitChildren(visitor); | |
2866 safelyVisitChild(_definingCompilationUnit, visitor); | |
2867 safelyVisitChildren(_exports, visitor); | |
2868 safelyVisitChildren(_imports, visitor); | |
2869 safelyVisitChildren(_parts, visitor); | |
2870 } | |
2871 /** | |
2872 * Answer {@code true} if the receiver directly or indirectly imports the dart
:html libraries. | |
2873 * @return {@code true} if the receiver directly or indirectly imports the dar
t:html libraries | |
2874 */ | |
2875 bool isOrImportsBrowserLibrary() { | |
2876 List<LibraryElement> visited = new List<LibraryElement>(); | |
2877 Source htmlLibSource = definingCompilationUnit.source.resolve("dart:html"); | |
2878 visited.add(this); | |
2879 for (int index = 0; index < visited.length; index++) { | |
2880 LibraryElement library = visited[index]; | |
2881 Source source10 = library.definingCompilationUnit.source; | |
2882 if (source10 == htmlLibSource) { | |
2883 return true; | |
2884 } | |
2885 for (LibraryElement importedLibrary in library.importedLibraries) { | |
2886 if (!visited.contains(importedLibrary)) { | |
2887 visited.add(importedLibrary); | |
2888 } | |
2889 } | |
2890 for (LibraryElement exportedLibrary in library.exportedLibraries) { | |
2891 if (!visited.contains(exportedLibrary)) { | |
2892 visited.add(exportedLibrary); | |
2893 } | |
2894 } | |
2895 } | |
2896 return false; | |
2897 } | |
2898 } | |
2899 /** | |
2900 * Instances of the class {@code LocalVariableElementImpl} implement a {@code Lo
calVariableElement}. | |
2901 * @coverage dart.engine.element | |
2902 */ | |
2903 class LocalVariableElementImpl extends VariableElementImpl implements LocalVaria
bleElement { | |
2904 /** | |
2905 * The offset to the beginning of the visible range for this element. | |
2906 */ | |
2907 int _visibleRangeOffset = 0; | |
2908 /** | |
2909 * The length of the visible range for this element, or {@code -1} if this ele
ment does not have a | |
2910 * visible range. | |
2911 */ | |
2912 int _visibleRangeLength = -1; | |
2913 /** | |
2914 * An empty array of field elements. | |
2915 */ | |
2916 static List<LocalVariableElement> EMPTY_ARRAY = new List<LocalVariableElement>
(0); | |
2917 /** | |
2918 * Initialize a newly created parameter element to have the given name. | |
2919 * @param name the name of this element | |
2920 */ | |
2921 LocalVariableElementImpl(Identifier name) : super.con1(name) { | |
2922 } | |
2923 accept(ElementVisitor visitor) => visitor.visitLocalVariableElement(this); | |
2924 ElementKind get kind => ElementKind.LOCAL_VARIABLE; | |
2925 SourceRange get visibleRange { | |
2926 if (_visibleRangeLength < 0) { | |
2927 return null; | |
2928 } | |
2929 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); | |
2930 } | |
2931 /** | |
2932 * Set the visible range for this element to the range starting at the given o
ffset with the given | |
2933 * length. | |
2934 * @param offset the offset to the beginning of the visible range for this ele
ment | |
2935 * @param length the length of the visible range for this element, or {@code -
1} if this element | |
2936 * does not have a visible range | |
2937 */ | |
2938 void setVisibleRange(int offset, int length) { | |
2939 _visibleRangeOffset = offset; | |
2940 _visibleRangeLength = length; | |
2941 } | |
2942 void appendTo(JavaStringBuilder builder) { | |
2943 builder.append(type); | |
2944 builder.append(" "); | |
2945 builder.append(name); | |
2946 } | |
2947 } | |
2948 /** | |
2949 * Instances of the class {@code MethodElementImpl} implement a {@code MethodEle
ment}. | |
2950 * @coverage dart.engine.element | |
2951 */ | |
2952 class MethodElementImpl extends ExecutableElementImpl implements MethodElement { | |
2953 /** | |
2954 * An empty array of method elements. | |
2955 */ | |
2956 static List<MethodElement> EMPTY_ARRAY = new List<MethodElement>(0); | |
2957 /** | |
2958 * Initialize a newly created method element to have the given name. | |
2959 * @param name the name of this element | |
2960 */ | |
2961 MethodElementImpl.con1(Identifier name) : super.con1(name) { | |
2962 _jtd_constructor_181_impl(name); | |
2963 } | |
2964 _jtd_constructor_181_impl(Identifier name) { | |
2965 } | |
2966 /** | |
2967 * Initialize a newly created method element to have the given name. | |
2968 * @param name the name of this element | |
2969 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
2970 * declaration of this element | |
2971 */ | |
2972 MethodElementImpl.con2(String name, int nameOffset) : super.con2(name, nameOff
set) { | |
2973 _jtd_constructor_182_impl(name, nameOffset); | |
2974 } | |
2975 _jtd_constructor_182_impl(String name, int nameOffset) { | |
2976 } | |
2977 accept(ElementVisitor visitor) => visitor.visitMethodElement(this); | |
2978 ClassElement get enclosingElement => super.enclosingElement as ClassElement; | |
2979 ElementKind get kind => ElementKind.METHOD; | |
2980 bool isAbstract() => hasModifier(Modifier.ABSTRACT); | |
2981 bool isStatic() => hasModifier(Modifier.STATIC); | |
2982 /** | |
2983 * Set whether this method is abstract to correspond to the given value. | |
2984 * @param isAbstract {@code true} if the method is abstract | |
2985 */ | |
2986 void set abstract(bool isAbstract) { | |
2987 setModifier(Modifier.ABSTRACT, isAbstract); | |
2988 } | |
2989 /** | |
2990 * Set whether this method is static to correspond to the given value. | |
2991 * @param isStatic {@code true} if the method is static | |
2992 */ | |
2993 void set static(bool isStatic) { | |
2994 setModifier(Modifier.STATIC, isStatic); | |
2995 } | |
2996 void appendTo(JavaStringBuilder builder) { | |
2997 builder.append(enclosingElement.name); | |
2998 builder.append("."); | |
2999 builder.append(name); | |
3000 super.appendTo(builder); | |
3001 } | |
3002 } | |
3003 /** | |
3004 * The enumeration {@code Modifier} defines constants for all of the modifiers d
efined by the Dart | |
3005 * language and for a few additional flags that are useful. | |
3006 * @coverage dart.engine.element | |
3007 */ | |
3008 class Modifier { | |
3009 static final Modifier ABSTRACT = new Modifier('ABSTRACT', 0); | |
3010 static final Modifier CONST = new Modifier('CONST', 1); | |
3011 static final Modifier FACTORY = new Modifier('FACTORY', 2); | |
3012 static final Modifier FINAL = new Modifier('FINAL', 3); | |
3013 static final Modifier GETTER = new Modifier('GETTER', 4); | |
3014 static final Modifier INITIALIZING_FORMAL = new Modifier('INITIALIZING_FORMAL'
, 5); | |
3015 static final Modifier MIXIN = new Modifier('MIXIN', 6); | |
3016 static final Modifier SETTER = new Modifier('SETTER', 7); | |
3017 static final Modifier STATIC = new Modifier('STATIC', 8); | |
3018 static final Modifier SYNTHETIC = new Modifier('SYNTHETIC', 9); | |
3019 static final Modifier TYPEDEF = new Modifier('TYPEDEF', 10); | |
3020 static final List<Modifier> values = [ABSTRACT, CONST, FACTORY, FINAL, GETTER,
INITIALIZING_FORMAL, MIXIN, SETTER, STATIC, SYNTHETIC, TYPEDEF]; | |
3021 final String __name; | |
3022 final int __ordinal; | |
3023 int get ordinal => __ordinal; | |
3024 Modifier(this.__name, this.__ordinal) { | |
3025 } | |
3026 String toString() => __name; | |
3027 } | |
3028 /** | |
3029 * Instances of the class {@code MultiplyDefinedElementImpl} represent a collect
ion of elements that | |
3030 * have the same name within the same scope. | |
3031 * @coverage dart.engine.element | |
3032 */ | |
3033 class MultiplyDefinedElementImpl implements MultiplyDefinedElement { | |
3034 /** | |
3035 * The analysis context in which the multiply defined elements are defined. | |
3036 */ | |
3037 AnalysisContext _context; | |
3038 /** | |
3039 * The name of the conflicting elements. | |
3040 */ | |
3041 String _name; | |
3042 /** | |
3043 * A list containing all of the elements that conflict. | |
3044 */ | |
3045 List<Element> _conflictingElements; | |
3046 /** | |
3047 * Initialize a newly created element to represent a list of conflicting eleme
nts. | |
3048 * @param context the analysis context in which the multiply defined elements
are defined | |
3049 * @param firstElement the first element that conflicts | |
3050 * @param secondElement the second element that conflicts | |
3051 */ | |
3052 MultiplyDefinedElementImpl(AnalysisContext context, Element firstElement, Elem
ent secondElement) { | |
3053 _name = firstElement.name; | |
3054 _conflictingElements = computeConflictingElements(firstElement, secondElemen
t); | |
3055 } | |
3056 accept(ElementVisitor visitor) => visitor.visitMultiplyDefinedElement(this); | |
3057 Element getAncestor(Type elementClass) => null; | |
3058 List<Element> get conflictingElements => _conflictingElements; | |
3059 AnalysisContext get context => _context; | |
3060 Element get enclosingElement => null; | |
3061 ElementKind get kind => ElementKind.ERROR; | |
3062 LibraryElement get library => null; | |
3063 ElementLocation get location => null; | |
3064 List<Annotation> get metadata => AnnotationImpl.EMPTY_ARRAY; | |
3065 String get name => _name; | |
3066 int get nameOffset => -1; | |
3067 Source get source => null; | |
3068 bool isAccessibleIn(LibraryElement library) { | |
3069 for (Element element in _conflictingElements) { | |
3070 if (element.isAccessibleIn(library)) { | |
3071 return true; | |
3072 } | |
3073 } | |
3074 return false; | |
3075 } | |
3076 bool isSynthetic() => true; | |
3077 String toString() { | |
3078 JavaStringBuilder builder = new JavaStringBuilder(); | |
3079 builder.append("["); | |
3080 int count = _conflictingElements.length; | |
3081 for (int i = 0; i < count; i++) { | |
3082 if (i > 0) { | |
3083 builder.append(", "); | |
3084 } | |
3085 ((_conflictingElements[i] as ElementImpl)).appendTo(builder); | |
3086 } | |
3087 builder.append("]"); | |
3088 return builder.toString(); | |
3089 } | |
3090 void visitChildren(ElementVisitor<Object> visitor) { | |
3091 } | |
3092 /** | |
3093 * Add the given element to the list of elements. If the element is a multiply
-defined element, | |
3094 * add all of the conflicting elements that it represents. | |
3095 * @param elements the list to which the element(s) are to be added | |
3096 * @param element the element(s) to be added | |
3097 */ | |
3098 void add(List<Element> elements, Element element) { | |
3099 if (element is MultiplyDefinedElementImpl) { | |
3100 for (Element conflictingElement in ((element as MultiplyDefinedElementImpl
))._conflictingElements) { | |
3101 elements.add(conflictingElement); | |
3102 } | |
3103 } else { | |
3104 elements.add(element); | |
3105 } | |
3106 } | |
3107 /** | |
3108 * Use the given elements to construct an array of conflicting elements. If ei
ther of the given | |
3109 * elements are multiply-defined elements then the conflicting elements they r
epresent will be | |
3110 * included in the array. Otherwise, the element itself will be included. | |
3111 * @param firstElement the first element to be included | |
3112 * @param secondElement the second element to be included | |
3113 * @return an array containing all of the conflicting elements | |
3114 */ | |
3115 List<Element> computeConflictingElements(Element firstElement, Element secondE
lement) { | |
3116 List<Element> elements = new List<Element>(); | |
3117 add(elements, firstElement); | |
3118 add(elements, secondElement); | |
3119 return new List.from(elements); | |
3120 } | |
3121 } | |
3122 /** | |
3123 * Instances of the class {@code ParameterElementImpl} implement a {@code Parame
terElement}. | |
3124 * @coverage dart.engine.element | |
3125 */ | |
3126 class ParameterElementImpl extends VariableElementImpl implements ParameterEleme
nt { | |
3127 /** | |
3128 * The kind of this parameter. | |
3129 */ | |
3130 ParameterKind _parameterKind; | |
3131 /** | |
3132 * The offset to the beginning of the visible range for this element. | |
3133 */ | |
3134 int _visibleRangeOffset = 0; | |
3135 /** | |
3136 * The length of the visible range for this element, or {@code -1} if this ele
ment does not have a | |
3137 * visible range. | |
3138 */ | |
3139 int _visibleRangeLength = -1; | |
3140 /** | |
3141 * An empty array of field elements. | |
3142 */ | |
3143 static List<ParameterElement> EMPTY_ARRAY = new List<ParameterElement>(0); | |
3144 /** | |
3145 * Initialize a newly created parameter element to have the given name. | |
3146 * @param name the name of this element | |
3147 */ | |
3148 ParameterElementImpl(Identifier name) : super.con1(name) { | |
3149 } | |
3150 accept(ElementVisitor visitor) => visitor.visitParameterElement(this); | |
3151 ElementKind get kind => ElementKind.PARAMETER; | |
3152 ParameterKind get parameterKind => _parameterKind; | |
3153 SourceRange get visibleRange { | |
3154 if (_visibleRangeLength < 0) { | |
3155 return null; | |
3156 } | |
3157 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); | |
3158 } | |
3159 bool isInitializingFormal() => hasModifier(Modifier.INITIALIZING_FORMAL); | |
3160 /** | |
3161 * Set whether this parameter is an initializing formal parameter to match the
given value. | |
3162 * @param isInitializingFormal {@code true} if this parameter is an initializi
ng formal parameter | |
3163 */ | |
3164 void set initializingFormal(bool isInitializingFormal) { | |
3165 setModifier(Modifier.INITIALIZING_FORMAL, isInitializingFormal); | |
3166 } | |
3167 /** | |
3168 * Set the kind of this parameter to the given kind. | |
3169 * @param parameterKind the new kind of this parameter | |
3170 */ | |
3171 void set parameterKind(ParameterKind parameterKind2) { | |
3172 this._parameterKind = parameterKind2; | |
3173 } | |
3174 /** | |
3175 * Set the visible range for this element to the range starting at the given o
ffset with the given | |
3176 * length. | |
3177 * @param offset the offset to the beginning of the visible range for this ele
ment | |
3178 * @param length the length of the visible range for this element, or {@code -
1} if this element | |
3179 * does not have a visible range | |
3180 */ | |
3181 void setVisibleRange(int offset, int length) { | |
3182 _visibleRangeOffset = offset; | |
3183 _visibleRangeLength = length; | |
3184 } | |
3185 void appendTo(JavaStringBuilder builder) { | |
3186 builder.append(type); | |
3187 builder.append(" "); | |
3188 builder.append(name); | |
3189 builder.append(" ("); | |
3190 builder.append(kind); | |
3191 builder.append(")"); | |
3192 } | |
3193 } | |
3194 /** | |
3195 * Instances of the class {@code PrefixElementImpl} implement a {@code PrefixEle
ment}. | |
3196 * @coverage dart.engine.element | |
3197 */ | |
3198 class PrefixElementImpl extends ElementImpl implements PrefixElement { | |
3199 /** | |
3200 * An array containing all of the libraries that are imported using this prefi
x. | |
3201 */ | |
3202 List<LibraryElement> _importedLibraries = LibraryElementImpl.EMPTY_ARRAY; | |
3203 /** | |
3204 * An empty array of prefix elements. | |
3205 */ | |
3206 static List<PrefixElement> EMPTY_ARRAY = new List<PrefixElement>(0); | |
3207 /** | |
3208 * Initialize a newly created prefix element to have the given name. | |
3209 * @param name the name of this element | |
3210 */ | |
3211 PrefixElementImpl(Identifier name) : super.con1(name) { | |
3212 } | |
3213 accept(ElementVisitor visitor) => visitor.visitPrefixElement(this); | |
3214 LibraryElement get enclosingElement => super.enclosingElement as LibraryElemen
t; | |
3215 List<LibraryElement> get importedLibraries => _importedLibraries; | |
3216 ElementKind get kind => ElementKind.PREFIX; | |
3217 /** | |
3218 * Set the libraries that are imported using this prefix to the given librarie
s. | |
3219 * @param importedLibraries the libraries that are imported using this prefix | |
3220 */ | |
3221 void set importedLibraries(List<LibraryElement> importedLibraries2) { | |
3222 for (LibraryElement library in importedLibraries2) { | |
3223 ((library as LibraryElementImpl)).enclosingElement = this; | |
3224 } | |
3225 this._importedLibraries = importedLibraries2; | |
3226 } | |
3227 void appendTo(JavaStringBuilder builder) { | |
3228 builder.append("as "); | |
3229 super.appendTo(builder); | |
3230 } | |
3231 } | |
3232 /** | |
3233 * Instances of the class {@code PropertyAccessorElementImpl} implement a{@code
PropertyAccessorElement}. | |
3234 * @coverage dart.engine.element | |
3235 */ | |
3236 class PropertyAccessorElementImpl extends ExecutableElementImpl implements Prope
rtyAccessorElement { | |
3237 /** | |
3238 * The variable associated with this accessor. | |
3239 */ | |
3240 PropertyInducingElement _variable; | |
3241 /** | |
3242 * An empty array of property accessor elements. | |
3243 */ | |
3244 static List<PropertyAccessorElement> EMPTY_ARRAY = new List<PropertyAccessorEl
ement>(0); | |
3245 /** | |
3246 * Initialize a newly created property accessor element to have the given name
. | |
3247 * @param name the name of this element | |
3248 */ | |
3249 PropertyAccessorElementImpl.con1(Identifier name) : super.con1(name) { | |
3250 _jtd_constructor_187_impl(name); | |
3251 } | |
3252 _jtd_constructor_187_impl(Identifier name) { | |
3253 } | |
3254 /** | |
3255 * Initialize a newly created synthetic property accessor element to be associ
ated with the given | |
3256 * variable. | |
3257 * @param variable the variable with which this access is associated | |
3258 */ | |
3259 PropertyAccessorElementImpl.con2(PropertyInducingElementImpl variable2) : supe
r.con2(variable2.name, -1) { | |
3260 _jtd_constructor_188_impl(variable2); | |
3261 } | |
3262 _jtd_constructor_188_impl(PropertyInducingElementImpl variable2) { | |
3263 this._variable = variable2; | |
3264 synthetic = true; | |
3265 } | |
3266 accept(ElementVisitor visitor) => visitor.visitPropertyAccessorElement(this); | |
3267 bool operator ==(Object object) => super == object && identical(isGetter(), ((
object as PropertyAccessorElement)).isGetter()); | |
3268 ElementKind get kind { | |
3269 if (isGetter()) { | |
3270 return ElementKind.GETTER; | |
3271 } | |
3272 return ElementKind.SETTER; | |
3273 } | |
3274 PropertyInducingElement get variable => _variable; | |
3275 bool isGetter() => hasModifier(Modifier.GETTER); | |
3276 bool isSetter() => hasModifier(Modifier.SETTER); | |
3277 bool isStatic() => variable.isStatic(); | |
3278 /** | |
3279 * Set whether this accessor is a getter to correspond to the given value. | |
3280 * @param isGetter {@code true} if the accessor is a getter | |
3281 */ | |
3282 void set getter(bool isGetter) { | |
3283 setModifier(Modifier.GETTER, isGetter); | |
3284 } | |
3285 /** | |
3286 * Set whether this accessor is a setter to correspond to the given value. | |
3287 * @param isSetter {@code true} if the accessor is a setter | |
3288 */ | |
3289 void set setter(bool isSetter) { | |
3290 setModifier(Modifier.SETTER, isSetter); | |
3291 } | |
3292 /** | |
3293 * Set the variable associated with this accessor to the given variable. | |
3294 * @param variable the variable associated with this accessor | |
3295 */ | |
3296 void set variable(PropertyInducingElement variable3) { | |
3297 this._variable = variable3; | |
3298 } | |
3299 void appendTo(JavaStringBuilder builder) { | |
3300 builder.append(isGetter() ? "get " : "set "); | |
3301 builder.append(variable.name); | |
3302 super.appendTo(builder); | |
3303 } | |
3304 } | |
3305 /** | |
3306 * Instances of the class {@code PropertyInducingElementImpl} implement a{@code
PropertyInducingElement}. | |
3307 * @coverage dart.engine.element | |
3308 */ | |
3309 abstract class PropertyInducingElementImpl extends VariableElementImpl implement
s PropertyInducingElement { | |
3310 /** | |
3311 * The getter associated with this element. | |
3312 */ | |
3313 PropertyAccessorElement _getter; | |
3314 /** | |
3315 * The setter associated with this element, or {@code null} if the element is
effectively{@code final} and therefore does not have a setter associated with it
. | |
3316 */ | |
3317 PropertyAccessorElement _setter; | |
3318 /** | |
3319 * An empty array of elements. | |
3320 */ | |
3321 static List<PropertyInducingElement> EMPTY_ARRAY = new List<PropertyInducingEl
ement>(0); | |
3322 /** | |
3323 * Initialize a newly created element to have the given name. | |
3324 * @param name the name of this element | |
3325 */ | |
3326 PropertyInducingElementImpl.con1(Identifier name) : super.con1(name) { | |
3327 _jtd_constructor_189_impl(name); | |
3328 } | |
3329 _jtd_constructor_189_impl(Identifier name) { | |
3330 } | |
3331 /** | |
3332 * Initialize a newly created synthetic element to have the given name. | |
3333 * @param name the name of this element | |
3334 */ | |
3335 PropertyInducingElementImpl.con2(String name) : super.con2(name, -1) { | |
3336 _jtd_constructor_190_impl(name); | |
3337 } | |
3338 _jtd_constructor_190_impl(String name) { | |
3339 synthetic = true; | |
3340 } | |
3341 PropertyAccessorElement get getter => _getter; | |
3342 PropertyAccessorElement get setter => _setter; | |
3343 /** | |
3344 * Set the getter associated with this element to the given accessor. | |
3345 * @param getter the getter associated with this element | |
3346 */ | |
3347 void set getter(PropertyAccessorElement getter2) { | |
3348 this._getter = getter2; | |
3349 } | |
3350 /** | |
3351 * Set the setter associated with this element to the given accessor. | |
3352 * @param setter the setter associated with this element | |
3353 */ | |
3354 void set setter(PropertyAccessorElement setter2) { | |
3355 this._setter = setter2; | |
3356 } | |
3357 } | |
3358 /** | |
3359 * Instances of the class {@code ShowCombinatorImpl} implement a {@link ShowComb
inator}. | |
3360 * @coverage dart.engine.element | |
3361 */ | |
3362 class ShowCombinatorImpl implements ShowCombinator { | |
3363 /** | |
3364 * The names that are to be made visible in the importing library if they are
defined in the | |
3365 * imported library. | |
3366 */ | |
3367 List<String> _shownNames = StringUtilities.EMPTY_ARRAY; | |
3368 /** | |
3369 * Initialize a newly created combinator. | |
3370 */ | |
3371 ShowCombinatorImpl() : super() { | |
3372 } | |
3373 List<String> get shownNames => _shownNames; | |
3374 /** | |
3375 * Set the names that are to be made visible in the importing library if they
are defined in the | |
3376 * imported library to the given names. | |
3377 * @param shownNames the names that are to be made visible in the importing li
brary | |
3378 */ | |
3379 void set shownNames(List<String> shownNames2) { | |
3380 this._shownNames = shownNames2; | |
3381 } | |
3382 String toString() { | |
3383 JavaStringBuilder builder = new JavaStringBuilder(); | |
3384 builder.append("show "); | |
3385 int count = _shownNames.length; | |
3386 for (int i = 0; i < count; i++) { | |
3387 if (i > 0) { | |
3388 builder.append(", "); | |
3389 } | |
3390 builder.append(_shownNames[i]); | |
3391 } | |
3392 return builder.toString(); | |
3393 } | |
3394 } | |
3395 /** | |
3396 * Instances of the class {@code TopLevelVariableElementImpl} implement a{@code
TopLevelVariableElement}. | |
3397 * @coverage dart.engine.element | |
3398 */ | |
3399 class TopLevelVariableElementImpl extends PropertyInducingElementImpl implements
TopLevelVariableElement { | |
3400 /** | |
3401 * An empty array of top-level variable elements. | |
3402 */ | |
3403 static List<TopLevelVariableElement> EMPTY_ARRAY = new List<TopLevelVariableEl
ement>(0); | |
3404 /** | |
3405 * Initialize a newly created top-level variable element to have the given nam
e. | |
3406 * @param name the name of this element | |
3407 */ | |
3408 TopLevelVariableElementImpl.con1(Identifier name) : super.con1(name) { | |
3409 _jtd_constructor_192_impl(name); | |
3410 } | |
3411 _jtd_constructor_192_impl(Identifier name) { | |
3412 } | |
3413 /** | |
3414 * Initialize a newly created synthetic top-level variable element to have the
given name. | |
3415 * @param name the name of this element | |
3416 */ | |
3417 TopLevelVariableElementImpl.con2(String name) : super.con2(name) { | |
3418 _jtd_constructor_193_impl(name); | |
3419 } | |
3420 _jtd_constructor_193_impl(String name) { | |
3421 } | |
3422 accept(ElementVisitor visitor) => visitor.visitTopLevelVariableElement(this); | |
3423 ElementKind get kind => ElementKind.TOP_LEVEL_VARIABLE; | |
3424 bool isStatic() => true; | |
3425 } | |
3426 /** | |
3427 * Instances of the class {@code TypeAliasElementImpl} implement a {@code TypeAl
iasElement}. | |
3428 * @coverage dart.engine.element | |
3429 */ | |
3430 class TypeAliasElementImpl extends ElementImpl implements TypeAliasElement { | |
3431 /** | |
3432 * An array containing all of the parameters defined by this type alias. | |
3433 */ | |
3434 List<ParameterElement> _parameters = ParameterElementImpl.EMPTY_ARRAY; | |
3435 /** | |
3436 * The type of function defined by this type alias. | |
3437 */ | |
3438 FunctionType _type; | |
3439 /** | |
3440 * An array containing all of the type variables defined for this type. | |
3441 */ | |
3442 List<TypeVariableElement> _typeVariables = TypeVariableElementImpl.EMPTY_ARRAY
; | |
3443 /** | |
3444 * An empty array of type alias elements. | |
3445 */ | |
3446 static List<TypeAliasElement> EMPTY_ARRAY = new List<TypeAliasElement>(0); | |
3447 /** | |
3448 * Initialize a newly created type alias element to have the given name. | |
3449 * @param name the name of this element | |
3450 */ | |
3451 TypeAliasElementImpl(Identifier name) : super.con1(name) { | |
3452 } | |
3453 accept(ElementVisitor visitor) => visitor.visitTypeAliasElement(this); | |
3454 ElementImpl getChild(String identifier29) { | |
3455 for (VariableElement parameter in _parameters) { | |
3456 if (((parameter as VariableElementImpl)).identifier == identifier29) { | |
3457 return parameter as VariableElementImpl; | |
3458 } | |
3459 } | |
3460 for (TypeVariableElement typeVariable in _typeVariables) { | |
3461 if (((typeVariable as TypeVariableElementImpl)).identifier == identifier29
) { | |
3462 return typeVariable as TypeVariableElementImpl; | |
3463 } | |
3464 } | |
3465 return null; | |
3466 } | |
3467 CompilationUnitElement get enclosingElement => super.enclosingElement as Compi
lationUnitElement; | |
3468 ElementKind get kind => ElementKind.TYPE_ALIAS; | |
3469 List<ParameterElement> get parameters => _parameters; | |
3470 FunctionType get type => _type; | |
3471 List<TypeVariableElement> get typeVariables => _typeVariables; | |
3472 /** | |
3473 * Set the parameters defined by this type alias to the given parameters. | |
3474 * @param parameters the parameters defined by this type alias | |
3475 */ | |
3476 void set parameters(List<ParameterElement> parameters8) { | |
3477 if (parameters8 != null) { | |
3478 for (ParameterElement parameter in parameters8) { | |
3479 ((parameter as ParameterElementImpl)).enclosingElement = this; | |
3480 } | |
3481 } | |
3482 this._parameters = parameters8; | |
3483 } | |
3484 /** | |
3485 * Set the type of function defined by this type alias to the given type. | |
3486 * @param type the type of function defined by this type alias | |
3487 */ | |
3488 void set type(FunctionType type8) { | |
3489 this._type = type8; | |
3490 } | |
3491 /** | |
3492 * Set the type variables defined for this type to the given variables. | |
3493 * @param typeVariables the type variables defined for this type | |
3494 */ | |
3495 void set typeVariables(List<TypeVariableElement> typeVariables3) { | |
3496 for (TypeVariableElement variable in typeVariables3) { | |
3497 ((variable as TypeVariableElementImpl)).enclosingElement = this; | |
3498 } | |
3499 this._typeVariables = typeVariables3; | |
3500 } | |
3501 void visitChildren(ElementVisitor<Object> visitor) { | |
3502 super.visitChildren(visitor); | |
3503 safelyVisitChildren(_parameters, visitor); | |
3504 safelyVisitChildren(_typeVariables, visitor); | |
3505 } | |
3506 void appendTo(JavaStringBuilder builder) { | |
3507 builder.append("typedef "); | |
3508 builder.append(name); | |
3509 int variableCount = _typeVariables.length; | |
3510 if (variableCount > 0) { | |
3511 builder.append("<"); | |
3512 for (int i = 0; i < variableCount; i++) { | |
3513 if (i > 0) { | |
3514 builder.append(", "); | |
3515 } | |
3516 ((_typeVariables[i] as TypeVariableElementImpl)).appendTo(builder); | |
3517 } | |
3518 builder.append(">"); | |
3519 } | |
3520 builder.append("("); | |
3521 int parameterCount = _parameters.length; | |
3522 for (int i = 0; i < parameterCount; i++) { | |
3523 if (i > 0) { | |
3524 builder.append(", "); | |
3525 } | |
3526 ((_parameters[i] as ParameterElementImpl)).appendTo(builder); | |
3527 } | |
3528 builder.append(")"); | |
3529 if (_type != null) { | |
3530 builder.append(" -> "); | |
3531 builder.append(_type.returnType); | |
3532 } | |
3533 } | |
3534 } | |
3535 /** | |
3536 * Instances of the class {@code TypeVariableElementImpl} implement a {@code Typ
eVariableElement}. | |
3537 * @coverage dart.engine.element | |
3538 */ | |
3539 class TypeVariableElementImpl extends ElementImpl implements TypeVariableElement
{ | |
3540 /** | |
3541 * The type defined by this type variable. | |
3542 */ | |
3543 TypeVariableType _type; | |
3544 /** | |
3545 * The type representing the bound associated with this variable, or {@code nu
ll} if this variable | |
3546 * does not have an explicit bound. | |
3547 */ | |
3548 Type2 _bound; | |
3549 /** | |
3550 * An empty array of type variable elements. | |
3551 */ | |
3552 static List<TypeVariableElement> EMPTY_ARRAY = new List<TypeVariableElement>(0
); | |
3553 /** | |
3554 * Initialize a newly created type variable element to have the given name. | |
3555 * @param name the name of this element | |
3556 */ | |
3557 TypeVariableElementImpl(Identifier name) : super.con1(name) { | |
3558 } | |
3559 accept(ElementVisitor visitor) => visitor.visitTypeVariableElement(this); | |
3560 Type2 get bound => _bound; | |
3561 ElementKind get kind => ElementKind.TYPE_VARIABLE; | |
3562 TypeVariableType get type => _type; | |
3563 /** | |
3564 * Set the type representing the bound associated with this variable to the gi
ven type. | |
3565 * @param bound the type representing the bound associated with this variable | |
3566 */ | |
3567 void set bound(Type2 bound2) { | |
3568 this._bound = bound2; | |
3569 } | |
3570 /** | |
3571 * Set the type defined by this type variable to the given type | |
3572 * @param type the type defined by this type variable | |
3573 */ | |
3574 void set type(TypeVariableType type9) { | |
3575 this._type = type9; | |
3576 } | |
3577 void appendTo(JavaStringBuilder builder) { | |
3578 builder.append(name); | |
3579 if (_bound != null) { | |
3580 builder.append(" extends "); | |
3581 builder.append(_bound); | |
3582 } | |
3583 } | |
3584 } | |
3585 /** | |
3586 * Instances of the class {@code VariableElementImpl} implement a {@code Variabl
eElement}. | |
3587 * @coverage dart.engine.element | |
3588 */ | |
3589 abstract class VariableElementImpl extends ElementImpl implements VariableElemen
t { | |
3590 /** | |
3591 * The declared type of this variable. | |
3592 */ | |
3593 Type2 _type; | |
3594 /** | |
3595 * A synthetic function representing this variable's initializer, or {@code nu
ll} if this variable | |
3596 * does not have an initializer. | |
3597 */ | |
3598 FunctionElement _initializer; | |
3599 /** | |
3600 * An empty array of variable elements. | |
3601 */ | |
3602 static List<VariableElement> EMPTY_ARRAY = new List<VariableElement>(0); | |
3603 /** | |
3604 * Initialize a newly created variable element to have the given name. | |
3605 * @param name the name of this element | |
3606 */ | |
3607 VariableElementImpl.con1(Identifier name) : super.con1(name) { | |
3608 _jtd_constructor_196_impl(name); | |
3609 } | |
3610 _jtd_constructor_196_impl(Identifier name) { | |
3611 } | |
3612 /** | |
3613 * Initialize a newly created variable element to have the given name. | |
3614 * @param name the name of this element | |
3615 * @param nameOffset the offset of the name of this element in the file that c
ontains the | |
3616 * declaration of this element | |
3617 */ | |
3618 VariableElementImpl.con2(String name, int nameOffset) : super.con2(name, nameO
ffset) { | |
3619 _jtd_constructor_197_impl(name, nameOffset); | |
3620 } | |
3621 _jtd_constructor_197_impl(String name, int nameOffset) { | |
3622 } | |
3623 FunctionElement get initializer => _initializer; | |
3624 Type2 get type => _type; | |
3625 bool isConst() => hasModifier(Modifier.CONST); | |
3626 bool isFinal() => hasModifier(Modifier.FINAL); | |
3627 /** | |
3628 * Set whether this variable is const to correspond to the given value. | |
3629 * @param isConst {@code true} if the variable is const | |
3630 */ | |
3631 void set const2(bool isConst) { | |
3632 setModifier(Modifier.CONST, isConst); | |
3633 } | |
3634 /** | |
3635 * Set whether this variable is final to correspond to the given value. | |
3636 * @param isFinal {@code true} if the variable is final | |
3637 */ | |
3638 void set final2(bool isFinal) { | |
3639 setModifier(Modifier.FINAL, isFinal); | |
3640 } | |
3641 /** | |
3642 * Set the function representing this variable's initializer to the given func
tion. | |
3643 * @param initializer the function representing this variable's initializer | |
3644 */ | |
3645 void set initializer(FunctionElement initializer3) { | |
3646 if (initializer3 != null) { | |
3647 ((initializer3 as FunctionElementImpl)).enclosingElement = this; | |
3648 } | |
3649 this._initializer = initializer3; | |
3650 } | |
3651 /** | |
3652 * Set the declared type of this variable to the given type. | |
3653 * @param type the declared type of this variable | |
3654 */ | |
3655 void set type(Type2 type10) { | |
3656 this._type = type10; | |
3657 } | |
3658 void visitChildren(ElementVisitor<Object> visitor) { | |
3659 super.visitChildren(visitor); | |
3660 safelyVisitChild(_initializer, visitor); | |
3661 } | |
3662 void appendTo(JavaStringBuilder builder) { | |
3663 builder.append(type); | |
3664 builder.append(" "); | |
3665 builder.append(name); | |
3666 } | |
3667 } | |
3668 /** | |
3669 * The unique instance of the class {@code BottomTypeImpl} implements the type {
@code bottom}. | |
3670 * @coverage dart.engine.type | |
3671 */ | |
3672 class BottomTypeImpl extends TypeImpl { | |
3673 /** | |
3674 * The unique instance of this class. | |
3675 */ | |
3676 static BottomTypeImpl _INSTANCE = new BottomTypeImpl(); | |
3677 /** | |
3678 * Return the unique instance of this class. | |
3679 * @return the unique instance of this class | |
3680 */ | |
3681 static BottomTypeImpl get instance => _INSTANCE; | |
3682 /** | |
3683 * Prevent the creation of instances of this class. | |
3684 */ | |
3685 BottomTypeImpl() : super(null, "<bottom>") { | |
3686 } | |
3687 bool operator ==(Object object) => identical(object, this); | |
3688 bool isMoreSpecificThan(Type2 type) => true; | |
3689 bool isSubtypeOf(Type2 type) => true; | |
3690 bool isSupertypeOf(Type2 type) => false; | |
3691 BottomTypeImpl substitute2(List<Type2> argumentTypes, List<Type2> parameterTyp
es) => this; | |
3692 } | |
3693 /** | |
3694 * The unique instance of the class {@code DynamicTypeImpl} implements the type
{@code dynamic}. | |
3695 * @coverage dart.engine.type | |
3696 */ | |
3697 class DynamicTypeImpl extends TypeImpl { | |
3698 /** | |
3699 * The unique instance of this class. | |
3700 */ | |
3701 static DynamicTypeImpl _INSTANCE = new DynamicTypeImpl(); | |
3702 /** | |
3703 * Return the unique instance of this class. | |
3704 * @return the unique instance of this class | |
3705 */ | |
3706 static DynamicTypeImpl get instance => _INSTANCE; | |
3707 /** | |
3708 * Prevent the creation of instances of this class. | |
3709 */ | |
3710 DynamicTypeImpl() : super(new DynamicElementImpl(), Keyword.DYNAMIC.syntax) { | |
3711 ((element as DynamicElementImpl)).type = this; | |
3712 } | |
3713 bool operator ==(Object object) => object is DynamicTypeImpl; | |
3714 bool isDynamic() => true; | |
3715 bool isMoreSpecificThan(Type2 type) => false; | |
3716 bool isSubtypeOf(Type2 type) => identical(this, type); | |
3717 bool isSupertypeOf(Type2 type) => true; | |
3718 DynamicTypeImpl substitute2(List<Type2> argumentTypes, List<Type2> parameterTy
pes) => this; | |
3719 } | |
3720 /** | |
3721 * Instances of the class {@code FunctionTypeImpl} defines the behavior common t
o objects | |
3722 * representing the type of a function, method, constructor, getter, or setter. | |
3723 * @coverage dart.engine.type | |
3724 */ | |
3725 class FunctionTypeImpl extends TypeImpl implements FunctionType { | |
3726 /** | |
3727 * Return {@code true} if all of the name/type pairs in the first map are equa
l to the | |
3728 * corresponding name/type pairs in the second map. The maps are expected to i
terate over their | |
3729 * entries in the same order in which those entries were added to the map. | |
3730 * @param firstTypes the first map of name/type pairs being compared | |
3731 * @param secondTypes the second map of name/type pairs being compared | |
3732 * @return {@code true} if all of the name/type pairs in the first map are equ
al to the | |
3733 * corresponding name/type pairs in the second map | |
3734 */ | |
3735 static bool equals2(Map<String, Type2> firstTypes, Map<String, Type2> secondTy
pes) { | |
3736 if (secondTypes.length != firstTypes.length) { | |
3737 return false; | |
3738 } | |
3739 JavaIterator<MapEntry<String, Type2>> firstIterator = new JavaIterator(getMa
pEntrySet(firstTypes)); | |
3740 JavaIterator<MapEntry<String, Type2>> secondIterator = new JavaIterator(getM
apEntrySet(firstTypes)); | |
3741 while (firstIterator.hasNext) { | |
3742 MapEntry<String, Type2> firstEntry = firstIterator.next(); | |
3743 MapEntry<String, Type2> secondEntry = secondIterator.next(); | |
3744 if (firstEntry.getKey() != secondEntry.getKey() || firstEntry.getValue() !
= secondEntry.getValue()) { | |
3745 return false; | |
3746 } | |
3747 } | |
3748 return true; | |
3749 } | |
3750 /** | |
3751 * Return a map containing the results of using the given argument types and p
arameter types to | |
3752 * perform a substitution on all of the values in the given map. The order of
the entries will be | |
3753 * preserved. | |
3754 * @param types the types on which a substitution is to be performed | |
3755 * @param argumentTypes the argument types for the substitution | |
3756 * @param parameterTypes the parameter types for the substitution | |
3757 * @return the result of performing the substitution on each of the types | |
3758 */ | |
3759 static Map<String, Type2> substitute3(Map<String, Type2> types, List<Type2> ar
gumentTypes, List<Type2> parameterTypes) { | |
3760 if (types.isEmpty) { | |
3761 return types; | |
3762 } | |
3763 LinkedHashMap<String, Type2> newTypes = new LinkedHashMap<String, Type2>(); | |
3764 for (MapEntry<String, Type2> entry in getMapEntrySet(types)) { | |
3765 newTypes[entry.getKey()] = entry.getValue().substitute2(argumentTypes, par
ameterTypes); | |
3766 } | |
3767 return newTypes; | |
3768 } | |
3769 /** | |
3770 * An array containing the actual types of the type arguments. | |
3771 */ | |
3772 List<Type2> _typeArguments = TypeImpl.EMPTY_ARRAY; | |
3773 /** | |
3774 * An array containing the types of the normal parameters of this type of func
tion. The parameter | |
3775 * types are in the same order as they appear in the declaration of the functi
on. | |
3776 * @return the types of the normal parameters of this type of function | |
3777 */ | |
3778 List<Type2> _normalParameterTypes = TypeImpl.EMPTY_ARRAY; | |
3779 /** | |
3780 * A table mapping the names of optional (positional) parameters to the types
of the optional | |
3781 * parameters of this type of function. | |
3782 */ | |
3783 List<Type2> _optionalParameterTypes = TypeImpl.EMPTY_ARRAY; | |
3784 /** | |
3785 * A table mapping the names of named parameters to the types of the named par
ameters of this type | |
3786 * of function. | |
3787 */ | |
3788 Map<String, Type2> _namedParameterTypes = new Map(); | |
3789 /** | |
3790 * The type of object returned by this type of function. | |
3791 */ | |
3792 Type2 _returnType = VoidTypeImpl.instance; | |
3793 /** | |
3794 * Initialize a newly created function type to be declared by the given elemen
t and to have the | |
3795 * given name. | |
3796 * @param element the element representing the declaration of the function typ
e | |
3797 */ | |
3798 FunctionTypeImpl.con1(ExecutableElement element) : super(element, element == n
ull ? null : element.name) { | |
3799 _jtd_constructor_248_impl(element); | |
3800 } | |
3801 _jtd_constructor_248_impl(ExecutableElement element) { | |
3802 } | |
3803 /** | |
3804 * Initialize a newly created function type to be declared by the given elemen
t and to have the | |
3805 * given name. | |
3806 * @param element the element representing the declaration of the function typ
e | |
3807 */ | |
3808 FunctionTypeImpl.con2(TypeAliasElement element) : super(element, element == nu
ll ? null : element.name) { | |
3809 _jtd_constructor_249_impl(element); | |
3810 } | |
3811 _jtd_constructor_249_impl(TypeAliasElement element) { | |
3812 } | |
3813 bool operator ==(Object object) { | |
3814 if (object is! FunctionTypeImpl) { | |
3815 return false; | |
3816 } | |
3817 FunctionTypeImpl otherType = object as FunctionTypeImpl; | |
3818 return element == otherType.element && JavaArrays.equals(_normalParameterTyp
es, otherType._normalParameterTypes) && JavaArrays.equals(_optionalParameterType
s, otherType._optionalParameterTypes) && equals2(_namedParameterTypes, otherType
._namedParameterTypes); | |
3819 } | |
3820 Map<String, Type2> get namedParameterTypes => _namedParameterTypes; | |
3821 List<Type2> get normalParameterTypes => _normalParameterTypes; | |
3822 List<Type2> get optionalParameterTypes => _optionalParameterTypes; | |
3823 Type2 get returnType => _returnType; | |
3824 List<Type2> get typeArguments => _typeArguments; | |
3825 int get hashCode { | |
3826 Element element39 = element; | |
3827 if (element39 == null) { | |
3828 return 0; | |
3829 } | |
3830 return element39.hashCode; | |
3831 } | |
3832 bool isSubtypeOf(Type2 type) { | |
3833 if (type == null) { | |
3834 return false; | |
3835 } else if (identical(this, type) || type.isDynamic() || type.isDartCoreFunct
ion()) { | |
3836 return true; | |
3837 } else if (type is! FunctionType) { | |
3838 return false; | |
3839 } else if (this == type) { | |
3840 return true; | |
3841 } | |
3842 FunctionType t = this; | |
3843 FunctionType s = type as FunctionType; | |
3844 if (t.normalParameterTypes.length != s.normalParameterTypes.length) { | |
3845 return false; | |
3846 } else if (t.normalParameterTypes.length > 0) { | |
3847 List<Type2> tTypes = t.normalParameterTypes; | |
3848 List<Type2> sTypes = s.normalParameterTypes; | |
3849 for (int i = 0; i < tTypes.length; i++) { | |
3850 if (!tTypes[i].isAssignableTo(sTypes[i])) { | |
3851 return false; | |
3852 } | |
3853 } | |
3854 } | |
3855 if (t.optionalParameterTypes.length > 0) { | |
3856 List<Type2> tOpTypes = t.optionalParameterTypes; | |
3857 List<Type2> sOpTypes = s.optionalParameterTypes; | |
3858 if (tOpTypes.length < sOpTypes.length) { | |
3859 return false; | |
3860 } | |
3861 for (int i = 0; i < sOpTypes.length; i++) { | |
3862 if (!tOpTypes[i].isAssignableTo(sOpTypes[i])) { | |
3863 return false; | |
3864 } | |
3865 } | |
3866 if (t.namedParameterTypes.length > 0 || s.namedParameterTypes.length > 0)
{ | |
3867 return false; | |
3868 } | |
3869 } else if (s.optionalParameterTypes.length > 0) { | |
3870 return false; | |
3871 } | |
3872 if (t.namedParameterTypes.length > 0) { | |
3873 Map<String, Type2> namedTypesT = t.namedParameterTypes; | |
3874 Map<String, Type2> namedTypesS = s.namedParameterTypes; | |
3875 if (namedTypesT.length < namedTypesS.length) { | |
3876 return false; | |
3877 } | |
3878 JavaIterator<MapEntry<String, Type2>> iteratorS = new JavaIterator(getMapE
ntrySet(namedTypesS)); | |
3879 while (iteratorS.hasNext) { | |
3880 MapEntry<String, Type2> entryS = iteratorS.next(); | |
3881 Type2 typeT = namedTypesT[entryS.getKey()]; | |
3882 if (typeT == null) { | |
3883 return false; | |
3884 } | |
3885 if (!entryS.getValue().isAssignableTo(typeT)) { | |
3886 return false; | |
3887 } | |
3888 } | |
3889 } else if (s.namedParameterTypes.length > 0) { | |
3890 return false; | |
3891 } | |
3892 return s.returnType == VoidTypeImpl.instance || t.returnType.isAssignableTo(
s.returnType); | |
3893 } | |
3894 /** | |
3895 * Set the mapping of the names of named parameters to the types of the named
parameters of this | |
3896 * type of function to the given mapping. | |
3897 * @param namedParameterTypes the mapping of the names of named parameters to
the types of the | |
3898 * named parameters of this type of function | |
3899 */ | |
3900 void set namedParameterTypes(LinkedHashMap<String, Type2> namedParameterTypes2
) { | |
3901 this._namedParameterTypes = namedParameterTypes2; | |
3902 } | |
3903 /** | |
3904 * Set the types of the normal parameters of this type of function to the type
s in the given | |
3905 * array. | |
3906 * @param normalParameterTypes the types of the normal parameters of this type
of function | |
3907 */ | |
3908 void set normalParameterTypes(List<Type2> normalParameterTypes2) { | |
3909 this._normalParameterTypes = normalParameterTypes2; | |
3910 } | |
3911 /** | |
3912 * Set the types of the optional parameters of this type of function to the ty
pes in the given | |
3913 * array. | |
3914 * @param optionalParameterTypes the types of the optional parameters of this
type of function | |
3915 */ | |
3916 void set optionalParameterTypes(List<Type2> optionalParameterTypes2) { | |
3917 this._optionalParameterTypes = optionalParameterTypes2; | |
3918 } | |
3919 /** | |
3920 * Set the type of object returned by this type of function to the given type. | |
3921 * @param returnType the type of object returned by this type of function | |
3922 */ | |
3923 void set returnType(Type2 returnType3) { | |
3924 this._returnType = returnType3; | |
3925 } | |
3926 /** | |
3927 * Set the actual types of the type arguments to the given types. | |
3928 * @param typeArguments the actual types of the type arguments | |
3929 */ | |
3930 void set typeArguments(List<Type2> typeArguments4) { | |
3931 this._typeArguments = typeArguments4; | |
3932 } | |
3933 FunctionTypeImpl substitute4(List<Type2> argumentTypes) => substitute2(argumen
tTypes, typeArguments); | |
3934 FunctionTypeImpl substitute2(List<Type2> argumentTypes, List<Type2> parameterT
ypes) { | |
3935 if (argumentTypes.length != parameterTypes.length) { | |
3936 throw new IllegalArgumentException("argumentTypes.length (${argumentTypes.
length}) != parameterTypes.length (${parameterTypes.length})"); | |
3937 } | |
3938 if (argumentTypes.length == 0) { | |
3939 return this; | |
3940 } | |
3941 Element element40 = element; | |
3942 FunctionTypeImpl newType = (element40 is ExecutableElement) ? new FunctionTy
peImpl.con1((element40 as ExecutableElement)) : new FunctionTypeImpl.con2((eleme
nt40 as TypeAliasElement)); | |
3943 newType.returnType = _returnType.substitute2(argumentTypes, parameterTypes); | |
3944 newType.normalParameterTypes = TypeImpl.substitute(_normalParameterTypes, ar
gumentTypes, parameterTypes); | |
3945 newType.optionalParameterTypes = TypeImpl.substitute(_optionalParameterTypes
, argumentTypes, parameterTypes); | |
3946 newType._namedParameterTypes = substitute3(_namedParameterTypes, argumentTyp
es, parameterTypes); | |
3947 return newType; | |
3948 } | |
3949 void appendTo(JavaStringBuilder builder) { | |
3950 builder.append("("); | |
3951 bool needsComma = false; | |
3952 if (_normalParameterTypes.length > 0) { | |
3953 for (Type2 type in _normalParameterTypes) { | |
3954 if (needsComma) { | |
3955 builder.append(", "); | |
3956 } else { | |
3957 needsComma = true; | |
3958 } | |
3959 ((type as TypeImpl)).appendTo(builder); | |
3960 } | |
3961 } | |
3962 if (_optionalParameterTypes.length > 0) { | |
3963 if (needsComma) { | |
3964 builder.append(", "); | |
3965 needsComma = false; | |
3966 } | |
3967 builder.append("["); | |
3968 for (Type2 type in _optionalParameterTypes) { | |
3969 if (needsComma) { | |
3970 builder.append(", "); | |
3971 } else { | |
3972 needsComma = true; | |
3973 } | |
3974 ((type as TypeImpl)).appendTo(builder); | |
3975 } | |
3976 builder.append("]"); | |
3977 needsComma = true; | |
3978 } | |
3979 if (_namedParameterTypes.length > 0) { | |
3980 if (needsComma) { | |
3981 builder.append(", "); | |
3982 needsComma = false; | |
3983 } | |
3984 builder.append("{"); | |
3985 for (MapEntry<String, Type2> entry in getMapEntrySet(_namedParameterTypes)
) { | |
3986 if (needsComma) { | |
3987 builder.append(", "); | |
3988 } else { | |
3989 needsComma = true; | |
3990 } | |
3991 builder.append(entry.getKey()); | |
3992 builder.append(": "); | |
3993 ((entry.getValue() as TypeImpl)).appendTo(builder); | |
3994 } | |
3995 builder.append("}"); | |
3996 needsComma = true; | |
3997 } | |
3998 builder.append(") -> "); | |
3999 if (_returnType == null) { | |
4000 builder.append("null"); | |
4001 } else { | |
4002 ((_returnType as TypeImpl)).appendTo(builder); | |
4003 } | |
4004 } | |
4005 } | |
4006 /** | |
4007 * Instances of the class {@code InterfaceTypeImpl} defines the behavior common
to objects | |
4008 * representing the type introduced by either a class or an interface, or a refe
rence to such a | |
4009 * type. | |
4010 * @coverage dart.engine.type | |
4011 */ | |
4012 class InterfaceTypeImpl extends TypeImpl implements InterfaceType { | |
4013 /** | |
4014 * An empty array of types. | |
4015 */ | |
4016 static List<InterfaceType> EMPTY_ARRAY = new List<InterfaceType>(0); | |
4017 /** | |
4018 * This method computes the longest inheritance path from some passed {@link T
ype} to Object. | |
4019 * @param type the {@link Type} to compute the longest inheritance path of fro
m the passed{@link Type} to Object | |
4020 * @return the computed longest inheritance path to Object | |
4021 * @see #computeLongestInheritancePathToObject(Type,int) | |
4022 * @see InterfaceType#getLeastUpperBound(Type) | |
4023 */ | |
4024 static int computeLongestInheritancePathToObject(InterfaceType type) => comput
eLongestInheritancePathToObject2(type, 0); | |
4025 /** | |
4026 * Returns the set of all superinterfaces of the passed {@link Type}. | |
4027 * @param type the {@link Type} to compute the set of superinterfaces of | |
4028 * @return the {@link Set} of superinterfaces of the passed {@link Type} | |
4029 * @see #computeSuperinterfaceSet(Type,HashSet) | |
4030 * @see #getLeastUpperBound(Type) | |
4031 */ | |
4032 static Set<InterfaceType> computeSuperinterfaceSet(InterfaceType type) => comp
uteSuperinterfaceSet2(type, new Set<InterfaceType>()); | |
4033 /** | |
4034 * This method computes the longest inheritance path from some passed {@link T
ype} to Object. This | |
4035 * method calls itself recursively, callers should use the public method{@link
#computeLongestInheritancePathToObject(Type)}. | |
4036 * @param type the {@link Type} to compute the longest inheritance path of fro
m the passed{@link Type} to Object | |
4037 * @param depth a field used recursively | |
4038 * @return the computed longest inheritance path to Object | |
4039 * @see #computeLongestInheritancePathToObject(Type) | |
4040 * @see #getLeastUpperBound(Type) | |
4041 */ | |
4042 static int computeLongestInheritancePathToObject2(InterfaceType type, int dept
h) { | |
4043 ClassElement classElement = type.element; | |
4044 if (classElement.supertype == null) { | |
4045 return depth; | |
4046 } | |
4047 List<InterfaceType> superinterfaces = classElement.interfaces; | |
4048 int longestPath = 1; | |
4049 int pathLength; | |
4050 if (superinterfaces.length > 0) { | |
4051 for (InterfaceType superinterface in superinterfaces) { | |
4052 pathLength = computeLongestInheritancePathToObject2(superinterface, dept
h + 1); | |
4053 if (pathLength > longestPath) { | |
4054 longestPath = pathLength; | |
4055 } | |
4056 } | |
4057 } | |
4058 InterfaceType supertype3 = classElement.supertype; | |
4059 pathLength = computeLongestInheritancePathToObject2(supertype3, depth + 1); | |
4060 if (pathLength > longestPath) { | |
4061 longestPath = pathLength; | |
4062 } | |
4063 return longestPath; | |
4064 } | |
4065 /** | |
4066 * Returns the set of all superinterfaces of the passed {@link Type}. This is
a recursive method, | |
4067 * callers should call the public {@link #computeSuperinterfaceSet(Type)}. | |
4068 * @param type the {@link Type} to compute the set of superinterfaces of | |
4069 * @param set a {@link HashSet} used recursively by this method | |
4070 * @return the {@link Set} of superinterfaces of the passed {@link Type} | |
4071 * @see #computeSuperinterfaceSet(Type) | |
4072 * @see #getLeastUpperBound(Type) | |
4073 */ | |
4074 static Set<InterfaceType> computeSuperinterfaceSet2(InterfaceType type, Set<In
terfaceType> set) { | |
4075 Element element41 = type.element; | |
4076 if (element41 != null && element41 is ClassElement) { | |
4077 ClassElement classElement = element41 as ClassElement; | |
4078 List<InterfaceType> superinterfaces = classElement.interfaces; | |
4079 for (InterfaceType superinterface in superinterfaces) { | |
4080 javaSetAdd(set, superinterface); | |
4081 computeSuperinterfaceSet2(superinterface, set); | |
4082 } | |
4083 InterfaceType supertype4 = classElement.supertype; | |
4084 if (supertype4 != null) { | |
4085 javaSetAdd(set, supertype4); | |
4086 computeSuperinterfaceSet2(supertype4, set); | |
4087 } | |
4088 } | |
4089 return set; | |
4090 } | |
4091 /** | |
4092 * An array containing the actual types of the type arguments. | |
4093 */ | |
4094 List<Type2> _typeArguments = TypeImpl.EMPTY_ARRAY; | |
4095 /** | |
4096 * Initialize a newly created type to be declared by the given element. | |
4097 * @param element the element representing the declaration of the type | |
4098 */ | |
4099 InterfaceTypeImpl.con1(ClassElement element) : super(element, element.name) { | |
4100 _jtd_constructor_250_impl(element); | |
4101 } | |
4102 _jtd_constructor_250_impl(ClassElement element) { | |
4103 } | |
4104 /** | |
4105 * Initialize a newly created type to have the given name. This constructor sh
ould only be used in | |
4106 * cases where there is no declaration of the type. | |
4107 * @param name the name of the type | |
4108 */ | |
4109 InterfaceTypeImpl.con2(String name) : super(null, name) { | |
4110 _jtd_constructor_251_impl(name); | |
4111 } | |
4112 _jtd_constructor_251_impl(String name) { | |
4113 } | |
4114 bool operator ==(Object object) { | |
4115 if (object is! InterfaceTypeImpl) { | |
4116 return false; | |
4117 } | |
4118 InterfaceTypeImpl otherType = object as InterfaceTypeImpl; | |
4119 return element == otherType.element && JavaArrays.equals(_typeArguments, oth
erType._typeArguments); | |
4120 } | |
4121 ClassElement get element => super.element as ClassElement; | |
4122 Type2 getLeastUpperBound(Type2 type) { | |
4123 Type2 dynamicType = DynamicTypeImpl.instance; | |
4124 if (identical(this, dynamicType) || identical(type, dynamicType)) { | |
4125 return dynamicType; | |
4126 } | |
4127 if (type == null || type is! InterfaceType) { | |
4128 return null; | |
4129 } | |
4130 InterfaceType i = this; | |
4131 InterfaceType j = type as InterfaceType; | |
4132 Set<InterfaceType> si = computeSuperinterfaceSet(i); | |
4133 Set<InterfaceType> sj = computeSuperinterfaceSet(j); | |
4134 javaSetAdd(si, i); | |
4135 javaSetAdd(sj, j); | |
4136 si.retainAll(sj); | |
4137 Set<InterfaceType> s = si; | |
4138 List<InterfaceType> sn = new List.from(s); | |
4139 List<int> depths = new List<int>.filled(sn.length, 0); | |
4140 int maxDepth = 0; | |
4141 for (int n = 0; n < sn.length; n++) { | |
4142 depths[n] = computeLongestInheritancePathToObject(sn[n]); | |
4143 if (depths[n] > maxDepth) { | |
4144 maxDepth = depths[n]; | |
4145 } | |
4146 } | |
4147 for (; maxDepth >= 0; maxDepth--) { | |
4148 int indexOfLeastUpperBound = -1; | |
4149 int numberOfTypesAtMaxDepth = 0; | |
4150 for (int m = 0; m < depths.length; m++) { | |
4151 if (depths[m] == maxDepth) { | |
4152 numberOfTypesAtMaxDepth++; | |
4153 indexOfLeastUpperBound = m; | |
4154 } | |
4155 } | |
4156 if (numberOfTypesAtMaxDepth == 1) { | |
4157 return sn[indexOfLeastUpperBound]; | |
4158 } | |
4159 } | |
4160 return null; | |
4161 } | |
4162 Type2 get superclass { | |
4163 ClassElement classElement = element; | |
4164 return element.supertype.substitute2(_typeArguments, TypeVariableTypeImpl.ge
tTypes(classElement.typeVariables)); | |
4165 } | |
4166 List<Type2> get typeArguments => _typeArguments; | |
4167 int get hashCode { | |
4168 ClassElement element42 = element; | |
4169 if (element42 == null) { | |
4170 return 0; | |
4171 } | |
4172 return element42.hashCode; | |
4173 } | |
4174 bool isDartCoreFunction() { | |
4175 ClassElement element43 = element; | |
4176 if (element43 == null) { | |
4177 return false; | |
4178 } | |
4179 return element43.name == "Function" && element43.library.isDartCore(); | |
4180 } | |
4181 bool isDirectSupertypeOf(InterfaceType type) { | |
4182 ClassElement i = element; | |
4183 ClassElement j = type.element; | |
4184 InterfaceType supertype5 = j.supertype; | |
4185 if (supertype5 == null) { | |
4186 return false; | |
4187 } | |
4188 ClassElement supertypeElement = supertype5.element; | |
4189 if (supertypeElement == i) { | |
4190 return true; | |
4191 } | |
4192 for (InterfaceType interfaceType in j.interfaces) { | |
4193 if (interfaceType.element == i) { | |
4194 return true; | |
4195 } | |
4196 } | |
4197 for (InterfaceType mixinType in j.mixins) { | |
4198 if (mixinType.element == i) { | |
4199 return true; | |
4200 } | |
4201 } | |
4202 return false; | |
4203 } | |
4204 bool isMoreSpecificThan(Type2 type) { | |
4205 if (identical(type, DynamicTypeImpl.instance)) { | |
4206 return true; | |
4207 } else if (type is! InterfaceType) { | |
4208 return false; | |
4209 } | |
4210 InterfaceType s = type as InterfaceType; | |
4211 if (this == s) { | |
4212 return true; | |
4213 } | |
4214 if (s.isDirectSupertypeOf(this)) { | |
4215 return true; | |
4216 } | |
4217 ClassElement tElement = element; | |
4218 ClassElement sElement = s.element; | |
4219 if (tElement == sElement) { | |
4220 List<Type2> tArguments = typeArguments; | |
4221 List<Type2> sArguments = s.typeArguments; | |
4222 if (tArguments.length != sArguments.length) { | |
4223 return false; | |
4224 } | |
4225 for (int i = 0; i < tArguments.length; i++) { | |
4226 if (!tArguments[i].isMoreSpecificThan(sArguments[i])) { | |
4227 return false; | |
4228 } | |
4229 } | |
4230 return true; | |
4231 } | |
4232 if (element.supertype == null) { | |
4233 return false; | |
4234 } | |
4235 return element.supertype.isMoreSpecificThan(type); | |
4236 } | |
4237 bool isSubtypeOf(Type2 type) { | |
4238 if (identical(type, DynamicTypeImpl.instance)) { | |
4239 return true; | |
4240 } else if (type is TypeVariableType) { | |
4241 return true; | |
4242 } else if (type is! InterfaceType) { | |
4243 return false; | |
4244 } else if (this == type) { | |
4245 return true; | |
4246 } | |
4247 InterfaceType typeT = this; | |
4248 InterfaceType typeS = type as InterfaceType; | |
4249 ClassElement elementT = element; | |
4250 if (elementT == null) { | |
4251 return false; | |
4252 } | |
4253 typeT = substitute2(_typeArguments, TypeVariableTypeImpl.getTypes(elementT.t
ypeVariables)); | |
4254 if (typeT == typeS) { | |
4255 return true; | |
4256 } else if (elementT == typeS.element) { | |
4257 List<Type2> typeTArgs = typeT.typeArguments; | |
4258 List<Type2> typeSArgs = typeS.typeArguments; | |
4259 if (typeTArgs.length != typeSArgs.length) { | |
4260 return false; | |
4261 } | |
4262 for (int i = 0; i < typeTArgs.length; i++) { | |
4263 if (!typeTArgs[i].isSubtypeOf(typeSArgs[i])) { | |
4264 return false; | |
4265 } | |
4266 } | |
4267 return true; | |
4268 } | |
4269 Type2 supertype6 = elementT.supertype; | |
4270 if (supertype6 == null) { | |
4271 return false; | |
4272 } | |
4273 List<Type2> interfaceTypes = elementT.interfaces; | |
4274 for (Type2 interfaceType in interfaceTypes) { | |
4275 if (interfaceType.isSubtypeOf(typeS)) { | |
4276 return true; | |
4277 } | |
4278 } | |
4279 List<Type2> mixinTypes = elementT.mixins; | |
4280 for (Type2 mixinType in mixinTypes) { | |
4281 if (mixinType == typeS) { | |
4282 return true; | |
4283 } | |
4284 } | |
4285 return supertype6.isSubtypeOf(typeS); | |
4286 } | |
4287 /** | |
4288 * Set the actual types of the type arguments to those in the given array. | |
4289 * @param typeArguments the actual types of the type arguments | |
4290 */ | |
4291 void set typeArguments(List<Type2> typeArguments5) { | |
4292 this._typeArguments = typeArguments5; | |
4293 } | |
4294 InterfaceTypeImpl substitute5(List<Type2> argumentTypes) => substitute2(argume
ntTypes, typeArguments); | |
4295 InterfaceTypeImpl substitute2(List<Type2> argumentTypes, List<Type2> parameter
Types) { | |
4296 if (argumentTypes.length != parameterTypes.length) { | |
4297 throw new IllegalArgumentException("argumentTypes.length (${argumentTypes.
length}) != parameterTypes.length (${parameterTypes.length})"); | |
4298 } | |
4299 if (argumentTypes.length == 0) { | |
4300 return this; | |
4301 } | |
4302 InterfaceTypeImpl newType = new InterfaceTypeImpl.con1(element); | |
4303 newType.typeArguments = TypeImpl.substitute(_typeArguments, argumentTypes, p
arameterTypes); | |
4304 return newType; | |
4305 } | |
4306 void appendTo(JavaStringBuilder builder) { | |
4307 builder.append(name); | |
4308 int argumentCount = _typeArguments.length; | |
4309 if (argumentCount > 0) { | |
4310 builder.append("<"); | |
4311 for (int i = 0; i < argumentCount; i++) { | |
4312 if (i > 0) { | |
4313 builder.append(", "); | |
4314 } | |
4315 ((_typeArguments[i] as TypeImpl)).appendTo(builder); | |
4316 } | |
4317 builder.append(">"); | |
4318 } | |
4319 } | |
4320 } | |
4321 /** | |
4322 * The abstract class {@code TypeImpl} implements the behavior common to objects
representing the | |
4323 * declared type of elements in the element model. | |
4324 * @coverage dart.engine.type | |
4325 */ | |
4326 abstract class TypeImpl implements Type2 { | |
4327 /** | |
4328 * Return an array containing the results of using the given argument types an
d parameter types to | |
4329 * perform a substitution on all of the given types. | |
4330 * @param types the types on which a substitution is to be performed | |
4331 * @param argumentTypes the argument types for the substitution | |
4332 * @param parameterTypes the parameter types for the substitution | |
4333 * @return the result of performing the substitution on each of the types | |
4334 */ | |
4335 static List<Type2> substitute(List<Type2> types, List<Type2> argumentTypes, Li
st<Type2> parameterTypes) { | |
4336 int length6 = types.length; | |
4337 if (length6 == 0) { | |
4338 return types; | |
4339 } | |
4340 List<Type2> newTypes = new List<Type2>(length6); | |
4341 for (int i = 0; i < length6; i++) { | |
4342 newTypes[i] = types[i].substitute2(argumentTypes, parameterTypes); | |
4343 } | |
4344 return newTypes; | |
4345 } | |
4346 /** | |
4347 * The element representing the declaration of this type, or {@code null} if t
he type has not, or | |
4348 * cannot, be associated with an element. | |
4349 */ | |
4350 Element _element; | |
4351 /** | |
4352 * The name of this type, or {@code null} if the type does not have a name. | |
4353 */ | |
4354 String _name; | |
4355 /** | |
4356 * An empty array of types. | |
4357 */ | |
4358 static List<Type2> EMPTY_ARRAY = new List<Type2>(0); | |
4359 /** | |
4360 * Initialize a newly created type to be declared by the given element and to
have the given name. | |
4361 * @param element the element representing the declaration of the type | |
4362 * @param name the name of the type | |
4363 */ | |
4364 TypeImpl(Element element, String name) { | |
4365 this._element = element; | |
4366 this._name = name; | |
4367 } | |
4368 Element get element => _element; | |
4369 Type2 getLeastUpperBound(Type2 type) => null; | |
4370 String get name => _name; | |
4371 bool isAssignableTo(Type2 type) => this.isSubtypeOf(type) || type.isSubtypeOf(
this); | |
4372 bool isDartCoreFunction() => false; | |
4373 bool isDynamic() => false; | |
4374 bool isMoreSpecificThan(Type2 type) => false; | |
4375 bool isSupertypeOf(Type2 type) => type.isSubtypeOf(this); | |
4376 bool isVoid() => false; | |
4377 String toString() { | |
4378 JavaStringBuilder builder = new JavaStringBuilder(); | |
4379 appendTo(builder); | |
4380 return builder.toString(); | |
4381 } | |
4382 /** | |
4383 * Append a textual representation of this type to the given builder. | |
4384 * @param builder the builder to which the text is to be appended | |
4385 */ | |
4386 void appendTo(JavaStringBuilder builder) { | |
4387 if (_name == null) { | |
4388 builder.append("<unnamed type>"); | |
4389 } else { | |
4390 builder.append(_name); | |
4391 } | |
4392 } | |
4393 } | |
4394 /** | |
4395 * Instances of the class {@code TypeVariableTypeImpl} defines the behavior of o
bjects representing | |
4396 * the type introduced by a type variable. | |
4397 * @coverage dart.engine.type | |
4398 */ | |
4399 class TypeVariableTypeImpl extends TypeImpl implements TypeVariableType { | |
4400 /** | |
4401 * Return an array containing the type variable types defined by the given arr
ay of type variable | |
4402 * elements. | |
4403 * @param typeVariables the type variable elements defining the type variable
types to be returned | |
4404 * @return the type variable types defined by the type variable elements | |
4405 */ | |
4406 static List<TypeVariableType> getTypes(List<TypeVariableElement> typeVariables
) { | |
4407 int count = typeVariables.length; | |
4408 List<TypeVariableType> types = new List<TypeVariableType>(count); | |
4409 for (int i = 0; i < count; i++) { | |
4410 types[i] = typeVariables[i].type; | |
4411 } | |
4412 return types; | |
4413 } | |
4414 /** | |
4415 * Initialize a newly created type variable to be declared by the given elemen
t and to have the | |
4416 * given name. | |
4417 * @param element the element representing the declaration of the type variabl
e | |
4418 */ | |
4419 TypeVariableTypeImpl(TypeVariableElement element) : super(element, element.nam
e) { | |
4420 } | |
4421 bool operator ==(Object object) => object is TypeVariableTypeImpl && element =
= ((object as TypeVariableTypeImpl)).element; | |
4422 TypeVariableElement get element => super.element as TypeVariableElement; | |
4423 int get hashCode => element.hashCode; | |
4424 bool isMoreSpecificThan(Type2 type) { | |
4425 Type2 upperBound = element.bound; | |
4426 return type == upperBound; | |
4427 } | |
4428 bool isSubtypeOf(Type2 type) => true; | |
4429 Type2 substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes) { | |
4430 int length7 = parameterTypes.length; | |
4431 for (int i = 0; i < length7; i++) { | |
4432 if (parameterTypes[i] == this) { | |
4433 return argumentTypes[i]; | |
4434 } | |
4435 } | |
4436 return this; | |
4437 } | |
4438 } | |
4439 /** | |
4440 * The unique instance of the class {@code VoidTypeImpl} implements the type {@c
ode void}. | |
4441 * @coverage dart.engine.type | |
4442 */ | |
4443 class VoidTypeImpl extends TypeImpl implements VoidType { | |
4444 /** | |
4445 * The unique instance of this class. | |
4446 */ | |
4447 static VoidTypeImpl _INSTANCE = new VoidTypeImpl(); | |
4448 /** | |
4449 * Return the unique instance of this class. | |
4450 * @return the unique instance of this class | |
4451 */ | |
4452 static VoidTypeImpl get instance => _INSTANCE; | |
4453 /** | |
4454 * Prevent the creation of instances of this class. | |
4455 */ | |
4456 VoidTypeImpl() : super(null, Keyword.VOID.syntax) { | |
4457 } | |
4458 bool operator ==(Object object) => identical(object, this); | |
4459 bool isSubtypeOf(Type2 type) => identical(type, this) || identical(type, Dynam
icTypeImpl.instance); | |
4460 bool isVoid() => true; | |
4461 VoidTypeImpl substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes
) => this; | |
4462 } | |
4463 /** | |
4464 * The interface {@code FunctionType} defines the behavior common to objects rep
resenting the type | |
4465 * of a function, method, constructor, getter, or setter. Function types come in
three variations: | |
4466 * <ol> | |
4467 * <li>The types of functions that only have required parameters. These have the
general form | |
4468 * <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T</i>.</li> | |
4469 * <li>The types of functions with optional positional parameters. These have th
e general form | |
4470 * <i>(T<sub>1</sub>, …, T<sub>n</sub>, [T<sub>n+1</sub>, …, T<sub
>n+k</sub>]) → | |
4471 * T</i>.</li> | |
4472 * <li>The types of functions with named positional parameters. These have the g
eneral form | |
4473 * <i>(T<sub>1</sub>, …, T<sub>n</sub>, {T<sub>x1</sub> x1, …, T<s
ub>xk</sub> xk}) | |
4474 * → T</i>.</li> | |
4475 * </ol> | |
4476 * @coverage dart.engine.type | |
4477 */ | |
4478 abstract class FunctionType implements Type2 { | |
4479 /** | |
4480 * Return a map from the names of named parameters to the types of the named p
arameters of this | |
4481 * type of function. The entries in the map will be iterated in the same order
as the order in | |
4482 * which the named parameters were defined. If there were no named parameters
declared then the | |
4483 * map will be empty. | |
4484 * @return a map from the name to the types of the named parameters of this ty
pe of function | |
4485 */ | |
4486 Map<String, Type2> get namedParameterTypes; | |
4487 /** | |
4488 * Return an array containing the types of the normal parameters of this type
of function. The | |
4489 * parameter types are in the same order as they appear in the declaration of
the function. | |
4490 * @return the types of the normal parameters of this type of function | |
4491 */ | |
4492 List<Type2> get normalParameterTypes; | |
4493 /** | |
4494 * Return a map from the names of optional (positional) parameters to the type
s of the optional | |
4495 * parameters of this type of function. The entries in the map will be iterate
d in the same order | |
4496 * as the order in which the optional parameters were defined. If there were n
o optional | |
4497 * parameters declared then the map will be empty. | |
4498 * @return a map from the name to the types of the optional parameters of this
type of function | |
4499 */ | |
4500 List<Type2> get optionalParameterTypes; | |
4501 /** | |
4502 * Return the type of object returned by this type of function. | |
4503 * @return the type of object returned by this type of function | |
4504 */ | |
4505 Type2 get returnType; | |
4506 /** | |
4507 * Return an array containing the actual types of the type arguments. If this
type's element does | |
4508 * not have type parameters, then the array should be empty (although it is po
ssible for type | |
4509 * arguments to be erroneously declared). If the element has type parameters a
nd the actual type | |
4510 * does not explicitly include argument values, then the type "dynamic" will b
e automatically | |
4511 * provided. | |
4512 * @return the actual types of the type arguments | |
4513 */ | |
4514 List<Type2> get typeArguments; | |
4515 /** | |
4516 * Return {@code true} if this type is a subtype of the given type. | |
4517 * <p> | |
4518 * A function type <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T</i> is
a subtype of the | |
4519 * function type <i>(S<sub>1</sub>, …, S<sub>n</sub>) → S</i>, if
all of the following | |
4520 * conditions are met: | |
4521 * <ul> | |
4522 * <li>Either | |
4523 * <ul> | |
4524 * <li><i>S</i> is void, or</li> | |
4525 * <li><i>T ⇔ S</i>.</li> | |
4526 * </ul> | |
4527 * </li> | |
4528 * <li>For all <i>i</i>, 1 <= <i>i</i> <= <i>n</i>, <i>T<sub>i</sub> ⇔ S<
sub>i</sub></i>.</li> | |
4529 * </ul> | |
4530 * A function type <i>(T<sub>1</sub>, …, T<sub>n</sub>, [T<sub>n+1</sub
>, …, | |
4531 * T<sub>n+k</sub>]) → T</i> is a subtype of the function type <i>(S<sub>
1</sub>, …, | |
4532 * S<sub>n</sub>, [S<sub>n+1</sub>, …, S<sub>n+m</sub>]) → S</i>,
if all of the | |
4533 * following conditions are met: | |
4534 * <ul> | |
4535 * <li>Either | |
4536 * <ul> | |
4537 * <li><i>S</i> is void, or</li> | |
4538 * <li><i>T ⇔ S</i>.</li> | |
4539 * </ul> | |
4540 * </li> | |
4541 * <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> | |
4542 * ⇔ S<sub>i</sub></i>.</li> | |
4543 * </ul> | |
4544 * A function type <i>(T<sub>1</sub>, …, T<sub>n</sub>, {T<sub>x1</sub>
x1, …, | |
4545 * T<sub>xk</sub> xk}) → T</i> is a subtype of the function type <i>(S<su
b>1</sub>, …, | |
4546 * S<sub>n</sub>, {S<sub>y1</sub> y1, …, S<sub>ym</sub> ym}) → S</
i>, if all of the | |
4547 * following conditions are met: | |
4548 * <ul> | |
4549 * <li>Either | |
4550 * <ul> | |
4551 * <li><i>S</i> is void,</li> | |
4552 * <li>or <i>T ⇔ S</i>.</li> | |
4553 * </ul> | |
4554 * </li> | |
4555 * <li>For all <i>i</i>, 1 <= <i>i</i> <= <i>n</i>, <i>T<sub>i</sub> ⇔ S<
sub>i</sub></i>.</li> | |
4556 * <li><i>k</i> >= <i>m</i> and <i>y<sub>i</sub></i> in <i>{x<sub>1</sub>, &he
llip;, | |
4557 * x<sub>k</sub>}</i>, 1 <= <i>i</i> <= <i>m</i>.</li> | |
4558 * <li>For all <i>y<sub>i</sub></i> in <i>{y<sub>1</sub>, …, y<sub>m</s
ub>}</i>, | |
4559 * <i>y<sub>i</sub> = x<sub>j</sub> => Tj ⇔ Si</i>.</li> | |
4560 * </ul> | |
4561 * In addition, the following subtype rules apply: | |
4562 * <p> | |
4563 * <i>(T<sub>1</sub>, …, T<sub>n</sub>, []) → T <: (T<sub>1</sub>,
…, | |
4564 * T<sub>n</sub>) → T.</i><br> | |
4565 * <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T <: (T<sub>1</sub>, &he
llip;, | |
4566 * T<sub>n</sub>, {}) → T.</i><br> | |
4567 * <i>(T<sub>1</sub>, …, T<sub>n</sub>, {}) → T <: (T<sub>1</sub>,
…, | |
4568 * T<sub>n</sub>) → T.</i><br> | |
4569 * <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T <: (T<sub>1</sub>, &he
llip;, | |
4570 * T<sub>n</sub>, []) → T.</i> | |
4571 * <p> | |
4572 * All functions implement the class {@code Function}. However not all functio
n types are a | |
4573 * 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 | |
4574 * considered to be a subtype of <i>F</i>. | |
4575 * @param type the type being compared with this type | |
4576 * @return {@code true} if this type is a subtype of the given type | |
4577 */ | |
4578 bool isSubtypeOf(Type2 type); | |
4579 /** | |
4580 * Return the type resulting from substituting the given arguments for this ty
pe's parameters. | |
4581 * This is fully equivalent to {@code substitute(argumentTypes, getTypeArgumen
ts())}. | |
4582 * @param argumentTypes the actual type arguments being substituted for the ty
pe parameters | |
4583 * @return the result of performing the substitution | |
4584 */ | |
4585 FunctionType substitute4(List<Type2> argumentTypes); | |
4586 FunctionType substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes
); | |
4587 } | |
4588 /** | |
4589 * The interface {@code InterfaceType} defines the behavior common to objects re
presenting the type | |
4590 * introduced by either a class or an interface, or a reference to such a type. | |
4591 * @coverage dart.engine.type | |
4592 */ | |
4593 abstract class InterfaceType implements Type2 { | |
4594 ClassElement get element; | |
4595 /** | |
4596 * Return the least upper bound of this type and the given type, or {@code nul
l} if there is no | |
4597 * least upper bound. | |
4598 * <p> | |
4599 * Given two interfaces <i>I</i> and <i>J</i>, let <i>S<sub>I</sub></i> be the
set of | |
4600 * superinterfaces of <i>I<i>, let <i>S<sub>J</sub></i> be the set of superint
erfaces of <i>J</i> | |
4601 * and let <i>S = (I ∪ S<sub>I</sub>) ∩ (J ∪ S<sub>J</sub>)</i>. F
urthermore, we | |
4602 * define <i>S<sub>n</sub> = {T | T ∈ S ∧ depth(T) = n}</i> for any f
inite <i>n</i>, | |
4603 * where <i>depth(T)</i> is the number of steps in the longest inheritance pat
h from <i>T</i> to | |
4604 * <i>Object</i>. Let <i>q</i> be the largest number such that <i>S<sub>q</sub
></i> has | |
4605 * cardinality one. The least upper bound of <i>I</i> and <i>J</i> is the sole
element of | |
4606 * <i>S<sub>q</sub></i>. | |
4607 * @param type the other type used to compute the least upper bound | |
4608 * @return the least upper bound of this type and the given type | |
4609 */ | |
4610 Type2 getLeastUpperBound(Type2 type); | |
4611 /** | |
4612 * Return the type representing the superclass of this type. Note that this is
<b>not</b>, in | |
4613 * general, equivalent to getting the superclass from this type's element beca
use the type | |
4614 * returned by this method will have had it's type parameters replaced. | |
4615 * @return the superclass of this type | |
4616 */ | |
4617 Type2 get superclass; | |
4618 /** | |
4619 * Return an array containing the actual types of the type arguments. If this
type's element does | |
4620 * not have type parameters, then the array should be empty (although it is po
ssible for type | |
4621 * arguments to be erroneously declared). If the element has type parameters a
nd the actual type | |
4622 * does not explicitly include argument values, then the type "dynamic" will b
e automatically | |
4623 * provided. | |
4624 * @return the actual types of the type arguments | |
4625 */ | |
4626 List<Type2> get typeArguments; | |
4627 /** | |
4628 * Return {@code true} if this type is a direct supertype of the given type. T
he implicit | |
4629 * interface of class <i>I</i> is a direct supertype of the implicit interface
of class <i>J</i> | |
4630 * iff: | |
4631 * <ul> | |
4632 * <li><i>I</i> is Object, and <i>J</i> has no extends clause.</li> | |
4633 * <li><i>I</i> is listed in the extends clause of <i>J</i>.</li> | |
4634 * <li><i>I</i> is listed in the implements clause of <i>J</i>.</li> | |
4635 * <li><i>I</i> is listed in the with clause of <i>J</i>.</li> | |
4636 * <li><i>J</i> is a mixin application of the mixin of <i>I</i>.</li> | |
4637 * </ul> | |
4638 * @param type the type being compared with this type | |
4639 * @return {@code true} if this type is a direct supertype of the given type | |
4640 */ | |
4641 bool isDirectSupertypeOf(InterfaceType type); | |
4642 /** | |
4643 * Return {@code true} if this type is more specific than the given type. An i
nterface type | |
4644 * <i>T</i> is more specific than an interface type <i>S</i>, written <i>T &la
quo; S</i>, if one | |
4645 * of the following conditions is met: | |
4646 * <ul> | |
4647 * <li>Reflexivity: <i>T</i> is <i>S</i>. | |
4648 * <li><i>T</i> is bottom. | |
4649 * <li><i>S</i> is dynamic. | |
4650 * <li>Direct supertype: <i>S</i> is a direct supertype of <i>T</i>. | |
4651 * <li><i>T</i> is a type variable and <i>S</i> is the upper bound of <i>T</i>
. | |
4652 * <li>Covariance: <i>T</i> is of the form <i>I<T<sub>1</sub>, …, T<
sub>n</sub>></i> | |
4653 * and S</i> is of the form <i>I<S<sub>1</sub>, …, S<sub>n</sub>>
</i> and | |
4654 * <i>T<sub>i</sub> « S<sub>i</sub></i>, <i>1 <= i <= n</i>. | |
4655 * <li>Transitivity: <i>T « U</i> and <i>U « S</i>. | |
4656 * </ul> | |
4657 * @param type the type being compared with this type | |
4658 * @return {@code true} if this type is more specific than the given type | |
4659 */ | |
4660 bool isMoreSpecificThan(Type2 type); | |
4661 /** | |
4662 * Return {@code true} if this type is a subtype of the given type. An interfa
ce type <i>T</i> is | |
4663 * a subtype of an interface type <i>S</i>, written <i>T</i> <: <i>S</i>, iff | |
4664 * <i>[bottom/dynamic]T</i> « <i>S</i> (<i>T</i> is more specific than <
i>S</i>). If an | |
4665 * interface type <i>I</i> includes a method named <i>call()</i>, and the type
of <i>call()</i> is | |
4666 * the function type <i>F</i>, then <i>I</i> is considered to be a subtype of
<i>F</i>. | |
4667 * @param type the type being compared with this type | |
4668 * @return {@code true} if this type is a subtype of the given type | |
4669 */ | |
4670 bool isSubtypeOf(Type2 type); | |
4671 /** | |
4672 * Return the type resulting from substituting the given arguments for this ty
pe's parameters. | |
4673 * This is fully equivalent to {@code substitute(argumentTypes, getTypeArgumen
ts())}. | |
4674 * @param argumentTypes the actual type arguments being substituted for the ty
pe parameters | |
4675 * @return the result of performing the substitution | |
4676 */ | |
4677 InterfaceType substitute5(List<Type2> argumentTypes); | |
4678 InterfaceType substitute2(List<Type2> argumentTypes, List<Type2> parameterType
s); | |
4679 } | |
4680 /** | |
4681 * The interface {@code Type} defines the behavior of objects representing the d
eclared type of | |
4682 * elements in the element model. | |
4683 * @coverage dart.engine.type | |
4684 */ | |
4685 abstract class Type2 { | |
4686 /** | |
4687 * Return the element representing the declaration of this type, or {@code nul
l} if the type has | |
4688 * not, or cannot, be associated with an element. The former case will occur i
f the element model | |
4689 * is not yet complete; the latter case will occur if this object represents a
n undefined type. | |
4690 * @return the element representing the declaration of this type | |
4691 */ | |
4692 Element get element; | |
4693 /** | |
4694 * Return the least upper bound of this type and the given type, or {@code nul
l} if there is no | |
4695 * least upper bound. | |
4696 * @param type the other type used to compute the least upper bound | |
4697 * @return the least upper bound of this type and the given type | |
4698 */ | |
4699 Type2 getLeastUpperBound(Type2 type); | |
4700 /** | |
4701 * Return the name of this type, or {@code null} if the type does not have a n
ame, such as when | |
4702 * the type represents the type of an unnamed function. | |
4703 * @return the name of this type | |
4704 */ | |
4705 String get name; | |
4706 /** | |
4707 * Return {@code true} if this type is assignable to the given type. A type <i
>T</i> may be | |
4708 * assigned to a type <i>S</i>, written <i>T</i> ⇔ <i>S</i>, iff either <
i>T</i> <: <i>S</i> | |
4709 * or <i>S</i> <: <i>T</i>. | |
4710 * @param type the type being compared with this type | |
4711 * @return {@code true} if this type is assignable to the given type | |
4712 */ | |
4713 bool isAssignableTo(Type2 type); | |
4714 /** | |
4715 * Return {@code true} if this type represents the type 'Function' defined in
the dart:core | |
4716 * library. | |
4717 * @return {@code true} if this type represents the type 'Function' defined in
the dart:core | |
4718 * library | |
4719 */ | |
4720 bool isDartCoreFunction(); | |
4721 /** | |
4722 * Return {@code true} if this type represents the type 'dynamic'. | |
4723 * @return {@code true} if this type represents the type 'dynamic' | |
4724 */ | |
4725 bool isDynamic(); | |
4726 /** | |
4727 * Return {@code true} if this type is more specific than the given type. | |
4728 * @param type the type being compared with this type | |
4729 * @return {@code true} if this type is more specific than the given type | |
4730 */ | |
4731 bool isMoreSpecificThan(Type2 type); | |
4732 /** | |
4733 * Return {@code true} if this type is a subtype of the given type. | |
4734 * @param type the type being compared with this type | |
4735 * @return {@code true} if this type is a subtype of the given type | |
4736 */ | |
4737 bool isSubtypeOf(Type2 type); | |
4738 /** | |
4739 * Return {@code true} if this type is a supertype of the given type. A type <
i>S</i> is a | |
4740 * supertype of <i>T</i>, written <i>S</i> :> <i>T</i>, iff <i>T</i> is a subt
ype of <i>S</i>. | |
4741 * @param type the type being compared with this type | |
4742 * @return {@code true} if this type is a supertype of the given type | |
4743 */ | |
4744 bool isSupertypeOf(Type2 type); | |
4745 /** | |
4746 * Return {@code true} if this type represents the type 'void'. | |
4747 * @return {@code true} if this type represents the type 'void' | |
4748 */ | |
4749 bool isVoid(); | |
4750 /** | |
4751 * Return the type resulting from substituting the given arguments for the giv
en parameters in | |
4752 * this type. The specification defines this operation in section 2: <blockquo
te> The notation | |
4753 * <i>[x<sub>1</sub>, ..., x<sub>n</sub>/y<sub>1</sub>, ..., y<sub>n</sub>]E</
i> denotes a copy of | |
4754 * <i>E</i> in which all occurrences of <i>y<sub>i</sub>, 1 <= i <= n</i> have
been replaced with | |
4755 * <i>x<sub>i</sub></i>.</blockquote> Note that, contrary to the specification
, this method will | |
4756 * not create a copy of this type if no substitutions were required, but will
return this type | |
4757 * directly. | |
4758 * @param argumentTypes the actual type arguments being substituted for the pa
rameters | |
4759 * @param parameterTypes the parameters to be replaced | |
4760 * @return the result of performing the substitution | |
4761 */ | |
4762 Type2 substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes); | |
4763 } | |
4764 /** | |
4765 * The interface {@code TypeVariableType} defines the behavior of objects repres
enting the type | |
4766 * introduced by a type variable. | |
4767 * @coverage dart.engine.type | |
4768 */ | |
4769 abstract class TypeVariableType implements Type2 { | |
4770 TypeVariableElement get element; | |
4771 } | |
4772 /** | |
4773 * The interface {@code VoidType} defines the behavior of the unique object repr
esenting the type{@code void}. | |
4774 * @coverage dart.engine.type | |
4775 */ | |
4776 abstract class VoidType implements Type2 { | |
4777 VoidType substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes); | |
4778 } | |
OLD | NEW |