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.ast; | |
5 | |
6 import 'dart:collection'; | |
7 import 'java_core.dart'; | |
8 import 'java_engine.dart'; | |
9 import 'error.dart'; | |
10 import 'source.dart' show LineInfo; | |
11 import 'scanner.dart'; | |
12 import 'engine.dart' show AnalysisEngine; | |
13 import 'utilities_dart.dart'; | |
14 import 'element.dart' hide Annotation; | |
15 | |
16 /** | |
17 * The abstract class {@code ASTNode} defines the behavior common to all nodes i
n the AST structure | |
18 * for a Dart program. | |
19 * @coverage dart.engine.ast | |
20 */ | |
21 abstract class ASTNode { | |
22 /** | |
23 * The parent of the node, or {@code null} if the node is the root of an AST s
tructure. | |
24 */ | |
25 ASTNode _parent; | |
26 /** | |
27 * A table mapping the names of properties to their values, or {@code null} if
this node does not | |
28 * have any properties associated with it. | |
29 */ | |
30 Map<String, Object> _propertyMap; | |
31 /** | |
32 * A comparator that can be used to sort AST nodes in lexical order. In other
words,{@code compare} will return a negative value if the offset of the first no
de is less than the | |
33 * offset of the second node, zero (0) if the nodes have the same offset, and
a positive value if | |
34 * if the offset of the first node is greater than the offset of the second no
de. | |
35 */ | |
36 static Comparator<ASTNode> LEXICAL_ORDER = (ASTNode first, ASTNode second) =>
second.offset - first.offset; | |
37 /** | |
38 * Use the given visitor to visit this node. | |
39 * @param visitor the visitor that will visit this node | |
40 * @return the value returned by the visitor as a result of visiting this node | |
41 */ | |
42 accept(ASTVisitor visitor); | |
43 /** | |
44 * @return the {@link ASTNode} of given {@link Class} which is {@link ASTNode}
itself, or one of | |
45 * its parents. | |
46 */ | |
47 ASTNode getAncestor(Type enclosingClass) { | |
48 ASTNode node = this; | |
49 while (node != null && !isInstanceOf(node, enclosingClass)) { | |
50 node = node.parent; | |
51 } | |
52 ; | |
53 return node as ASTNode; | |
54 } | |
55 /** | |
56 * Return the first token included in this node's source range. | |
57 * @return the first token included in this node's source range | |
58 */ | |
59 Token get beginToken; | |
60 /** | |
61 * Return the offset of the character immediately following the last character
of this node's | |
62 * source range. This is equivalent to {@code node.getOffset() + node.getLengt
h()}. For a | |
63 * compilation unit this will be equal to the length of the unit's source. For
synthetic nodes | |
64 * this will be equivalent to the node's offset (because the length is zero (0
) by definition). | |
65 * @return the offset of the character just past the node's source range | |
66 */ | |
67 int get end => offset + length; | |
68 /** | |
69 * Return the last token included in this node's source range. | |
70 * @return the last token included in this node's source range | |
71 */ | |
72 Token get endToken; | |
73 /** | |
74 * Return the number of characters in the node's source range. | |
75 * @return the number of characters in the node's source range | |
76 */ | |
77 int get length { | |
78 Token beginToken2 = beginToken; | |
79 Token endToken2 = endToken; | |
80 if (beginToken2 == null || endToken2 == null) { | |
81 return -1; | |
82 } | |
83 return endToken2.offset + endToken2.length - beginToken2.offset; | |
84 } | |
85 /** | |
86 * Return the offset from the beginning of the file to the first character in
the node's source | |
87 * range. | |
88 * @return the offset from the beginning of the file to the first character in
the node's source | |
89 * range | |
90 */ | |
91 int get offset { | |
92 Token beginToken3 = beginToken; | |
93 if (beginToken3 == null) { | |
94 return -1; | |
95 } | |
96 return beginToken.offset; | |
97 } | |
98 /** | |
99 * Return this node's parent node, or {@code null} if this node is the root of
an AST structure. | |
100 * <p> | |
101 * Note that the relationship between an AST node and its parent node may chan
ge over the lifetime | |
102 * of a node. | |
103 * @return the parent of this node, or {@code null} if none | |
104 */ | |
105 ASTNode get parent => _parent; | |
106 /** | |
107 * Return the value of the property with the given name, or {@code null} if th
is node does not | |
108 * have a property with the given name. | |
109 * @return the value of the property with the given name | |
110 */ | |
111 Object getProperty(String propertyName) { | |
112 if (_propertyMap == null) { | |
113 return null; | |
114 } | |
115 return _propertyMap[propertyName]; | |
116 } | |
117 /** | |
118 * Return the node at the root of this node's AST structure. Note that this me
thod's performance | |
119 * is linear with respect to the depth of the node in the AST structure (O(dep
th)). | |
120 * @return the node at the root of this node's AST structure | |
121 */ | |
122 ASTNode get root { | |
123 ASTNode root = this; | |
124 ASTNode parent2 = parent; | |
125 while (parent2 != null) { | |
126 root = parent2; | |
127 parent2 = root.parent; | |
128 } | |
129 return root; | |
130 } | |
131 /** | |
132 * Return {@code true} if this node is a synthetic node. A synthetic node is a
node that was | |
133 * introduced by the parser in order to recover from an error in the code. Syn
thetic nodes always | |
134 * have a length of zero ({@code 0}). | |
135 * @return {@code true} if this node is a synthetic node | |
136 */ | |
137 bool isSynthetic() => false; | |
138 /** | |
139 * Set the value of the property with the given name to the given value. If th
e value is{@code null}, the property will effectively be removed. | |
140 * @param propertyName the name of the property whose value is to be set | |
141 * @param propertyValue the new value of the property | |
142 */ | |
143 void setProperty(String propertyName, Object propertyValue) { | |
144 if (propertyValue == null) { | |
145 if (_propertyMap != null) { | |
146 _propertyMap.remove(propertyName); | |
147 if (_propertyMap.isEmpty) { | |
148 _propertyMap = null; | |
149 } | |
150 } | |
151 } else { | |
152 if (_propertyMap == null) { | |
153 _propertyMap = new Map<String, Object>(); | |
154 } | |
155 _propertyMap[propertyName] = propertyValue; | |
156 } | |
157 } | |
158 /** | |
159 * Return a textual description of this node in a form approximating valid sou
rce. The returned | |
160 * string will not be valid source primarily in the case where the node itself
is not well-formed. | |
161 * @return the source code equivalent of this node | |
162 */ | |
163 String toSource() { | |
164 PrintStringWriter writer = new PrintStringWriter(); | |
165 accept(new ToSourceVisitor(writer)); | |
166 return writer.toString(); | |
167 } | |
168 String toString() => toSource(); | |
169 /** | |
170 * Use the given visitor to visit all of the children of this node. The childr
en will be visited | |
171 * in source order. | |
172 * @param visitor the visitor that will be used to visit the children of this
node | |
173 */ | |
174 void visitChildren(ASTVisitor<Object> visitor); | |
175 /** | |
176 * Make this node the parent of the given child node. | |
177 * @param child the node that will become a child of this node | |
178 * @return the node that was made a child of this node | |
179 */ | |
180 ASTNode becomeParentOf(ASTNode child) { | |
181 if (child != null) { | |
182 ASTNode node = child; | |
183 node.parent = this; | |
184 } | |
185 return child; | |
186 } | |
187 /** | |
188 * If the given child is not {@code null}, use the given visitor to visit it. | |
189 * @param child the child to be visited | |
190 * @param visitor the visitor that will be used to visit the child | |
191 */ | |
192 void safelyVisitChild(ASTNode child, ASTVisitor<Object> visitor) { | |
193 if (child != null) { | |
194 child.accept(visitor); | |
195 } | |
196 } | |
197 /** | |
198 * Set the parent of this node to the given node. | |
199 * @param newParent the node that is to be made the parent of this node | |
200 */ | |
201 void set parent(ASTNode newParent) { | |
202 _parent = newParent; | |
203 } | |
204 static int _hashCodeGenerator = 0; | |
205 final int hashCode = ++_hashCodeGenerator; | |
206 } | |
207 /** | |
208 * The interface {@code ASTVisitor} defines the behavior of objects that can be
used to visit an AST | |
209 * structure. | |
210 * @coverage dart.engine.ast | |
211 */ | |
212 abstract class ASTVisitor<R> { | |
213 R visitAdjacentStrings(AdjacentStrings node); | |
214 R visitAnnotation(Annotation node); | |
215 R visitArgumentDefinitionTest(ArgumentDefinitionTest node); | |
216 R visitArgumentList(ArgumentList node); | |
217 R visitAsExpression(AsExpression node); | |
218 R visitAssertStatement(AssertStatement assertStatement); | |
219 R visitAssignmentExpression(AssignmentExpression node); | |
220 R visitBinaryExpression(BinaryExpression node); | |
221 R visitBlock(Block node); | |
222 R visitBlockFunctionBody(BlockFunctionBody node); | |
223 R visitBooleanLiteral(BooleanLiteral node); | |
224 R visitBreakStatement(BreakStatement node); | |
225 R visitCascadeExpression(CascadeExpression node); | |
226 R visitCatchClause(CatchClause node); | |
227 R visitClassDeclaration(ClassDeclaration node); | |
228 R visitClassTypeAlias(ClassTypeAlias node); | |
229 R visitComment(Comment node); | |
230 R visitCommentReference(CommentReference node); | |
231 R visitCompilationUnit(CompilationUnit node); | |
232 R visitConditionalExpression(ConditionalExpression node); | |
233 R visitConstructorDeclaration(ConstructorDeclaration node); | |
234 R visitConstructorFieldInitializer(ConstructorFieldInitializer node); | |
235 R visitConstructorName(ConstructorName node); | |
236 R visitContinueStatement(ContinueStatement node); | |
237 R visitDeclaredIdentifier(DeclaredIdentifier node); | |
238 R visitDefaultFormalParameter(DefaultFormalParameter node); | |
239 R visitDoStatement(DoStatement node); | |
240 R visitDoubleLiteral(DoubleLiteral node); | |
241 R visitEmptyFunctionBody(EmptyFunctionBody node); | |
242 R visitEmptyStatement(EmptyStatement node); | |
243 R visitExportDirective(ExportDirective node); | |
244 R visitExpressionFunctionBody(ExpressionFunctionBody node); | |
245 R visitExpressionStatement(ExpressionStatement node); | |
246 R visitExtendsClause(ExtendsClause node); | |
247 R visitFieldDeclaration(FieldDeclaration node); | |
248 R visitFieldFormalParameter(FieldFormalParameter node); | |
249 R visitForEachStatement(ForEachStatement node); | |
250 R visitFormalParameterList(FormalParameterList node); | |
251 R visitForStatement(ForStatement node); | |
252 R visitFunctionDeclaration(FunctionDeclaration node); | |
253 R visitFunctionDeclarationStatement(FunctionDeclarationStatement node); | |
254 R visitFunctionExpression(FunctionExpression node); | |
255 R visitFunctionExpressionInvocation(FunctionExpressionInvocation node); | |
256 R visitFunctionTypeAlias(FunctionTypeAlias functionTypeAlias); | |
257 R visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node); | |
258 R visitHideCombinator(HideCombinator node); | |
259 R visitIfStatement(IfStatement node); | |
260 R visitImplementsClause(ImplementsClause node); | |
261 R visitImportDirective(ImportDirective node); | |
262 R visitIndexExpression(IndexExpression node); | |
263 R visitInstanceCreationExpression(InstanceCreationExpression node); | |
264 R visitIntegerLiteral(IntegerLiteral node); | |
265 R visitInterpolationExpression(InterpolationExpression node); | |
266 R visitInterpolationString(InterpolationString node); | |
267 R visitIsExpression(IsExpression node); | |
268 R visitLabel(Label node); | |
269 R visitLabeledStatement(LabeledStatement node); | |
270 R visitLibraryDirective(LibraryDirective node); | |
271 R visitLibraryIdentifier(LibraryIdentifier node); | |
272 R visitListLiteral(ListLiteral node); | |
273 R visitMapLiteral(MapLiteral node); | |
274 R visitMapLiteralEntry(MapLiteralEntry node); | |
275 R visitMethodDeclaration(MethodDeclaration node); | |
276 R visitMethodInvocation(MethodInvocation node); | |
277 R visitNamedExpression(NamedExpression node); | |
278 R visitNullLiteral(NullLiteral node); | |
279 R visitParenthesizedExpression(ParenthesizedExpression node); | |
280 R visitPartDirective(PartDirective node); | |
281 R visitPartOfDirective(PartOfDirective node); | |
282 R visitPostfixExpression(PostfixExpression node); | |
283 R visitPrefixedIdentifier(PrefixedIdentifier node); | |
284 R visitPrefixExpression(PrefixExpression node); | |
285 R visitPropertyAccess(PropertyAccess node); | |
286 R visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node)
; | |
287 R visitReturnStatement(ReturnStatement node); | |
288 R visitScriptTag(ScriptTag node); | |
289 R visitShowCombinator(ShowCombinator node); | |
290 R visitSimpleFormalParameter(SimpleFormalParameter node); | |
291 R visitSimpleIdentifier(SimpleIdentifier node); | |
292 R visitSimpleStringLiteral(SimpleStringLiteral node); | |
293 R visitStringInterpolation(StringInterpolation node); | |
294 R visitSuperConstructorInvocation(SuperConstructorInvocation node); | |
295 R visitSuperExpression(SuperExpression node); | |
296 R visitSwitchCase(SwitchCase node); | |
297 R visitSwitchDefault(SwitchDefault node); | |
298 R visitSwitchStatement(SwitchStatement node); | |
299 R visitThisExpression(ThisExpression node); | |
300 R visitThrowExpression(ThrowExpression node); | |
301 R visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node); | |
302 R visitTryStatement(TryStatement node); | |
303 R visitTypeArgumentList(TypeArgumentList node); | |
304 R visitTypeName(TypeName node); | |
305 R visitTypeParameter(TypeParameter node); | |
306 R visitTypeParameterList(TypeParameterList node); | |
307 R visitVariableDeclaration(VariableDeclaration node); | |
308 R visitVariableDeclarationList(VariableDeclarationList node); | |
309 R visitVariableDeclarationStatement(VariableDeclarationStatement node); | |
310 R visitWhileStatement(WhileStatement node); | |
311 R visitWithClause(WithClause node); | |
312 } | |
313 /** | |
314 * Instances of the class {@code AdjacentStrings} represents two or more string
literals that are | |
315 * implicitly concatenated because of being adjacent (separated only by whitespa
ce). | |
316 * <p> | |
317 * While the grammar only allows adjacent strings when all of the strings are of
the same kind | |
318 * (single line or multi-line), this class doesn't enforce that restriction. | |
319 * <pre> | |
320 * adjacentStrings ::={@link StringLiteral string} {@link StringLiteral string}+ | |
321 * </pre> | |
322 * @coverage dart.engine.ast | |
323 */ | |
324 class AdjacentStrings extends StringLiteral { | |
325 /** | |
326 * The strings that are implicitly concatenated. | |
327 */ | |
328 NodeList<StringLiteral> _strings; | |
329 /** | |
330 * Initialize a newly created list of adjacent strings. | |
331 * @param strings the strings that are implicitly concatenated | |
332 */ | |
333 AdjacentStrings.full(List<StringLiteral> strings) { | |
334 this._strings = new NodeList<StringLiteral>(this); | |
335 this._strings.addAll(strings); | |
336 } | |
337 /** | |
338 * Initialize a newly created list of adjacent strings. | |
339 * @param strings the strings that are implicitly concatenated | |
340 */ | |
341 AdjacentStrings({List<StringLiteral> strings}) : this.full(strings); | |
342 accept(ASTVisitor visitor) => visitor.visitAdjacentStrings(this); | |
343 Token get beginToken => _strings.beginToken; | |
344 Token get endToken => _strings.endToken; | |
345 /** | |
346 * Return the strings that are implicitly concatenated. | |
347 * @return the strings that are implicitly concatenated | |
348 */ | |
349 NodeList<StringLiteral> get strings => _strings; | |
350 void visitChildren(ASTVisitor<Object> visitor) { | |
351 _strings.accept(visitor); | |
352 } | |
353 } | |
354 /** | |
355 * The abstract class {@code AnnotatedNode} defines the behavior of nodes that c
an be annotated with | |
356 * both a comment and metadata. | |
357 * @coverage dart.engine.ast | |
358 */ | |
359 abstract class AnnotatedNode extends ASTNode { | |
360 /** | |
361 * The documentation comment associated with this node, or {@code null} if thi
s node does not have | |
362 * a documentation comment associated with it. | |
363 */ | |
364 Comment _comment; | |
365 /** | |
366 * The annotations associated with this node. | |
367 */ | |
368 NodeList<Annotation> _metadata; | |
369 /** | |
370 * Initialize a newly created node. | |
371 * @param comment the documentation comment associated with this node | |
372 * @param metadata the annotations associated with this node | |
373 */ | |
374 AnnotatedNode.full(Comment comment, List<Annotation> metadata) { | |
375 this._metadata = new NodeList<Annotation>(this); | |
376 this._comment = becomeParentOf(comment); | |
377 this._metadata.addAll(metadata); | |
378 } | |
379 /** | |
380 * Initialize a newly created node. | |
381 * @param comment the documentation comment associated with this node | |
382 * @param metadata the annotations associated with this node | |
383 */ | |
384 AnnotatedNode({Comment comment, List<Annotation> metadata}) : this.full(commen
t, metadata); | |
385 Token get beginToken { | |
386 if (_comment == null) { | |
387 if (_metadata.isEmpty) { | |
388 return firstTokenAfterCommentAndMetadata; | |
389 } else { | |
390 return _metadata.beginToken; | |
391 } | |
392 } else if (_metadata.isEmpty) { | |
393 return _comment.beginToken; | |
394 } | |
395 Token commentToken = _comment.beginToken; | |
396 Token metadataToken = _metadata.beginToken; | |
397 if (commentToken.offset < metadataToken.offset) { | |
398 return commentToken; | |
399 } | |
400 return metadataToken; | |
401 } | |
402 /** | |
403 * Return the documentation comment associated with this node, or {@code null}
if this node does | |
404 * not have a documentation comment associated with it. | |
405 * @return the documentation comment associated with this node | |
406 */ | |
407 Comment get documentationComment => _comment; | |
408 /** | |
409 * Return the annotations associated with this node. | |
410 * @return the annotations associated with this node | |
411 */ | |
412 NodeList<Annotation> get metadata => _metadata; | |
413 /** | |
414 * Set the documentation comment associated with this node to the given commen
t | |
415 * @param comment the documentation comment to be associated with this node | |
416 */ | |
417 void set documentationComment(Comment comment2) { | |
418 this._comment = becomeParentOf(comment2); | |
419 } | |
420 void visitChildren(ASTVisitor<Object> visitor) { | |
421 if (commentIsBeforeAnnotations()) { | |
422 safelyVisitChild(_comment, visitor); | |
423 _metadata.accept(visitor); | |
424 } else { | |
425 for (ASTNode child in sortedCommentAndAnnotations) { | |
426 child.accept(visitor); | |
427 } | |
428 } | |
429 } | |
430 /** | |
431 * Return the first token following the comment and metadata. | |
432 * @return the first token following the comment and metadata | |
433 */ | |
434 Token get firstTokenAfterCommentAndMetadata; | |
435 /** | |
436 * Return {@code true} if the comment is lexically before any annotations. | |
437 * @return {@code true} if the comment is lexically before any annotations | |
438 */ | |
439 bool commentIsBeforeAnnotations() { | |
440 if (_comment == null || _metadata.isEmpty) { | |
441 return true; | |
442 } | |
443 Annotation firstAnnotation = _metadata[0]; | |
444 return _comment.offset < firstAnnotation.offset; | |
445 } | |
446 /** | |
447 * Return an array containing the comment and annotations associated with this
node, sorted in | |
448 * lexical order. | |
449 * @return the comment and annotations associated with this node in the order
in which they | |
450 * appeared in the original source | |
451 */ | |
452 List<ASTNode> get sortedCommentAndAnnotations { | |
453 List<ASTNode> childList = new List<ASTNode>(); | |
454 childList.add(_comment); | |
455 childList.addAll(_metadata); | |
456 List<ASTNode> children = new List.from(childList); | |
457 children.sort(); | |
458 return children; | |
459 } | |
460 } | |
461 /** | |
462 * Instances of the class {@code Annotation} represent an annotation that can be
associated with an | |
463 * AST node. | |
464 * <pre> | |
465 * metadata ::= | |
466 * annotation | |
467 * annotation ::= | |
468 * '@' {@link Identifier qualified} (‘.’ {@link SimpleIdentifier identifier}
)? {@link ArgumentList arguments}? | |
469 * </pre> | |
470 * @coverage dart.engine.ast | |
471 */ | |
472 class Annotation extends ASTNode { | |
473 /** | |
474 * The at sign that introduced the annotation. | |
475 */ | |
476 Token _atSign; | |
477 /** | |
478 * The name of the class defining the constructor that is being invoked or the
name of the field | |
479 * that is being referenced. | |
480 */ | |
481 Identifier _name; | |
482 /** | |
483 * The period before the constructor name, or {@code null} if this annotation
is not the | |
484 * invocation of a named constructor. | |
485 */ | |
486 Token _period; | |
487 /** | |
488 * The name of the constructor being invoked, or {@code null} if this annotati
on is not the | |
489 * invocation of a named constructor. | |
490 */ | |
491 SimpleIdentifier _constructorName; | |
492 /** | |
493 * The arguments to the constructor being invoked, or {@code null} if this ann
otation is not the | |
494 * invocation of a constructor. | |
495 */ | |
496 ArgumentList _arguments; | |
497 /** | |
498 * Initialize a newly created annotation. | |
499 * @param atSign the at sign that introduced the annotation | |
500 * @param name the name of the class defining the constructor that is being in
voked or the name of | |
501 * the field that is being referenced | |
502 * @param period the period before the constructor name, or {@code null} if th
is annotation is not | |
503 * the invocation of a named constructor | |
504 * @param constructorName the name of the constructor being invoked, or {@code
null} if this | |
505 * annotation is not the invocation of a named constructor | |
506 * @param arguments the arguments to the constructor being invoked, or {@code
null} if this | |
507 * annotation is not the invocation of a constructor | |
508 */ | |
509 Annotation.full(Token atSign, Identifier name, Token period, SimpleIdentifier
constructorName, ArgumentList arguments) { | |
510 this._atSign = atSign; | |
511 this._name = becomeParentOf(name); | |
512 this._period = period; | |
513 this._constructorName = becomeParentOf(constructorName); | |
514 this._arguments = becomeParentOf(arguments); | |
515 } | |
516 /** | |
517 * Initialize a newly created annotation. | |
518 * @param atSign the at sign that introduced the annotation | |
519 * @param name the name of the class defining the constructor that is being in
voked or the name of | |
520 * the field that is being referenced | |
521 * @param period the period before the constructor name, or {@code null} if th
is annotation is not | |
522 * the invocation of a named constructor | |
523 * @param constructorName the name of the constructor being invoked, or {@code
null} if this | |
524 * annotation is not the invocation of a named constructor | |
525 * @param arguments the arguments to the constructor being invoked, or {@code
null} if this | |
526 * annotation is not the invocation of a constructor | |
527 */ | |
528 Annotation({Token atSign, Identifier name, Token period, SimpleIdentifier cons
tructorName, ArgumentList arguments}) : this.full(atSign, name, period, construc
torName, arguments); | |
529 accept(ASTVisitor visitor) => visitor.visitAnnotation(this); | |
530 /** | |
531 * Return the arguments to the constructor being invoked, or {@code null} if t
his annotation is | |
532 * not the invocation of a constructor. | |
533 * @return the arguments to the constructor being invoked | |
534 */ | |
535 ArgumentList get arguments => _arguments; | |
536 /** | |
537 * Return the at sign that introduced the annotation. | |
538 * @return the at sign that introduced the annotation | |
539 */ | |
540 Token get atSign => _atSign; | |
541 Token get beginToken => _atSign; | |
542 /** | |
543 * Return the name of the constructor being invoked, or {@code null} if this a
nnotation is not the | |
544 * invocation of a named constructor. | |
545 * @return the name of the constructor being invoked | |
546 */ | |
547 SimpleIdentifier get constructorName => _constructorName; | |
548 Token get endToken { | |
549 if (_arguments != null) { | |
550 return _arguments.endToken; | |
551 } else if (_constructorName != null) { | |
552 return _constructorName.endToken; | |
553 } | |
554 return _name.endToken; | |
555 } | |
556 /** | |
557 * Return the name of the class defining the constructor that is being invoked
or the name of the | |
558 * field that is being referenced. | |
559 * @return the name of the constructor being invoked or the name of the field
being referenced | |
560 */ | |
561 Identifier get name => _name; | |
562 /** | |
563 * Return the period before the constructor name, or {@code null} if this anno
tation is not the | |
564 * invocation of a named constructor. | |
565 * @return the period before the constructor name | |
566 */ | |
567 Token get period => _period; | |
568 /** | |
569 * Set the arguments to the constructor being invoked to the given arguments. | |
570 * @param arguments the arguments to the constructor being invoked | |
571 */ | |
572 void set arguments(ArgumentList arguments2) { | |
573 this._arguments = becomeParentOf(arguments2); | |
574 } | |
575 /** | |
576 * Set the at sign that introduced the annotation to the given token. | |
577 * @param atSign the at sign that introduced the annotation | |
578 */ | |
579 void set atSign(Token atSign2) { | |
580 this._atSign = atSign2; | |
581 } | |
582 /** | |
583 * Set the name of the constructor being invoked to the given name. | |
584 * @param constructorName the name of the constructor being invoked | |
585 */ | |
586 void set constructorName(SimpleIdentifier constructorName2) { | |
587 this._constructorName = becomeParentOf(constructorName2); | |
588 } | |
589 /** | |
590 * Set the name of the class defining the constructor that is being invoked or
the name of the | |
591 * field that is being referenced to the given name. | |
592 * @param name the name of the constructor being invoked or the name of the fi
eld being referenced | |
593 */ | |
594 void set name(Identifier name2) { | |
595 this._name = becomeParentOf(name2); | |
596 } | |
597 /** | |
598 * Set the period before the constructor name to the given token. | |
599 * @param period the period before the constructor name | |
600 */ | |
601 void set period(Token period2) { | |
602 this._period = period2; | |
603 } | |
604 void visitChildren(ASTVisitor<Object> visitor) { | |
605 safelyVisitChild(_name, visitor); | |
606 safelyVisitChild(_constructorName, visitor); | |
607 safelyVisitChild(_arguments, visitor); | |
608 } | |
609 } | |
610 /** | |
611 * Instances of the class {@code ArgumentDefinitionTest} represent an argument d
efinition test. | |
612 * <pre> | |
613 * argumentDefinitionTest ::= | |
614 * '?' {@link SimpleIdentifier identifier}</pre> | |
615 * @coverage dart.engine.ast | |
616 */ | |
617 class ArgumentDefinitionTest extends Expression { | |
618 /** | |
619 * The token representing the question mark. | |
620 */ | |
621 Token _question; | |
622 /** | |
623 * The identifier representing the argument being tested. | |
624 */ | |
625 SimpleIdentifier _identifier; | |
626 /** | |
627 * Initialize a newly created argument definition test. | |
628 * @param question the token representing the question mark | |
629 * @param identifier the identifier representing the argument being tested | |
630 */ | |
631 ArgumentDefinitionTest.full(Token question, SimpleIdentifier identifier) { | |
632 this._question = question; | |
633 this._identifier = becomeParentOf(identifier); | |
634 } | |
635 /** | |
636 * Initialize a newly created argument definition test. | |
637 * @param question the token representing the question mark | |
638 * @param identifier the identifier representing the argument being tested | |
639 */ | |
640 ArgumentDefinitionTest({Token question, SimpleIdentifier identifier}) : this.f
ull(question, identifier); | |
641 accept(ASTVisitor visitor) => visitor.visitArgumentDefinitionTest(this); | |
642 Token get beginToken => _question; | |
643 Token get endToken => _identifier.endToken; | |
644 /** | |
645 * Return the identifier representing the argument being tested. | |
646 * @return the identifier representing the argument being tested | |
647 */ | |
648 SimpleIdentifier get identifier => _identifier; | |
649 /** | |
650 * Return the token representing the question mark. | |
651 * @return the token representing the question mark | |
652 */ | |
653 Token get question => _question; | |
654 /** | |
655 * Set the identifier representing the argument being tested to the given iden
tifier. | |
656 * @param identifier the identifier representing the argument being tested | |
657 */ | |
658 void set identifier(SimpleIdentifier identifier7) { | |
659 this._identifier = becomeParentOf(identifier7); | |
660 } | |
661 /** | |
662 * Set the token representing the question mark to the given token. | |
663 * @param question the token representing the question mark | |
664 */ | |
665 void set question(Token question2) { | |
666 this._question = question2; | |
667 } | |
668 void visitChildren(ASTVisitor<Object> visitor) { | |
669 safelyVisitChild(_identifier, visitor); | |
670 } | |
671 } | |
672 /** | |
673 * Instances of the class {@code ArgumentList} represent a list of arguments in
the invocation of a | |
674 * executable element: a function, method, or constructor. | |
675 * <pre> | |
676 * argumentList ::= | |
677 * '(' arguments? ')' | |
678 * arguments ::={@link NamedExpression namedArgument} (',' {@link NamedExpressio
n namedArgument}) | |
679 * | {@link Expression expressionList} (',' {@link NamedExpression namedArgument
}) | |
680 * </pre> | |
681 * @coverage dart.engine.ast | |
682 */ | |
683 class ArgumentList extends ASTNode { | |
684 /** | |
685 * The left parenthesis. | |
686 */ | |
687 Token _leftParenthesis; | |
688 /** | |
689 * The expressions producing the values of the arguments. | |
690 */ | |
691 NodeList<Expression> _arguments; | |
692 /** | |
693 * The right parenthesis. | |
694 */ | |
695 Token _rightParenthesis; | |
696 /** | |
697 * An array containing the elements representing the parameters corresponding
to each of the | |
698 * arguments in this list, or {@code null} if the AST has not been resolved or
if the function or | |
699 * method being invoked could not be determined. The array must be the same le
ngth as the number | |
700 * of arguments, but can contain {@code null} entries if a given argument does
not correspond to a | |
701 * formal parameter. | |
702 */ | |
703 List<ParameterElement> _correspondingParameters; | |
704 /** | |
705 * Initialize a newly created list of arguments. | |
706 * @param leftParenthesis the left parenthesis | |
707 * @param arguments the expressions producing the values of the arguments | |
708 * @param rightParenthesis the right parenthesis | |
709 */ | |
710 ArgumentList.full(Token leftParenthesis, List<Expression> arguments, Token rig
htParenthesis) { | |
711 this._arguments = new NodeList<Expression>(this); | |
712 this._leftParenthesis = leftParenthesis; | |
713 this._arguments.addAll(arguments); | |
714 this._rightParenthesis = rightParenthesis; | |
715 } | |
716 /** | |
717 * Initialize a newly created list of arguments. | |
718 * @param leftParenthesis the left parenthesis | |
719 * @param arguments the expressions producing the values of the arguments | |
720 * @param rightParenthesis the right parenthesis | |
721 */ | |
722 ArgumentList({Token leftParenthesis, List<Expression> arguments, Token rightPa
renthesis}) : this.full(leftParenthesis, arguments, rightParenthesis); | |
723 accept(ASTVisitor visitor) => visitor.visitArgumentList(this); | |
724 /** | |
725 * Return the expressions producing the values of the arguments. Although the
language requires | |
726 * that positional arguments appear before named arguments, this class allows
them to be | |
727 * intermixed. | |
728 * @return the expressions producing the values of the arguments | |
729 */ | |
730 NodeList<Expression> get arguments => _arguments; | |
731 Token get beginToken => _leftParenthesis; | |
732 Token get endToken => _rightParenthesis; | |
733 /** | |
734 * Return the left parenthesis. | |
735 * @return the left parenthesis | |
736 */ | |
737 Token get leftParenthesis => _leftParenthesis; | |
738 /** | |
739 * Return the right parenthesis. | |
740 * @return the right parenthesis | |
741 */ | |
742 Token get rightParenthesis => _rightParenthesis; | |
743 /** | |
744 * Set the parameter elements corresponding to each of the arguments in this l
ist to the given | |
745 * array of parameters. The array of parameters must be the same length as the
number of | |
746 * arguments, but can contain {@code null} entries if a given argument does no
t correspond to a | |
747 * formal parameter. | |
748 * @param parameters the parameter elements corresponding to the arguments | |
749 */ | |
750 void set correspondingParameters(List<ParameterElement> parameters) { | |
751 if (parameters.length != _arguments.length) { | |
752 throw new IllegalArgumentException("Expected ${_arguments.length} paramete
rs, not ${parameters.length}"); | |
753 } | |
754 _correspondingParameters = parameters; | |
755 } | |
756 /** | |
757 * Set the left parenthesis to the given token. | |
758 * @param parenthesis the left parenthesis | |
759 */ | |
760 void set leftParenthesis(Token parenthesis) { | |
761 _leftParenthesis = parenthesis; | |
762 } | |
763 /** | |
764 * Set the right parenthesis to the given token. | |
765 * @param parenthesis the right parenthesis | |
766 */ | |
767 void set rightParenthesis(Token parenthesis) { | |
768 _rightParenthesis = parenthesis; | |
769 } | |
770 void visitChildren(ASTVisitor<Object> visitor) { | |
771 _arguments.accept(visitor); | |
772 } | |
773 /** | |
774 * If the given expression is a child of this list, and the AST structure has
been resolved, and | |
775 * the function being invoked is known, and the expression corresponds to one
of the parameters of | |
776 * the function being invoked, then return the parameter element representing
the parameter to | |
777 * which the value of the given expression will be bound. Otherwise, return {@
code null}. | |
778 * <p> | |
779 * This method is only intended to be used by {@link Expression#getParameterEl
ement()}. | |
780 * @param expression the expression corresponding to the parameter to be retur
ned | |
781 * @return the parameter element representing the parameter to which the value
of the expression | |
782 * will be bound | |
783 */ | |
784 ParameterElement getParameterElementFor(Expression expression) { | |
785 if (_correspondingParameters == null) { | |
786 return null; | |
787 } | |
788 int index = _arguments.indexOf(expression); | |
789 if (index < 0) { | |
790 return null; | |
791 } | |
792 return _correspondingParameters[index]; | |
793 } | |
794 } | |
795 /** | |
796 * Instances of the class {@code AsExpression} represent an 'as' expression. | |
797 * <pre> | |
798 * asExpression ::={@link Expression expression} 'as' {@link TypeName type}</pre
> | |
799 * @coverage dart.engine.ast | |
800 */ | |
801 class AsExpression extends Expression { | |
802 /** | |
803 * The expression used to compute the value being cast. | |
804 */ | |
805 Expression _expression; | |
806 /** | |
807 * The as operator. | |
808 */ | |
809 Token _asOperator; | |
810 /** | |
811 * The name of the type being cast to. | |
812 */ | |
813 TypeName _type; | |
814 /** | |
815 * Initialize a newly created as expression. | |
816 * @param expression the expression used to compute the value being cast | |
817 * @param isOperator the is operator | |
818 * @param type the name of the type being cast to | |
819 */ | |
820 AsExpression.full(Expression expression, Token isOperator, TypeName type) { | |
821 this._expression = becomeParentOf(expression); | |
822 this._asOperator = isOperator; | |
823 this._type = becomeParentOf(type); | |
824 } | |
825 /** | |
826 * Initialize a newly created as expression. | |
827 * @param expression the expression used to compute the value being cast | |
828 * @param isOperator the is operator | |
829 * @param type the name of the type being cast to | |
830 */ | |
831 AsExpression({Expression expression, Token isOperator, TypeName type}) : this.
full(expression, isOperator, type); | |
832 accept(ASTVisitor visitor) => visitor.visitAsExpression(this); | |
833 /** | |
834 * Return the is operator being applied. | |
835 * @return the is operator being applied | |
836 */ | |
837 Token get asOperator => _asOperator; | |
838 Token get beginToken => _expression.beginToken; | |
839 Token get endToken => _type.endToken; | |
840 /** | |
841 * Return the expression used to compute the value being cast. | |
842 * @return the expression used to compute the value being cast | |
843 */ | |
844 Expression get expression => _expression; | |
845 /** | |
846 * Return the name of the type being cast to. | |
847 * @return the name of the type being cast to | |
848 */ | |
849 TypeName get type => _type; | |
850 /** | |
851 * Set the is operator being applied to the given operator. | |
852 * @param asOperator the is operator being applied | |
853 */ | |
854 void set asOperator(Token asOperator2) { | |
855 this._asOperator = asOperator2; | |
856 } | |
857 /** | |
858 * Set the expression used to compute the value being cast to the given expres
sion. | |
859 * @param expression the expression used to compute the value being cast | |
860 */ | |
861 void set expression(Expression expression2) { | |
862 this._expression = becomeParentOf(expression2); | |
863 } | |
864 /** | |
865 * Set the name of the type being cast to to the given name. | |
866 * @param name the name of the type being cast to | |
867 */ | |
868 void set type(TypeName name) { | |
869 this._type = becomeParentOf(name); | |
870 } | |
871 void visitChildren(ASTVisitor<Object> visitor) { | |
872 safelyVisitChild(_expression, visitor); | |
873 safelyVisitChild(_type, visitor); | |
874 } | |
875 } | |
876 /** | |
877 * Instances of the class {@code AssertStatement} represent an assert statement. | |
878 * <pre> | |
879 * assertStatement ::= | |
880 * 'assert' '(' {@link Expression conditionalExpression} ')' ';' | |
881 * </pre> | |
882 * @coverage dart.engine.ast | |
883 */ | |
884 class AssertStatement extends Statement { | |
885 /** | |
886 * The token representing the 'assert' keyword. | |
887 */ | |
888 Token _keyword; | |
889 /** | |
890 * The left parenthesis. | |
891 */ | |
892 Token _leftParenthesis; | |
893 /** | |
894 * The condition that is being asserted to be {@code true}. | |
895 */ | |
896 Expression _condition; | |
897 /** | |
898 * The right parenthesis. | |
899 */ | |
900 Token _rightParenthesis; | |
901 /** | |
902 * The semicolon terminating the statement. | |
903 */ | |
904 Token _semicolon; | |
905 /** | |
906 * Initialize a newly created assert statement. | |
907 * @param keyword the token representing the 'assert' keyword | |
908 * @param leftParenthesis the left parenthesis | |
909 * @param condition the condition that is being asserted to be {@code true} | |
910 * @param rightParenthesis the right parenthesis | |
911 * @param semicolon the semicolon terminating the statement | |
912 */ | |
913 AssertStatement.full(Token keyword, Token leftParenthesis, Expression conditio
n, Token rightParenthesis, Token semicolon) { | |
914 this._keyword = keyword; | |
915 this._leftParenthesis = leftParenthesis; | |
916 this._condition = becomeParentOf(condition); | |
917 this._rightParenthesis = rightParenthesis; | |
918 this._semicolon = semicolon; | |
919 } | |
920 /** | |
921 * Initialize a newly created assert statement. | |
922 * @param keyword the token representing the 'assert' keyword | |
923 * @param leftParenthesis the left parenthesis | |
924 * @param condition the condition that is being asserted to be {@code true} | |
925 * @param rightParenthesis the right parenthesis | |
926 * @param semicolon the semicolon terminating the statement | |
927 */ | |
928 AssertStatement({Token keyword, Token leftParenthesis, Expression condition, T
oken rightParenthesis, Token semicolon}) : this.full(keyword, leftParenthesis, c
ondition, rightParenthesis, semicolon); | |
929 accept(ASTVisitor visitor) => visitor.visitAssertStatement(this); | |
930 Token get beginToken => _keyword; | |
931 /** | |
932 * Return the condition that is being asserted to be {@code true}. | |
933 * @return the condition that is being asserted to be {@code true} | |
934 */ | |
935 Expression get condition => _condition; | |
936 Token get endToken => _semicolon; | |
937 /** | |
938 * Return the token representing the 'assert' keyword. | |
939 * @return the token representing the 'assert' keyword | |
940 */ | |
941 Token get keyword => _keyword; | |
942 /** | |
943 * Return the left parenthesis. | |
944 * @return the left parenthesis | |
945 */ | |
946 Token get leftParenthesis => _leftParenthesis; | |
947 /** | |
948 * Return the right parenthesis. | |
949 * @return the right parenthesis | |
950 */ | |
951 Token get rightParenthesis => _rightParenthesis; | |
952 /** | |
953 * Return the semicolon terminating the statement. | |
954 * @return the semicolon terminating the statement | |
955 */ | |
956 Token get semicolon => _semicolon; | |
957 /** | |
958 * Set the condition that is being asserted to be {@code true} to the given ex
pression. | |
959 * @param the condition that is being asserted to be {@code true} | |
960 */ | |
961 void set condition(Expression condition2) { | |
962 this._condition = becomeParentOf(condition2); | |
963 } | |
964 /** | |
965 * Set the token representing the 'assert' keyword to the given token. | |
966 * @param keyword the token representing the 'assert' keyword | |
967 */ | |
968 void set keyword(Token keyword3) { | |
969 this._keyword = keyword3; | |
970 } | |
971 /** | |
972 * Set the left parenthesis to the given token. | |
973 * @param the left parenthesis | |
974 */ | |
975 void set leftParenthesis(Token leftParenthesis2) { | |
976 this._leftParenthesis = leftParenthesis2; | |
977 } | |
978 /** | |
979 * Set the right parenthesis to the given token. | |
980 * @param rightParenthesis the right parenthesis | |
981 */ | |
982 void set rightParenthesis(Token rightParenthesis2) { | |
983 this._rightParenthesis = rightParenthesis2; | |
984 } | |
985 /** | |
986 * Set the semicolon terminating the statement to the given token. | |
987 * @param semicolon the semicolon terminating the statement | |
988 */ | |
989 void set semicolon(Token semicolon2) { | |
990 this._semicolon = semicolon2; | |
991 } | |
992 void visitChildren(ASTVisitor<Object> visitor) { | |
993 safelyVisitChild(_condition, visitor); | |
994 } | |
995 } | |
996 /** | |
997 * Instances of the class {@code AssignmentExpression} represent an assignment e
xpression. | |
998 * <pre> | |
999 * assignmentExpression ::={@link Expression leftHandSide} {@link Token operator
} {@link Expression rightHandSide}</pre> | |
1000 * @coverage dart.engine.ast | |
1001 */ | |
1002 class AssignmentExpression extends Expression { | |
1003 /** | |
1004 * The expression used to compute the left hand side. | |
1005 */ | |
1006 Expression _leftHandSide; | |
1007 /** | |
1008 * The assignment operator being applied. | |
1009 */ | |
1010 Token _operator; | |
1011 /** | |
1012 * The expression used to compute the right hand side. | |
1013 */ | |
1014 Expression _rightHandSide; | |
1015 /** | |
1016 * The element associated with the operator, or {@code null} if the AST struct
ure has not been | |
1017 * resolved, if the operator is not a compound operator, or if the operator co
uld not be resolved. | |
1018 */ | |
1019 MethodElement _element; | |
1020 /** | |
1021 * Initialize a newly created assignment expression. | |
1022 * @param leftHandSide the expression used to compute the left hand side | |
1023 * @param operator the assignment operator being applied | |
1024 * @param rightHandSide the expression used to compute the right hand side | |
1025 */ | |
1026 AssignmentExpression.full(Expression leftHandSide, Token operator, Expression
rightHandSide) { | |
1027 this._leftHandSide = becomeParentOf(leftHandSide); | |
1028 this._operator = operator; | |
1029 this._rightHandSide = becomeParentOf(rightHandSide); | |
1030 } | |
1031 /** | |
1032 * Initialize a newly created assignment expression. | |
1033 * @param leftHandSide the expression used to compute the left hand side | |
1034 * @param operator the assignment operator being applied | |
1035 * @param rightHandSide the expression used to compute the right hand side | |
1036 */ | |
1037 AssignmentExpression({Expression leftHandSide, Token operator, Expression righ
tHandSide}) : this.full(leftHandSide, operator, rightHandSide); | |
1038 accept(ASTVisitor visitor) => visitor.visitAssignmentExpression(this); | |
1039 Token get beginToken => _leftHandSide.beginToken; | |
1040 /** | |
1041 * Return the element associated with the operator, or {@code null} if the AST
structure has not | |
1042 * been resolved, if the operator is not a compound operator, or if the operat
or could not be | |
1043 * resolved. One example of the latter case is an operator that is not defined
for the type of the | |
1044 * left-hand operand. | |
1045 * @return the element associated with the operator | |
1046 */ | |
1047 MethodElement get element => _element; | |
1048 Token get endToken => _rightHandSide.endToken; | |
1049 /** | |
1050 * Set the expression used to compute the left hand side to the given expressi
on. | |
1051 * @return the expression used to compute the left hand side | |
1052 */ | |
1053 Expression get leftHandSide => _leftHandSide; | |
1054 /** | |
1055 * Return the assignment operator being applied. | |
1056 * @return the assignment operator being applied | |
1057 */ | |
1058 Token get operator => _operator; | |
1059 /** | |
1060 * Return the expression used to compute the right hand side. | |
1061 * @return the expression used to compute the right hand side | |
1062 */ | |
1063 Expression get rightHandSide => _rightHandSide; | |
1064 /** | |
1065 * Set the element associated with the operator to the given element. | |
1066 * @param element the element associated with the operator | |
1067 */ | |
1068 void set element(MethodElement element3) { | |
1069 this._element = element3; | |
1070 } | |
1071 /** | |
1072 * Return the expression used to compute the left hand side. | |
1073 * @param expression the expression used to compute the left hand side | |
1074 */ | |
1075 void set leftHandSide(Expression expression) { | |
1076 _leftHandSide = becomeParentOf(expression); | |
1077 } | |
1078 /** | |
1079 * Set the assignment operator being applied to the given operator. | |
1080 * @param operator the assignment operator being applied | |
1081 */ | |
1082 void set operator(Token operator2) { | |
1083 this._operator = operator2; | |
1084 } | |
1085 /** | |
1086 * Set the expression used to compute the left hand side to the given expressi
on. | |
1087 * @param expression the expression used to compute the left hand side | |
1088 */ | |
1089 void set rightHandSide(Expression expression) { | |
1090 _rightHandSide = becomeParentOf(expression); | |
1091 } | |
1092 void visitChildren(ASTVisitor<Object> visitor) { | |
1093 safelyVisitChild(_leftHandSide, visitor); | |
1094 safelyVisitChild(_rightHandSide, visitor); | |
1095 } | |
1096 } | |
1097 /** | |
1098 * Instances of the class {@code BinaryExpression} represent a binary (infix) ex
pression. | |
1099 * <pre> | |
1100 * binaryExpression ::={@link Expression leftOperand} {@link Token operator} {@l
ink Expression rightOperand}</pre> | |
1101 * @coverage dart.engine.ast | |
1102 */ | |
1103 class BinaryExpression extends Expression { | |
1104 /** | |
1105 * The expression used to compute the left operand. | |
1106 */ | |
1107 Expression _leftOperand; | |
1108 /** | |
1109 * The binary operator being applied. | |
1110 */ | |
1111 Token _operator; | |
1112 /** | |
1113 * The expression used to compute the right operand. | |
1114 */ | |
1115 Expression _rightOperand; | |
1116 /** | |
1117 * The element associated with the operator, or {@code null} if the AST struct
ure has not been | |
1118 * resolved, if the operator is not user definable, or if the operator could n
ot be resolved. | |
1119 */ | |
1120 MethodElement _element; | |
1121 /** | |
1122 * Initialize a newly created binary expression. | |
1123 * @param leftOperand the expression used to compute the left operand | |
1124 * @param operator the binary operator being applied | |
1125 * @param rightOperand the expression used to compute the right operand | |
1126 */ | |
1127 BinaryExpression.full(Expression leftOperand, Token operator, Expression right
Operand) { | |
1128 this._leftOperand = becomeParentOf(leftOperand); | |
1129 this._operator = operator; | |
1130 this._rightOperand = becomeParentOf(rightOperand); | |
1131 } | |
1132 /** | |
1133 * Initialize a newly created binary expression. | |
1134 * @param leftOperand the expression used to compute the left operand | |
1135 * @param operator the binary operator being applied | |
1136 * @param rightOperand the expression used to compute the right operand | |
1137 */ | |
1138 BinaryExpression({Expression leftOperand, Token operator, Expression rightOper
and}) : this.full(leftOperand, operator, rightOperand); | |
1139 accept(ASTVisitor visitor) => visitor.visitBinaryExpression(this); | |
1140 Token get beginToken => _leftOperand.beginToken; | |
1141 /** | |
1142 * Return the element associated with the operator, or {@code null} if the AST
structure has not | |
1143 * been resolved, if the operator is not user definable, or if the operator co
uld not be resolved. | |
1144 * One example of the latter case is an operator that is not defined for the t
ype of the left-hand | |
1145 * operand. | |
1146 * @return the element associated with the operator | |
1147 */ | |
1148 MethodElement get element => _element; | |
1149 Token get endToken => _rightOperand.endToken; | |
1150 /** | |
1151 * Return the expression used to compute the left operand. | |
1152 * @return the expression used to compute the left operand | |
1153 */ | |
1154 Expression get leftOperand => _leftOperand; | |
1155 /** | |
1156 * Return the binary operator being applied. | |
1157 * @return the binary operator being applied | |
1158 */ | |
1159 Token get operator => _operator; | |
1160 /** | |
1161 * Return the expression used to compute the right operand. | |
1162 * @return the expression used to compute the right operand | |
1163 */ | |
1164 Expression get rightOperand => _rightOperand; | |
1165 /** | |
1166 * Set the element associated with the operator to the given element. | |
1167 * @param element the element associated with the operator | |
1168 */ | |
1169 void set element(MethodElement element4) { | |
1170 this._element = element4; | |
1171 } | |
1172 /** | |
1173 * Set the expression used to compute the left operand to the given expression
. | |
1174 * @param expression the expression used to compute the left operand | |
1175 */ | |
1176 void set leftOperand(Expression expression) { | |
1177 _leftOperand = becomeParentOf(expression); | |
1178 } | |
1179 /** | |
1180 * Set the binary operator being applied to the given operator. | |
1181 * @return the binary operator being applied | |
1182 */ | |
1183 void set operator(Token operator3) { | |
1184 this._operator = operator3; | |
1185 } | |
1186 /** | |
1187 * Set the expression used to compute the right operand to the given expressio
n. | |
1188 * @param expression the expression used to compute the right operand | |
1189 */ | |
1190 void set rightOperand(Expression expression) { | |
1191 _rightOperand = becomeParentOf(expression); | |
1192 } | |
1193 void visitChildren(ASTVisitor<Object> visitor) { | |
1194 safelyVisitChild(_leftOperand, visitor); | |
1195 safelyVisitChild(_rightOperand, visitor); | |
1196 } | |
1197 } | |
1198 /** | |
1199 * Instances of the class {@code Block} represent a sequence of statements. | |
1200 * <pre> | |
1201 * block ::= | |
1202 * '{' statement* '}' | |
1203 * </pre> | |
1204 * @coverage dart.engine.ast | |
1205 */ | |
1206 class Block extends Statement { | |
1207 /** | |
1208 * The left curly bracket. | |
1209 */ | |
1210 Token _leftBracket; | |
1211 /** | |
1212 * The statements contained in the block. | |
1213 */ | |
1214 NodeList<Statement> _statements; | |
1215 /** | |
1216 * The right curly bracket. | |
1217 */ | |
1218 Token _rightBracket; | |
1219 /** | |
1220 * Initialize a newly created block of code. | |
1221 * @param leftBracket the left curly bracket | |
1222 * @param statements the statements contained in the block | |
1223 * @param rightBracket the right curly bracket | |
1224 */ | |
1225 Block.full(Token leftBracket, List<Statement> statements, Token rightBracket)
{ | |
1226 this._statements = new NodeList<Statement>(this); | |
1227 this._leftBracket = leftBracket; | |
1228 this._statements.addAll(statements); | |
1229 this._rightBracket = rightBracket; | |
1230 } | |
1231 /** | |
1232 * Initialize a newly created block of code. | |
1233 * @param leftBracket the left curly bracket | |
1234 * @param statements the statements contained in the block | |
1235 * @param rightBracket the right curly bracket | |
1236 */ | |
1237 Block({Token leftBracket, List<Statement> statements, Token rightBracket}) : t
his.full(leftBracket, statements, rightBracket); | |
1238 accept(ASTVisitor visitor) => visitor.visitBlock(this); | |
1239 Token get beginToken => _leftBracket; | |
1240 Token get endToken => _rightBracket; | |
1241 /** | |
1242 * Return the left curly bracket. | |
1243 * @return the left curly bracket | |
1244 */ | |
1245 Token get leftBracket => _leftBracket; | |
1246 /** | |
1247 * Return the right curly bracket. | |
1248 * @return the right curly bracket | |
1249 */ | |
1250 Token get rightBracket => _rightBracket; | |
1251 /** | |
1252 * Return the statements contained in the block. | |
1253 * @return the statements contained in the block | |
1254 */ | |
1255 NodeList<Statement> get statements => _statements; | |
1256 /** | |
1257 * Set the left curly bracket to the given token. | |
1258 * @param leftBracket the left curly bracket | |
1259 */ | |
1260 void set leftBracket(Token leftBracket2) { | |
1261 this._leftBracket = leftBracket2; | |
1262 } | |
1263 /** | |
1264 * Set the right curly bracket to the given token. | |
1265 * @param rightBracket the right curly bracket | |
1266 */ | |
1267 void set rightBracket(Token rightBracket2) { | |
1268 this._rightBracket = rightBracket2; | |
1269 } | |
1270 void visitChildren(ASTVisitor<Object> visitor) { | |
1271 _statements.accept(visitor); | |
1272 } | |
1273 } | |
1274 /** | |
1275 * Instances of the class {@code BlockFunctionBody} represent a function body th
at consists of a | |
1276 * block of statements. | |
1277 * <pre> | |
1278 * blockFunctionBody ::={@link Block block}</pre> | |
1279 * @coverage dart.engine.ast | |
1280 */ | |
1281 class BlockFunctionBody extends FunctionBody { | |
1282 /** | |
1283 * The block representing the body of the function. | |
1284 */ | |
1285 Block _block; | |
1286 /** | |
1287 * Initialize a newly created function body consisting of a block of statement
s. | |
1288 * @param block the block representing the body of the function | |
1289 */ | |
1290 BlockFunctionBody.full(Block block) { | |
1291 this._block = becomeParentOf(block); | |
1292 } | |
1293 /** | |
1294 * Initialize a newly created function body consisting of a block of statement
s. | |
1295 * @param block the block representing the body of the function | |
1296 */ | |
1297 BlockFunctionBody({Block block}) : this.full(block); | |
1298 accept(ASTVisitor visitor) => visitor.visitBlockFunctionBody(this); | |
1299 Token get beginToken => _block.beginToken; | |
1300 /** | |
1301 * Return the block representing the body of the function. | |
1302 * @return the block representing the body of the function | |
1303 */ | |
1304 Block get block => _block; | |
1305 Token get endToken => _block.endToken; | |
1306 /** | |
1307 * Set the block representing the body of the function to the given block. | |
1308 * @param block the block representing the body of the function | |
1309 */ | |
1310 void set block(Block block2) { | |
1311 this._block = becomeParentOf(block2); | |
1312 } | |
1313 void visitChildren(ASTVisitor<Object> visitor) { | |
1314 safelyVisitChild(_block, visitor); | |
1315 } | |
1316 } | |
1317 /** | |
1318 * Instances of the class {@code BooleanLiteral} represent a boolean literal exp
ression. | |
1319 * <pre> | |
1320 * booleanLiteral ::= | |
1321 * 'false' | 'true' | |
1322 * </pre> | |
1323 * @coverage dart.engine.ast | |
1324 */ | |
1325 class BooleanLiteral extends Literal { | |
1326 /** | |
1327 * The token representing the literal. | |
1328 */ | |
1329 Token _literal; | |
1330 /** | |
1331 * The value of the literal. | |
1332 */ | |
1333 bool _value = false; | |
1334 /** | |
1335 * Initialize a newly created boolean literal. | |
1336 * @param literal the token representing the literal | |
1337 * @param value the value of the literal | |
1338 */ | |
1339 BooleanLiteral.full(Token literal, bool value) { | |
1340 this._literal = literal; | |
1341 this._value = value; | |
1342 } | |
1343 /** | |
1344 * Initialize a newly created boolean literal. | |
1345 * @param literal the token representing the literal | |
1346 * @param value the value of the literal | |
1347 */ | |
1348 BooleanLiteral({Token literal, bool value}) : this.full(literal, value); | |
1349 accept(ASTVisitor visitor) => visitor.visitBooleanLiteral(this); | |
1350 Token get beginToken => _literal; | |
1351 Token get endToken => _literal; | |
1352 /** | |
1353 * Return the token representing the literal. | |
1354 * @return the token representing the literal | |
1355 */ | |
1356 Token get literal => _literal; | |
1357 /** | |
1358 * Return the value of the literal. | |
1359 * @return the value of the literal | |
1360 */ | |
1361 bool get value => _value; | |
1362 bool isSynthetic() => _literal.isSynthetic(); | |
1363 /** | |
1364 * Set the token representing the literal to the given token. | |
1365 * @param literal the token representing the literal | |
1366 */ | |
1367 void set literal(Token literal2) { | |
1368 this._literal = literal2; | |
1369 } | |
1370 /** | |
1371 * Set the value of the literal to the given value. | |
1372 * @param value the value of the literal | |
1373 */ | |
1374 void set value(bool value4) { | |
1375 this._value = value4; | |
1376 } | |
1377 void visitChildren(ASTVisitor<Object> visitor) { | |
1378 } | |
1379 } | |
1380 /** | |
1381 * Instances of the class {@code BreakStatement} represent a break statement. | |
1382 * <pre> | |
1383 * breakStatement ::= | |
1384 * 'break' {@link SimpleIdentifier label}? ';' | |
1385 * </pre> | |
1386 * @coverage dart.engine.ast | |
1387 */ | |
1388 class BreakStatement extends Statement { | |
1389 /** | |
1390 * The token representing the 'break' keyword. | |
1391 */ | |
1392 Token _keyword; | |
1393 /** | |
1394 * The label associated with the statement, or {@code null} if there is no lab
el. | |
1395 */ | |
1396 SimpleIdentifier _label; | |
1397 /** | |
1398 * The semicolon terminating the statement. | |
1399 */ | |
1400 Token _semicolon; | |
1401 /** | |
1402 * Initialize a newly created break statement. | |
1403 * @param keyword the token representing the 'break' keyword | |
1404 * @param label the label associated with the statement | |
1405 * @param semicolon the semicolon terminating the statement | |
1406 */ | |
1407 BreakStatement.full(Token keyword, SimpleIdentifier label, Token semicolon) { | |
1408 this._keyword = keyword; | |
1409 this._label = becomeParentOf(label); | |
1410 this._semicolon = semicolon; | |
1411 } | |
1412 /** | |
1413 * Initialize a newly created break statement. | |
1414 * @param keyword the token representing the 'break' keyword | |
1415 * @param label the label associated with the statement | |
1416 * @param semicolon the semicolon terminating the statement | |
1417 */ | |
1418 BreakStatement({Token keyword, SimpleIdentifier label, Token semicolon}) : thi
s.full(keyword, label, semicolon); | |
1419 accept(ASTVisitor visitor) => visitor.visitBreakStatement(this); | |
1420 Token get beginToken => _keyword; | |
1421 Token get endToken => _semicolon; | |
1422 /** | |
1423 * Return the token representing the 'break' keyword. | |
1424 * @return the token representing the 'break' keyword | |
1425 */ | |
1426 Token get keyword => _keyword; | |
1427 /** | |
1428 * Return the label associated with the statement, or {@code null} if there is
no label. | |
1429 * @return the label associated with the statement | |
1430 */ | |
1431 SimpleIdentifier get label => _label; | |
1432 /** | |
1433 * Return the semicolon terminating the statement. | |
1434 * @return the semicolon terminating the statement | |
1435 */ | |
1436 Token get semicolon => _semicolon; | |
1437 /** | |
1438 * Set the token representing the 'break' keyword to the given token. | |
1439 * @param keyword the token representing the 'break' keyword | |
1440 */ | |
1441 void set keyword(Token keyword4) { | |
1442 this._keyword = keyword4; | |
1443 } | |
1444 /** | |
1445 * Set the label associated with the statement to the given identifier. | |
1446 * @param identifier the label associated with the statement | |
1447 */ | |
1448 void set label(SimpleIdentifier identifier) { | |
1449 _label = becomeParentOf(identifier); | |
1450 } | |
1451 /** | |
1452 * Set the semicolon terminating the statement to the given token. | |
1453 * @param semicolon the semicolon terminating the statement | |
1454 */ | |
1455 void set semicolon(Token semicolon3) { | |
1456 this._semicolon = semicolon3; | |
1457 } | |
1458 void visitChildren(ASTVisitor<Object> visitor) { | |
1459 safelyVisitChild(_label, visitor); | |
1460 } | |
1461 } | |
1462 /** | |
1463 * Instances of the class {@code CascadeExpression} represent a sequence of casc
aded expressions: | |
1464 * expressions that share a common target. There are three kinds of expressions
that can be used in | |
1465 * a cascade expression: {@link IndexExpression}, {@link MethodInvocation} and{@
link PropertyAccess}. | |
1466 * <pre> | |
1467 * cascadeExpression ::={@link Expression conditionalExpression} cascadeSection | |
1468 * cascadeSection ::= | |
1469 * '..' (cascadeSelector arguments*) (assignableSelector arguments*)* (assignme
ntOperator expressionWithoutCascade)? | |
1470 * cascadeSelector ::= | |
1471 * '[ ' expression '] ' | |
1472 * | identifier | |
1473 * </pre> | |
1474 * @coverage dart.engine.ast | |
1475 */ | |
1476 class CascadeExpression extends Expression { | |
1477 /** | |
1478 * The target of the cascade sections. | |
1479 */ | |
1480 Expression _target; | |
1481 /** | |
1482 * The cascade sections sharing the common target. | |
1483 */ | |
1484 NodeList<Expression> _cascadeSections; | |
1485 /** | |
1486 * Initialize a newly created cascade expression. | |
1487 * @param target the target of the cascade sections | |
1488 * @param cascadeSections the cascade sections sharing the common target | |
1489 */ | |
1490 CascadeExpression.full(Expression target, List<Expression> cascadeSections) { | |
1491 this._cascadeSections = new NodeList<Expression>(this); | |
1492 this._target = becomeParentOf(target); | |
1493 this._cascadeSections.addAll(cascadeSections); | |
1494 } | |
1495 /** | |
1496 * Initialize a newly created cascade expression. | |
1497 * @param target the target of the cascade sections | |
1498 * @param cascadeSections the cascade sections sharing the common target | |
1499 */ | |
1500 CascadeExpression({Expression target, List<Expression> cascadeSections}) : thi
s.full(target, cascadeSections); | |
1501 accept(ASTVisitor visitor) => visitor.visitCascadeExpression(this); | |
1502 Token get beginToken => _target.beginToken; | |
1503 /** | |
1504 * Return the cascade sections sharing the common target. | |
1505 * @return the cascade sections sharing the common target | |
1506 */ | |
1507 NodeList<Expression> get cascadeSections => _cascadeSections; | |
1508 Token get endToken => _cascadeSections.endToken; | |
1509 /** | |
1510 * Return the target of the cascade sections. | |
1511 * @return the target of the cascade sections | |
1512 */ | |
1513 Expression get target => _target; | |
1514 /** | |
1515 * Set the target of the cascade sections to the given expression. | |
1516 * @param target the target of the cascade sections | |
1517 */ | |
1518 void set target(Expression target2) { | |
1519 this._target = becomeParentOf(target2); | |
1520 } | |
1521 void visitChildren(ASTVisitor<Object> visitor) { | |
1522 safelyVisitChild(_target, visitor); | |
1523 _cascadeSections.accept(visitor); | |
1524 } | |
1525 } | |
1526 /** | |
1527 * Instances of the class {@code CatchClause} represent a catch clause within a
try statement. | |
1528 * <pre> | |
1529 * onPart ::= | |
1530 * catchPart {@link Block block}| 'on' type catchPart? {@link Block block}catchP
art ::= | |
1531 * 'catch' '(' {@link SimpleIdentifier exceptionParameter} (',' {@link SimpleIde
ntifier stackTraceParameter})? ')' | |
1532 * </pre> | |
1533 * @coverage dart.engine.ast | |
1534 */ | |
1535 class CatchClause extends ASTNode { | |
1536 /** | |
1537 * The token representing the 'on' keyword, or {@code null} if there is no 'on
' keyword. | |
1538 */ | |
1539 Token _onKeyword; | |
1540 /** | |
1541 * The type of exceptions caught by this catch clause, or {@code null} if this
catch clause | |
1542 * catches every type of exception. | |
1543 */ | |
1544 TypeName _exceptionType; | |
1545 /** | |
1546 * The token representing the 'catch' keyword, or {@code null} if there is no
'catch' keyword. | |
1547 */ | |
1548 Token _catchKeyword; | |
1549 /** | |
1550 * The left parenthesis. | |
1551 */ | |
1552 Token _leftParenthesis; | |
1553 /** | |
1554 * The parameter whose value will be the exception that was thrown. | |
1555 */ | |
1556 SimpleIdentifier _exceptionParameter; | |
1557 /** | |
1558 * The comma separating the exception parameter from the stack trace parameter
. | |
1559 */ | |
1560 Token _comma; | |
1561 /** | |
1562 * The parameter whose value will be the stack trace associated with the excep
tion. | |
1563 */ | |
1564 SimpleIdentifier _stackTraceParameter; | |
1565 /** | |
1566 * The right parenthesis. | |
1567 */ | |
1568 Token _rightParenthesis; | |
1569 /** | |
1570 * The body of the catch block. | |
1571 */ | |
1572 Block _body; | |
1573 /** | |
1574 * Initialize a newly created catch clause. | |
1575 * @param onKeyword the token representing the 'on' keyword | |
1576 * @param exceptionType the type of exceptions caught by this catch clause | |
1577 * @param leftParenthesis the left parenthesis | |
1578 * @param exceptionParameter the parameter whose value will be the exception t
hat was thrown | |
1579 * @param comma the comma separating the exception parameter from the stack tr
ace parameter | |
1580 * @param stackTraceParameter the parameter whose value will be the stack trac
e associated with | |
1581 * the exception | |
1582 * @param rightParenthesis the right parenthesis | |
1583 * @param body the body of the catch block | |
1584 */ | |
1585 CatchClause.full(Token onKeyword, TypeName exceptionType, Token catchKeyword,
Token leftParenthesis, SimpleIdentifier exceptionParameter, Token comma, SimpleI
dentifier stackTraceParameter, Token rightParenthesis, Block body) { | |
1586 this._onKeyword = onKeyword; | |
1587 this._exceptionType = becomeParentOf(exceptionType); | |
1588 this._catchKeyword = catchKeyword; | |
1589 this._leftParenthesis = leftParenthesis; | |
1590 this._exceptionParameter = becomeParentOf(exceptionParameter); | |
1591 this._comma = comma; | |
1592 this._stackTraceParameter = becomeParentOf(stackTraceParameter); | |
1593 this._rightParenthesis = rightParenthesis; | |
1594 this._body = becomeParentOf(body); | |
1595 } | |
1596 /** | |
1597 * Initialize a newly created catch clause. | |
1598 * @param onKeyword the token representing the 'on' keyword | |
1599 * @param exceptionType the type of exceptions caught by this catch clause | |
1600 * @param leftParenthesis the left parenthesis | |
1601 * @param exceptionParameter the parameter whose value will be the exception t
hat was thrown | |
1602 * @param comma the comma separating the exception parameter from the stack tr
ace parameter | |
1603 * @param stackTraceParameter the parameter whose value will be the stack trac
e associated with | |
1604 * the exception | |
1605 * @param rightParenthesis the right parenthesis | |
1606 * @param body the body of the catch block | |
1607 */ | |
1608 CatchClause({Token onKeyword, TypeName exceptionType, Token catchKeyword, Toke
n leftParenthesis, SimpleIdentifier exceptionParameter, Token comma, SimpleIdent
ifier stackTraceParameter, Token rightParenthesis, Block body}) : this.full(onKe
yword, exceptionType, catchKeyword, leftParenthesis, exceptionParameter, comma,
stackTraceParameter, rightParenthesis, body); | |
1609 accept(ASTVisitor visitor) => visitor.visitCatchClause(this); | |
1610 Token get beginToken { | |
1611 if (_onKeyword != null) { | |
1612 return _onKeyword; | |
1613 } | |
1614 return _catchKeyword; | |
1615 } | |
1616 /** | |
1617 * Return the body of the catch block. | |
1618 * @return the body of the catch block | |
1619 */ | |
1620 Block get body => _body; | |
1621 /** | |
1622 * Return the token representing the 'catch' keyword, or {@code null} if there
is no 'catch' | |
1623 * keyword. | |
1624 * @return the token representing the 'catch' keyword | |
1625 */ | |
1626 Token get catchKeyword => _catchKeyword; | |
1627 /** | |
1628 * Return the comma. | |
1629 * @return the comma | |
1630 */ | |
1631 Token get comma => _comma; | |
1632 Token get endToken => _body.endToken; | |
1633 /** | |
1634 * Return the parameter whose value will be the exception that was thrown. | |
1635 * @return the parameter whose value will be the exception that was thrown | |
1636 */ | |
1637 SimpleIdentifier get exceptionParameter => _exceptionParameter; | |
1638 /** | |
1639 * Return the type of exceptions caught by this catch clause, or {@code null}
if this catch clause | |
1640 * catches every type of exception. | |
1641 * @return the type of exceptions caught by this catch clause | |
1642 */ | |
1643 TypeName get exceptionType => _exceptionType; | |
1644 /** | |
1645 * Return the left parenthesis. | |
1646 * @return the left parenthesis | |
1647 */ | |
1648 Token get leftParenthesis => _leftParenthesis; | |
1649 /** | |
1650 * Return the token representing the 'on' keyword, or {@code null} if there is
no 'on' keyword. | |
1651 * @return the token representing the 'on' keyword | |
1652 */ | |
1653 Token get onKeyword => _onKeyword; | |
1654 /** | |
1655 * Return the right parenthesis. | |
1656 * @return the right parenthesis | |
1657 */ | |
1658 Token get rightParenthesis => _rightParenthesis; | |
1659 /** | |
1660 * Return the parameter whose value will be the stack trace associated with th
e exception. | |
1661 * @return the parameter whose value will be the stack trace associated with t
he exception | |
1662 */ | |
1663 SimpleIdentifier get stackTraceParameter => _stackTraceParameter; | |
1664 /** | |
1665 * Set the body of the catch block to the given block. | |
1666 * @param block the body of the catch block | |
1667 */ | |
1668 void set body(Block block) { | |
1669 _body = becomeParentOf(block); | |
1670 } | |
1671 /** | |
1672 * Set the token representing the 'catch' keyword to the given token. | |
1673 * @param catchKeyword the token representing the 'catch' keyword | |
1674 */ | |
1675 void set catchKeyword(Token catchKeyword2) { | |
1676 this._catchKeyword = catchKeyword2; | |
1677 } | |
1678 /** | |
1679 * Set the comma to the given token. | |
1680 * @param comma the comma | |
1681 */ | |
1682 void set comma(Token comma2) { | |
1683 this._comma = comma2; | |
1684 } | |
1685 /** | |
1686 * Set the parameter whose value will be the exception that was thrown to the
given parameter. | |
1687 * @param parameter the parameter whose value will be the exception that was t
hrown | |
1688 */ | |
1689 void set exceptionParameter(SimpleIdentifier parameter) { | |
1690 _exceptionParameter = becomeParentOf(parameter); | |
1691 } | |
1692 /** | |
1693 * Set the type of exceptions caught by this catch clause to the given type. | |
1694 * @param exceptionType the type of exceptions caught by this catch clause | |
1695 */ | |
1696 void set exceptionType(TypeName exceptionType2) { | |
1697 this._exceptionType = exceptionType2; | |
1698 } | |
1699 /** | |
1700 * Set the left parenthesis to the given token. | |
1701 * @param parenthesis the left parenthesis | |
1702 */ | |
1703 void set leftParenthesis(Token parenthesis) { | |
1704 _leftParenthesis = parenthesis; | |
1705 } | |
1706 /** | |
1707 * Set the token representing the 'on' keyword to the given keyword. | |
1708 * @param onKeyword the token representing the 'on' keyword | |
1709 */ | |
1710 void set onKeyword(Token onKeyword2) { | |
1711 this._onKeyword = onKeyword2; | |
1712 } | |
1713 /** | |
1714 * Set the right parenthesis to the given token. | |
1715 * @param parenthesis the right parenthesis | |
1716 */ | |
1717 void set rightParenthesis(Token parenthesis) { | |
1718 _rightParenthesis = parenthesis; | |
1719 } | |
1720 /** | |
1721 * Set the parameter whose value will be the stack trace associated with the e
xception to the | |
1722 * given parameter. | |
1723 * @param parameter the parameter whose value will be the stack trace associat
ed with the | |
1724 * exception | |
1725 */ | |
1726 void set stackTraceParameter(SimpleIdentifier parameter) { | |
1727 _stackTraceParameter = becomeParentOf(parameter); | |
1728 } | |
1729 void visitChildren(ASTVisitor<Object> visitor) { | |
1730 safelyVisitChild(_exceptionType, visitor); | |
1731 safelyVisitChild(_exceptionParameter, visitor); | |
1732 safelyVisitChild(_stackTraceParameter, visitor); | |
1733 safelyVisitChild(_body, visitor); | |
1734 } | |
1735 } | |
1736 /** | |
1737 * Instances of the class {@code ClassDeclaration} represent the declaration of
a class. | |
1738 * <pre> | |
1739 * classDeclaration ::= | |
1740 * 'abstract'? 'class' {@link SimpleIdentifier name} {@link TypeParameterList ty
peParameterList}? | |
1741 * ({@link ExtendsClause extendsClause} {@link WithClause withClause}?)?{@link I
mplementsClause implementsClause}? | |
1742 * '{' {@link ClassMember classMember}* '}' | |
1743 * </pre> | |
1744 * @coverage dart.engine.ast | |
1745 */ | |
1746 class ClassDeclaration extends CompilationUnitMember { | |
1747 /** | |
1748 * The 'abstract' keyword, or {@code null} if the keyword was absent. | |
1749 */ | |
1750 Token _abstractKeyword; | |
1751 /** | |
1752 * The token representing the 'class' keyword. | |
1753 */ | |
1754 Token _classKeyword; | |
1755 /** | |
1756 * The name of the class being declared. | |
1757 */ | |
1758 SimpleIdentifier _name; | |
1759 /** | |
1760 * The type parameters for the class, or {@code null} if the class does not ha
ve any type | |
1761 * parameters. | |
1762 */ | |
1763 TypeParameterList _typeParameters; | |
1764 /** | |
1765 * The extends clause for the class, or {@code null} if the class does not ext
end any other class. | |
1766 */ | |
1767 ExtendsClause _extendsClause; | |
1768 /** | |
1769 * The with clause for the class, or {@code null} if the class does not have a
with clause. | |
1770 */ | |
1771 WithClause _withClause; | |
1772 /** | |
1773 * The implements clause for the class, or {@code null} if the class does not
implement any | |
1774 * interfaces. | |
1775 */ | |
1776 ImplementsClause _implementsClause; | |
1777 /** | |
1778 * The left curly bracket. | |
1779 */ | |
1780 Token _leftBracket; | |
1781 /** | |
1782 * The members defined by the class. | |
1783 */ | |
1784 NodeList<ClassMember> _members; | |
1785 /** | |
1786 * The right curly bracket. | |
1787 */ | |
1788 Token _rightBracket; | |
1789 /** | |
1790 * Initialize a newly created class declaration. | |
1791 * @param comment the documentation comment associated with this class | |
1792 * @param metadata the annotations associated with this class | |
1793 * @param abstractKeyword the 'abstract' keyword, or {@code null} if the keywo
rd was absent | |
1794 * @param classKeyword the token representing the 'class' keyword | |
1795 * @param name the name of the class being declared | |
1796 * @param typeParameters the type parameters for the class | |
1797 * @param extendsClause the extends clause for the class | |
1798 * @param withClause the with clause for the class | |
1799 * @param implementsClause the implements clause for the class | |
1800 * @param leftBracket the left curly bracket | |
1801 * @param members the members defined by the class | |
1802 * @param rightBracket the right curly bracket | |
1803 */ | |
1804 ClassDeclaration.full(Comment comment, List<Annotation> metadata, Token abstra
ctKeyword, Token classKeyword, SimpleIdentifier name, TypeParameterList typePara
meters, ExtendsClause extendsClause, WithClause withClause, ImplementsClause imp
lementsClause, Token leftBracket, List<ClassMember> members, Token rightBracket)
: super.full(comment, metadata) { | |
1805 this._members = new NodeList<ClassMember>(this); | |
1806 this._abstractKeyword = abstractKeyword; | |
1807 this._classKeyword = classKeyword; | |
1808 this._name = becomeParentOf(name); | |
1809 this._typeParameters = becomeParentOf(typeParameters); | |
1810 this._extendsClause = becomeParentOf(extendsClause); | |
1811 this._withClause = becomeParentOf(withClause); | |
1812 this._implementsClause = becomeParentOf(implementsClause); | |
1813 this._leftBracket = leftBracket; | |
1814 this._members.addAll(members); | |
1815 this._rightBracket = rightBracket; | |
1816 } | |
1817 /** | |
1818 * Initialize a newly created class declaration. | |
1819 * @param comment the documentation comment associated with this class | |
1820 * @param metadata the annotations associated with this class | |
1821 * @param abstractKeyword the 'abstract' keyword, or {@code null} if the keywo
rd was absent | |
1822 * @param classKeyword the token representing the 'class' keyword | |
1823 * @param name the name of the class being declared | |
1824 * @param typeParameters the type parameters for the class | |
1825 * @param extendsClause the extends clause for the class | |
1826 * @param withClause the with clause for the class | |
1827 * @param implementsClause the implements clause for the class | |
1828 * @param leftBracket the left curly bracket | |
1829 * @param members the members defined by the class | |
1830 * @param rightBracket the right curly bracket | |
1831 */ | |
1832 ClassDeclaration({Comment comment, List<Annotation> metadata, Token abstractKe
yword, Token classKeyword, SimpleIdentifier name, TypeParameterList typeParamete
rs, ExtendsClause extendsClause, WithClause withClause, ImplementsClause impleme
ntsClause, Token leftBracket, List<ClassMember> members, Token rightBracket}) :
this.full(comment, metadata, abstractKeyword, classKeyword, name, typeParameters
, extendsClause, withClause, implementsClause, leftBracket, members, rightBracke
t); | |
1833 accept(ASTVisitor visitor) => visitor.visitClassDeclaration(this); | |
1834 /** | |
1835 * Return the 'abstract' keyword, or {@code null} if the keyword was absent. | |
1836 * @return the 'abstract' keyword | |
1837 */ | |
1838 Token get abstractKeyword => _abstractKeyword; | |
1839 /** | |
1840 * Return the token representing the 'class' keyword. | |
1841 * @return the token representing the 'class' keyword | |
1842 */ | |
1843 Token get classKeyword => _classKeyword; | |
1844 ClassElement get element => _name != null ? (_name.element as ClassElement) :
null; | |
1845 Token get endToken => _rightBracket; | |
1846 /** | |
1847 * Return the extends clause for this class, or {@code null} if the class does
not extend any | |
1848 * other class. | |
1849 * @return the extends clause for this class | |
1850 */ | |
1851 ExtendsClause get extendsClause => _extendsClause; | |
1852 /** | |
1853 * Return the implements clause for the class, or {@code null} if the class do
es not implement any | |
1854 * interfaces. | |
1855 * @return the implements clause for the class | |
1856 */ | |
1857 ImplementsClause get implementsClause => _implementsClause; | |
1858 /** | |
1859 * Return the left curly bracket. | |
1860 * @return the left curly bracket | |
1861 */ | |
1862 Token get leftBracket => _leftBracket; | |
1863 /** | |
1864 * Return the members defined by the class. | |
1865 * @return the members defined by the class | |
1866 */ | |
1867 NodeList<ClassMember> get members => _members; | |
1868 /** | |
1869 * Return the name of the class being declared. | |
1870 * @return the name of the class being declared | |
1871 */ | |
1872 SimpleIdentifier get name => _name; | |
1873 /** | |
1874 * Return the right curly bracket. | |
1875 * @return the right curly bracket | |
1876 */ | |
1877 Token get rightBracket => _rightBracket; | |
1878 /** | |
1879 * Return the type parameters for the class, or {@code null} if the class does
not have any type | |
1880 * parameters. | |
1881 * @return the type parameters for the class | |
1882 */ | |
1883 TypeParameterList get typeParameters => _typeParameters; | |
1884 /** | |
1885 * Return the with clause for the class, or {@code null} if the class does not
have a with clause. | |
1886 * @return the with clause for the class | |
1887 */ | |
1888 WithClause get withClause => _withClause; | |
1889 /** | |
1890 * Set the 'abstract' keyword to the given keyword. | |
1891 * @param abstractKeyword the 'abstract' keyword | |
1892 */ | |
1893 void set abstractKeyword(Token abstractKeyword2) { | |
1894 this._abstractKeyword = abstractKeyword2; | |
1895 } | |
1896 /** | |
1897 * Set the token representing the 'class' keyword to the given token. | |
1898 * @param classKeyword the token representing the 'class' keyword | |
1899 */ | |
1900 void set classKeyword(Token classKeyword2) { | |
1901 this._classKeyword = classKeyword2; | |
1902 } | |
1903 /** | |
1904 * Set the extends clause for this class to the given clause. | |
1905 * @param extendsClause the extends clause for this class | |
1906 */ | |
1907 void set extendsClause(ExtendsClause extendsClause3) { | |
1908 this._extendsClause = becomeParentOf(extendsClause3); | |
1909 } | |
1910 /** | |
1911 * Set the implements clause for the class to the given clause. | |
1912 * @param implementsClause the implements clause for the class | |
1913 */ | |
1914 void set implementsClause(ImplementsClause implementsClause4) { | |
1915 this._implementsClause = becomeParentOf(implementsClause4); | |
1916 } | |
1917 /** | |
1918 * Set the left curly bracket to the given token. | |
1919 * @param leftBracket the left curly bracket | |
1920 */ | |
1921 void set leftBracket(Token leftBracket3) { | |
1922 this._leftBracket = leftBracket3; | |
1923 } | |
1924 /** | |
1925 * Set the name of the class being declared to the given identifier. | |
1926 * @param identifier the name of the class being declared | |
1927 */ | |
1928 void set name(SimpleIdentifier identifier) { | |
1929 _name = becomeParentOf(identifier); | |
1930 } | |
1931 /** | |
1932 * Set the right curly bracket to the given token. | |
1933 * @param rightBracket the right curly bracket | |
1934 */ | |
1935 void set rightBracket(Token rightBracket3) { | |
1936 this._rightBracket = rightBracket3; | |
1937 } | |
1938 /** | |
1939 * Set the type parameters for the class to the given list of type parameters. | |
1940 * @param typeParameters the type parameters for the class | |
1941 */ | |
1942 void set typeParameters(TypeParameterList typeParameters2) { | |
1943 this._typeParameters = typeParameters2; | |
1944 } | |
1945 /** | |
1946 * Set the with clause for the class to the given clause. | |
1947 * @param withClause the with clause for the class | |
1948 */ | |
1949 void set withClause(WithClause withClause4) { | |
1950 this._withClause = becomeParentOf(withClause4); | |
1951 } | |
1952 void visitChildren(ASTVisitor<Object> visitor) { | |
1953 safelyVisitChild(documentationComment, visitor); | |
1954 safelyVisitChild(_name, visitor); | |
1955 safelyVisitChild(_typeParameters, visitor); | |
1956 safelyVisitChild(_extendsClause, visitor); | |
1957 safelyVisitChild(_withClause, visitor); | |
1958 safelyVisitChild(_implementsClause, visitor); | |
1959 members.accept(visitor); | |
1960 } | |
1961 Token get firstTokenAfterCommentAndMetadata { | |
1962 if (_abstractKeyword != null) { | |
1963 return _abstractKeyword; | |
1964 } | |
1965 return _classKeyword; | |
1966 } | |
1967 } | |
1968 /** | |
1969 * The abstract class {@code ClassMember} defines the behavior common to nodes t
hat declare a name | |
1970 * within the scope of a class. | |
1971 * @coverage dart.engine.ast | |
1972 */ | |
1973 abstract class ClassMember extends Declaration { | |
1974 /** | |
1975 * Initialize a newly created member of a class. | |
1976 * @param comment the documentation comment associated with this member | |
1977 * @param metadata the annotations associated with this member | |
1978 */ | |
1979 ClassMember.full(Comment comment, List<Annotation> metadata) : super.full(comm
ent, metadata) { | |
1980 } | |
1981 /** | |
1982 * Initialize a newly created member of a class. | |
1983 * @param comment the documentation comment associated with this member | |
1984 * @param metadata the annotations associated with this member | |
1985 */ | |
1986 ClassMember({Comment comment, List<Annotation> metadata}) : this.full(comment,
metadata); | |
1987 } | |
1988 /** | |
1989 * Instances of the class {@code ClassTypeAlias} represent a class type alias. | |
1990 * <pre> | |
1991 * classTypeAlias ::={@link SimpleIdentifier identifier} {@link TypeParameterLis
t typeParameters}? '=' 'abstract'? mixinApplication | |
1992 * mixinApplication ::={@link TypeName superclass} {@link WithClause withClause}
{@link ImplementsClause implementsClause}? ';' | |
1993 * </pre> | |
1994 * @coverage dart.engine.ast | |
1995 */ | |
1996 class ClassTypeAlias extends TypeAlias { | |
1997 /** | |
1998 * The name of the class being declared. | |
1999 */ | |
2000 SimpleIdentifier _name; | |
2001 /** | |
2002 * The type parameters for the class, or {@code null} if the class does not ha
ve any type | |
2003 * parameters. | |
2004 */ | |
2005 TypeParameterList _typeParameters; | |
2006 /** | |
2007 * The token for the '=' separating the name from the definition. | |
2008 */ | |
2009 Token _equals; | |
2010 /** | |
2011 * The token for the 'abstract' keyword, or {@code null} if this is not defini
ng an abstract | |
2012 * class. | |
2013 */ | |
2014 Token _abstractKeyword; | |
2015 /** | |
2016 * The name of the superclass of the class being declared. | |
2017 */ | |
2018 TypeName _superclass; | |
2019 /** | |
2020 * The with clause for this class. | |
2021 */ | |
2022 WithClause _withClause; | |
2023 /** | |
2024 * The implements clause for this class, or {@code null} if there is no implem
ents clause. | |
2025 */ | |
2026 ImplementsClause _implementsClause; | |
2027 /** | |
2028 * Initialize a newly created class type alias. | |
2029 * @param comment the documentation comment associated with this type alias | |
2030 * @param metadata the annotations associated with this type alias | |
2031 * @param keyword the token representing the 'typedef' keyword | |
2032 * @param name the name of the class being declared | |
2033 * @param typeParameters the type parameters for the class | |
2034 * @param equals the token for the '=' separating the name from the definition | |
2035 * @param abstractKeyword the token for the 'abstract' keyword | |
2036 * @param superclass the name of the superclass of the class being declared | |
2037 * @param withClause the with clause for this class | |
2038 * @param implementsClause the implements clause for this class | |
2039 * @param semicolon the semicolon terminating the declaration | |
2040 */ | |
2041 ClassTypeAlias.full(Comment comment, List<Annotation> metadata, Token keyword,
SimpleIdentifier name, TypeParameterList typeParameters, Token equals, Token ab
stractKeyword, TypeName superclass, WithClause withClause, ImplementsClause impl
ementsClause, Token semicolon) : super.full(comment, metadata, keyword, semicolo
n) { | |
2042 this._name = becomeParentOf(name); | |
2043 this._typeParameters = becomeParentOf(typeParameters); | |
2044 this._equals = equals; | |
2045 this._abstractKeyword = abstractKeyword; | |
2046 this._superclass = becomeParentOf(superclass); | |
2047 this._withClause = becomeParentOf(withClause); | |
2048 this._implementsClause = becomeParentOf(implementsClause); | |
2049 } | |
2050 /** | |
2051 * Initialize a newly created class type alias. | |
2052 * @param comment the documentation comment associated with this type alias | |
2053 * @param metadata the annotations associated with this type alias | |
2054 * @param keyword the token representing the 'typedef' keyword | |
2055 * @param name the name of the class being declared | |
2056 * @param typeParameters the type parameters for the class | |
2057 * @param equals the token for the '=' separating the name from the definition | |
2058 * @param abstractKeyword the token for the 'abstract' keyword | |
2059 * @param superclass the name of the superclass of the class being declared | |
2060 * @param withClause the with clause for this class | |
2061 * @param implementsClause the implements clause for this class | |
2062 * @param semicolon the semicolon terminating the declaration | |
2063 */ | |
2064 ClassTypeAlias({Comment comment, List<Annotation> metadata, Token keyword, Sim
pleIdentifier name, TypeParameterList typeParameters, Token equals, Token abstra
ctKeyword, TypeName superclass, WithClause withClause, ImplementsClause implemen
tsClause, Token semicolon}) : this.full(comment, metadata, keyword, name, typePa
rameters, equals, abstractKeyword, superclass, withClause, implementsClause, sem
icolon); | |
2065 accept(ASTVisitor visitor) => visitor.visitClassTypeAlias(this); | |
2066 /** | |
2067 * Return the token for the 'abstract' keyword, or {@code null} if this is not
defining an | |
2068 * abstract class. | |
2069 * @return the token for the 'abstract' keyword | |
2070 */ | |
2071 Token get abstractKeyword => _abstractKeyword; | |
2072 ClassElement get element => _name != null ? (_name.element as ClassElement) :
null; | |
2073 /** | |
2074 * Return the token for the '=' separating the name from the definition. | |
2075 * @return the token for the '=' separating the name from the definition | |
2076 */ | |
2077 Token get equals => _equals; | |
2078 /** | |
2079 * Return the implements clause for this class, or {@code null} if there is no
implements clause. | |
2080 * @return the implements clause for this class | |
2081 */ | |
2082 ImplementsClause get implementsClause => _implementsClause; | |
2083 /** | |
2084 * Return the name of the class being declared. | |
2085 * @return the name of the class being declared | |
2086 */ | |
2087 SimpleIdentifier get name => _name; | |
2088 /** | |
2089 * Return the name of the superclass of the class being declared. | |
2090 * @return the name of the superclass of the class being declared | |
2091 */ | |
2092 TypeName get superclass => _superclass; | |
2093 /** | |
2094 * Return the type parameters for the class, or {@code null} if the class does
not have any type | |
2095 * parameters. | |
2096 * @return the type parameters for the class | |
2097 */ | |
2098 TypeParameterList get typeParameters => _typeParameters; | |
2099 /** | |
2100 * Return the with clause for this class. | |
2101 * @return the with clause for this class | |
2102 */ | |
2103 WithClause get withClause => _withClause; | |
2104 /** | |
2105 * Set the token for the 'abstract' keyword to the given token. | |
2106 * @param abstractKeyword the token for the 'abstract' keyword | |
2107 */ | |
2108 void set abstractKeyword(Token abstractKeyword3) { | |
2109 this._abstractKeyword = abstractKeyword3; | |
2110 } | |
2111 /** | |
2112 * Set the token for the '=' separating the name from the definition to the gi
ven token. | |
2113 * @param equals the token for the '=' separating the name from the definition | |
2114 */ | |
2115 void set equals(Token equals4) { | |
2116 this._equals = equals4; | |
2117 } | |
2118 /** | |
2119 * Set the implements clause for this class to the given implements clause. | |
2120 * @param implementsClause the implements clause for this class | |
2121 */ | |
2122 void set implementsClause(ImplementsClause implementsClause5) { | |
2123 this._implementsClause = becomeParentOf(implementsClause5); | |
2124 } | |
2125 /** | |
2126 * Set the name of the class being declared to the given identifier. | |
2127 * @param name the name of the class being declared | |
2128 */ | |
2129 void set name(SimpleIdentifier name3) { | |
2130 this._name = becomeParentOf(name3); | |
2131 } | |
2132 /** | |
2133 * Set the name of the superclass of the class being declared to the given nam
e. | |
2134 * @param superclass the name of the superclass of the class being declared | |
2135 */ | |
2136 void set superclass(TypeName superclass2) { | |
2137 this._superclass = becomeParentOf(superclass2); | |
2138 } | |
2139 /** | |
2140 * Set the type parameters for the class to the given list of parameters. | |
2141 * @param typeParameters the type parameters for the class | |
2142 */ | |
2143 void set typeParameters(TypeParameterList typeParameters3) { | |
2144 this._typeParameters = becomeParentOf(typeParameters3); | |
2145 } | |
2146 /** | |
2147 * Set the with clause for this class to the given with clause. | |
2148 * @param withClause the with clause for this class | |
2149 */ | |
2150 void set withClause(WithClause withClause5) { | |
2151 this._withClause = becomeParentOf(withClause5); | |
2152 } | |
2153 void visitChildren(ASTVisitor<Object> visitor) { | |
2154 super.visitChildren(visitor); | |
2155 safelyVisitChild(_name, visitor); | |
2156 safelyVisitChild(_typeParameters, visitor); | |
2157 safelyVisitChild(_superclass, visitor); | |
2158 safelyVisitChild(_withClause, visitor); | |
2159 safelyVisitChild(_implementsClause, visitor); | |
2160 } | |
2161 } | |
2162 /** | |
2163 * Instances of the class {@code Combinator} represent the combinator associated
with an import | |
2164 * directive. | |
2165 * <pre> | |
2166 * combinator ::={@link HideCombinator hideCombinator}| {@link ShowCombinator sh
owCombinator}</pre> | |
2167 * @coverage dart.engine.ast | |
2168 */ | |
2169 abstract class Combinator extends ASTNode { | |
2170 /** | |
2171 * The keyword specifying what kind of processing is to be done on the importe
d names. | |
2172 */ | |
2173 Token _keyword; | |
2174 /** | |
2175 * Initialize a newly created import combinator. | |
2176 * @param keyword the keyword specifying what kind of processing is to be done
on the imported | |
2177 * names | |
2178 */ | |
2179 Combinator.full(Token keyword) { | |
2180 this._keyword = keyword; | |
2181 } | |
2182 /** | |
2183 * Initialize a newly created import combinator. | |
2184 * @param keyword the keyword specifying what kind of processing is to be done
on the imported | |
2185 * names | |
2186 */ | |
2187 Combinator({Token keyword}) : this.full(keyword); | |
2188 Token get beginToken => _keyword; | |
2189 /** | |
2190 * Return the keyword specifying what kind of processing is to be done on the
imported names. | |
2191 * @return the keyword specifying what kind of processing is to be done on the
imported names | |
2192 */ | |
2193 Token get keyword => _keyword; | |
2194 /** | |
2195 * Set the keyword specifying what kind of processing is to be done on the imp
orted names to the | |
2196 * given token. | |
2197 * @param keyword the keyword specifying what kind of processing is to be done
on the imported | |
2198 * names | |
2199 */ | |
2200 void set keyword(Token keyword5) { | |
2201 this._keyword = keyword5; | |
2202 } | |
2203 } | |
2204 /** | |
2205 * Instances of the class {@code Comment} represent a comment within the source
code. | |
2206 * <pre> | |
2207 * comment ::= | |
2208 * endOfLineComment | |
2209 * | blockComment | |
2210 * | documentationComment | |
2211 * endOfLineComment ::= | |
2212 * '//' (CHARACTER - EOL)* EOL | |
2213 * blockComment ::= | |
2214 * '/ *' CHARACTER* '*/' | |
2215 * documentationComment ::= | |
2216 * '/ **' (CHARACTER | {@link CommentReference commentReference})* '*/' | |
2217 * | ('///' (CHARACTER - EOL)* EOL)+ | |
2218 * </pre> | |
2219 * @coverage dart.engine.ast | |
2220 */ | |
2221 class Comment extends ASTNode { | |
2222 /** | |
2223 * Create a block comment. | |
2224 * @param tokens the tokens representing the comment | |
2225 * @return the block comment that was created | |
2226 */ | |
2227 static Comment createBlockComment(List<Token> tokens) => new Comment.full(toke
ns, CommentType.BLOCK, null); | |
2228 /** | |
2229 * Create a documentation comment. | |
2230 * @param tokens the tokens representing the comment | |
2231 * @return the documentation comment that was created | |
2232 */ | |
2233 static Comment createDocumentationComment(List<Token> tokens) => new Comment.f
ull(tokens, CommentType.DOCUMENTATION, new List<CommentReference>()); | |
2234 /** | |
2235 * Create a documentation comment. | |
2236 * @param tokens the tokens representing the comment | |
2237 * @param references the references embedded within the documentation comment | |
2238 * @return the documentation comment that was created | |
2239 */ | |
2240 static Comment createDocumentationComment2(List<Token> tokens, List<CommentRef
erence> references) => new Comment.full(tokens, CommentType.DOCUMENTATION, refer
ences); | |
2241 /** | |
2242 * Create an end-of-line comment. | |
2243 * @param tokens the tokens representing the comment | |
2244 * @return the end-of-line comment that was created | |
2245 */ | |
2246 static Comment createEndOfLineComment(List<Token> tokens) => new Comment.full(
tokens, CommentType.END_OF_LINE, null); | |
2247 /** | |
2248 * The tokens representing the comment. | |
2249 */ | |
2250 List<Token> _tokens; | |
2251 /** | |
2252 * The type of the comment. | |
2253 */ | |
2254 CommentType _type; | |
2255 /** | |
2256 * The references embedded within the documentation comment. This list will be
empty unless this | |
2257 * is a documentation comment that has references embedded within it. | |
2258 */ | |
2259 NodeList<CommentReference> _references; | |
2260 /** | |
2261 * Initialize a newly created comment. | |
2262 * @param tokens the tokens representing the comment | |
2263 * @param type the type of the comment | |
2264 * @param references the references embedded within the documentation comment | |
2265 */ | |
2266 Comment.full(List<Token> tokens, CommentType type, List<CommentReference> refe
rences) { | |
2267 this._references = new NodeList<CommentReference>(this); | |
2268 this._tokens = tokens; | |
2269 this._type = type; | |
2270 this._references.addAll(references); | |
2271 } | |
2272 /** | |
2273 * Initialize a newly created comment. | |
2274 * @param tokens the tokens representing the comment | |
2275 * @param type the type of the comment | |
2276 * @param references the references embedded within the documentation comment | |
2277 */ | |
2278 Comment({List<Token> tokens, CommentType type, List<CommentReference> referenc
es}) : this.full(tokens, type, references); | |
2279 accept(ASTVisitor visitor) => visitor.visitComment(this); | |
2280 Token get beginToken => _tokens[0]; | |
2281 Token get endToken => _tokens[_tokens.length - 1]; | |
2282 /** | |
2283 * Return the references embedded within the documentation comment. | |
2284 * @return the references embedded within the documentation comment | |
2285 */ | |
2286 NodeList<CommentReference> get references => _references; | |
2287 /** | |
2288 * Return {@code true} if this is a block comment. | |
2289 * @return {@code true} if this is a block comment | |
2290 */ | |
2291 bool isBlock() => identical(_type, CommentType.BLOCK); | |
2292 /** | |
2293 * Return {@code true} if this is a documentation comment. | |
2294 * @return {@code true} if this is a documentation comment | |
2295 */ | |
2296 bool isDocumentation() => identical(_type, CommentType.DOCUMENTATION); | |
2297 /** | |
2298 * Return {@code true} if this is an end-of-line comment. | |
2299 * @return {@code true} if this is an end-of-line comment | |
2300 */ | |
2301 bool isEndOfLine() => identical(_type, CommentType.END_OF_LINE); | |
2302 void visitChildren(ASTVisitor<Object> visitor) { | |
2303 _references.accept(visitor); | |
2304 } | |
2305 } | |
2306 /** | |
2307 * The enumeration {@code CommentType} encodes all the different types of commen
ts that are | |
2308 * recognized by the parser. | |
2309 */ | |
2310 class CommentType { | |
2311 /** | |
2312 * An end-of-line comment. | |
2313 */ | |
2314 static final CommentType END_OF_LINE = new CommentType('END_OF_LINE', 0); | |
2315 /** | |
2316 * A block comment. | |
2317 */ | |
2318 static final CommentType BLOCK = new CommentType('BLOCK', 1); | |
2319 /** | |
2320 * A documentation comment. | |
2321 */ | |
2322 static final CommentType DOCUMENTATION = new CommentType('DOCUMENTATION', 2); | |
2323 static final List<CommentType> values = [END_OF_LINE, BLOCK, DOCUMENTATION]; | |
2324 final String __name; | |
2325 final int __ordinal; | |
2326 int get ordinal => __ordinal; | |
2327 CommentType(this.__name, this.__ordinal) { | |
2328 } | |
2329 String toString() => __name; | |
2330 } | |
2331 /** | |
2332 * Instances of the class {@code CommentReference} represent a reference to a Da
rt element that is | |
2333 * found within a documentation comment. | |
2334 * <pre> | |
2335 * commentReference ::= | |
2336 * '[' 'new'? {@link Identifier identifier} ']' | |
2337 * </pre> | |
2338 * @coverage dart.engine.ast | |
2339 */ | |
2340 class CommentReference extends ASTNode { | |
2341 /** | |
2342 * The token representing the 'new' keyword, or {@code null} if there was no '
new' keyword. | |
2343 */ | |
2344 Token _newKeyword; | |
2345 /** | |
2346 * The identifier being referenced. | |
2347 */ | |
2348 Identifier _identifier; | |
2349 /** | |
2350 * Initialize a newly created reference to a Dart element. | |
2351 * @param newKeyword the token representing the 'new' keyword | |
2352 * @param identifier the identifier being referenced | |
2353 */ | |
2354 CommentReference.full(Token newKeyword, Identifier identifier) { | |
2355 this._newKeyword = newKeyword; | |
2356 this._identifier = becomeParentOf(identifier); | |
2357 } | |
2358 /** | |
2359 * Initialize a newly created reference to a Dart element. | |
2360 * @param newKeyword the token representing the 'new' keyword | |
2361 * @param identifier the identifier being referenced | |
2362 */ | |
2363 CommentReference({Token newKeyword, Identifier identifier}) : this.full(newKey
word, identifier); | |
2364 accept(ASTVisitor visitor) => visitor.visitCommentReference(this); | |
2365 Token get beginToken => _identifier.beginToken; | |
2366 Token get endToken => _identifier.endToken; | |
2367 /** | |
2368 * Return the identifier being referenced. | |
2369 * @return the identifier being referenced | |
2370 */ | |
2371 Identifier get identifier => _identifier; | |
2372 /** | |
2373 * Return the token representing the 'new' keyword, or {@code null} if there w
as no 'new' keyword. | |
2374 * @return the token representing the 'new' keyword | |
2375 */ | |
2376 Token get newKeyword => _newKeyword; | |
2377 /** | |
2378 * Set the identifier being referenced to the given identifier. | |
2379 * @param identifier the identifier being referenced | |
2380 */ | |
2381 void set identifier(Identifier identifier24) { | |
2382 identifier24 = becomeParentOf(identifier24); | |
2383 } | |
2384 /** | |
2385 * Set the token representing the 'new' keyword to the given token. | |
2386 * @param newKeyword the token representing the 'new' keyword | |
2387 */ | |
2388 void set newKeyword(Token newKeyword2) { | |
2389 this._newKeyword = newKeyword2; | |
2390 } | |
2391 void visitChildren(ASTVisitor<Object> visitor) { | |
2392 safelyVisitChild(_identifier, visitor); | |
2393 } | |
2394 } | |
2395 /** | |
2396 * Instances of the class {@code CompilationUnit} represent a compilation unit. | |
2397 * <p> | |
2398 * While the grammar restricts the order of the directives and declarations with
in a compilation | |
2399 * unit, this class does not enforce those restrictions. In particular, the chil
dren of a | |
2400 * compilation unit will be visited in lexical order even if lexical order does
not conform to the | |
2401 * restrictions of the grammar. | |
2402 * <pre> | |
2403 * compilationUnit ::= | |
2404 * directives declarations | |
2405 * directives ::={@link ScriptTag scriptTag}? {@link LibraryDirective libraryDir
ective}? namespaceDirective* {@link PartDirective partDirective}| {@link PartOfD
irective partOfDirective}namespaceDirective ::={@link ImportDirective importDire
ctive}| {@link ExportDirective exportDirective}declarations ::={@link Compilatio
nUnitMember compilationUnitMember}</pre> | |
2406 * @coverage dart.engine.ast | |
2407 */ | |
2408 class CompilationUnit extends ASTNode { | |
2409 /** | |
2410 * The first token in the token stream that was parsed to form this compilatio
n unit. | |
2411 */ | |
2412 Token _beginToken; | |
2413 /** | |
2414 * The script tag at the beginning of the compilation unit, or {@code null} if
there is no script | |
2415 * tag in this compilation unit. | |
2416 */ | |
2417 ScriptTag _scriptTag; | |
2418 /** | |
2419 * The directives contained in this compilation unit. | |
2420 */ | |
2421 NodeList<Directive> _directives; | |
2422 /** | |
2423 * The declarations contained in this compilation unit. | |
2424 */ | |
2425 NodeList<CompilationUnitMember> _declarations; | |
2426 /** | |
2427 * The last token in the token stream that was parsed to form this compilation
unit. This token | |
2428 * should always have a type of {@link TokenType.EOF}. | |
2429 */ | |
2430 Token _endToken; | |
2431 /** | |
2432 * The element associated with this compilation unit, or {@code null} if the A
ST structure has not | |
2433 * been resolved. | |
2434 */ | |
2435 CompilationUnitElement _element; | |
2436 /** | |
2437 * The {@link LineInfo} for this {@link CompilationUnit}. | |
2438 */ | |
2439 LineInfo _lineInfo; | |
2440 /** | |
2441 * The parsing errors encountered when the receiver was parsed. | |
2442 */ | |
2443 List<AnalysisError> _parsingErrors = AnalysisError.NO_ERRORS; | |
2444 /** | |
2445 * The resolution errors encountered when the receiver was resolved. | |
2446 */ | |
2447 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; | |
2448 /** | |
2449 * Initialize a newly created compilation unit to have the given directives an
d declarations. | |
2450 * @param beginToken the first token in the token stream | |
2451 * @param scriptTag the script tag at the beginning of the compilation unit | |
2452 * @param directives the directives contained in this compilation unit | |
2453 * @param declarations the declarations contained in this compilation unit | |
2454 * @param endToken the last token in the token stream | |
2455 */ | |
2456 CompilationUnit.full(Token beginToken, ScriptTag scriptTag, List<Directive> di
rectives, List<CompilationUnitMember> declarations, Token endToken) { | |
2457 this._directives = new NodeList<Directive>(this); | |
2458 this._declarations = new NodeList<CompilationUnitMember>(this); | |
2459 this._beginToken = beginToken; | |
2460 this._scriptTag = becomeParentOf(scriptTag); | |
2461 this._directives.addAll(directives); | |
2462 this._declarations.addAll(declarations); | |
2463 this._endToken = endToken; | |
2464 } | |
2465 /** | |
2466 * Initialize a newly created compilation unit to have the given directives an
d declarations. | |
2467 * @param beginToken the first token in the token stream | |
2468 * @param scriptTag the script tag at the beginning of the compilation unit | |
2469 * @param directives the directives contained in this compilation unit | |
2470 * @param declarations the declarations contained in this compilation unit | |
2471 * @param endToken the last token in the token stream | |
2472 */ | |
2473 CompilationUnit({Token beginToken, ScriptTag scriptTag, List<Directive> direct
ives, List<CompilationUnitMember> declarations, Token endToken}) : this.full(beg
inToken, scriptTag, directives, declarations, endToken); | |
2474 accept(ASTVisitor visitor) => visitor.visitCompilationUnit(this); | |
2475 Token get beginToken => _beginToken; | |
2476 /** | |
2477 * Return the declarations contained in this compilation unit. | |
2478 * @return the declarations contained in this compilation unit | |
2479 */ | |
2480 NodeList<CompilationUnitMember> get declarations => _declarations; | |
2481 /** | |
2482 * Return the directives contained in this compilation unit. | |
2483 * @return the directives contained in this compilation unit | |
2484 */ | |
2485 NodeList<Directive> get directives => _directives; | |
2486 /** | |
2487 * Return the element associated with this compilation unit, or {@code null} i
f the AST structure | |
2488 * has not been resolved. | |
2489 * @return the element associated with this compilation unit | |
2490 */ | |
2491 CompilationUnitElement get element => _element; | |
2492 Token get endToken => _endToken; | |
2493 /** | |
2494 * Return an array containing all of the errors associated with the receiver.
If the receiver has | |
2495 * not been resolved, then return {@code null}. | |
2496 * @return an array of errors (contains no {@code null}s) or {@code null} if t
he receiver has not | |
2497 * been resolved | |
2498 */ | |
2499 List<AnalysisError> get errors { | |
2500 List<AnalysisError> parserErrors = parsingErrors; | |
2501 List<AnalysisError> resolverErrors = resolutionErrors; | |
2502 if (resolverErrors.length == 0) { | |
2503 return parserErrors; | |
2504 } else if (parserErrors.length == 0) { | |
2505 return resolverErrors; | |
2506 } else { | |
2507 List<AnalysisError> allErrors = new List<AnalysisError>(parserErrors.lengt
h + resolverErrors.length); | |
2508 JavaSystem.arraycopy(parserErrors, 0, allErrors, 0, parserErrors.length); | |
2509 JavaSystem.arraycopy(resolverErrors, 0, allErrors, parserErrors.length, re
solverErrors.length); | |
2510 return allErrors; | |
2511 } | |
2512 } | |
2513 int get length { | |
2514 Token endToken3 = endToken; | |
2515 if (endToken3 == null) { | |
2516 return 0; | |
2517 } | |
2518 return endToken3.offset + endToken3.length; | |
2519 } | |
2520 /** | |
2521 * Get the {@link LineInfo} object for this compilation unit. | |
2522 * @return the associated {@link LineInfo} | |
2523 */ | |
2524 LineInfo get lineInfo => _lineInfo; | |
2525 int get offset => 0; | |
2526 /** | |
2527 * Return an array containing all of the parsing errors associated with the re
ceiver. | |
2528 * @return an array of errors (not {@code null}, contains no {@code null}s). | |
2529 */ | |
2530 List<AnalysisError> get parsingErrors => _parsingErrors; | |
2531 /** | |
2532 * Return an array containing all of the resolution errors associated with the
receiver. If the | |
2533 * receiver has not been resolved, then return {@code null}. | |
2534 * @return an array of errors (contains no {@code null}s) or {@code null} if t
he receiver has not | |
2535 * been resolved | |
2536 */ | |
2537 List<AnalysisError> get resolutionErrors => _resolutionErrors; | |
2538 /** | |
2539 * Return the script tag at the beginning of the compilation unit, or {@code n
ull} if there is no | |
2540 * script tag in this compilation unit. | |
2541 * @return the script tag at the beginning of the compilation unit | |
2542 */ | |
2543 ScriptTag get scriptTag => _scriptTag; | |
2544 /** | |
2545 * Set the element associated with this compilation unit to the given element. | |
2546 * @param element the element associated with this compilation unit | |
2547 */ | |
2548 void set element(CompilationUnitElement element5) { | |
2549 this._element = element5; | |
2550 } | |
2551 /** | |
2552 * Set the {@link LineInfo} object for this compilation unit. | |
2553 * @param errors LineInfo to associate with this compilation unit | |
2554 */ | |
2555 void set lineInfo(LineInfo lineInfo2) { | |
2556 this._lineInfo = lineInfo2; | |
2557 } | |
2558 /** | |
2559 * Called to cache the parsing errors when the unit is parsed. | |
2560 * @param errors an array of parsing errors, if <code>null</code> is passed, t
he error array is | |
2561 * set to an empty array, {@link AnalysisError#NO_ERRORS} | |
2562 */ | |
2563 void set parsingErrors(List<AnalysisError> errors) { | |
2564 _parsingErrors = errors == null ? AnalysisError.NO_ERRORS : errors; | |
2565 } | |
2566 /** | |
2567 * Called to cache the resolution errors when the unit is resolved. | |
2568 * @param errors an array of resolution errors, if <code>null</code> is passed
, the error array is | |
2569 * set to an empty array, {@link AnalysisError#NO_ERRORS} | |
2570 */ | |
2571 void set resolutionErrors(List<AnalysisError> errors) { | |
2572 _resolutionErrors = errors == null ? AnalysisError.NO_ERRORS : errors; | |
2573 } | |
2574 /** | |
2575 * Set the script tag at the beginning of the compilation unit to the given sc
ript tag. | |
2576 * @param scriptTag the script tag at the beginning of the compilation unit | |
2577 */ | |
2578 void set scriptTag(ScriptTag scriptTag2) { | |
2579 this._scriptTag = becomeParentOf(scriptTag2); | |
2580 } | |
2581 void visitChildren(ASTVisitor<Object> visitor) { | |
2582 safelyVisitChild(_scriptTag, visitor); | |
2583 if (directivesAreBeforeDeclarations()) { | |
2584 _directives.accept(visitor); | |
2585 _declarations.accept(visitor); | |
2586 } else { | |
2587 for (ASTNode child in sortedDirectivesAndDeclarations) { | |
2588 child.accept(visitor); | |
2589 } | |
2590 } | |
2591 } | |
2592 /** | |
2593 * Return {@code true} if all of the directives are lexically before any decla
rations. | |
2594 * @return {@code true} if all of the directives are lexically before any decl
arations | |
2595 */ | |
2596 bool directivesAreBeforeDeclarations() { | |
2597 if (_directives.isEmpty || _declarations.isEmpty) { | |
2598 return true; | |
2599 } | |
2600 Directive lastDirective = _directives[_directives.length - 1]; | |
2601 CompilationUnitMember firstDeclaration = _declarations[0]; | |
2602 return lastDirective.offset < firstDeclaration.offset; | |
2603 } | |
2604 /** | |
2605 * Return an array containing all of the directives and declarations in this c
ompilation unit, | |
2606 * sorted in lexical order. | |
2607 * @return the directives and declarations in this compilation unit in the ord
er in which they | |
2608 * appeared in the original source | |
2609 */ | |
2610 List<ASTNode> get sortedDirectivesAndDeclarations { | |
2611 List<ASTNode> childList = new List<ASTNode>(); | |
2612 childList.addAll(_directives); | |
2613 childList.addAll(_declarations); | |
2614 List<ASTNode> children = new List.from(childList); | |
2615 children.sort(); | |
2616 return children; | |
2617 } | |
2618 } | |
2619 /** | |
2620 * Instances of the class {@code CompilationUnitMember} defines the behavior com
mon to nodes that | |
2621 * declare a name within the scope of a compilation unit. | |
2622 * <pre> | |
2623 * compilationUnitMember ::={@link ClassDeclaration classDeclaration}| {@link Ty
peAlias typeAlias}| {@link FunctionDeclaration functionDeclaration}| {@link Meth
odDeclaration getOrSetDeclaration}| {@link VariableDeclaration constantsDeclarat
ion}| {@link VariableDeclaration variablesDeclaration}</pre> | |
2624 * @coverage dart.engine.ast | |
2625 */ | |
2626 abstract class CompilationUnitMember extends Declaration { | |
2627 /** | |
2628 * Initialize a newly created generic compilation unit member. | |
2629 * @param comment the documentation comment associated with this member | |
2630 * @param metadata the annotations associated with this member | |
2631 */ | |
2632 CompilationUnitMember.full(Comment comment, List<Annotation> metadata) : super
.full(comment, metadata) { | |
2633 } | |
2634 /** | |
2635 * Initialize a newly created generic compilation unit member. | |
2636 * @param comment the documentation comment associated with this member | |
2637 * @param metadata the annotations associated with this member | |
2638 */ | |
2639 CompilationUnitMember({Comment comment, List<Annotation> metadata}) : this.ful
l(comment, metadata); | |
2640 } | |
2641 /** | |
2642 * Instances of the class {@code ConditionalExpression} represent a conditional
expression. | |
2643 * <pre> | |
2644 * conditionalExpression ::={@link Expression condition} '?' {@link Expression t
henExpression} ':' {@link Expression elseExpression}</pre> | |
2645 * @coverage dart.engine.ast | |
2646 */ | |
2647 class ConditionalExpression extends Expression { | |
2648 /** | |
2649 * The condition used to determine which of the expressions is executed next. | |
2650 */ | |
2651 Expression _condition; | |
2652 /** | |
2653 * The token used to separate the condition from the then expression. | |
2654 */ | |
2655 Token _question; | |
2656 /** | |
2657 * The expression that is executed if the condition evaluates to {@code true}. | |
2658 */ | |
2659 Expression _thenExpression; | |
2660 /** | |
2661 * The token used to separate the then expression from the else expression. | |
2662 */ | |
2663 Token _colon; | |
2664 /** | |
2665 * The expression that is executed if the condition evaluates to {@code false}
. | |
2666 */ | |
2667 Expression _elseExpression; | |
2668 /** | |
2669 * Initialize a newly created conditional expression. | |
2670 * @param condition the condition used to determine which expression is execut
ed next | |
2671 * @param question the token used to separate the condition from the then expr
ession | |
2672 * @param thenExpression the expression that is executed if the condition eval
uates to{@code true} | |
2673 * @param colon the token used to separate the then expression from the else e
xpression | |
2674 * @param elseExpression the expression that is executed if the condition eval
uates to{@code false} | |
2675 */ | |
2676 ConditionalExpression.full(Expression condition, Token question, Expression th
enExpression, Token colon, Expression elseExpression) { | |
2677 this._condition = becomeParentOf(condition); | |
2678 this._question = question; | |
2679 this._thenExpression = becomeParentOf(thenExpression); | |
2680 this._colon = colon; | |
2681 this._elseExpression = becomeParentOf(elseExpression); | |
2682 } | |
2683 /** | |
2684 * Initialize a newly created conditional expression. | |
2685 * @param condition the condition used to determine which expression is execut
ed next | |
2686 * @param question the token used to separate the condition from the then expr
ession | |
2687 * @param thenExpression the expression that is executed if the condition eval
uates to{@code true} | |
2688 * @param colon the token used to separate the then expression from the else e
xpression | |
2689 * @param elseExpression the expression that is executed if the condition eval
uates to{@code false} | |
2690 */ | |
2691 ConditionalExpression({Expression condition, Token question, Expression thenEx
pression, Token colon, Expression elseExpression}) : this.full(condition, questi
on, thenExpression, colon, elseExpression); | |
2692 accept(ASTVisitor visitor) => visitor.visitConditionalExpression(this); | |
2693 Token get beginToken => _condition.beginToken; | |
2694 /** | |
2695 * Return the token used to separate the then expression from the else express
ion. | |
2696 * @return the token used to separate the then expression from the else expres
sion | |
2697 */ | |
2698 Token get colon => _colon; | |
2699 /** | |
2700 * Return the condition used to determine which of the expressions is executed
next. | |
2701 * @return the condition used to determine which expression is executed next | |
2702 */ | |
2703 Expression get condition => _condition; | |
2704 /** | |
2705 * Return the expression that is executed if the condition evaluates to {@code
false}. | |
2706 * @return the expression that is executed if the condition evaluates to {@cod
e false} | |
2707 */ | |
2708 Expression get elseExpression => _elseExpression; | |
2709 Token get endToken => _elseExpression.endToken; | |
2710 /** | |
2711 * Return the token used to separate the condition from the then expression. | |
2712 * @return the token used to separate the condition from the then expression | |
2713 */ | |
2714 Token get question => _question; | |
2715 /** | |
2716 * Return the expression that is executed if the condition evaluates to {@code
true}. | |
2717 * @return the expression that is executed if the condition evaluates to {@cod
e true} | |
2718 */ | |
2719 Expression get thenExpression => _thenExpression; | |
2720 /** | |
2721 * Set the token used to separate the then expression from the else expression
to the given token. | |
2722 * @param colon the token used to separate the then expression from the else e
xpression | |
2723 */ | |
2724 void set colon(Token colon2) { | |
2725 this._colon = colon2; | |
2726 } | |
2727 /** | |
2728 * Set the condition used to determine which of the expressions is executed ne
xt to the given | |
2729 * expression. | |
2730 * @param expression the condition used to determine which expression is execu
ted next | |
2731 */ | |
2732 void set condition(Expression expression) { | |
2733 _condition = becomeParentOf(expression); | |
2734 } | |
2735 /** | |
2736 * Set the expression that is executed if the condition evaluates to {@code fa
lse} to the given | |
2737 * expression. | |
2738 * @param expression the expression that is executed if the condition evaluate
s to {@code false} | |
2739 */ | |
2740 void set elseExpression(Expression expression) { | |
2741 _elseExpression = becomeParentOf(expression); | |
2742 } | |
2743 /** | |
2744 * Set the token used to separate the condition from the then expression to th
e given token. | |
2745 * @param question the token used to separate the condition from the then expr
ession | |
2746 */ | |
2747 void set question(Token question3) { | |
2748 this._question = question3; | |
2749 } | |
2750 /** | |
2751 * Set the expression that is executed if the condition evaluates to {@code tr
ue} to the given | |
2752 * expression. | |
2753 * @param expression the expression that is executed if the condition evaluate
s to {@code true} | |
2754 */ | |
2755 void set thenExpression(Expression expression) { | |
2756 _thenExpression = becomeParentOf(expression); | |
2757 } | |
2758 void visitChildren(ASTVisitor<Object> visitor) { | |
2759 safelyVisitChild(_condition, visitor); | |
2760 safelyVisitChild(_thenExpression, visitor); | |
2761 safelyVisitChild(_elseExpression, visitor); | |
2762 } | |
2763 } | |
2764 /** | |
2765 * Instances of the class {@code ConstructorDeclaration} represent a constructor
declaration. | |
2766 * <pre> | |
2767 * constructorDeclaration ::= | |
2768 * constructorSignature {@link FunctionBody body}? | |
2769 * | constructorName formalParameterList ':' 'this' ('.' {@link SimpleIdentifier
name})? arguments | |
2770 * constructorSignature ::= | |
2771 * 'external'? constructorName formalParameterList initializerList? | |
2772 * | 'external'? 'factory' factoryName formalParameterList initializerList? | |
2773 * | 'external'? 'const' constructorName formalParameterList initializerList? | |
2774 * constructorName ::={@link SimpleIdentifier returnType} ('.' {@link SimpleIden
tifier name})? | |
2775 * factoryName ::={@link Identifier returnType} ('.' {@link SimpleIdentifier nam
e})? | |
2776 * initializerList ::= | |
2777 * ':' {@link ConstructorInitializer initializer} (',' {@link ConstructorInitial
izer initializer}) | |
2778 * </pre> | |
2779 * @coverage dart.engine.ast | |
2780 */ | |
2781 class ConstructorDeclaration extends ClassMember { | |
2782 /** | |
2783 * The token for the 'external' keyword, or {@code null} if the constructor is
not external. | |
2784 */ | |
2785 Token _externalKeyword; | |
2786 /** | |
2787 * The token for the 'const' keyword, or {@code null} if the constructor is no
t a const | |
2788 * constructor. | |
2789 */ | |
2790 Token _constKeyword; | |
2791 /** | |
2792 * The token for the 'factory' keyword, or {@code null} if the constructor is
not a factory | |
2793 * constructor. | |
2794 */ | |
2795 Token _factoryKeyword; | |
2796 /** | |
2797 * The type of object being created. This can be different than the type in wh
ich the constructor | |
2798 * is being declared if the constructor is the implementation of a factory con
structor. | |
2799 */ | |
2800 Identifier _returnType; | |
2801 /** | |
2802 * The token for the period before the constructor name, or {@code null} if th
e constructor being | |
2803 * declared is unnamed. | |
2804 */ | |
2805 Token _period; | |
2806 /** | |
2807 * The name of the constructor, or {@code null} if the constructor being decla
red is unnamed. | |
2808 */ | |
2809 SimpleIdentifier _name; | |
2810 /** | |
2811 * The element associated with this constructor, or {@code null} if the AST st
ructure has not been | |
2812 * resolved or if this constructor could not be resolved. | |
2813 */ | |
2814 ConstructorElement _element; | |
2815 /** | |
2816 * The parameters associated with the constructor. | |
2817 */ | |
2818 FormalParameterList _parameters; | |
2819 /** | |
2820 * The token for the separator (colon or equals) before the initializers, or {
@code null} if there | |
2821 * are no initializers. | |
2822 */ | |
2823 Token _separator; | |
2824 /** | |
2825 * The initializers associated with the constructor. | |
2826 */ | |
2827 NodeList<ConstructorInitializer> _initializers; | |
2828 /** | |
2829 * The name of the constructor to which this constructor will be redirected, o
r {@code null} if | |
2830 * this is not a redirecting factory constructor. | |
2831 */ | |
2832 ConstructorName _redirectedConstructor; | |
2833 /** | |
2834 * The body of the constructor, or {@code null} if the constructor does not ha
ve a body. | |
2835 */ | |
2836 FunctionBody _body; | |
2837 /** | |
2838 * Initialize a newly created constructor declaration. | |
2839 * @param externalKeyword the token for the 'external' keyword | |
2840 * @param comment the documentation comment associated with this constructor | |
2841 * @param metadata the annotations associated with this constructor | |
2842 * @param constKeyword the token for the 'const' keyword | |
2843 * @param factoryKeyword the token for the 'factory' keyword | |
2844 * @param returnType the return type of the constructor | |
2845 * @param period the token for the period before the constructor name | |
2846 * @param name the name of the constructor | |
2847 * @param parameters the parameters associated with the constructor | |
2848 * @param separator the token for the colon or equals before the initializers | |
2849 * @param initializers the initializers associated with the constructor | |
2850 * @param redirectedConstructor the name of the constructor to which this cons
tructor will be | |
2851 * redirected | |
2852 * @param body the body of the constructor | |
2853 */ | |
2854 ConstructorDeclaration.full(Comment comment, List<Annotation> metadata, Token
externalKeyword, Token constKeyword, Token factoryKeyword, Identifier returnType
, Token period, SimpleIdentifier name, FormalParameterList parameters, Token sep
arator, List<ConstructorInitializer> initializers, ConstructorName redirectedCon
structor, FunctionBody body) : super.full(comment, metadata) { | |
2855 this._initializers = new NodeList<ConstructorInitializer>(this); | |
2856 this._externalKeyword = externalKeyword; | |
2857 this._constKeyword = constKeyword; | |
2858 this._factoryKeyword = factoryKeyword; | |
2859 this._returnType = becomeParentOf(returnType); | |
2860 this._period = period; | |
2861 this._name = becomeParentOf(name); | |
2862 this._parameters = becomeParentOf(parameters); | |
2863 this._separator = separator; | |
2864 this._initializers.addAll(initializers); | |
2865 this._redirectedConstructor = becomeParentOf(redirectedConstructor); | |
2866 this._body = becomeParentOf(body); | |
2867 } | |
2868 /** | |
2869 * Initialize a newly created constructor declaration. | |
2870 * @param externalKeyword the token for the 'external' keyword | |
2871 * @param comment the documentation comment associated with this constructor | |
2872 * @param metadata the annotations associated with this constructor | |
2873 * @param constKeyword the token for the 'const' keyword | |
2874 * @param factoryKeyword the token for the 'factory' keyword | |
2875 * @param returnType the return type of the constructor | |
2876 * @param period the token for the period before the constructor name | |
2877 * @param name the name of the constructor | |
2878 * @param parameters the parameters associated with the constructor | |
2879 * @param separator the token for the colon or equals before the initializers | |
2880 * @param initializers the initializers associated with the constructor | |
2881 * @param redirectedConstructor the name of the constructor to which this cons
tructor will be | |
2882 * redirected | |
2883 * @param body the body of the constructor | |
2884 */ | |
2885 ConstructorDeclaration({Comment comment, List<Annotation> metadata, Token exte
rnalKeyword, Token constKeyword, Token factoryKeyword, Identifier returnType, To
ken period, SimpleIdentifier name, FormalParameterList parameters, Token separat
or, List<ConstructorInitializer> initializers, ConstructorName redirectedConstru
ctor, FunctionBody body}) : this.full(comment, metadata, externalKeyword, constK
eyword, factoryKeyword, returnType, period, name, parameters, separator, initial
izers, redirectedConstructor, body); | |
2886 accept(ASTVisitor visitor) => visitor.visitConstructorDeclaration(this); | |
2887 /** | |
2888 * Return the body of the constructor, or {@code null} if the constructor does
not have a body. | |
2889 * @return the body of the constructor | |
2890 */ | |
2891 FunctionBody get body => _body; | |
2892 /** | |
2893 * Return the token for the 'const' keyword. | |
2894 * @return the token for the 'const' keyword | |
2895 */ | |
2896 Token get constKeyword => _constKeyword; | |
2897 ConstructorElement get element => _element; | |
2898 Token get endToken { | |
2899 if (_body != null) { | |
2900 return _body.endToken; | |
2901 } else if (!_initializers.isEmpty) { | |
2902 return _initializers.endToken; | |
2903 } | |
2904 return _parameters.endToken; | |
2905 } | |
2906 /** | |
2907 * Return the token for the 'external' keyword, or {@code null} if the constru
ctor is not | |
2908 * external. | |
2909 * @return the token for the 'external' keyword | |
2910 */ | |
2911 Token get externalKeyword => _externalKeyword; | |
2912 /** | |
2913 * Return the token for the 'factory' keyword. | |
2914 * @return the token for the 'factory' keyword | |
2915 */ | |
2916 Token get factoryKeyword => _factoryKeyword; | |
2917 /** | |
2918 * Return the initializers associated with the constructor. | |
2919 * @return the initializers associated with the constructor | |
2920 */ | |
2921 NodeList<ConstructorInitializer> get initializers => _initializers; | |
2922 /** | |
2923 * Return the name of the constructor, or {@code null} if the constructor bein
g declared is | |
2924 * unnamed. | |
2925 * @return the name of the constructor | |
2926 */ | |
2927 SimpleIdentifier get name => _name; | |
2928 /** | |
2929 * Return the parameters associated with the constructor. | |
2930 * @return the parameters associated with the constructor | |
2931 */ | |
2932 FormalParameterList get parameters => _parameters; | |
2933 /** | |
2934 * Return the token for the period before the constructor name, or {@code null
} if the constructor | |
2935 * being declared is unnamed. | |
2936 * @return the token for the period before the constructor name | |
2937 */ | |
2938 Token get period => _period; | |
2939 /** | |
2940 * Return the name of the constructor to which this constructor will be redire
cted, or{@code null} if this is not a redirecting factory constructor. | |
2941 * @return the name of the constructor to which this constructor will be redir
ected | |
2942 */ | |
2943 ConstructorName get redirectedConstructor => _redirectedConstructor; | |
2944 /** | |
2945 * Return the type of object being created. This can be different than the typ
e in which the | |
2946 * constructor is being declared if the constructor is the implementation of a
factory | |
2947 * constructor. | |
2948 * @return the type of object being created | |
2949 */ | |
2950 Identifier get returnType => _returnType; | |
2951 /** | |
2952 * Return the token for the separator (colon or equals) before the initializer
s, or {@code null}if there are no initializers. | |
2953 * @return the token for the separator (colon or equals) before the initialize
rs | |
2954 */ | |
2955 Token get separator => _separator; | |
2956 /** | |
2957 * Set the body of the constructor to the given function body. | |
2958 * @param functionBody the body of the constructor | |
2959 */ | |
2960 void set body(FunctionBody functionBody) { | |
2961 _body = becomeParentOf(functionBody); | |
2962 } | |
2963 /** | |
2964 * Set the token for the 'const' keyword to the given token. | |
2965 * @param constKeyword the token for the 'const' keyword | |
2966 */ | |
2967 void set constKeyword(Token constKeyword2) { | |
2968 this._constKeyword = constKeyword2; | |
2969 } | |
2970 /** | |
2971 * Set the element associated with this constructor to the given element. | |
2972 * @param element the element associated with this constructor | |
2973 */ | |
2974 void set element(ConstructorElement element6) { | |
2975 this._element = element6; | |
2976 } | |
2977 /** | |
2978 * Set the token for the 'external' keyword to the given token. | |
2979 * @param externalKeyword the token for the 'external' keyword | |
2980 */ | |
2981 void set externalKeyword(Token externalKeyword2) { | |
2982 this._externalKeyword = externalKeyword2; | |
2983 } | |
2984 /** | |
2985 * Set the token for the 'factory' keyword to the given token. | |
2986 * @param factoryKeyword the token for the 'factory' keyword | |
2987 */ | |
2988 void set factoryKeyword(Token factoryKeyword2) { | |
2989 this._factoryKeyword = factoryKeyword2; | |
2990 } | |
2991 /** | |
2992 * Set the name of the constructor to the given identifier. | |
2993 * @param identifier the name of the constructor | |
2994 */ | |
2995 void set name(SimpleIdentifier identifier) { | |
2996 _name = becomeParentOf(identifier); | |
2997 } | |
2998 /** | |
2999 * Set the parameters associated with the constructor to the given list of par
ameters. | |
3000 * @param parameters the parameters associated with the constructor | |
3001 */ | |
3002 void set parameters(FormalParameterList parameters2) { | |
3003 this._parameters = becomeParentOf(parameters2); | |
3004 } | |
3005 /** | |
3006 * Set the token for the period before the constructor name to the given token
. | |
3007 * @param period the token for the period before the constructor name | |
3008 */ | |
3009 void set period(Token period3) { | |
3010 this._period = period3; | |
3011 } | |
3012 /** | |
3013 * Set the name of the constructor to which this constructor will be redirecte
d to the given | |
3014 * constructor name. | |
3015 * @param redirectedConstructor the name of the constructor to which this cons
tructor will be | |
3016 * redirected | |
3017 */ | |
3018 void set redirectedConstructor(ConstructorName redirectedConstructor2) { | |
3019 this._redirectedConstructor = becomeParentOf(redirectedConstructor2); | |
3020 } | |
3021 /** | |
3022 * Set the type of object being created to the given type name. | |
3023 * @param typeName the type of object being created | |
3024 */ | |
3025 void set returnType(Identifier typeName) { | |
3026 _returnType = becomeParentOf(typeName); | |
3027 } | |
3028 /** | |
3029 * Set the token for the separator (colon or equals) before the initializers t
o the given token. | |
3030 * @param separator the token for the separator (colon or equals) before the i
nitializers | |
3031 */ | |
3032 void set separator(Token separator2) { | |
3033 this._separator = separator2; | |
3034 } | |
3035 void visitChildren(ASTVisitor<Object> visitor) { | |
3036 super.visitChildren(visitor); | |
3037 safelyVisitChild(_returnType, visitor); | |
3038 safelyVisitChild(_name, visitor); | |
3039 safelyVisitChild(_parameters, visitor); | |
3040 _initializers.accept(visitor); | |
3041 safelyVisitChild(_redirectedConstructor, visitor); | |
3042 safelyVisitChild(_body, visitor); | |
3043 } | |
3044 Token get firstTokenAfterCommentAndMetadata { | |
3045 Token leftMost2 = leftMost([_externalKeyword, _constKeyword, _factoryKeyword
]); | |
3046 if (leftMost2 != null) { | |
3047 return leftMost2; | |
3048 } | |
3049 return _returnType.beginToken; | |
3050 } | |
3051 /** | |
3052 * Return the left-most of the given tokens, or {@code null} if there are no t
okens given or if | |
3053 * all of the given tokens are {@code null}. | |
3054 * @param tokens the tokens being compared to find the left-most token | |
3055 * @return the left-most of the given tokens | |
3056 */ | |
3057 Token leftMost(List<Token> tokens) { | |
3058 Token leftMost = null; | |
3059 int offset = 2147483647; | |
3060 for (Token token in tokens) { | |
3061 if (token != null && token.offset < offset) { | |
3062 leftMost = token; | |
3063 } | |
3064 } | |
3065 return leftMost; | |
3066 } | |
3067 } | |
3068 /** | |
3069 * Instances of the class {@code ConstructorFieldInitializer} represent the init
ialization of a | |
3070 * field within a constructor's initialization list. | |
3071 * <pre> | |
3072 * fieldInitializer ::= | |
3073 * ('this' '.')? {@link SimpleIdentifier fieldName} '=' {@link Expression condit
ionalExpression cascadeSection*}</pre> | |
3074 * @coverage dart.engine.ast | |
3075 */ | |
3076 class ConstructorFieldInitializer extends ConstructorInitializer { | |
3077 /** | |
3078 * The token for the 'this' keyword, or {@code null} if there is no 'this' key
word. | |
3079 */ | |
3080 Token _keyword; | |
3081 /** | |
3082 * The token for the period after the 'this' keyword, or {@code null} if there
is no 'this' | |
3083 * keyword. | |
3084 */ | |
3085 Token _period; | |
3086 /** | |
3087 * The name of the field being initialized. | |
3088 */ | |
3089 SimpleIdentifier _fieldName; | |
3090 /** | |
3091 * The token for the equal sign between the field name and the expression. | |
3092 */ | |
3093 Token _equals; | |
3094 /** | |
3095 * The expression computing the value to which the field will be initialized. | |
3096 */ | |
3097 Expression _expression; | |
3098 /** | |
3099 * Initialize a newly created field initializer to initialize the field with t
he given name to the | |
3100 * value of the given expression. | |
3101 * @param keyword the token for the 'this' keyword | |
3102 * @param period the token for the period after the 'this' keyword | |
3103 * @param fieldName the name of the field being initialized | |
3104 * @param equals the token for the equal sign between the field name and the e
xpression | |
3105 * @param expression the expression computing the value to which the field wil
l be initialized | |
3106 */ | |
3107 ConstructorFieldInitializer.full(Token keyword, Token period, SimpleIdentifier
fieldName, Token equals, Expression expression) { | |
3108 this._keyword = keyword; | |
3109 this._period = period; | |
3110 this._fieldName = becomeParentOf(fieldName); | |
3111 this._equals = equals; | |
3112 this._expression = becomeParentOf(expression); | |
3113 } | |
3114 /** | |
3115 * Initialize a newly created field initializer to initialize the field with t
he given name to the | |
3116 * value of the given expression. | |
3117 * @param keyword the token for the 'this' keyword | |
3118 * @param period the token for the period after the 'this' keyword | |
3119 * @param fieldName the name of the field being initialized | |
3120 * @param equals the token for the equal sign between the field name and the e
xpression | |
3121 * @param expression the expression computing the value to which the field wil
l be initialized | |
3122 */ | |
3123 ConstructorFieldInitializer({Token keyword, Token period, SimpleIdentifier fie
ldName, Token equals, Expression expression}) : this.full(keyword, period, field
Name, equals, expression); | |
3124 accept(ASTVisitor visitor) => visitor.visitConstructorFieldInitializer(this); | |
3125 Token get beginToken { | |
3126 if (_keyword != null) { | |
3127 return _keyword; | |
3128 } | |
3129 return _fieldName.beginToken; | |
3130 } | |
3131 Token get endToken => _expression.endToken; | |
3132 /** | |
3133 * Return the token for the equal sign between the field name and the expressi
on. | |
3134 * @return the token for the equal sign between the field name and the express
ion | |
3135 */ | |
3136 Token get equals => _equals; | |
3137 /** | |
3138 * Return the expression computing the value to which the field will be initia
lized. | |
3139 * @return the expression computing the value to which the field will be initi
alized | |
3140 */ | |
3141 Expression get expression => _expression; | |
3142 /** | |
3143 * Return the name of the field being initialized. | |
3144 * @return the name of the field being initialized | |
3145 */ | |
3146 SimpleIdentifier get fieldName => _fieldName; | |
3147 /** | |
3148 * Return the token for the 'this' keyword, or {@code null} if there is no 'th
is' keyword. | |
3149 * @return the token for the 'this' keyword | |
3150 */ | |
3151 Token get keyword => _keyword; | |
3152 /** | |
3153 * Return the token for the period after the 'this' keyword, or {@code null} i
f there is no 'this' | |
3154 * keyword. | |
3155 * @return the token for the period after the 'this' keyword | |
3156 */ | |
3157 Token get period => _period; | |
3158 /** | |
3159 * Set the token for the equal sign between the field name and the expression
to the given token. | |
3160 * @param equals the token for the equal sign between the field name and the e
xpression | |
3161 */ | |
3162 void set equals(Token equals5) { | |
3163 this._equals = equals5; | |
3164 } | |
3165 /** | |
3166 * Set the expression computing the value to which the field will be initializ
ed to the given | |
3167 * expression. | |
3168 * @param expression the expression computing the value to which the field wil
l be initialized | |
3169 */ | |
3170 void set expression(Expression expression3) { | |
3171 this._expression = becomeParentOf(expression3); | |
3172 } | |
3173 /** | |
3174 * Set the name of the field being initialized to the given identifier. | |
3175 * @param identifier the name of the field being initialized | |
3176 */ | |
3177 void set fieldName(SimpleIdentifier identifier) { | |
3178 _fieldName = becomeParentOf(identifier); | |
3179 } | |
3180 /** | |
3181 * Set the token for the 'this' keyword to the given token. | |
3182 * @param keyword the token for the 'this' keyword | |
3183 */ | |
3184 void set keyword(Token keyword6) { | |
3185 this._keyword = keyword6; | |
3186 } | |
3187 /** | |
3188 * Set the token for the period after the 'this' keyword to the given token. | |
3189 * @param period the token for the period after the 'this' keyword | |
3190 */ | |
3191 void set period(Token period4) { | |
3192 this._period = period4; | |
3193 } | |
3194 void visitChildren(ASTVisitor<Object> visitor) { | |
3195 safelyVisitChild(_fieldName, visitor); | |
3196 safelyVisitChild(_expression, visitor); | |
3197 } | |
3198 } | |
3199 /** | |
3200 * Instances of the class {@code ConstructorInitializer} defines the behavior of
nodes that can | |
3201 * occur in the initializer list of a constructor declaration. | |
3202 * <pre> | |
3203 * constructorInitializer ::={@link SuperConstructorInvocation superInvocation}|
{@link ConstructorFieldInitializer fieldInitializer}</pre> | |
3204 * @coverage dart.engine.ast | |
3205 */ | |
3206 abstract class ConstructorInitializer extends ASTNode { | |
3207 } | |
3208 /** | |
3209 * Instances of the class {@code ConstructorName} represent the name of the cons
tructor. | |
3210 * <pre> | |
3211 * constructorName: | |
3212 * type ('.' identifier)? | |
3213 * </pre> | |
3214 * @coverage dart.engine.ast | |
3215 */ | |
3216 class ConstructorName extends ASTNode { | |
3217 /** | |
3218 * The name of the type defining the constructor. | |
3219 */ | |
3220 TypeName _type; | |
3221 /** | |
3222 * The token for the period before the constructor name, or {@code null} if th
e specified | |
3223 * constructor is the unnamed constructor. | |
3224 */ | |
3225 Token _period; | |
3226 /** | |
3227 * The name of the constructor, or {@code null} if the specified constructor i
s the unnamed | |
3228 * constructor. | |
3229 */ | |
3230 SimpleIdentifier _name; | |
3231 /** | |
3232 * The element associated with this constructor name, or {@code null} if the A
ST structure has not | |
3233 * been resolved or if this constructor name could not be resolved. | |
3234 */ | |
3235 ConstructorElement _element; | |
3236 /** | |
3237 * Initialize a newly created constructor name. | |
3238 * @param type the name of the type defining the constructor | |
3239 * @param period the token for the period before the constructor name | |
3240 * @param name the name of the constructor | |
3241 */ | |
3242 ConstructorName.full(TypeName type, Token period, SimpleIdentifier name) { | |
3243 this._type = becomeParentOf(type); | |
3244 this._period = period; | |
3245 this._name = becomeParentOf(name); | |
3246 } | |
3247 /** | |
3248 * Initialize a newly created constructor name. | |
3249 * @param type the name of the type defining the constructor | |
3250 * @param period the token for the period before the constructor name | |
3251 * @param name the name of the constructor | |
3252 */ | |
3253 ConstructorName({TypeName type, Token period, SimpleIdentifier name}) : this.f
ull(type, period, name); | |
3254 accept(ASTVisitor visitor) => visitor.visitConstructorName(this); | |
3255 Token get beginToken => _type.beginToken; | |
3256 /** | |
3257 * Return the element associated with this constructor name, or {@code null} i
f the AST structure | |
3258 * has not been resolved or if this constructor name could not be resolved. | |
3259 * @return the element associated with this constructor name | |
3260 */ | |
3261 ConstructorElement get element => _element; | |
3262 Token get endToken { | |
3263 if (_name != null) { | |
3264 return _name.endToken; | |
3265 } | |
3266 return _type.endToken; | |
3267 } | |
3268 /** | |
3269 * Return the name of the constructor, or {@code null} if the specified constr
uctor is the unnamed | |
3270 * constructor. | |
3271 * @return the name of the constructor | |
3272 */ | |
3273 SimpleIdentifier get name => _name; | |
3274 /** | |
3275 * Return the token for the period before the constructor name, or {@code null
} if the specified | |
3276 * constructor is the unnamed constructor. | |
3277 * @return the token for the period before the constructor name | |
3278 */ | |
3279 Token get period => _period; | |
3280 /** | |
3281 * Return the name of the type defining the constructor. | |
3282 * @return the name of the type defining the constructor | |
3283 */ | |
3284 TypeName get type => _type; | |
3285 /** | |
3286 * Set the element associated with this constructor name to the given element. | |
3287 * @param element the element associated with this constructor name | |
3288 */ | |
3289 void set element(ConstructorElement element7) { | |
3290 this._element = element7; | |
3291 } | |
3292 /** | |
3293 * Set the name of the constructor to the given name. | |
3294 * @param name the name of the constructor | |
3295 */ | |
3296 void set name(SimpleIdentifier name4) { | |
3297 this._name = becomeParentOf(name4); | |
3298 } | |
3299 /** | |
3300 * Return the token for the period before the constructor name to the given to
ken. | |
3301 * @param period the token for the period before the constructor name | |
3302 */ | |
3303 void set period(Token period5) { | |
3304 this._period = period5; | |
3305 } | |
3306 /** | |
3307 * Set the name of the type defining the constructor to the given type name. | |
3308 * @param type the name of the type defining the constructor | |
3309 */ | |
3310 void set type(TypeName type2) { | |
3311 this._type = becomeParentOf(type2); | |
3312 } | |
3313 void visitChildren(ASTVisitor<Object> visitor) { | |
3314 safelyVisitChild(_type, visitor); | |
3315 safelyVisitChild(_name, visitor); | |
3316 } | |
3317 } | |
3318 /** | |
3319 * Instances of the class {@code ContinueStatement} represent a continue stateme
nt. | |
3320 * <pre> | |
3321 * continueStatement ::= | |
3322 * 'continue' {@link SimpleIdentifier label}? ';' | |
3323 * </pre> | |
3324 * @coverage dart.engine.ast | |
3325 */ | |
3326 class ContinueStatement extends Statement { | |
3327 /** | |
3328 * The token representing the 'continue' keyword. | |
3329 */ | |
3330 Token _keyword; | |
3331 /** | |
3332 * The label associated with the statement, or {@code null} if there is no lab
el. | |
3333 */ | |
3334 SimpleIdentifier _label; | |
3335 /** | |
3336 * The semicolon terminating the statement. | |
3337 */ | |
3338 Token _semicolon; | |
3339 /** | |
3340 * Initialize a newly created continue statement. | |
3341 * @param keyword the token representing the 'continue' keyword | |
3342 * @param label the label associated with the statement | |
3343 * @param semicolon the semicolon terminating the statement | |
3344 */ | |
3345 ContinueStatement.full(Token keyword, SimpleIdentifier label, Token semicolon)
{ | |
3346 this._keyword = keyword; | |
3347 this._label = becomeParentOf(label); | |
3348 this._semicolon = semicolon; | |
3349 } | |
3350 /** | |
3351 * Initialize a newly created continue statement. | |
3352 * @param keyword the token representing the 'continue' keyword | |
3353 * @param label the label associated with the statement | |
3354 * @param semicolon the semicolon terminating the statement | |
3355 */ | |
3356 ContinueStatement({Token keyword, SimpleIdentifier label, Token semicolon}) :
this.full(keyword, label, semicolon); | |
3357 accept(ASTVisitor visitor) => visitor.visitContinueStatement(this); | |
3358 Token get beginToken => _keyword; | |
3359 Token get endToken => _semicolon; | |
3360 /** | |
3361 * Return the token representing the 'continue' keyword. | |
3362 * @return the token representing the 'continue' keyword | |
3363 */ | |
3364 Token get keyword => _keyword; | |
3365 /** | |
3366 * Return the label associated with the statement, or {@code null} if there is
no label. | |
3367 * @return the label associated with the statement | |
3368 */ | |
3369 SimpleIdentifier get label => _label; | |
3370 /** | |
3371 * Return the semicolon terminating the statement. | |
3372 * @return the semicolon terminating the statement | |
3373 */ | |
3374 Token get semicolon => _semicolon; | |
3375 /** | |
3376 * Set the token representing the 'continue' keyword to the given token. | |
3377 * @param keyword the token representing the 'continue' keyword | |
3378 */ | |
3379 void set keyword(Token keyword7) { | |
3380 this._keyword = keyword7; | |
3381 } | |
3382 /** | |
3383 * Set the label associated with the statement to the given label. | |
3384 * @param identifier the label associated with the statement | |
3385 */ | |
3386 void set label(SimpleIdentifier identifier) { | |
3387 _label = becomeParentOf(identifier); | |
3388 } | |
3389 /** | |
3390 * Set the semicolon terminating the statement to the given token. | |
3391 * @param semicolon the semicolon terminating the statement | |
3392 */ | |
3393 void set semicolon(Token semicolon4) { | |
3394 this._semicolon = semicolon4; | |
3395 } | |
3396 void visitChildren(ASTVisitor<Object> visitor) { | |
3397 safelyVisitChild(_label, visitor); | |
3398 } | |
3399 } | |
3400 /** | |
3401 * The abstract class {@code Declaration} defines the behavior common to nodes t
hat represent the | |
3402 * declaration of a name. Each declared name is visible within a name scope. | |
3403 * @coverage dart.engine.ast | |
3404 */ | |
3405 abstract class Declaration extends AnnotatedNode { | |
3406 /** | |
3407 * Initialize a newly created declaration. | |
3408 * @param comment the documentation comment associated with this declaration | |
3409 * @param metadata the annotations associated with this declaration | |
3410 */ | |
3411 Declaration.full(Comment comment, List<Annotation> metadata) : super.full(comm
ent, metadata) { | |
3412 } | |
3413 /** | |
3414 * Initialize a newly created declaration. | |
3415 * @param comment the documentation comment associated with this declaration | |
3416 * @param metadata the annotations associated with this declaration | |
3417 */ | |
3418 Declaration({Comment comment, List<Annotation> metadata}) : this.full(comment,
metadata); | |
3419 /** | |
3420 * Return the element associated with this declaration, or {@code null} if eit
her this node | |
3421 * corresponds to a list of declarations or if the AST structure has not been
resolved. | |
3422 * @return the element associated with this declaration | |
3423 */ | |
3424 Element get element; | |
3425 } | |
3426 /** | |
3427 * Instances of the class {@code DeclaredIdentifier} represent the declaration o
f a single | |
3428 * identifier. | |
3429 * <pre> | |
3430 * declaredIdentifier ::= | |
3431 * ({@link Annotation metadata} finalConstVarOrType {@link SimpleIdentifier iden
tifier}</pre> | |
3432 * @coverage dart.engine.ast | |
3433 */ | |
3434 class DeclaredIdentifier extends Declaration { | |
3435 /** | |
3436 * The token representing either the 'final', 'const' or 'var' keyword, or {@c
ode null} if no | |
3437 * keyword was used. | |
3438 */ | |
3439 Token _keyword; | |
3440 /** | |
3441 * The name of the declared type of the parameter, or {@code null} if the para
meter does not have | |
3442 * a declared type. | |
3443 */ | |
3444 TypeName _type; | |
3445 /** | |
3446 * The name of the variable being declared. | |
3447 */ | |
3448 SimpleIdentifier _identifier; | |
3449 /** | |
3450 * Initialize a newly created formal parameter. | |
3451 * @param comment the documentation comment associated with this parameter | |
3452 * @param metadata the annotations associated with this parameter | |
3453 * @param keyword the token representing either the 'final', 'const' or 'var'
keyword | |
3454 * @param type the name of the declared type of the parameter | |
3455 * @param identifier the name of the parameter being declared | |
3456 */ | |
3457 DeclaredIdentifier.full(Comment comment, List<Annotation> metadata, Token keyw
ord, TypeName type, SimpleIdentifier identifier) : super.full(comment, metadata)
{ | |
3458 this._keyword = keyword; | |
3459 this._type = becomeParentOf(type); | |
3460 this._identifier = becomeParentOf(identifier); | |
3461 } | |
3462 /** | |
3463 * Initialize a newly created formal parameter. | |
3464 * @param comment the documentation comment associated with this parameter | |
3465 * @param metadata the annotations associated with this parameter | |
3466 * @param keyword the token representing either the 'final', 'const' or 'var'
keyword | |
3467 * @param type the name of the declared type of the parameter | |
3468 * @param identifier the name of the parameter being declared | |
3469 */ | |
3470 DeclaredIdentifier({Comment comment, List<Annotation> metadata, Token keyword,
TypeName type, SimpleIdentifier identifier}) : this.full(comment, metadata, key
word, type, identifier); | |
3471 accept(ASTVisitor visitor) => visitor.visitDeclaredIdentifier(this); | |
3472 LocalVariableElement get element { | |
3473 SimpleIdentifier identifier11 = identifier; | |
3474 if (identifier11 == null) { | |
3475 return null; | |
3476 } | |
3477 return identifier11.element as LocalVariableElement; | |
3478 } | |
3479 Token get endToken => _identifier.endToken; | |
3480 /** | |
3481 * Return the name of the variable being declared. | |
3482 * @return the name of the variable being declared | |
3483 */ | |
3484 SimpleIdentifier get identifier => _identifier; | |
3485 /** | |
3486 * Return the token representing either the 'final', 'const' or 'var' keyword. | |
3487 * @return the token representing either the 'final', 'const' or 'var' keyword | |
3488 */ | |
3489 Token get keyword => _keyword; | |
3490 /** | |
3491 * Return the name of the declared type of the parameter, or {@code null} if t
he parameter does | |
3492 * not have a declared type. | |
3493 * @return the name of the declared type of the parameter | |
3494 */ | |
3495 TypeName get type => _type; | |
3496 /** | |
3497 * Return {@code true} if this variable was declared with the 'const' modifier
. | |
3498 * @return {@code true} if this variable was declared with the 'const' modifie
r | |
3499 */ | |
3500 bool isConst() => (_keyword is KeywordToken) && identical(((_keyword as Keywor
dToken)).keyword, Keyword.CONST); | |
3501 /** | |
3502 * Return {@code true} if this variable was declared with the 'final' modifier
. Variables that are | |
3503 * declared with the 'const' modifier will return {@code false} even though th
ey are implicitly | |
3504 * final. | |
3505 * @return {@code true} if this variable was declared with the 'final' modifie
r | |
3506 */ | |
3507 bool isFinal() => (_keyword is KeywordToken) && identical(((_keyword as Keywor
dToken)).keyword, Keyword.FINAL); | |
3508 /** | |
3509 * Set the token representing either the 'final', 'const' or 'var' keyword to
the given token. | |
3510 * @param keyword the token representing either the 'final', 'const' or 'var'
keyword | |
3511 */ | |
3512 void set keyword(Token keyword8) { | |
3513 this._keyword = keyword8; | |
3514 } | |
3515 /** | |
3516 * Set the name of the declared type of the parameter to the given type name. | |
3517 * @param typeName the name of the declared type of the parameter | |
3518 */ | |
3519 void set type(TypeName typeName) { | |
3520 _type = becomeParentOf(typeName); | |
3521 } | |
3522 void visitChildren(ASTVisitor<Object> visitor) { | |
3523 super.visitChildren(visitor); | |
3524 safelyVisitChild(_type, visitor); | |
3525 safelyVisitChild(_identifier, visitor); | |
3526 } | |
3527 Token get firstTokenAfterCommentAndMetadata { | |
3528 if (_keyword != null) { | |
3529 return _keyword; | |
3530 } else if (_type != null) { | |
3531 return _type.beginToken; | |
3532 } | |
3533 return _identifier.beginToken; | |
3534 } | |
3535 } | |
3536 /** | |
3537 * Instances of the class {@code DefaultFormalParameter} represent a formal para
meter with a default | |
3538 * value. There are two kinds of parameters that are both represented by this cl
ass: named formal | |
3539 * parameters and positional formal parameters. | |
3540 * <pre> | |
3541 * defaultFormalParameter ::={@link NormalFormalParameter normalFormalParameter}
('=' {@link Expression defaultValue})? | |
3542 * defaultNamedParameter ::={@link NormalFormalParameter normalFormalParameter}
(':' {@link Expression defaultValue})? | |
3543 * </pre> | |
3544 * @coverage dart.engine.ast | |
3545 */ | |
3546 class DefaultFormalParameter extends FormalParameter { | |
3547 /** | |
3548 * The formal parameter with which the default value is associated. | |
3549 */ | |
3550 NormalFormalParameter _parameter; | |
3551 /** | |
3552 * The kind of this parameter. | |
3553 */ | |
3554 ParameterKind _kind; | |
3555 /** | |
3556 * The token separating the parameter from the default value, or {@code null}
if there is no | |
3557 * default value. | |
3558 */ | |
3559 Token _separator; | |
3560 /** | |
3561 * The expression computing the default value for the parameter, or {@code nul
l} if there is no | |
3562 * default value. | |
3563 */ | |
3564 Expression _defaultValue; | |
3565 /** | |
3566 * Initialize a newly created default formal parameter. | |
3567 * @param parameter the formal parameter with which the default value is assoc
iated | |
3568 * @param kind the kind of this parameter | |
3569 * @param separator the token separating the parameter from the default value | |
3570 * @param defaultValue the expression computing the default value for the para
meter | |
3571 */ | |
3572 DefaultFormalParameter.full(NormalFormalParameter parameter, ParameterKind kin
d, Token separator, Expression defaultValue) { | |
3573 this._parameter = becomeParentOf(parameter); | |
3574 this._kind = kind; | |
3575 this._separator = separator; | |
3576 this._defaultValue = becomeParentOf(defaultValue); | |
3577 } | |
3578 /** | |
3579 * Initialize a newly created default formal parameter. | |
3580 * @param parameter the formal parameter with which the default value is assoc
iated | |
3581 * @param kind the kind of this parameter | |
3582 * @param separator the token separating the parameter from the default value | |
3583 * @param defaultValue the expression computing the default value for the para
meter | |
3584 */ | |
3585 DefaultFormalParameter({NormalFormalParameter parameter, ParameterKind kind, T
oken separator, Expression defaultValue}) : this.full(parameter, kind, separator
, defaultValue); | |
3586 accept(ASTVisitor visitor) => visitor.visitDefaultFormalParameter(this); | |
3587 Token get beginToken => _parameter.beginToken; | |
3588 /** | |
3589 * Return the expression computing the default value for the parameter, or {@c
ode null} if there | |
3590 * is no default value. | |
3591 * @return the expression computing the default value for the parameter | |
3592 */ | |
3593 Expression get defaultValue => _defaultValue; | |
3594 Token get endToken { | |
3595 if (_defaultValue != null) { | |
3596 return _defaultValue.endToken; | |
3597 } | |
3598 return _parameter.endToken; | |
3599 } | |
3600 SimpleIdentifier get identifier => _parameter.identifier; | |
3601 ParameterKind get kind => _kind; | |
3602 /** | |
3603 * Return the formal parameter with which the default value is associated. | |
3604 * @return the formal parameter with which the default value is associated | |
3605 */ | |
3606 NormalFormalParameter get parameter => _parameter; | |
3607 /** | |
3608 * Return the token separating the parameter from the default value, or {@code
null} if there is | |
3609 * no default value. | |
3610 * @return the token separating the parameter from the default value | |
3611 */ | |
3612 Token get separator => _separator; | |
3613 /** | |
3614 * Return {@code true} if this parameter was declared with the 'const' modifie
r. | |
3615 * @return {@code true} if this parameter was declared with the 'const' modifi
er | |
3616 */ | |
3617 bool isConst() => _parameter != null && _parameter.isConst(); | |
3618 /** | |
3619 * Return {@code true} if this parameter was declared with the 'final' modifie
r. Parameters that | |
3620 * are declared with the 'const' modifier will return {@code false} even thoug
h they are | |
3621 * implicitly final. | |
3622 * @return {@code true} if this parameter was declared with the 'final' modifi
er | |
3623 */ | |
3624 bool isFinal() => _parameter != null && _parameter.isFinal(); | |
3625 /** | |
3626 * Set the expression computing the default value for the parameter to the giv
en expression. | |
3627 * @param expression the expression computing the default value for the parame
ter | |
3628 */ | |
3629 void set defaultValue(Expression expression) { | |
3630 _defaultValue = becomeParentOf(expression); | |
3631 } | |
3632 /** | |
3633 * Set the kind of this parameter to the given kind. | |
3634 * @param kind the kind of this parameter | |
3635 */ | |
3636 void set kind(ParameterKind kind2) { | |
3637 this._kind = kind2; | |
3638 } | |
3639 /** | |
3640 * Set the formal parameter with which the default value is associated to the
given parameter. | |
3641 * @param formalParameter the formal parameter with which the default value is
associated | |
3642 */ | |
3643 void set parameter(NormalFormalParameter formalParameter) { | |
3644 _parameter = becomeParentOf(formalParameter); | |
3645 } | |
3646 /** | |
3647 * Set the token separating the parameter from the default value to the given
token. | |
3648 * @param separator the token separating the parameter from the default value | |
3649 */ | |
3650 void set separator(Token separator3) { | |
3651 this._separator = separator3; | |
3652 } | |
3653 void visitChildren(ASTVisitor<Object> visitor) { | |
3654 safelyVisitChild(_parameter, visitor); | |
3655 safelyVisitChild(_defaultValue, visitor); | |
3656 } | |
3657 } | |
3658 /** | |
3659 * The abstract class {@code Directive} defines the behavior common to nodes tha
t represent a | |
3660 * directive. | |
3661 * <pre> | |
3662 * directive ::={@link ExportDirective exportDirective}| {@link ImportDirective
importDirective}| {@link LibraryDirective libraryDirective}| {@link PartDirectiv
e partDirective}| {@link PartOfDirective partOfDirective}</pre> | |
3663 * @coverage dart.engine.ast | |
3664 */ | |
3665 abstract class Directive extends AnnotatedNode { | |
3666 /** | |
3667 * The element associated with this directive, or {@code null} if the AST stru
cture has not been | |
3668 * resolved or if this directive could not be resolved. | |
3669 */ | |
3670 Element _element; | |
3671 /** | |
3672 * Initialize a newly create directive. | |
3673 * @param comment the documentation comment associated with this directive | |
3674 * @param metadata the annotations associated with the directive | |
3675 */ | |
3676 Directive.full(Comment comment, List<Annotation> metadata) : super.full(commen
t, metadata) { | |
3677 } | |
3678 /** | |
3679 * Initialize a newly create directive. | |
3680 * @param comment the documentation comment associated with this directive | |
3681 * @param metadata the annotations associated with the directive | |
3682 */ | |
3683 Directive({Comment comment, List<Annotation> metadata}) : this.full(comment, m
etadata); | |
3684 /** | |
3685 * Return the element associated with this directive, or {@code null} if the A
ST structure has not | |
3686 * been resolved or if this directive could not be resolved. Examples of the l
atter case include a | |
3687 * directive that contains an invalid URL or a URL that does not exist. | |
3688 * @return the element associated with this directive | |
3689 */ | |
3690 Element get element => _element; | |
3691 /** | |
3692 * Return the token representing the keyword that introduces this directive ('
import', 'export', | |
3693 * 'library' or 'part'). | |
3694 * @return the token representing the keyword that introduces this directive | |
3695 */ | |
3696 Token get keyword; | |
3697 /** | |
3698 * Set the element associated with this directive to the given element. | |
3699 * @param element the element associated with this directive | |
3700 */ | |
3701 void set element(Element element8) { | |
3702 this._element = element8; | |
3703 } | |
3704 } | |
3705 /** | |
3706 * Instances of the class {@code DoStatement} represent a do statement. | |
3707 * <pre> | |
3708 * doStatement ::= | |
3709 * 'do' {@link Statement body} 'while' '(' {@link Expression condition} ')' ';' | |
3710 * </pre> | |
3711 * @coverage dart.engine.ast | |
3712 */ | |
3713 class DoStatement extends Statement { | |
3714 /** | |
3715 * The token representing the 'do' keyword. | |
3716 */ | |
3717 Token _doKeyword; | |
3718 /** | |
3719 * The body of the loop. | |
3720 */ | |
3721 Statement _body; | |
3722 /** | |
3723 * The token representing the 'while' keyword. | |
3724 */ | |
3725 Token _whileKeyword; | |
3726 /** | |
3727 * The left parenthesis. | |
3728 */ | |
3729 Token _leftParenthesis; | |
3730 /** | |
3731 * The condition that determines when the loop will terminate. | |
3732 */ | |
3733 Expression _condition; | |
3734 /** | |
3735 * The right parenthesis. | |
3736 */ | |
3737 Token _rightParenthesis; | |
3738 /** | |
3739 * The semicolon terminating the statement. | |
3740 */ | |
3741 Token _semicolon; | |
3742 /** | |
3743 * Initialize a newly created do loop. | |
3744 * @param doKeyword the token representing the 'do' keyword | |
3745 * @param body the body of the loop | |
3746 * @param whileKeyword the token representing the 'while' keyword | |
3747 * @param leftParenthesis the left parenthesis | |
3748 * @param condition the condition that determines when the loop will terminate | |
3749 * @param rightParenthesis the right parenthesis | |
3750 * @param semicolon the semicolon terminating the statement | |
3751 */ | |
3752 DoStatement.full(Token doKeyword, Statement body, Token whileKeyword, Token le
ftParenthesis, Expression condition, Token rightParenthesis, Token semicolon) { | |
3753 this._doKeyword = doKeyword; | |
3754 this._body = becomeParentOf(body); | |
3755 this._whileKeyword = whileKeyword; | |
3756 this._leftParenthesis = leftParenthesis; | |
3757 this._condition = becomeParentOf(condition); | |
3758 this._rightParenthesis = rightParenthesis; | |
3759 this._semicolon = semicolon; | |
3760 } | |
3761 /** | |
3762 * Initialize a newly created do loop. | |
3763 * @param doKeyword the token representing the 'do' keyword | |
3764 * @param body the body of the loop | |
3765 * @param whileKeyword the token representing the 'while' keyword | |
3766 * @param leftParenthesis the left parenthesis | |
3767 * @param condition the condition that determines when the loop will terminate | |
3768 * @param rightParenthesis the right parenthesis | |
3769 * @param semicolon the semicolon terminating the statement | |
3770 */ | |
3771 DoStatement({Token doKeyword, Statement body, Token whileKeyword, Token leftPa
renthesis, Expression condition, Token rightParenthesis, Token semicolon}) : thi
s.full(doKeyword, body, whileKeyword, leftParenthesis, condition, rightParenthes
is, semicolon); | |
3772 accept(ASTVisitor visitor) => visitor.visitDoStatement(this); | |
3773 Token get beginToken => _doKeyword; | |
3774 /** | |
3775 * Return the body of the loop. | |
3776 * @return the body of the loop | |
3777 */ | |
3778 Statement get body => _body; | |
3779 /** | |
3780 * Return the condition that determines when the loop will terminate. | |
3781 * @return the condition that determines when the loop will terminate | |
3782 */ | |
3783 Expression get condition => _condition; | |
3784 /** | |
3785 * Return the token representing the 'do' keyword. | |
3786 * @return the token representing the 'do' keyword | |
3787 */ | |
3788 Token get doKeyword => _doKeyword; | |
3789 Token get endToken => _semicolon; | |
3790 /** | |
3791 * Return the left parenthesis. | |
3792 * @return the left parenthesis | |
3793 */ | |
3794 Token get leftParenthesis => _leftParenthesis; | |
3795 /** | |
3796 * Return the right parenthesis. | |
3797 * @return the right parenthesis | |
3798 */ | |
3799 Token get rightParenthesis => _rightParenthesis; | |
3800 /** | |
3801 * Return the semicolon terminating the statement. | |
3802 * @return the semicolon terminating the statement | |
3803 */ | |
3804 Token get semicolon => _semicolon; | |
3805 /** | |
3806 * Return the token representing the 'while' keyword. | |
3807 * @return the token representing the 'while' keyword | |
3808 */ | |
3809 Token get whileKeyword => _whileKeyword; | |
3810 /** | |
3811 * Set the body of the loop to the given statement. | |
3812 * @param statement the body of the loop | |
3813 */ | |
3814 void set body(Statement statement) { | |
3815 _body = becomeParentOf(statement); | |
3816 } | |
3817 /** | |
3818 * Set the condition that determines when the loop will terminate to the given
expression. | |
3819 * @param expression the condition that determines when the loop will terminat
e | |
3820 */ | |
3821 void set condition(Expression expression) { | |
3822 _condition = becomeParentOf(expression); | |
3823 } | |
3824 /** | |
3825 * Set the token representing the 'do' keyword to the given token. | |
3826 * @param doKeyword the token representing the 'do' keyword | |
3827 */ | |
3828 void set doKeyword(Token doKeyword2) { | |
3829 this._doKeyword = doKeyword2; | |
3830 } | |
3831 /** | |
3832 * Set the left parenthesis to the given token. | |
3833 * @param parenthesis the left parenthesis | |
3834 */ | |
3835 void set leftParenthesis(Token parenthesis) { | |
3836 _leftParenthesis = parenthesis; | |
3837 } | |
3838 /** | |
3839 * Set the right parenthesis to the given token. | |
3840 * @param parenthesis the right parenthesis | |
3841 */ | |
3842 void set rightParenthesis(Token parenthesis) { | |
3843 _rightParenthesis = parenthesis; | |
3844 } | |
3845 /** | |
3846 * Set the semicolon terminating the statement to the given token. | |
3847 * @param semicolon the semicolon terminating the statement | |
3848 */ | |
3849 void set semicolon(Token semicolon5) { | |
3850 this._semicolon = semicolon5; | |
3851 } | |
3852 /** | |
3853 * Set the token representing the 'while' keyword to the given token. | |
3854 * @param whileKeyword the token representing the 'while' keyword | |
3855 */ | |
3856 void set whileKeyword(Token whileKeyword2) { | |
3857 this._whileKeyword = whileKeyword2; | |
3858 } | |
3859 void visitChildren(ASTVisitor<Object> visitor) { | |
3860 safelyVisitChild(_body, visitor); | |
3861 safelyVisitChild(_condition, visitor); | |
3862 } | |
3863 } | |
3864 /** | |
3865 * Instances of the class {@code DoubleLiteral} represent a floating point liter
al expression. | |
3866 * <pre> | |
3867 * doubleLiteral ::= | |
3868 * decimalDigit+ ('.' decimalDigit*)? exponent? | |
3869 * | '.' decimalDigit+ exponent? | |
3870 * exponent ::= | |
3871 * ('e' | 'E') ('+' | '-')? decimalDigit+ | |
3872 * </pre> | |
3873 * @coverage dart.engine.ast | |
3874 */ | |
3875 class DoubleLiteral extends Literal { | |
3876 /** | |
3877 * The token representing the literal. | |
3878 */ | |
3879 Token _literal; | |
3880 /** | |
3881 * The value of the literal. | |
3882 */ | |
3883 double _value = 0.0; | |
3884 /** | |
3885 * Initialize a newly created floating point literal. | |
3886 * @param literal the token representing the literal | |
3887 * @param value the value of the literal | |
3888 */ | |
3889 DoubleLiteral.full(Token literal, double value) { | |
3890 this._literal = literal; | |
3891 this._value = value; | |
3892 } | |
3893 /** | |
3894 * Initialize a newly created floating point literal. | |
3895 * @param literal the token representing the literal | |
3896 * @param value the value of the literal | |
3897 */ | |
3898 DoubleLiteral({Token literal, double value}) : this.full(literal, value); | |
3899 accept(ASTVisitor visitor) => visitor.visitDoubleLiteral(this); | |
3900 Token get beginToken => _literal; | |
3901 Token get endToken => _literal; | |
3902 /** | |
3903 * Return the token representing the literal. | |
3904 * @return the token representing the literal | |
3905 */ | |
3906 Token get literal => _literal; | |
3907 /** | |
3908 * Return the value of the literal. | |
3909 * @return the value of the literal | |
3910 */ | |
3911 double get value => _value; | |
3912 /** | |
3913 * Set the token representing the literal to the given token. | |
3914 * @param literal the token representing the literal | |
3915 */ | |
3916 void set literal(Token literal3) { | |
3917 this._literal = literal3; | |
3918 } | |
3919 /** | |
3920 * Set the value of the literal to the given value. | |
3921 * @param value the value of the literal | |
3922 */ | |
3923 void set value(double value5) { | |
3924 this._value = value5; | |
3925 } | |
3926 void visitChildren(ASTVisitor<Object> visitor) { | |
3927 } | |
3928 } | |
3929 /** | |
3930 * Instances of the class {@code EmptyFunctionBody} represent an empty function
body, which can only | |
3931 * appear in constructors or abstract methods. | |
3932 * <pre> | |
3933 * emptyFunctionBody ::= | |
3934 * ';' | |
3935 * </pre> | |
3936 * @coverage dart.engine.ast | |
3937 */ | |
3938 class EmptyFunctionBody extends FunctionBody { | |
3939 /** | |
3940 * The token representing the semicolon that marks the end of the function bod
y. | |
3941 */ | |
3942 Token _semicolon; | |
3943 /** | |
3944 * Initialize a newly created function body. | |
3945 * @param semicolon the token representing the semicolon that marks the end of
the function body | |
3946 */ | |
3947 EmptyFunctionBody.full(Token semicolon) { | |
3948 this._semicolon = semicolon; | |
3949 } | |
3950 /** | |
3951 * Initialize a newly created function body. | |
3952 * @param semicolon the token representing the semicolon that marks the end of
the function body | |
3953 */ | |
3954 EmptyFunctionBody({Token semicolon}) : this.full(semicolon); | |
3955 accept(ASTVisitor visitor) => visitor.visitEmptyFunctionBody(this); | |
3956 Token get beginToken => _semicolon; | |
3957 Token get endToken => _semicolon; | |
3958 /** | |
3959 * Return the token representing the semicolon that marks the end of the funct
ion body. | |
3960 * @return the token representing the semicolon that marks the end of the func
tion body | |
3961 */ | |
3962 Token get semicolon => _semicolon; | |
3963 /** | |
3964 * Set the token representing the semicolon that marks the end of the function
body to the given | |
3965 * token. | |
3966 * @param semicolon the token representing the semicolon that marks the end of
the function body | |
3967 */ | |
3968 void set semicolon(Token semicolon6) { | |
3969 this._semicolon = semicolon6; | |
3970 } | |
3971 void visitChildren(ASTVisitor<Object> visitor) { | |
3972 } | |
3973 } | |
3974 /** | |
3975 * Instances of the class {@code EmptyStatement} represent an empty statement. | |
3976 * <pre> | |
3977 * emptyStatement ::= | |
3978 * ';' | |
3979 * </pre> | |
3980 * @coverage dart.engine.ast | |
3981 */ | |
3982 class EmptyStatement extends Statement { | |
3983 /** | |
3984 * The semicolon terminating the statement. | |
3985 */ | |
3986 Token _semicolon; | |
3987 /** | |
3988 * Initialize a newly created empty statement. | |
3989 * @param semicolon the semicolon terminating the statement | |
3990 */ | |
3991 EmptyStatement.full(Token semicolon) { | |
3992 this._semicolon = semicolon; | |
3993 } | |
3994 /** | |
3995 * Initialize a newly created empty statement. | |
3996 * @param semicolon the semicolon terminating the statement | |
3997 */ | |
3998 EmptyStatement({Token semicolon}) : this.full(semicolon); | |
3999 accept(ASTVisitor visitor) => visitor.visitEmptyStatement(this); | |
4000 Token get beginToken => _semicolon; | |
4001 Token get endToken => _semicolon; | |
4002 /** | |
4003 * Return the semicolon terminating the statement. | |
4004 * @return the semicolon terminating the statement | |
4005 */ | |
4006 Token get semicolon => _semicolon; | |
4007 /** | |
4008 * Set the semicolon terminating the statement to the given token. | |
4009 * @param semicolon the semicolon terminating the statement | |
4010 */ | |
4011 void set semicolon(Token semicolon7) { | |
4012 this._semicolon = semicolon7; | |
4013 } | |
4014 void visitChildren(ASTVisitor<Object> visitor) { | |
4015 } | |
4016 } | |
4017 /** | |
4018 * Ephemeral identifiers are created as needed to mimic the presence of an empty
identifier. | |
4019 * @coverage dart.engine.ast | |
4020 */ | |
4021 class EphemeralIdentifier extends SimpleIdentifier { | |
4022 EphemeralIdentifier.full(ASTNode parent, int location) : super.full(new Token(
TokenType.IDENTIFIER, location)) { | |
4023 parent.becomeParentOf(this); | |
4024 } | |
4025 EphemeralIdentifier({ASTNode parent, int location}) : this.full(parent, locati
on); | |
4026 } | |
4027 /** | |
4028 * Instances of the class {@code ExportDirective} represent an export directive. | |
4029 * <pre> | |
4030 * exportDirective ::={@link Annotation metadata} 'export' {@link StringLiteral
libraryUri} {@link Combinator combinator}* ';' | |
4031 * </pre> | |
4032 * @coverage dart.engine.ast | |
4033 */ | |
4034 class ExportDirective extends NamespaceDirective { | |
4035 /** | |
4036 * Initialize a newly created export directive. | |
4037 * @param comment the documentation comment associated with this directive | |
4038 * @param metadata the annotations associated with the directive | |
4039 * @param keyword the token representing the 'export' keyword | |
4040 * @param libraryUri the URI of the library being exported | |
4041 * @param combinators the combinators used to control which names are exported | |
4042 * @param semicolon the semicolon terminating the directive | |
4043 */ | |
4044 ExportDirective.full(Comment comment, List<Annotation> metadata, Token keyword
, StringLiteral libraryUri, List<Combinator> combinators, Token semicolon) : sup
er.full(comment, metadata, keyword, libraryUri, combinators, semicolon) { | |
4045 } | |
4046 /** | |
4047 * Initialize a newly created export directive. | |
4048 * @param comment the documentation comment associated with this directive | |
4049 * @param metadata the annotations associated with the directive | |
4050 * @param keyword the token representing the 'export' keyword | |
4051 * @param libraryUri the URI of the library being exported | |
4052 * @param combinators the combinators used to control which names are exported | |
4053 * @param semicolon the semicolon terminating the directive | |
4054 */ | |
4055 ExportDirective({Comment comment, List<Annotation> metadata, Token keyword, St
ringLiteral libraryUri, List<Combinator> combinators, Token semicolon}) : this.f
ull(comment, metadata, keyword, libraryUri, combinators, semicolon); | |
4056 accept(ASTVisitor visitor) => visitor.visitExportDirective(this); | |
4057 void visitChildren(ASTVisitor<Object> visitor) { | |
4058 super.visitChildren(visitor); | |
4059 combinators.accept(visitor); | |
4060 } | |
4061 } | |
4062 /** | |
4063 * Instances of the class {@code Expression} defines the behavior common to node
s that represent an | |
4064 * expression. | |
4065 * <pre> | |
4066 * expression ::={@link AssignmentExpression assignmentExpression}| {@link Condi
tionalExpression conditionalExpression} cascadeSection | |
4067 * | {@link ThrowExpression throwExpression}</pre> | |
4068 * @coverage dart.engine.ast | |
4069 */ | |
4070 abstract class Expression extends ASTNode { | |
4071 /** | |
4072 * The static type of this expression, or {@code null} if the AST structure ha
s not been resolved. | |
4073 */ | |
4074 Type2 _staticType; | |
4075 /** | |
4076 * The propagated type of this expression, or {@code null} if type propagation
has not been | |
4077 * performed on the AST structure. | |
4078 */ | |
4079 Type2 _propagatedType; | |
4080 /** | |
4081 * If this expression is an argument to an invocation, and the AST structure h
as been resolved, | |
4082 * and the function being invoked is known, and this expression corresponds to
one of the | |
4083 * parameters of the function being invoked, then return the parameter element
representing the | |
4084 * parameter to which the value of this expression will be bound. Otherwise, r
eturn {@code null}. | |
4085 * @return the parameter element representing the parameter to which the value
of this expression | |
4086 * will be bound | |
4087 */ | |
4088 ParameterElement get parameterElement { | |
4089 ASTNode parent3 = parent; | |
4090 if (parent3 is ArgumentList) { | |
4091 return ((parent3 as ArgumentList)).getParameterElementFor(this); | |
4092 } | |
4093 return null; | |
4094 } | |
4095 /** | |
4096 * Return the propagated type of this expression, or {@code null} if type prop
agation has not been | |
4097 * performed on the AST structure. | |
4098 * @return the propagated type of this expression | |
4099 */ | |
4100 Type2 get propagatedType => _propagatedType; | |
4101 /** | |
4102 * Return the static type of this expression, or {@code null} if the AST struc
ture has not been | |
4103 * resolved. | |
4104 * @return the static type of this expression | |
4105 */ | |
4106 Type2 get staticType => _staticType; | |
4107 /** | |
4108 * Return {@code true} if this expression is syntactically valid for the LHS o
f an{@link AssignmentExpression assignment expression}. | |
4109 * @return {@code true} if this expression matches the {@code assignableExpres
sion} production | |
4110 */ | |
4111 bool isAssignable() => false; | |
4112 /** | |
4113 * Set the propagated type of this expression to the given type. | |
4114 * @param propagatedType the propagated type of this expression | |
4115 */ | |
4116 void set propagatedType(Type2 propagatedType2) { | |
4117 this._propagatedType = propagatedType2; | |
4118 } | |
4119 /** | |
4120 * Set the static type of this expression to the given type. | |
4121 * @param staticType the static type of this expression | |
4122 */ | |
4123 void set staticType(Type2 staticType2) { | |
4124 this._staticType = staticType2; | |
4125 } | |
4126 } | |
4127 /** | |
4128 * Instances of the class {@code ExpressionFunctionBody} represent a function bo
dy consisting of a | |
4129 * single expression. | |
4130 * <pre> | |
4131 * expressionFunctionBody ::= | |
4132 * '=>' {@link Expression expression} ';' | |
4133 * </pre> | |
4134 * @coverage dart.engine.ast | |
4135 */ | |
4136 class ExpressionFunctionBody extends FunctionBody { | |
4137 /** | |
4138 * The token introducing the expression that represents the body of the functi
on. | |
4139 */ | |
4140 Token _functionDefinition; | |
4141 /** | |
4142 * The expression representing the body of the function. | |
4143 */ | |
4144 Expression _expression; | |
4145 /** | |
4146 * The semicolon terminating the statement. | |
4147 */ | |
4148 Token _semicolon; | |
4149 /** | |
4150 * Initialize a newly created function body consisting of a block of statement
s. | |
4151 * @param functionDefinition the token introducing the expression that represe
nts the body of the | |
4152 * function | |
4153 * @param expression the expression representing the body of the function | |
4154 * @param semicolon the semicolon terminating the statement | |
4155 */ | |
4156 ExpressionFunctionBody.full(Token functionDefinition, Expression expression, T
oken semicolon) { | |
4157 this._functionDefinition = functionDefinition; | |
4158 this._expression = becomeParentOf(expression); | |
4159 this._semicolon = semicolon; | |
4160 } | |
4161 /** | |
4162 * Initialize a newly created function body consisting of a block of statement
s. | |
4163 * @param functionDefinition the token introducing the expression that represe
nts the body of the | |
4164 * function | |
4165 * @param expression the expression representing the body of the function | |
4166 * @param semicolon the semicolon terminating the statement | |
4167 */ | |
4168 ExpressionFunctionBody({Token functionDefinition, Expression expression, Token
semicolon}) : this.full(functionDefinition, expression, semicolon); | |
4169 accept(ASTVisitor visitor) => visitor.visitExpressionFunctionBody(this); | |
4170 Token get beginToken => _functionDefinition; | |
4171 Token get endToken { | |
4172 if (_semicolon != null) { | |
4173 return _semicolon; | |
4174 } | |
4175 return _expression.endToken; | |
4176 } | |
4177 /** | |
4178 * Return the expression representing the body of the function. | |
4179 * @return the expression representing the body of the function | |
4180 */ | |
4181 Expression get expression => _expression; | |
4182 /** | |
4183 * Return the token introducing the expression that represents the body of the
function. | |
4184 * @return the function definition token | |
4185 */ | |
4186 Token get functionDefinition => _functionDefinition; | |
4187 /** | |
4188 * Return the semicolon terminating the statement. | |
4189 * @return the semicolon terminating the statement | |
4190 */ | |
4191 Token get semicolon => _semicolon; | |
4192 /** | |
4193 * Set the expression representing the body of the function to the given expre
ssion. | |
4194 * @param expression the expression representing the body of the function | |
4195 */ | |
4196 void set expression(Expression expression4) { | |
4197 this._expression = becomeParentOf(expression4); | |
4198 } | |
4199 /** | |
4200 * Set the token introducing the expression that represents the body of the fu
nction to the given | |
4201 * token. | |
4202 * @param functionDefinition the function definition token | |
4203 */ | |
4204 void set functionDefinition(Token functionDefinition2) { | |
4205 this._functionDefinition = functionDefinition2; | |
4206 } | |
4207 /** | |
4208 * Set the semicolon terminating the statement to the given token. | |
4209 * @param semicolon the semicolon terminating the statement | |
4210 */ | |
4211 void set semicolon(Token semicolon8) { | |
4212 this._semicolon = semicolon8; | |
4213 } | |
4214 void visitChildren(ASTVisitor<Object> visitor) { | |
4215 safelyVisitChild(_expression, visitor); | |
4216 } | |
4217 } | |
4218 /** | |
4219 * Instances of the class {@code ExpressionStatement} wrap an expression as a st
atement. | |
4220 * <pre> | |
4221 * expressionStatement ::={@link Expression expression}? ';' | |
4222 * </pre> | |
4223 * @coverage dart.engine.ast | |
4224 */ | |
4225 class ExpressionStatement extends Statement { | |
4226 /** | |
4227 * The expression that comprises the statement. | |
4228 */ | |
4229 Expression _expression; | |
4230 /** | |
4231 * The semicolon terminating the statement, or {@code null} if the expression
is a function | |
4232 * expression and isn't followed by a semicolon. | |
4233 */ | |
4234 Token _semicolon; | |
4235 /** | |
4236 * Initialize a newly created expression statement. | |
4237 * @param expression the expression that comprises the statement | |
4238 * @param semicolon the semicolon terminating the statement | |
4239 */ | |
4240 ExpressionStatement.full(Expression expression, Token semicolon) { | |
4241 this._expression = becomeParentOf(expression); | |
4242 this._semicolon = semicolon; | |
4243 } | |
4244 /** | |
4245 * Initialize a newly created expression statement. | |
4246 * @param expression the expression that comprises the statement | |
4247 * @param semicolon the semicolon terminating the statement | |
4248 */ | |
4249 ExpressionStatement({Expression expression, Token semicolon}) : this.full(expr
ession, semicolon); | |
4250 accept(ASTVisitor visitor) => visitor.visitExpressionStatement(this); | |
4251 Token get beginToken => _expression.beginToken; | |
4252 Token get endToken { | |
4253 if (_semicolon != null) { | |
4254 return _semicolon; | |
4255 } | |
4256 return _expression.endToken; | |
4257 } | |
4258 /** | |
4259 * Return the expression that comprises the statement. | |
4260 * @return the expression that comprises the statement | |
4261 */ | |
4262 Expression get expression => _expression; | |
4263 /** | |
4264 * Return the semicolon terminating the statement. | |
4265 * @return the semicolon terminating the statement | |
4266 */ | |
4267 Token get semicolon => _semicolon; | |
4268 bool isSynthetic() => _expression.isSynthetic() && _semicolon.isSynthetic(); | |
4269 /** | |
4270 * Set the expression that comprises the statement to the given expression. | |
4271 * @param expression the expression that comprises the statement | |
4272 */ | |
4273 void set expression(Expression expression5) { | |
4274 this._expression = becomeParentOf(expression5); | |
4275 } | |
4276 /** | |
4277 * Set the semicolon terminating the statement to the given token. | |
4278 * @param semicolon the semicolon terminating the statement | |
4279 */ | |
4280 void set semicolon(Token semicolon9) { | |
4281 this._semicolon = semicolon9; | |
4282 } | |
4283 void visitChildren(ASTVisitor<Object> visitor) { | |
4284 safelyVisitChild(_expression, visitor); | |
4285 } | |
4286 } | |
4287 /** | |
4288 * Instances of the class {@code ExtendsClause} represent the "extends" clause i
n a class | |
4289 * declaration. | |
4290 * <pre> | |
4291 * extendsClause ::= | |
4292 * 'extends' {@link TypeName superclass}</pre> | |
4293 * @coverage dart.engine.ast | |
4294 */ | |
4295 class ExtendsClause extends ASTNode { | |
4296 /** | |
4297 * The token representing the 'extends' keyword. | |
4298 */ | |
4299 Token _keyword; | |
4300 /** | |
4301 * The name of the class that is being extended. | |
4302 */ | |
4303 TypeName _superclass; | |
4304 /** | |
4305 * Initialize a newly created extends clause. | |
4306 * @param keyword the token representing the 'extends' keyword | |
4307 * @param superclass the name of the class that is being extended | |
4308 */ | |
4309 ExtendsClause.full(Token keyword, TypeName superclass) { | |
4310 this._keyword = keyword; | |
4311 this._superclass = becomeParentOf(superclass); | |
4312 } | |
4313 /** | |
4314 * Initialize a newly created extends clause. | |
4315 * @param keyword the token representing the 'extends' keyword | |
4316 * @param superclass the name of the class that is being extended | |
4317 */ | |
4318 ExtendsClause({Token keyword, TypeName superclass}) : this.full(keyword, super
class); | |
4319 accept(ASTVisitor visitor) => visitor.visitExtendsClause(this); | |
4320 Token get beginToken => _keyword; | |
4321 Token get endToken => _superclass.endToken; | |
4322 /** | |
4323 * Return the token representing the 'extends' keyword. | |
4324 * @return the token representing the 'extends' keyword | |
4325 */ | |
4326 Token get keyword => _keyword; | |
4327 /** | |
4328 * Return the name of the class that is being extended. | |
4329 * @return the name of the class that is being extended | |
4330 */ | |
4331 TypeName get superclass => _superclass; | |
4332 /** | |
4333 * Set the token representing the 'extends' keyword to the given token. | |
4334 * @param keyword the token representing the 'extends' keyword | |
4335 */ | |
4336 void set keyword(Token keyword9) { | |
4337 this._keyword = keyword9; | |
4338 } | |
4339 /** | |
4340 * Set the name of the class that is being extended to the given name. | |
4341 * @param name the name of the class that is being extended | |
4342 */ | |
4343 void set superclass(TypeName name) { | |
4344 _superclass = becomeParentOf(name); | |
4345 } | |
4346 void visitChildren(ASTVisitor<Object> visitor) { | |
4347 safelyVisitChild(_superclass, visitor); | |
4348 } | |
4349 } | |
4350 /** | |
4351 * Instances of the class {@code FieldDeclaration} represent the declaration of
one or more fields | |
4352 * of the same type. | |
4353 * <pre> | |
4354 * fieldDeclaration ::= | |
4355 * 'static'? {@link VariableDeclarationList fieldList} ';' | |
4356 * </pre> | |
4357 * @coverage dart.engine.ast | |
4358 */ | |
4359 class FieldDeclaration extends ClassMember { | |
4360 /** | |
4361 * The token representing the 'static' keyword, or {@code null} if the fields
are not static. | |
4362 */ | |
4363 Token _keyword; | |
4364 /** | |
4365 * The fields being declared. | |
4366 */ | |
4367 VariableDeclarationList _fieldList; | |
4368 /** | |
4369 * The semicolon terminating the declaration. | |
4370 */ | |
4371 Token _semicolon; | |
4372 /** | |
4373 * Initialize a newly created field declaration. | |
4374 * @param comment the documentation comment associated with this field | |
4375 * @param metadata the annotations associated with this field | |
4376 * @param keyword the token representing the 'static' keyword | |
4377 * @param fieldList the fields being declared | |
4378 * @param semicolon the semicolon terminating the declaration | |
4379 */ | |
4380 FieldDeclaration.full(Comment comment, List<Annotation> metadata, Token keywor
d, VariableDeclarationList fieldList, Token semicolon) : super.full(comment, met
adata) { | |
4381 this._keyword = keyword; | |
4382 this._fieldList = becomeParentOf(fieldList); | |
4383 this._semicolon = semicolon; | |
4384 } | |
4385 /** | |
4386 * Initialize a newly created field declaration. | |
4387 * @param comment the documentation comment associated with this field | |
4388 * @param metadata the annotations associated with this field | |
4389 * @param keyword the token representing the 'static' keyword | |
4390 * @param fieldList the fields being declared | |
4391 * @param semicolon the semicolon terminating the declaration | |
4392 */ | |
4393 FieldDeclaration({Comment comment, List<Annotation> metadata, Token keyword, V
ariableDeclarationList fieldList, Token semicolon}) : this.full(comment, metadat
a, keyword, fieldList, semicolon); | |
4394 accept(ASTVisitor visitor) => visitor.visitFieldDeclaration(this); | |
4395 Element get element => null; | |
4396 Token get endToken => _semicolon; | |
4397 /** | |
4398 * Return the fields being declared. | |
4399 * @return the fields being declared | |
4400 */ | |
4401 VariableDeclarationList get fields => _fieldList; | |
4402 /** | |
4403 * Return the token representing the 'static' keyword, or {@code null} if the
fields are not | |
4404 * static. | |
4405 * @return the token representing the 'static' keyword | |
4406 */ | |
4407 Token get keyword => _keyword; | |
4408 /** | |
4409 * Return the semicolon terminating the declaration. | |
4410 * @return the semicolon terminating the declaration | |
4411 */ | |
4412 Token get semicolon => _semicolon; | |
4413 /** | |
4414 * Set the fields being declared to the given list of variables. | |
4415 * @param fieldList the fields being declared | |
4416 */ | |
4417 void set fields(VariableDeclarationList fieldList) { | |
4418 fieldList = becomeParentOf(fieldList); | |
4419 } | |
4420 /** | |
4421 * Set the token representing the 'static' keyword to the given token. | |
4422 * @param keyword the token representing the 'static' keyword | |
4423 */ | |
4424 void set keyword(Token keyword10) { | |
4425 this._keyword = keyword10; | |
4426 } | |
4427 /** | |
4428 * Set the semicolon terminating the declaration to the given token. | |
4429 * @param semicolon the semicolon terminating the declaration | |
4430 */ | |
4431 void set semicolon(Token semicolon10) { | |
4432 this._semicolon = semicolon10; | |
4433 } | |
4434 void visitChildren(ASTVisitor<Object> visitor) { | |
4435 super.visitChildren(visitor); | |
4436 safelyVisitChild(_fieldList, visitor); | |
4437 } | |
4438 Token get firstTokenAfterCommentAndMetadata { | |
4439 if (_keyword != null) { | |
4440 return _keyword; | |
4441 } | |
4442 return _fieldList.beginToken; | |
4443 } | |
4444 } | |
4445 /** | |
4446 * Instances of the class {@code FieldFormalParameter} represent a field formal
parameter. | |
4447 * <pre> | |
4448 * fieldFormalParameter ::= | |
4449 * ('final' {@link TypeName type} | 'const' {@link TypeName type} | 'var' | {@li
nk TypeName type})? 'this' '.' {@link SimpleIdentifier identifier}</pre> | |
4450 * @coverage dart.engine.ast | |
4451 */ | |
4452 class FieldFormalParameter extends NormalFormalParameter { | |
4453 /** | |
4454 * The token representing either the 'final', 'const' or 'var' keyword, or {@c
ode null} if no | |
4455 * keyword was used. | |
4456 */ | |
4457 Token _keyword; | |
4458 /** | |
4459 * The name of the declared type of the parameter, or {@code null} if the para
meter does not have | |
4460 * a declared type. | |
4461 */ | |
4462 TypeName _type; | |
4463 /** | |
4464 * The token representing the 'this' keyword. | |
4465 */ | |
4466 Token _thisToken; | |
4467 /** | |
4468 * The token representing the period. | |
4469 */ | |
4470 Token _period; | |
4471 /** | |
4472 * Initialize a newly created formal parameter. | |
4473 * @param comment the documentation comment associated with this parameter | |
4474 * @param metadata the annotations associated with this parameter | |
4475 * @param keyword the token representing either the 'final', 'const' or 'var'
keyword | |
4476 * @param type the name of the declared type of the parameter | |
4477 * @param thisToken the token representing the 'this' keyword | |
4478 * @param period the token representing the period | |
4479 * @param identifier the name of the parameter being declared | |
4480 */ | |
4481 FieldFormalParameter.full(Comment comment, List<Annotation> metadata, Token ke
yword, TypeName type, Token thisToken, Token period, SimpleIdentifier identifier
) : super.full(comment, metadata, identifier) { | |
4482 this._keyword = keyword; | |
4483 this._type = becomeParentOf(type); | |
4484 this._thisToken = thisToken; | |
4485 this._period = period; | |
4486 } | |
4487 /** | |
4488 * Initialize a newly created formal parameter. | |
4489 * @param comment the documentation comment associated with this parameter | |
4490 * @param metadata the annotations associated with this parameter | |
4491 * @param keyword the token representing either the 'final', 'const' or 'var'
keyword | |
4492 * @param type the name of the declared type of the parameter | |
4493 * @param thisToken the token representing the 'this' keyword | |
4494 * @param period the token representing the period | |
4495 * @param identifier the name of the parameter being declared | |
4496 */ | |
4497 FieldFormalParameter({Comment comment, List<Annotation> metadata, Token keywor
d, TypeName type, Token thisToken, Token period, SimpleIdentifier identifier}) :
this.full(comment, metadata, keyword, type, thisToken, period, identifier); | |
4498 accept(ASTVisitor visitor) => visitor.visitFieldFormalParameter(this); | |
4499 Token get beginToken { | |
4500 if (_keyword != null) { | |
4501 return _keyword; | |
4502 } else if (_type != null) { | |
4503 return _type.beginToken; | |
4504 } | |
4505 return _thisToken; | |
4506 } | |
4507 Token get endToken => identifier.endToken; | |
4508 /** | |
4509 * Return the token representing either the 'final', 'const' or 'var' keyword. | |
4510 * @return the token representing either the 'final', 'const' or 'var' keyword | |
4511 */ | |
4512 Token get keyword => _keyword; | |
4513 /** | |
4514 * Return the token representing the period. | |
4515 * @return the token representing the period | |
4516 */ | |
4517 Token get period => _period; | |
4518 /** | |
4519 * Return the token representing the 'this' keyword. | |
4520 * @return the token representing the 'this' keyword | |
4521 */ | |
4522 Token get thisToken => _thisToken; | |
4523 /** | |
4524 * Return the name of the declared type of the parameter, or {@code null} if t
he parameter does | |
4525 * not have a declared type. | |
4526 * @return the name of the declared type of the parameter | |
4527 */ | |
4528 TypeName get type => _type; | |
4529 bool isConst() => (_keyword is KeywordToken) && identical(((_keyword as Keywor
dToken)).keyword, Keyword.CONST); | |
4530 bool isFinal() => (_keyword is KeywordToken) && identical(((_keyword as Keywor
dToken)).keyword, Keyword.FINAL); | |
4531 /** | |
4532 * Set the token representing either the 'final', 'const' or 'var' keyword to
the given token. | |
4533 * @param keyword the token representing either the 'final', 'const' or 'var'
keyword | |
4534 */ | |
4535 void set keyword(Token keyword11) { | |
4536 this._keyword = keyword11; | |
4537 } | |
4538 /** | |
4539 * Set the token representing the period to the given token. | |
4540 * @param period the token representing the period | |
4541 */ | |
4542 void set period(Token period6) { | |
4543 this._period = period6; | |
4544 } | |
4545 /** | |
4546 * Set the token representing the 'this' keyword to the given token. | |
4547 * @param thisToken the token representing the 'this' keyword | |
4548 */ | |
4549 void set thisToken(Token thisToken2) { | |
4550 this._thisToken = thisToken2; | |
4551 } | |
4552 /** | |
4553 * Set the name of the declared type of the parameter to the given type name. | |
4554 * @param typeName the name of the declared type of the parameter | |
4555 */ | |
4556 void set type(TypeName typeName) { | |
4557 _type = becomeParentOf(typeName); | |
4558 } | |
4559 void visitChildren(ASTVisitor<Object> visitor) { | |
4560 super.visitChildren(visitor); | |
4561 safelyVisitChild(_type, visitor); | |
4562 safelyVisitChild(identifier, visitor); | |
4563 } | |
4564 } | |
4565 /** | |
4566 * Instances of the class {@code ForEachStatement} represent a for-each statemen
t. | |
4567 * <pre> | |
4568 * forEachStatement ::= | |
4569 * 'for' '(' {@link SimpleFormalParameter loopParameter} 'in' {@link Expression
iterator} ')' {@link Block body}</pre> | |
4570 * @coverage dart.engine.ast | |
4571 */ | |
4572 class ForEachStatement extends Statement { | |
4573 /** | |
4574 * The token representing the 'for' keyword. | |
4575 */ | |
4576 Token _forKeyword; | |
4577 /** | |
4578 * The left parenthesis. | |
4579 */ | |
4580 Token _leftParenthesis; | |
4581 /** | |
4582 * The declaration of the loop variable. | |
4583 */ | |
4584 DeclaredIdentifier _loopVariable; | |
4585 /** | |
4586 * The token representing the 'in' keyword. | |
4587 */ | |
4588 Token _inKeyword; | |
4589 /** | |
4590 * The expression evaluated to produce the iterator. | |
4591 */ | |
4592 Expression _iterator; | |
4593 /** | |
4594 * The right parenthesis. | |
4595 */ | |
4596 Token _rightParenthesis; | |
4597 /** | |
4598 * The body of the loop. | |
4599 */ | |
4600 Statement _body; | |
4601 /** | |
4602 * Initialize a newly created for-each statement. | |
4603 * @param forKeyword the token representing the 'for' keyword | |
4604 * @param leftParenthesis the left parenthesis | |
4605 * @param loopVariable the declaration of the loop variable | |
4606 * @param iterator the expression evaluated to produce the iterator | |
4607 * @param rightParenthesis the right parenthesis | |
4608 * @param body the body of the loop | |
4609 */ | |
4610 ForEachStatement.full(Token forKeyword, Token leftParenthesis, DeclaredIdentif
ier loopVariable, Token inKeyword, Expression iterator, Token rightParenthesis,
Statement body) { | |
4611 this._forKeyword = forKeyword; | |
4612 this._leftParenthesis = leftParenthesis; | |
4613 this._loopVariable = becomeParentOf(loopVariable); | |
4614 this._inKeyword = inKeyword; | |
4615 this._iterator = becomeParentOf(iterator); | |
4616 this._rightParenthesis = rightParenthesis; | |
4617 this._body = becomeParentOf(body); | |
4618 } | |
4619 /** | |
4620 * Initialize a newly created for-each statement. | |
4621 * @param forKeyword the token representing the 'for' keyword | |
4622 * @param leftParenthesis the left parenthesis | |
4623 * @param loopVariable the declaration of the loop variable | |
4624 * @param iterator the expression evaluated to produce the iterator | |
4625 * @param rightParenthesis the right parenthesis | |
4626 * @param body the body of the loop | |
4627 */ | |
4628 ForEachStatement({Token forKeyword, Token leftParenthesis, DeclaredIdentifier
loopVariable, Token inKeyword, Expression iterator, Token rightParenthesis, Stat
ement body}) : this.full(forKeyword, leftParenthesis, loopVariable, inKeyword, i
terator, rightParenthesis, body); | |
4629 accept(ASTVisitor visitor) => visitor.visitForEachStatement(this); | |
4630 Token get beginToken => _forKeyword; | |
4631 /** | |
4632 * Return the body of the loop. | |
4633 * @return the body of the loop | |
4634 */ | |
4635 Statement get body => _body; | |
4636 Token get endToken => _body.endToken; | |
4637 /** | |
4638 * Return the token representing the 'for' keyword. | |
4639 * @return the token representing the 'for' keyword | |
4640 */ | |
4641 Token get forKeyword => _forKeyword; | |
4642 /** | |
4643 * Return the token representing the 'in' keyword. | |
4644 * @return the token representing the 'in' keyword | |
4645 */ | |
4646 Token get inKeyword => _inKeyword; | |
4647 /** | |
4648 * Return the expression evaluated to produce the iterator. | |
4649 * @return the expression evaluated to produce the iterator | |
4650 */ | |
4651 Expression get iterator => _iterator; | |
4652 /** | |
4653 * Return the left parenthesis. | |
4654 * @return the left parenthesis | |
4655 */ | |
4656 Token get leftParenthesis => _leftParenthesis; | |
4657 /** | |
4658 * Return the declaration of the loop variable. | |
4659 * @return the declaration of the loop variable | |
4660 */ | |
4661 DeclaredIdentifier get loopVariable => _loopVariable; | |
4662 /** | |
4663 * Return the right parenthesis. | |
4664 * @return the right parenthesis | |
4665 */ | |
4666 Token get rightParenthesis => _rightParenthesis; | |
4667 /** | |
4668 * Set the body of the loop to the given block. | |
4669 * @param body the body of the loop | |
4670 */ | |
4671 void set body(Statement body2) { | |
4672 this._body = becomeParentOf(body2); | |
4673 } | |
4674 /** | |
4675 * Set the token representing the 'for' keyword to the given token. | |
4676 * @param forKeyword the token representing the 'for' keyword | |
4677 */ | |
4678 void set forKeyword(Token forKeyword2) { | |
4679 this._forKeyword = forKeyword2; | |
4680 } | |
4681 /** | |
4682 * Set the token representing the 'in' keyword to the given token. | |
4683 * @param inKeyword the token representing the 'in' keyword | |
4684 */ | |
4685 void set inKeyword(Token inKeyword2) { | |
4686 this._inKeyword = inKeyword2; | |
4687 } | |
4688 /** | |
4689 * Set the expression evaluated to produce the iterator to the given expressio
n. | |
4690 * @param expression the expression evaluated to produce the iterator | |
4691 */ | |
4692 void set iterator(Expression expression) { | |
4693 _iterator = becomeParentOf(expression); | |
4694 } | |
4695 /** | |
4696 * Set the left parenthesis to the given token. | |
4697 * @param leftParenthesis the left parenthesis | |
4698 */ | |
4699 void set leftParenthesis(Token leftParenthesis3) { | |
4700 this._leftParenthesis = leftParenthesis3; | |
4701 } | |
4702 /** | |
4703 * Set the declaration of the loop variable to the given variable. | |
4704 * @param variable the declaration of the loop variable | |
4705 */ | |
4706 void set loopVariable(DeclaredIdentifier variable) { | |
4707 _loopVariable = becomeParentOf(variable); | |
4708 } | |
4709 /** | |
4710 * Set the right parenthesis to the given token. | |
4711 * @param rightParenthesis the right parenthesis | |
4712 */ | |
4713 void set rightParenthesis(Token rightParenthesis3) { | |
4714 this._rightParenthesis = rightParenthesis3; | |
4715 } | |
4716 void visitChildren(ASTVisitor<Object> visitor) { | |
4717 safelyVisitChild(_loopVariable, visitor); | |
4718 safelyVisitChild(_iterator, visitor); | |
4719 safelyVisitChild(_body, visitor); | |
4720 } | |
4721 } | |
4722 /** | |
4723 * Instances of the class {@code ForStatement} represent a for statement. | |
4724 * <pre> | |
4725 * forStatement ::= | |
4726 * 'for' '(' forLoopParts ')' {@link Statement statement}forLoopParts ::= | |
4727 * forInitializerStatement ';' {@link Expression expression}? ';' {@link Express
ion expressionList}? | |
4728 * forInitializerStatement ::={@link DefaultFormalParameter initializedVariableD
eclaration}| {@link Expression expression}? | |
4729 * </pre> | |
4730 * @coverage dart.engine.ast | |
4731 */ | |
4732 class ForStatement extends Statement { | |
4733 /** | |
4734 * The token representing the 'for' keyword. | |
4735 */ | |
4736 Token _forKeyword; | |
4737 /** | |
4738 * The left parenthesis. | |
4739 */ | |
4740 Token _leftParenthesis; | |
4741 /** | |
4742 * The declaration of the loop variables, or {@code null} if there are no vari
ables. Note that a | |
4743 * for statement cannot have both a variable list and an initialization expres
sion, but can | |
4744 * validly have neither. | |
4745 */ | |
4746 VariableDeclarationList _variableList; | |
4747 /** | |
4748 * The initialization expression, or {@code null} if there is no initializatio
n expression. Note | |
4749 * that a for statement cannot have both a variable list and an initialization
expression, but can | |
4750 * validly have neither. | |
4751 */ | |
4752 Expression _initialization; | |
4753 /** | |
4754 * The semicolon separating the initializer and the condition. | |
4755 */ | |
4756 Token _leftSeparator; | |
4757 /** | |
4758 * The condition used to determine when to terminate the loop. | |
4759 */ | |
4760 Expression _condition; | |
4761 /** | |
4762 * The semicolon separating the condition and the updater. | |
4763 */ | |
4764 Token _rightSeparator; | |
4765 /** | |
4766 * The list of expressions run after each execution of the loop body. | |
4767 */ | |
4768 NodeList<Expression> _updaters; | |
4769 /** | |
4770 * The right parenthesis. | |
4771 */ | |
4772 Token _rightParenthesis; | |
4773 /** | |
4774 * The body of the loop. | |
4775 */ | |
4776 Statement _body; | |
4777 /** | |
4778 * Initialize a newly created for statement. | |
4779 * @param forKeyword the token representing the 'for' keyword | |
4780 * @param leftParenthesis the left parenthesis | |
4781 * @param variableList the declaration of the loop variables | |
4782 * @param initialization the initialization expression | |
4783 * @param leftSeparator the semicolon separating the initializer and the condi
tion | |
4784 * @param condition the condition used to determine when to terminate the loop | |
4785 * @param rightSeparator the semicolon separating the condition and the update
r | |
4786 * @param updaters the list of expressions run after each execution of the loo
p body | |
4787 * @param rightParenthesis the right parenthesis | |
4788 * @param body the body of the loop | |
4789 */ | |
4790 ForStatement.full(Token forKeyword, Token leftParenthesis, VariableDeclaration
List variableList, Expression initialization, Token leftSeparator, Expression co
ndition, Token rightSeparator, List<Expression> updaters, Token rightParenthesis
, Statement body) { | |
4791 this._updaters = new NodeList<Expression>(this); | |
4792 this._forKeyword = forKeyword; | |
4793 this._leftParenthesis = leftParenthesis; | |
4794 this._variableList = becomeParentOf(variableList); | |
4795 this._initialization = becomeParentOf(initialization); | |
4796 this._leftSeparator = leftSeparator; | |
4797 this._condition = becomeParentOf(condition); | |
4798 this._rightSeparator = rightSeparator; | |
4799 this._updaters.addAll(updaters); | |
4800 this._rightParenthesis = rightParenthesis; | |
4801 this._body = becomeParentOf(body); | |
4802 } | |
4803 /** | |
4804 * Initialize a newly created for statement. | |
4805 * @param forKeyword the token representing the 'for' keyword | |
4806 * @param leftParenthesis the left parenthesis | |
4807 * @param variableList the declaration of the loop variables | |
4808 * @param initialization the initialization expression | |
4809 * @param leftSeparator the semicolon separating the initializer and the condi
tion | |
4810 * @param condition the condition used to determine when to terminate the loop | |
4811 * @param rightSeparator the semicolon separating the condition and the update
r | |
4812 * @param updaters the list of expressions run after each execution of the loo
p body | |
4813 * @param rightParenthesis the right parenthesis | |
4814 * @param body the body of the loop | |
4815 */ | |
4816 ForStatement({Token forKeyword, Token leftParenthesis, VariableDeclarationList
variableList, Expression initialization, Token leftSeparator, Expression condit
ion, Token rightSeparator, List<Expression> updaters, Token rightParenthesis, St
atement body}) : this.full(forKeyword, leftParenthesis, variableList, initializa
tion, leftSeparator, condition, rightSeparator, updaters, rightParenthesis, body
); | |
4817 accept(ASTVisitor visitor) => visitor.visitForStatement(this); | |
4818 Token get beginToken => _forKeyword; | |
4819 /** | |
4820 * Return the body of the loop. | |
4821 * @return the body of the loop | |
4822 */ | |
4823 Statement get body => _body; | |
4824 /** | |
4825 * Return the condition used to determine when to terminate the loop. | |
4826 * @return the condition used to determine when to terminate the loop | |
4827 */ | |
4828 Expression get condition => _condition; | |
4829 Token get endToken => _body.endToken; | |
4830 /** | |
4831 * Return the token representing the 'for' keyword. | |
4832 * @return the token representing the 'for' keyword | |
4833 */ | |
4834 Token get forKeyword => _forKeyword; | |
4835 /** | |
4836 * Return the initialization expression, or {@code null} if there is no initia
lization expression. | |
4837 * @return the initialization expression | |
4838 */ | |
4839 Expression get initialization => _initialization; | |
4840 /** | |
4841 * Return the left parenthesis. | |
4842 * @return the left parenthesis | |
4843 */ | |
4844 Token get leftParenthesis => _leftParenthesis; | |
4845 /** | |
4846 * Return the semicolon separating the initializer and the condition. | |
4847 * @return the semicolon separating the initializer and the condition | |
4848 */ | |
4849 Token get leftSeparator => _leftSeparator; | |
4850 /** | |
4851 * Return the right parenthesis. | |
4852 * @return the right parenthesis | |
4853 */ | |
4854 Token get rightParenthesis => _rightParenthesis; | |
4855 /** | |
4856 * Return the semicolon separating the condition and the updater. | |
4857 * @return the semicolon separating the condition and the updater | |
4858 */ | |
4859 Token get rightSeparator => _rightSeparator; | |
4860 /** | |
4861 * Return the list of expressions run after each execution of the loop body. | |
4862 * @return the list of expressions run after each execution of the loop body | |
4863 */ | |
4864 NodeList<Expression> get updaters => _updaters; | |
4865 /** | |
4866 * Return the declaration of the loop variables, or {@code null} if there are
no variables. | |
4867 * @return the declaration of the loop variables, or {@code null} if there are
no variables | |
4868 */ | |
4869 VariableDeclarationList get variables => _variableList; | |
4870 /** | |
4871 * Set the body of the loop to the given statement. | |
4872 * @param body the body of the loop | |
4873 */ | |
4874 void set body(Statement body3) { | |
4875 this._body = becomeParentOf(body3); | |
4876 } | |
4877 /** | |
4878 * Set the condition used to determine when to terminate the loop to the given
expression. | |
4879 * @param expression the condition used to determine when to terminate the loo
p | |
4880 */ | |
4881 void set condition(Expression expression) { | |
4882 _condition = becomeParentOf(expression); | |
4883 } | |
4884 /** | |
4885 * Set the token representing the 'for' keyword to the given token. | |
4886 * @param forKeyword the token representing the 'for' keyword | |
4887 */ | |
4888 void set forKeyword(Token forKeyword3) { | |
4889 this._forKeyword = forKeyword3; | |
4890 } | |
4891 /** | |
4892 * Set the initialization expression to the given expression. | |
4893 * @param initialization the initialization expression | |
4894 */ | |
4895 void set initialization(Expression initialization2) { | |
4896 this._initialization = becomeParentOf(initialization2); | |
4897 } | |
4898 /** | |
4899 * Set the left parenthesis to the given token. | |
4900 * @param leftParenthesis the left parenthesis | |
4901 */ | |
4902 void set leftParenthesis(Token leftParenthesis4) { | |
4903 this._leftParenthesis = leftParenthesis4; | |
4904 } | |
4905 /** | |
4906 * Set the semicolon separating the initializer and the condition to the given
token. | |
4907 * @param leftSeparator the semicolon separating the initializer and the condi
tion | |
4908 */ | |
4909 void set leftSeparator(Token leftSeparator2) { | |
4910 this._leftSeparator = leftSeparator2; | |
4911 } | |
4912 /** | |
4913 * Set the right parenthesis to the given token. | |
4914 * @param rightParenthesis the right parenthesis | |
4915 */ | |
4916 void set rightParenthesis(Token rightParenthesis4) { | |
4917 this._rightParenthesis = rightParenthesis4; | |
4918 } | |
4919 /** | |
4920 * Set the semicolon separating the condition and the updater to the given tok
en. | |
4921 * @param rightSeparator the semicolon separating the condition and the update
r | |
4922 */ | |
4923 void set rightSeparator(Token rightSeparator2) { | |
4924 this._rightSeparator = rightSeparator2; | |
4925 } | |
4926 /** | |
4927 * Set the declaration of the loop variables to the given parameter. | |
4928 * @param variableList the declaration of the loop variables | |
4929 */ | |
4930 void set variables(VariableDeclarationList variableList) { | |
4931 variableList = becomeParentOf(variableList); | |
4932 } | |
4933 void visitChildren(ASTVisitor<Object> visitor) { | |
4934 safelyVisitChild(_variableList, visitor); | |
4935 safelyVisitChild(_initialization, visitor); | |
4936 safelyVisitChild(_condition, visitor); | |
4937 _updaters.accept(visitor); | |
4938 safelyVisitChild(_body, visitor); | |
4939 } | |
4940 } | |
4941 /** | |
4942 * The abstract class {@code FormalParameter} defines the behavior of objects re
presenting a | |
4943 * parameter to a function. | |
4944 * <pre> | |
4945 * formalParameter ::={@link NormalFormalParameter normalFormalParameter}| {@lin
k DefaultFormalParameter namedFormalParameter}| {@link DefaultFormalParameter op
tionalFormalParameter}</pre> | |
4946 * @coverage dart.engine.ast | |
4947 */ | |
4948 abstract class FormalParameter extends ASTNode { | |
4949 /** | |
4950 * Return the element representing this parameter, or {@code null} if this par
ameter has not been | |
4951 * resolved. | |
4952 * @return the element representing this parameter | |
4953 */ | |
4954 ParameterElement get element { | |
4955 SimpleIdentifier identifier12 = identifier; | |
4956 if (identifier12 == null) { | |
4957 return null; | |
4958 } | |
4959 return identifier12.element as ParameterElement; | |
4960 } | |
4961 /** | |
4962 * Return the name of the parameter being declared. | |
4963 * @return the name of the parameter being declared | |
4964 */ | |
4965 SimpleIdentifier get identifier; | |
4966 /** | |
4967 * Return the kind of this parameter. | |
4968 * @return the kind of this parameter | |
4969 */ | |
4970 ParameterKind get kind; | |
4971 } | |
4972 /** | |
4973 * Instances of the class {@code FormalParameterList} represent the formal param
eter list of a | |
4974 * method declaration, function declaration, or function type alias. | |
4975 * <p> | |
4976 * While the grammar requires all optional formal parameters to follow all of th
e normal formal | |
4977 * parameters and at most one grouping of optional formal parameters, this class
does not enforce | |
4978 * those constraints. All parameters are flattened into a single list, which can
have any or all | |
4979 * kinds of parameters (normal, named, and positional) in any order. | |
4980 * <pre> | |
4981 * formalParameterList ::= | |
4982 * '(' ')' | |
4983 * | '(' normalFormalParameters (',' optionalFormalParameters)? ')' | |
4984 * | '(' optionalFormalParameters ')' | |
4985 * normalFormalParameters ::={@link NormalFormalParameter normalFormalParameter}
(',' {@link NormalFormalParameter normalFormalParameter}) | |
4986 * optionalFormalParameters ::= | |
4987 * optionalPositionalFormalParameters | |
4988 * | namedFormalParameters | |
4989 * optionalPositionalFormalParameters ::= | |
4990 * '[' {@link DefaultFormalParameter positionalFormalParameter} (',' {@link Defa
ultFormalParameter positionalFormalParameter})* ']' | |
4991 * namedFormalParameters ::= | |
4992 * '{' {@link DefaultFormalParameter namedFormalParameter} (',' {@link DefaultFo
rmalParameter namedFormalParameter})* '}' | |
4993 * </pre> | |
4994 * @coverage dart.engine.ast | |
4995 */ | |
4996 class FormalParameterList extends ASTNode { | |
4997 /** | |
4998 * The left parenthesis. | |
4999 */ | |
5000 Token _leftParenthesis; | |
5001 /** | |
5002 * The parameters associated with the method. | |
5003 */ | |
5004 NodeList<FormalParameter> _parameters; | |
5005 /** | |
5006 * The left square bracket ('[') or left curly brace ('{') introducing the opt
ional parameters. | |
5007 */ | |
5008 Token _leftDelimiter; | |
5009 /** | |
5010 * The right square bracket (']') or right curly brace ('}') introducing the o
ptional parameters. | |
5011 */ | |
5012 Token _rightDelimiter; | |
5013 /** | |
5014 * The right parenthesis. | |
5015 */ | |
5016 Token _rightParenthesis; | |
5017 /** | |
5018 * Initialize a newly created parameter list. | |
5019 * @param leftParenthesis the left parenthesis | |
5020 * @param parameters the parameters associated with the method | |
5021 * @param leftDelimiter the left delimiter introducing the optional parameters | |
5022 * @param rightDelimiter the right delimiter introducing the optional paramete
rs | |
5023 * @param rightParenthesis the right parenthesis | |
5024 */ | |
5025 FormalParameterList.full(Token leftParenthesis, List<FormalParameter> paramete
rs, Token leftDelimiter, Token rightDelimiter, Token rightParenthesis) { | |
5026 this._parameters = new NodeList<FormalParameter>(this); | |
5027 this._leftParenthesis = leftParenthesis; | |
5028 this._parameters.addAll(parameters); | |
5029 this._leftDelimiter = leftDelimiter; | |
5030 this._rightDelimiter = rightDelimiter; | |
5031 this._rightParenthesis = rightParenthesis; | |
5032 } | |
5033 /** | |
5034 * Initialize a newly created parameter list. | |
5035 * @param leftParenthesis the left parenthesis | |
5036 * @param parameters the parameters associated with the method | |
5037 * @param leftDelimiter the left delimiter introducing the optional parameters | |
5038 * @param rightDelimiter the right delimiter introducing the optional paramete
rs | |
5039 * @param rightParenthesis the right parenthesis | |
5040 */ | |
5041 FormalParameterList({Token leftParenthesis, List<FormalParameter> parameters,
Token leftDelimiter, Token rightDelimiter, Token rightParenthesis}) : this.full(
leftParenthesis, parameters, leftDelimiter, rightDelimiter, rightParenthesis); | |
5042 accept(ASTVisitor visitor) => visitor.visitFormalParameterList(this); | |
5043 Token get beginToken => _leftParenthesis; | |
5044 /** | |
5045 * Return an array containing the elements representing the parameters in this
list. The array | |
5046 * will contain {@code null}s if the parameters in this list have not been res
olved. | |
5047 * @return the elements representing the parameters in this list | |
5048 */ | |
5049 List<ParameterElement> get elements { | |
5050 int count = _parameters.length; | |
5051 List<ParameterElement> types = new List<ParameterElement>(count); | |
5052 for (int i = 0; i < count; i++) { | |
5053 types[i] = _parameters[i].element; | |
5054 } | |
5055 return types; | |
5056 } | |
5057 Token get endToken => _rightParenthesis; | |
5058 /** | |
5059 * Return the left square bracket ('[') or left curly brace ('{') introducing
the optional | |
5060 * parameters. | |
5061 * @return the left square bracket ('[') or left curly brace ('{') introducing
the optional | |
5062 * parameters | |
5063 */ | |
5064 Token get leftDelimiter => _leftDelimiter; | |
5065 /** | |
5066 * Return the left parenthesis. | |
5067 * @return the left parenthesis | |
5068 */ | |
5069 Token get leftParenthesis => _leftParenthesis; | |
5070 /** | |
5071 * Return the parameters associated with the method. | |
5072 * @return the parameters associated with the method | |
5073 */ | |
5074 NodeList<FormalParameter> get parameters => _parameters; | |
5075 /** | |
5076 * Return the right square bracket (']') or right curly brace ('}') introducin
g the optional | |
5077 * parameters. | |
5078 * @return the right square bracket (']') or right curly brace ('}') introduci
ng the optional | |
5079 * parameters | |
5080 */ | |
5081 Token get rightDelimiter => _rightDelimiter; | |
5082 /** | |
5083 * Return the right parenthesis. | |
5084 * @return the right parenthesis | |
5085 */ | |
5086 Token get rightParenthesis => _rightParenthesis; | |
5087 /** | |
5088 * Set the left square bracket ('[') or left curly brace ('{') introducing the
optional parameters | |
5089 * to the given token. | |
5090 * @param bracket the left delimiter introducing the optional parameters | |
5091 */ | |
5092 void set leftDelimiter(Token bracket) { | |
5093 _leftDelimiter = bracket; | |
5094 } | |
5095 /** | |
5096 * Set the left parenthesis to the given token. | |
5097 * @param parenthesis the left parenthesis | |
5098 */ | |
5099 void set leftParenthesis(Token parenthesis) { | |
5100 _leftParenthesis = parenthesis; | |
5101 } | |
5102 /** | |
5103 * Set the right square bracket (']') or right curly brace ('}') introducing t
he optional | |
5104 * parameters to the given token. | |
5105 * @param bracket the right delimiter introducing the optional parameters | |
5106 */ | |
5107 void set rightDelimiter(Token bracket) { | |
5108 _rightDelimiter = bracket; | |
5109 } | |
5110 /** | |
5111 * Set the right parenthesis to the given token. | |
5112 * @param parenthesis the right parenthesis | |
5113 */ | |
5114 void set rightParenthesis(Token parenthesis) { | |
5115 _rightParenthesis = parenthesis; | |
5116 } | |
5117 void visitChildren(ASTVisitor<Object> visitor) { | |
5118 _parameters.accept(visitor); | |
5119 } | |
5120 } | |
5121 /** | |
5122 * The abstract class {@code FunctionBody} defines the behavior common to object
s representing the | |
5123 * body of a function or method. | |
5124 * <pre> | |
5125 * functionBody ::={@link BlockFunctionBody blockFunctionBody}| {@link EmptyFunc
tionBody emptyFunctionBody}| {@link ExpressionFunctionBody expressionFunctionBod
y}</pre> | |
5126 * @coverage dart.engine.ast | |
5127 */ | |
5128 abstract class FunctionBody extends ASTNode { | |
5129 } | |
5130 /** | |
5131 * Instances of the class {@code FunctionDeclaration} wrap a {@link FunctionExpr
ession function | |
5132 * expression} as a top-level declaration. | |
5133 * <pre> | |
5134 * functionDeclaration ::= | |
5135 * 'external' functionSignature | |
5136 * | functionSignature {@link FunctionBody functionBody}functionSignature ::={@l
ink Type returnType}? ('get' | 'set')? {@link SimpleIdentifier functionName} {@l
ink FormalParameterList formalParameterList}</pre> | |
5137 * @coverage dart.engine.ast | |
5138 */ | |
5139 class FunctionDeclaration extends CompilationUnitMember { | |
5140 /** | |
5141 * The token representing the 'external' keyword, or {@code null} if this is n
ot an external | |
5142 * function. | |
5143 */ | |
5144 Token _externalKeyword; | |
5145 /** | |
5146 * The return type of the function, or {@code null} if no return type was decl
ared. | |
5147 */ | |
5148 TypeName _returnType; | |
5149 /** | |
5150 * The token representing the 'get' or 'set' keyword, or {@code null} if this
is a function | |
5151 * declaration rather than a property declaration. | |
5152 */ | |
5153 Token _propertyKeyword; | |
5154 /** | |
5155 * The name of the function, or {@code null} if the function is not named. | |
5156 */ | |
5157 SimpleIdentifier _name; | |
5158 /** | |
5159 * The function expression being wrapped. | |
5160 */ | |
5161 FunctionExpression _functionExpression; | |
5162 /** | |
5163 * Initialize a newly created function declaration. | |
5164 * @param comment the documentation comment associated with this function | |
5165 * @param metadata the annotations associated with this function | |
5166 * @param externalKeyword the token representing the 'external' keyword | |
5167 * @param returnType the return type of the function | |
5168 * @param propertyKeyword the token representing the 'get' or 'set' keyword | |
5169 * @param name the name of the function | |
5170 * @param functionExpression the function expression being wrapped | |
5171 */ | |
5172 FunctionDeclaration.full(Comment comment, List<Annotation> metadata, Token ext
ernalKeyword, TypeName returnType, Token propertyKeyword, SimpleIdentifier name,
FunctionExpression functionExpression) : super.full(comment, metadata) { | |
5173 this._externalKeyword = externalKeyword; | |
5174 this._returnType = becomeParentOf(returnType); | |
5175 this._propertyKeyword = propertyKeyword; | |
5176 this._name = becomeParentOf(name); | |
5177 this._functionExpression = becomeParentOf(functionExpression); | |
5178 } | |
5179 /** | |
5180 * Initialize a newly created function declaration. | |
5181 * @param comment the documentation comment associated with this function | |
5182 * @param metadata the annotations associated with this function | |
5183 * @param externalKeyword the token representing the 'external' keyword | |
5184 * @param returnType the return type of the function | |
5185 * @param propertyKeyword the token representing the 'get' or 'set' keyword | |
5186 * @param name the name of the function | |
5187 * @param functionExpression the function expression being wrapped | |
5188 */ | |
5189 FunctionDeclaration({Comment comment, List<Annotation> metadata, Token externa
lKeyword, TypeName returnType, Token propertyKeyword, SimpleIdentifier name, Fun
ctionExpression functionExpression}) : this.full(comment, metadata, externalKeyw
ord, returnType, propertyKeyword, name, functionExpression); | |
5190 accept(ASTVisitor visitor) => visitor.visitFunctionDeclaration(this); | |
5191 ExecutableElement get element => _name != null ? (_name.element as ExecutableE
lement) : null; | |
5192 Token get endToken => _functionExpression.endToken; | |
5193 /** | |
5194 * Return the token representing the 'external' keyword, or {@code null} if th
is is not an | |
5195 * external function. | |
5196 * @return the token representing the 'external' keyword | |
5197 */ | |
5198 Token get externalKeyword => _externalKeyword; | |
5199 /** | |
5200 * Return the function expression being wrapped. | |
5201 * @return the function expression being wrapped | |
5202 */ | |
5203 FunctionExpression get functionExpression => _functionExpression; | |
5204 /** | |
5205 * Return the name of the function, or {@code null} if the function is not nam
ed. | |
5206 * @return the name of the function | |
5207 */ | |
5208 SimpleIdentifier get name => _name; | |
5209 /** | |
5210 * Return the token representing the 'get' or 'set' keyword, or {@code null} i
f this is a function | |
5211 * declaration rather than a property declaration. | |
5212 * @return the token representing the 'get' or 'set' keyword | |
5213 */ | |
5214 Token get propertyKeyword => _propertyKeyword; | |
5215 /** | |
5216 * Return the return type of the function, or {@code null} if no return type w
as declared. | |
5217 * @return the return type of the function | |
5218 */ | |
5219 TypeName get returnType => _returnType; | |
5220 /** | |
5221 * Set the token representing the 'external' keyword to the given token. | |
5222 * @param externalKeyword the token representing the 'external' keyword | |
5223 */ | |
5224 void set externalKeyword(Token externalKeyword3) { | |
5225 this._externalKeyword = externalKeyword3; | |
5226 } | |
5227 /** | |
5228 * Set the function expression being wrapped to the given function expression. | |
5229 * @param functionExpression the function expression being wrapped | |
5230 */ | |
5231 void set functionExpression(FunctionExpression functionExpression3) { | |
5232 functionExpression3 = becomeParentOf(functionExpression3); | |
5233 } | |
5234 /** | |
5235 * Set the name of the function to the given identifier. | |
5236 * @param identifier the name of the function | |
5237 */ | |
5238 void set name(SimpleIdentifier identifier) { | |
5239 _name = becomeParentOf(identifier); | |
5240 } | |
5241 /** | |
5242 * Set the token representing the 'get' or 'set' keyword to the given token. | |
5243 * @param propertyKeyword the token representing the 'get' or 'set' keyword | |
5244 */ | |
5245 void set propertyKeyword(Token propertyKeyword2) { | |
5246 this._propertyKeyword = propertyKeyword2; | |
5247 } | |
5248 /** | |
5249 * Set the return type of the function to the given name. | |
5250 * @param name the return type of the function | |
5251 */ | |
5252 void set returnType(TypeName name) { | |
5253 _returnType = becomeParentOf(name); | |
5254 } | |
5255 void visitChildren(ASTVisitor<Object> visitor) { | |
5256 super.visitChildren(visitor); | |
5257 safelyVisitChild(_returnType, visitor); | |
5258 safelyVisitChild(_name, visitor); | |
5259 safelyVisitChild(_functionExpression, visitor); | |
5260 } | |
5261 Token get firstTokenAfterCommentAndMetadata { | |
5262 if (_externalKeyword != null) { | |
5263 return _externalKeyword; | |
5264 } | |
5265 if (_returnType != null) { | |
5266 return _returnType.beginToken; | |
5267 } else if (_propertyKeyword != null) { | |
5268 return _propertyKeyword; | |
5269 } else if (_name != null) { | |
5270 return _name.beginToken; | |
5271 } | |
5272 return _functionExpression.beginToken; | |
5273 } | |
5274 } | |
5275 /** | |
5276 * Instances of the class {@code FunctionDeclarationStatement} wrap a {@link Fun
ctionDeclarationfunction declaration} as a statement. | |
5277 * @coverage dart.engine.ast | |
5278 */ | |
5279 class FunctionDeclarationStatement extends Statement { | |
5280 /** | |
5281 * The function declaration being wrapped. | |
5282 */ | |
5283 FunctionDeclaration _functionDeclaration; | |
5284 /** | |
5285 * Initialize a newly created function declaration statement. | |
5286 * @param functionDeclaration the the function declaration being wrapped | |
5287 */ | |
5288 FunctionDeclarationStatement.full(FunctionDeclaration functionDeclaration) { | |
5289 this._functionDeclaration = becomeParentOf(functionDeclaration); | |
5290 } | |
5291 /** | |
5292 * Initialize a newly created function declaration statement. | |
5293 * @param functionDeclaration the the function declaration being wrapped | |
5294 */ | |
5295 FunctionDeclarationStatement({FunctionDeclaration functionDeclaration}) : this
.full(functionDeclaration); | |
5296 accept(ASTVisitor visitor) => visitor.visitFunctionDeclarationStatement(this); | |
5297 Token get beginToken => _functionDeclaration.beginToken; | |
5298 Token get endToken => _functionDeclaration.endToken; | |
5299 /** | |
5300 * Return the function declaration being wrapped. | |
5301 * @return the function declaration being wrapped | |
5302 */ | |
5303 FunctionDeclaration get functionDeclaration => _functionDeclaration; | |
5304 /** | |
5305 * Set the function declaration being wrapped to the given function declaratio
n. | |
5306 * @param functionDeclaration the function declaration being wrapped | |
5307 */ | |
5308 void set functionExpression(FunctionDeclaration functionDeclaration2) { | |
5309 this._functionDeclaration = becomeParentOf(functionDeclaration2); | |
5310 } | |
5311 void visitChildren(ASTVisitor<Object> visitor) { | |
5312 safelyVisitChild(_functionDeclaration, visitor); | |
5313 } | |
5314 } | |
5315 /** | |
5316 * Instances of the class {@code FunctionExpression} represent a function expres
sion. | |
5317 * <pre> | |
5318 * functionExpression ::={@link FormalParameterList formalParameterList} {@link
FunctionBody functionBody}</pre> | |
5319 * @coverage dart.engine.ast | |
5320 */ | |
5321 class FunctionExpression extends Expression { | |
5322 /** | |
5323 * The parameters associated with the function. | |
5324 */ | |
5325 FormalParameterList _parameters; | |
5326 /** | |
5327 * The body of the function, or {@code null} if this is an external function. | |
5328 */ | |
5329 FunctionBody _body; | |
5330 /** | |
5331 * The element associated with the function, or {@code null} if the AST struct
ure has not been | |
5332 * resolved. | |
5333 */ | |
5334 ExecutableElement _element; | |
5335 /** | |
5336 * Initialize a newly created function declaration. | |
5337 * @param parameters the parameters associated with the function | |
5338 * @param body the body of the function | |
5339 */ | |
5340 FunctionExpression.full(FormalParameterList parameters, FunctionBody body) { | |
5341 this._parameters = becomeParentOf(parameters); | |
5342 this._body = becomeParentOf(body); | |
5343 } | |
5344 /** | |
5345 * Initialize a newly created function declaration. | |
5346 * @param parameters the parameters associated with the function | |
5347 * @param body the body of the function | |
5348 */ | |
5349 FunctionExpression({FormalParameterList parameters, FunctionBody body}) : this
.full(parameters, body); | |
5350 accept(ASTVisitor visitor) => visitor.visitFunctionExpression(this); | |
5351 Token get beginToken { | |
5352 if (_parameters != null) { | |
5353 return _parameters.beginToken; | |
5354 } else if (_body != null) { | |
5355 return _body.beginToken; | |
5356 } | |
5357 throw new IllegalStateException("Non-external functions must have a body"); | |
5358 } | |
5359 /** | |
5360 * Return the body of the function, or {@code null} if this is an external fun
ction. | |
5361 * @return the body of the function | |
5362 */ | |
5363 FunctionBody get body => _body; | |
5364 /** | |
5365 * Return the element associated with this function, or {@code null} if the AS
T structure has not | |
5366 * been resolved. | |
5367 * @return the element associated with this function | |
5368 */ | |
5369 ExecutableElement get element => _element; | |
5370 Token get endToken { | |
5371 if (_body != null) { | |
5372 return _body.endToken; | |
5373 } else if (_parameters != null) { | |
5374 return _parameters.endToken; | |
5375 } | |
5376 throw new IllegalStateException("Non-external functions must have a body"); | |
5377 } | |
5378 /** | |
5379 * Return the parameters associated with the function. | |
5380 * @return the parameters associated with the function | |
5381 */ | |
5382 FormalParameterList get parameters => _parameters; | |
5383 /** | |
5384 * Set the body of the function to the given function body. | |
5385 * @param functionBody the body of the function | |
5386 */ | |
5387 void set body(FunctionBody functionBody) { | |
5388 _body = becomeParentOf(functionBody); | |
5389 } | |
5390 /** | |
5391 * Set the element associated with this function to the given element. | |
5392 * @param element the element associated with this function | |
5393 */ | |
5394 void set element(ExecutableElement element9) { | |
5395 this._element = element9; | |
5396 } | |
5397 /** | |
5398 * Set the parameters associated with the function to the given list of parame
ters. | |
5399 * @param parameters the parameters associated with the function | |
5400 */ | |
5401 void set parameters(FormalParameterList parameters3) { | |
5402 this._parameters = becomeParentOf(parameters3); | |
5403 } | |
5404 void visitChildren(ASTVisitor<Object> visitor) { | |
5405 safelyVisitChild(_parameters, visitor); | |
5406 safelyVisitChild(_body, visitor); | |
5407 } | |
5408 } | |
5409 /** | |
5410 * Instances of the class {@code FunctionExpressionInvocation} represent the inv
ocation of a | |
5411 * function resulting from evaluating an expression. Invocations of methods and
other forms of | |
5412 * functions are represented by {@link MethodInvocation method invocation} nodes
. Invocations of | |
5413 * getters and setters are represented by either {@link PrefixedIdentifier prefi
xed identifier} or{@link PropertyAccess property access} nodes. | |
5414 * <pre> | |
5415 * functionExpressionInvoction ::={@link Expression function} {@link ArgumentLis
t argumentList}</pre> | |
5416 * @coverage dart.engine.ast | |
5417 */ | |
5418 class FunctionExpressionInvocation extends Expression { | |
5419 /** | |
5420 * The expression producing the function being invoked. | |
5421 */ | |
5422 Expression _function; | |
5423 /** | |
5424 * The list of arguments to the function. | |
5425 */ | |
5426 ArgumentList _argumentList; | |
5427 /** | |
5428 * The element associated with the function being invoked, or {@code null} if
the AST structure | |
5429 * has not been resolved or the function could not be resolved. | |
5430 */ | |
5431 ExecutableElement _element; | |
5432 /** | |
5433 * Initialize a newly created function expression invocation. | |
5434 * @param function the expression producing the function being invoked | |
5435 * @param argumentList the list of arguments to the method | |
5436 */ | |
5437 FunctionExpressionInvocation.full(Expression function, ArgumentList argumentLi
st) { | |
5438 this._function = becomeParentOf(function); | |
5439 this._argumentList = becomeParentOf(argumentList); | |
5440 } | |
5441 /** | |
5442 * Initialize a newly created function expression invocation. | |
5443 * @param function the expression producing the function being invoked | |
5444 * @param argumentList the list of arguments to the method | |
5445 */ | |
5446 FunctionExpressionInvocation({Expression function, ArgumentList argumentList})
: this.full(function, argumentList); | |
5447 accept(ASTVisitor visitor) => visitor.visitFunctionExpressionInvocation(this); | |
5448 /** | |
5449 * Return the list of arguments to the method. | |
5450 * @return the list of arguments to the method | |
5451 */ | |
5452 ArgumentList get argumentList => _argumentList; | |
5453 Token get beginToken => _function.beginToken; | |
5454 /** | |
5455 * Return the element associated with the function being invoked, or {@code nu
ll} if the AST | |
5456 * structure has not been resolved or the function could not be resolved. One
common example of | |
5457 * the latter case is an expression whose value can change over time. | |
5458 * @return the element associated with the function being invoked | |
5459 */ | |
5460 ExecutableElement get element => _element; | |
5461 Token get endToken => _argumentList.endToken; | |
5462 /** | |
5463 * Return the expression producing the function being invoked. | |
5464 * @return the expression producing the function being invoked | |
5465 */ | |
5466 Expression get function => _function; | |
5467 /** | |
5468 * Set the list of arguments to the method to the given list. | |
5469 * @param argumentList the list of arguments to the method | |
5470 */ | |
5471 void set argumentList(ArgumentList argumentList5) { | |
5472 this._argumentList = becomeParentOf(argumentList5); | |
5473 } | |
5474 /** | |
5475 * Set the element associated with the function being invoked to the given ele
ment. | |
5476 * @param element the element associated with the function being invoked | |
5477 */ | |
5478 void set element(ExecutableElement element10) { | |
5479 this._element = element10; | |
5480 } | |
5481 /** | |
5482 * Set the expression producing the function being invoked to the given expres
sion. | |
5483 * @param function the expression producing the function being invoked | |
5484 */ | |
5485 void set function(Expression function2) { | |
5486 function2 = becomeParentOf(function2); | |
5487 } | |
5488 void visitChildren(ASTVisitor<Object> visitor) { | |
5489 safelyVisitChild(_function, visitor); | |
5490 safelyVisitChild(_argumentList, visitor); | |
5491 } | |
5492 } | |
5493 /** | |
5494 * Instances of the class {@code FunctionTypeAlias} represent a function type al
ias. | |
5495 * <pre> | |
5496 * functionTypeAlias ::= | |
5497 * functionPrefix {@link TypeParameterList typeParameterList}? {@link FormalPara
meterList formalParameterList} ';' | |
5498 * functionPrefix ::={@link TypeName returnType}? {@link SimpleIdentifier name}<
/pre> | |
5499 * @coverage dart.engine.ast | |
5500 */ | |
5501 class FunctionTypeAlias extends TypeAlias { | |
5502 /** | |
5503 * The name of the return type of the function type being defined, or {@code n
ull} if no return | |
5504 * type was given. | |
5505 */ | |
5506 TypeName _returnType; | |
5507 /** | |
5508 * The name of the function type being declared. | |
5509 */ | |
5510 SimpleIdentifier _name; | |
5511 /** | |
5512 * The type parameters for the function type, or {@code null} if the function
type does not have | |
5513 * any type parameters. | |
5514 */ | |
5515 TypeParameterList _typeParameters; | |
5516 /** | |
5517 * The parameters associated with the function type. | |
5518 */ | |
5519 FormalParameterList _parameters; | |
5520 /** | |
5521 * Initialize a newly created function type alias. | |
5522 * @param comment the documentation comment associated with this type alias | |
5523 * @param metadata the annotations associated with this type alias | |
5524 * @param keyword the token representing the 'typedef' keyword | |
5525 * @param returnType the name of the return type of the function type being de
fined | |
5526 * @param name the name of the type being declared | |
5527 * @param typeParameters the type parameters for the type | |
5528 * @param parameters the parameters associated with the function | |
5529 * @param semicolon the semicolon terminating the declaration | |
5530 */ | |
5531 FunctionTypeAlias.full(Comment comment, List<Annotation> metadata, Token keywo
rd, TypeName returnType, SimpleIdentifier name, TypeParameterList typeParameters
, FormalParameterList parameters, Token semicolon) : super.full(comment, metadat
a, keyword, semicolon) { | |
5532 this._returnType = becomeParentOf(returnType); | |
5533 this._name = becomeParentOf(name); | |
5534 this._typeParameters = becomeParentOf(typeParameters); | |
5535 this._parameters = becomeParentOf(parameters); | |
5536 } | |
5537 /** | |
5538 * Initialize a newly created function type alias. | |
5539 * @param comment the documentation comment associated with this type alias | |
5540 * @param metadata the annotations associated with this type alias | |
5541 * @param keyword the token representing the 'typedef' keyword | |
5542 * @param returnType the name of the return type of the function type being de
fined | |
5543 * @param name the name of the type being declared | |
5544 * @param typeParameters the type parameters for the type | |
5545 * @param parameters the parameters associated with the function | |
5546 * @param semicolon the semicolon terminating the declaration | |
5547 */ | |
5548 FunctionTypeAlias({Comment comment, List<Annotation> metadata, Token keyword,
TypeName returnType, SimpleIdentifier name, TypeParameterList typeParameters, Fo
rmalParameterList parameters, Token semicolon}) : this.full(comment, metadata, k
eyword, returnType, name, typeParameters, parameters, semicolon); | |
5549 accept(ASTVisitor visitor) => visitor.visitFunctionTypeAlias(this); | |
5550 TypeAliasElement get element => _name != null ? (_name.element as TypeAliasEle
ment) : null; | |
5551 /** | |
5552 * Return the name of the function type being declared. | |
5553 * @return the name of the function type being declared | |
5554 */ | |
5555 SimpleIdentifier get name => _name; | |
5556 /** | |
5557 * Return the parameters associated with the function type. | |
5558 * @return the parameters associated with the function type | |
5559 */ | |
5560 FormalParameterList get parameters => _parameters; | |
5561 /** | |
5562 * Return the name of the return type of the function type being defined, or {
@code null} if no | |
5563 * return type was given. | |
5564 * @return the name of the return type of the function type being defined | |
5565 */ | |
5566 TypeName get returnType => _returnType; | |
5567 /** | |
5568 * Return the type parameters for the function type, or {@code null} if the fu
nction type does not | |
5569 * have any type parameters. | |
5570 * @return the type parameters for the function type | |
5571 */ | |
5572 TypeParameterList get typeParameters => _typeParameters; | |
5573 /** | |
5574 * Set the name of the function type being declared to the given identifier. | |
5575 * @param name the name of the function type being declared | |
5576 */ | |
5577 void set name(SimpleIdentifier name5) { | |
5578 this._name = becomeParentOf(name5); | |
5579 } | |
5580 /** | |
5581 * Set the parameters associated with the function type to the given list of p
arameters. | |
5582 * @param parameters the parameters associated with the function type | |
5583 */ | |
5584 void set parameters(FormalParameterList parameters4) { | |
5585 this._parameters = becomeParentOf(parameters4); | |
5586 } | |
5587 /** | |
5588 * Set the name of the return type of the function type being defined to the g
iven type name. | |
5589 * @param typeName the name of the return type of the function type being defi
ned | |
5590 */ | |
5591 void set returnType(TypeName typeName) { | |
5592 _returnType = becomeParentOf(typeName); | |
5593 } | |
5594 /** | |
5595 * Set the type parameters for the function type to the given list of paramete
rs. | |
5596 * @param typeParameters the type parameters for the function type | |
5597 */ | |
5598 void set typeParameters(TypeParameterList typeParameters4) { | |
5599 this._typeParameters = becomeParentOf(typeParameters4); | |
5600 } | |
5601 void visitChildren(ASTVisitor<Object> visitor) { | |
5602 super.visitChildren(visitor); | |
5603 safelyVisitChild(_returnType, visitor); | |
5604 safelyVisitChild(_name, visitor); | |
5605 safelyVisitChild(_typeParameters, visitor); | |
5606 safelyVisitChild(_parameters, visitor); | |
5607 } | |
5608 } | |
5609 /** | |
5610 * Instances of the class {@code FunctionTypedFormalParameter} represent a funct
ion-typed formal | |
5611 * parameter. | |
5612 * <pre> | |
5613 * functionSignature ::={@link TypeName returnType}? {@link SimpleIdentifier ide
ntifier} {@link FormalParameterList formalParameterList}</pre> | |
5614 * @coverage dart.engine.ast | |
5615 */ | |
5616 class FunctionTypedFormalParameter extends NormalFormalParameter { | |
5617 /** | |
5618 * The return type of the function, or {@code null} if the function does not h
ave a return type. | |
5619 */ | |
5620 TypeName _returnType; | |
5621 /** | |
5622 * The parameters of the function-typed parameter. | |
5623 */ | |
5624 FormalParameterList _parameters; | |
5625 /** | |
5626 * Initialize a newly created formal parameter. | |
5627 * @param comment the documentation comment associated with this parameter | |
5628 * @param metadata the annotations associated with this parameter | |
5629 * @param returnType the return type of the function, or {@code null} if the f
unction does not | |
5630 * have a return type | |
5631 * @param identifier the name of the function-typed parameter | |
5632 * @param parameters the parameters of the function-typed parameter | |
5633 */ | |
5634 FunctionTypedFormalParameter.full(Comment comment, List<Annotation> metadata,
TypeName returnType, SimpleIdentifier identifier, FormalParameterList parameters
) : super.full(comment, metadata, identifier) { | |
5635 this._returnType = becomeParentOf(returnType); | |
5636 this._parameters = becomeParentOf(parameters); | |
5637 } | |
5638 /** | |
5639 * Initialize a newly created formal parameter. | |
5640 * @param comment the documentation comment associated with this parameter | |
5641 * @param metadata the annotations associated with this parameter | |
5642 * @param returnType the return type of the function, or {@code null} if the f
unction does not | |
5643 * have a return type | |
5644 * @param identifier the name of the function-typed parameter | |
5645 * @param parameters the parameters of the function-typed parameter | |
5646 */ | |
5647 FunctionTypedFormalParameter({Comment comment, List<Annotation> metadata, Type
Name returnType, SimpleIdentifier identifier, FormalParameterList parameters}) :
this.full(comment, metadata, returnType, identifier, parameters); | |
5648 accept(ASTVisitor visitor) => visitor.visitFunctionTypedFormalParameter(this); | |
5649 Token get beginToken { | |
5650 if (_returnType != null) { | |
5651 return _returnType.beginToken; | |
5652 } | |
5653 return identifier.beginToken; | |
5654 } | |
5655 Token get endToken => _parameters.endToken; | |
5656 /** | |
5657 * Return the parameters of the function-typed parameter. | |
5658 * @return the parameters of the function-typed parameter | |
5659 */ | |
5660 FormalParameterList get parameters => _parameters; | |
5661 /** | |
5662 * Return the return type of the function, or {@code null} if the function doe
s not have a return | |
5663 * type. | |
5664 * @return the return type of the function | |
5665 */ | |
5666 TypeName get returnType => _returnType; | |
5667 bool isConst() => false; | |
5668 bool isFinal() => false; | |
5669 /** | |
5670 * Set the parameters of the function-typed parameter to the given parameters. | |
5671 * @param parameters the parameters of the function-typed parameter | |
5672 */ | |
5673 void set parameters(FormalParameterList parameters5) { | |
5674 this._parameters = becomeParentOf(parameters5); | |
5675 } | |
5676 /** | |
5677 * Set the return type of the function to the given type. | |
5678 * @param returnType the return type of the function | |
5679 */ | |
5680 void set returnType(TypeName returnType2) { | |
5681 this._returnType = becomeParentOf(returnType2); | |
5682 } | |
5683 void visitChildren(ASTVisitor<Object> visitor) { | |
5684 super.visitChildren(visitor); | |
5685 safelyVisitChild(_returnType, visitor); | |
5686 safelyVisitChild(identifier, visitor); | |
5687 safelyVisitChild(_parameters, visitor); | |
5688 } | |
5689 } | |
5690 /** | |
5691 * Instances of the class {@code HideCombinator} represent a combinator that res
tricts the names | |
5692 * being imported to those that are not in a given list. | |
5693 * <pre> | |
5694 * hideCombinator ::= | |
5695 * 'hide' {@link SimpleIdentifier identifier} (',' {@link SimpleIdentifier ident
ifier}) | |
5696 * </pre> | |
5697 * @coverage dart.engine.ast | |
5698 */ | |
5699 class HideCombinator extends Combinator { | |
5700 /** | |
5701 * The list of names from the library that are hidden by this combinator. | |
5702 */ | |
5703 NodeList<SimpleIdentifier> _hiddenNames; | |
5704 /** | |
5705 * Initialize a newly created import show combinator. | |
5706 * @param keyword the comma introducing the combinator | |
5707 * @param hiddenNames the list of names from the library that are hidden by th
is combinator | |
5708 */ | |
5709 HideCombinator.full(Token keyword, List<SimpleIdentifier> hiddenNames) : super
.full(keyword) { | |
5710 this._hiddenNames = new NodeList<SimpleIdentifier>(this); | |
5711 this._hiddenNames.addAll(hiddenNames); | |
5712 } | |
5713 /** | |
5714 * Initialize a newly created import show combinator. | |
5715 * @param keyword the comma introducing the combinator | |
5716 * @param hiddenNames the list of names from the library that are hidden by th
is combinator | |
5717 */ | |
5718 HideCombinator({Token keyword, List<SimpleIdentifier> hiddenNames}) : this.ful
l(keyword, hiddenNames); | |
5719 accept(ASTVisitor visitor) => visitor.visitHideCombinator(this); | |
5720 Token get endToken => _hiddenNames.endToken; | |
5721 /** | |
5722 * Return the list of names from the library that are hidden by this combinato
r. | |
5723 * @return the list of names from the library that are hidden by this combinat
or | |
5724 */ | |
5725 NodeList<SimpleIdentifier> get hiddenNames => _hiddenNames; | |
5726 void visitChildren(ASTVisitor<Object> visitor) { | |
5727 _hiddenNames.accept(visitor); | |
5728 } | |
5729 } | |
5730 /** | |
5731 * The abstract class {@code Identifier} defines the behavior common to nodes th
at represent an | |
5732 * identifier. | |
5733 * <pre> | |
5734 * identifier ::={@link SimpleIdentifier simpleIdentifier}| {@link PrefixedIdent
ifier prefixedIdentifier}</pre> | |
5735 * @coverage dart.engine.ast | |
5736 */ | |
5737 abstract class Identifier extends Expression { | |
5738 /** | |
5739 * Return {@code true} if the given name is visible only within the library in
which it is | |
5740 * declared. | |
5741 * @param name the name being tested | |
5742 * @return {@code true} if the given name is private | |
5743 */ | |
5744 static bool isPrivateName(String name) => name.startsWith("_"); | |
5745 /** | |
5746 * Return the element associated with this identifier, or {@code null} if the
AST structure has | |
5747 * not been resolved or if this identifier could not be resolved. One example
of the latter case | |
5748 * is an identifier that is not defined within the scope in which it appears. | |
5749 * @return the element associated with this identifier | |
5750 */ | |
5751 Element get element; | |
5752 /** | |
5753 * Return the lexical representation of the identifier. | |
5754 * @return the lexical representation of the identifier | |
5755 */ | |
5756 String get name; | |
5757 bool isAssignable() => true; | |
5758 } | |
5759 /** | |
5760 * Instances of the class {@code IfStatement} represent an if statement. | |
5761 * <pre> | |
5762 * ifStatement ::= | |
5763 * 'if' '(' {@link Expression expression} ')' {@link Statement thenStatement} ('
else' {@link Statement elseStatement})? | |
5764 * </pre> | |
5765 * @coverage dart.engine.ast | |
5766 */ | |
5767 class IfStatement extends Statement { | |
5768 /** | |
5769 * The token representing the 'if' keyword. | |
5770 */ | |
5771 Token _ifKeyword; | |
5772 /** | |
5773 * The left parenthesis. | |
5774 */ | |
5775 Token _leftParenthesis; | |
5776 /** | |
5777 * The condition used to determine which of the statements is executed next. | |
5778 */ | |
5779 Expression _condition; | |
5780 /** | |
5781 * The right parenthesis. | |
5782 */ | |
5783 Token _rightParenthesis; | |
5784 /** | |
5785 * The statement that is executed if the condition evaluates to {@code true}. | |
5786 */ | |
5787 Statement _thenStatement; | |
5788 /** | |
5789 * The token representing the 'else' keyword. | |
5790 */ | |
5791 Token _elseKeyword; | |
5792 /** | |
5793 * The statement that is executed if the condition evaluates to {@code false},
or {@code null} if | |
5794 * there is no else statement. | |
5795 */ | |
5796 Statement _elseStatement; | |
5797 /** | |
5798 * Initialize a newly created if statement. | |
5799 * @param ifKeyword the token representing the 'if' keyword | |
5800 * @param leftParenthesis the left parenthesis | |
5801 * @param condition the condition used to determine which of the statements is
executed next | |
5802 * @param rightParenthesis the right parenthesis | |
5803 * @param thenStatement the statement that is executed if the condition evalua
tes to {@code true} | |
5804 * @param elseKeyword the token representing the 'else' keyword | |
5805 * @param elseStatement the statement that is executed if the condition evalua
tes to {@code false} | |
5806 */ | |
5807 IfStatement.full(Token ifKeyword, Token leftParenthesis, Expression condition,
Token rightParenthesis, Statement thenStatement, Token elseKeyword, Statement e
lseStatement) { | |
5808 this._ifKeyword = ifKeyword; | |
5809 this._leftParenthesis = leftParenthesis; | |
5810 this._condition = becomeParentOf(condition); | |
5811 this._rightParenthesis = rightParenthesis; | |
5812 this._thenStatement = becomeParentOf(thenStatement); | |
5813 this._elseKeyword = elseKeyword; | |
5814 this._elseStatement = becomeParentOf(elseStatement); | |
5815 } | |
5816 /** | |
5817 * Initialize a newly created if statement. | |
5818 * @param ifKeyword the token representing the 'if' keyword | |
5819 * @param leftParenthesis the left parenthesis | |
5820 * @param condition the condition used to determine which of the statements is
executed next | |
5821 * @param rightParenthesis the right parenthesis | |
5822 * @param thenStatement the statement that is executed if the condition evalua
tes to {@code true} | |
5823 * @param elseKeyword the token representing the 'else' keyword | |
5824 * @param elseStatement the statement that is executed if the condition evalua
tes to {@code false} | |
5825 */ | |
5826 IfStatement({Token ifKeyword, Token leftParenthesis, Expression condition, Tok
en rightParenthesis, Statement thenStatement, Token elseKeyword, Statement elseS
tatement}) : this.full(ifKeyword, leftParenthesis, condition, rightParenthesis,
thenStatement, elseKeyword, elseStatement); | |
5827 accept(ASTVisitor visitor) => visitor.visitIfStatement(this); | |
5828 Token get beginToken => _ifKeyword; | |
5829 /** | |
5830 * Return the condition used to determine which of the statements is executed
next. | |
5831 * @return the condition used to determine which statement is executed next | |
5832 */ | |
5833 Expression get condition => _condition; | |
5834 /** | |
5835 * Return the token representing the 'else' keyword. | |
5836 * @return the token representing the 'else' keyword | |
5837 */ | |
5838 Token get elseKeyword => _elseKeyword; | |
5839 /** | |
5840 * Return the statement that is executed if the condition evaluates to {@code
false}, or{@code null} if there is no else statement. | |
5841 * @return the statement that is executed if the condition evaluates to {@code
false} | |
5842 */ | |
5843 Statement get elseStatement => _elseStatement; | |
5844 Token get endToken { | |
5845 if (_elseStatement != null) { | |
5846 return _elseStatement.endToken; | |
5847 } | |
5848 return _thenStatement.endToken; | |
5849 } | |
5850 /** | |
5851 * Return the token representing the 'if' keyword. | |
5852 * @return the token representing the 'if' keyword | |
5853 */ | |
5854 Token get ifKeyword => _ifKeyword; | |
5855 /** | |
5856 * Return the left parenthesis. | |
5857 * @return the left parenthesis | |
5858 */ | |
5859 Token get leftParenthesis => _leftParenthesis; | |
5860 /** | |
5861 * Return the right parenthesis. | |
5862 * @return the right parenthesis | |
5863 */ | |
5864 Token get rightParenthesis => _rightParenthesis; | |
5865 /** | |
5866 * Return the statement that is executed if the condition evaluates to {@code
true}. | |
5867 * @return the statement that is executed if the condition evaluates to {@code
true} | |
5868 */ | |
5869 Statement get thenStatement => _thenStatement; | |
5870 /** | |
5871 * Set the condition used to determine which of the statements is executed nex
t to the given | |
5872 * expression. | |
5873 * @param expression the condition used to determine which statement is execut
ed next | |
5874 */ | |
5875 void set condition(Expression expression) { | |
5876 _condition = becomeParentOf(expression); | |
5877 } | |
5878 /** | |
5879 * Set the token representing the 'else' keyword to the given token. | |
5880 * @param elseKeyword the token representing the 'else' keyword | |
5881 */ | |
5882 void set elseKeyword(Token elseKeyword2) { | |
5883 this._elseKeyword = elseKeyword2; | |
5884 } | |
5885 /** | |
5886 * Set the statement that is executed if the condition evaluates to {@code fal
se} to the given | |
5887 * statement. | |
5888 * @param statement the statement that is executed if the condition evaluates
to {@code false} | |
5889 */ | |
5890 void set elseStatement(Statement statement) { | |
5891 _elseStatement = becomeParentOf(statement); | |
5892 } | |
5893 /** | |
5894 * Set the token representing the 'if' keyword to the given token. | |
5895 * @param ifKeyword the token representing the 'if' keyword | |
5896 */ | |
5897 void set ifKeyword(Token ifKeyword2) { | |
5898 this._ifKeyword = ifKeyword2; | |
5899 } | |
5900 /** | |
5901 * Set the left parenthesis to the given token. | |
5902 * @param leftParenthesis the left parenthesis | |
5903 */ | |
5904 void set leftParenthesis(Token leftParenthesis5) { | |
5905 this._leftParenthesis = leftParenthesis5; | |
5906 } | |
5907 /** | |
5908 * Set the right parenthesis to the given token. | |
5909 * @param rightParenthesis the right parenthesis | |
5910 */ | |
5911 void set rightParenthesis(Token rightParenthesis5) { | |
5912 this._rightParenthesis = rightParenthesis5; | |
5913 } | |
5914 /** | |
5915 * Set the statement that is executed if the condition evaluates to {@code tru
e} to the given | |
5916 * statement. | |
5917 * @param statement the statement that is executed if the condition evaluates
to {@code true} | |
5918 */ | |
5919 void set thenStatement(Statement statement) { | |
5920 _thenStatement = becomeParentOf(statement); | |
5921 } | |
5922 void visitChildren(ASTVisitor<Object> visitor) { | |
5923 safelyVisitChild(_condition, visitor); | |
5924 safelyVisitChild(_thenStatement, visitor); | |
5925 safelyVisitChild(_elseStatement, visitor); | |
5926 } | |
5927 } | |
5928 /** | |
5929 * Instances of the class {@code ImplementsClause} represent the "implements" cl
ause in an class | |
5930 * declaration. | |
5931 * <pre> | |
5932 * implementsClause ::= | |
5933 * 'implements' {@link TypeName superclass} (',' {@link TypeName superclass}) | |
5934 * </pre> | |
5935 * @coverage dart.engine.ast | |
5936 */ | |
5937 class ImplementsClause extends ASTNode { | |
5938 /** | |
5939 * The token representing the 'implements' keyword. | |
5940 */ | |
5941 Token _keyword; | |
5942 /** | |
5943 * The interfaces that are being implemented. | |
5944 */ | |
5945 NodeList<TypeName> _interfaces; | |
5946 /** | |
5947 * Initialize a newly created extends clause. | |
5948 * @param keyword the token representing the 'implements' keyword | |
5949 * @param interfaces the interfaces that are being implemented | |
5950 */ | |
5951 ImplementsClause.full(Token keyword, List<TypeName> interfaces) { | |
5952 this._interfaces = new NodeList<TypeName>(this); | |
5953 this._keyword = keyword; | |
5954 this._interfaces.addAll(interfaces); | |
5955 } | |
5956 /** | |
5957 * Initialize a newly created extends clause. | |
5958 * @param keyword the token representing the 'implements' keyword | |
5959 * @param interfaces the interfaces that are being implemented | |
5960 */ | |
5961 ImplementsClause({Token keyword, List<TypeName> interfaces}) : this.full(keywo
rd, interfaces); | |
5962 accept(ASTVisitor visitor) => visitor.visitImplementsClause(this); | |
5963 Token get beginToken => _keyword; | |
5964 Token get endToken => _interfaces.endToken; | |
5965 /** | |
5966 * Return the list of the interfaces that are being implemented. | |
5967 * @return the list of the interfaces that are being implemented | |
5968 */ | |
5969 NodeList<TypeName> get interfaces => _interfaces; | |
5970 /** | |
5971 * Return the token representing the 'implements' keyword. | |
5972 * @return the token representing the 'implements' keyword | |
5973 */ | |
5974 Token get keyword => _keyword; | |
5975 /** | |
5976 * Set the token representing the 'implements' keyword to the given token. | |
5977 * @param keyword the token representing the 'implements' keyword | |
5978 */ | |
5979 void set keyword(Token keyword12) { | |
5980 this._keyword = keyword12; | |
5981 } | |
5982 void visitChildren(ASTVisitor<Object> visitor) { | |
5983 _interfaces.accept(visitor); | |
5984 } | |
5985 } | |
5986 /** | |
5987 * Instances of the class {@code ImportDirective} represent an import directive. | |
5988 * <pre> | |
5989 * importDirective ::={@link Annotation metadata} 'import' {@link StringLiteral
libraryUri} ('as' identifier)? {@link Combinator combinator}* ';' | |
5990 * </pre> | |
5991 * @coverage dart.engine.ast | |
5992 */ | |
5993 class ImportDirective extends NamespaceDirective { | |
5994 /** | |
5995 * The token representing the 'as' token, or {@code null} if the imported name
s are not prefixed. | |
5996 */ | |
5997 Token _asToken; | |
5998 /** | |
5999 * The prefix to be used with the imported names, or {@code null} if the impor
ted names are not | |
6000 * prefixed. | |
6001 */ | |
6002 SimpleIdentifier _prefix; | |
6003 /** | |
6004 * Initialize a newly created import directive. | |
6005 * @param comment the documentation comment associated with this directive | |
6006 * @param metadata the annotations associated with the directive | |
6007 * @param keyword the token representing the 'import' keyword | |
6008 * @param libraryUri the URI of the library being imported | |
6009 * @param asToken the token representing the 'as' token | |
6010 * @param prefix the prefix to be used with the imported names | |
6011 * @param combinators the combinators used to control how names are imported | |
6012 * @param semicolon the semicolon terminating the directive | |
6013 */ | |
6014 ImportDirective.full(Comment comment, List<Annotation> metadata, Token keyword
, StringLiteral libraryUri, Token asToken, SimpleIdentifier prefix, List<Combina
tor> combinators, Token semicolon) : super.full(comment, metadata, keyword, libr
aryUri, combinators, semicolon) { | |
6015 this._asToken = asToken; | |
6016 this._prefix = becomeParentOf(prefix); | |
6017 } | |
6018 /** | |
6019 * Initialize a newly created import directive. | |
6020 * @param comment the documentation comment associated with this directive | |
6021 * @param metadata the annotations associated with the directive | |
6022 * @param keyword the token representing the 'import' keyword | |
6023 * @param libraryUri the URI of the library being imported | |
6024 * @param asToken the token representing the 'as' token | |
6025 * @param prefix the prefix to be used with the imported names | |
6026 * @param combinators the combinators used to control how names are imported | |
6027 * @param semicolon the semicolon terminating the directive | |
6028 */ | |
6029 ImportDirective({Comment comment, List<Annotation> metadata, Token keyword, St
ringLiteral libraryUri, Token asToken, SimpleIdentifier prefix, List<Combinator>
combinators, Token semicolon}) : this.full(comment, metadata, keyword, libraryU
ri, asToken, prefix, combinators, semicolon); | |
6030 accept(ASTVisitor visitor) => visitor.visitImportDirective(this); | |
6031 /** | |
6032 * Return the token representing the 'as' token, or {@code null} if the import
ed names are not | |
6033 * prefixed. | |
6034 * @return the token representing the 'as' token | |
6035 */ | |
6036 Token get asToken => _asToken; | |
6037 /** | |
6038 * Return the prefix to be used with the imported names, or {@code null} if th
e imported names are | |
6039 * not prefixed. | |
6040 * @return the prefix to be used with the imported names | |
6041 */ | |
6042 SimpleIdentifier get prefix => _prefix; | |
6043 /** | |
6044 * Set the token representing the 'as' token to the given token. | |
6045 * @param asToken the token representing the 'as' token | |
6046 */ | |
6047 void set asToken(Token asToken2) { | |
6048 this._asToken = asToken2; | |
6049 } | |
6050 /** | |
6051 * Set the prefix to be used with the imported names to the given identifier. | |
6052 * @param prefix the prefix to be used with the imported names | |
6053 */ | |
6054 void set prefix(SimpleIdentifier prefix2) { | |
6055 this._prefix = becomeParentOf(prefix2); | |
6056 } | |
6057 void visitChildren(ASTVisitor<Object> visitor) { | |
6058 super.visitChildren(visitor); | |
6059 safelyVisitChild(_prefix, visitor); | |
6060 combinators.accept(visitor); | |
6061 } | |
6062 } | |
6063 /** | |
6064 * Instances of the class {@code IndexExpression} represent an index expression. | |
6065 * <pre> | |
6066 * indexExpression ::={@link Expression target} '[' {@link Expression index} ']' | |
6067 * </pre> | |
6068 * @coverage dart.engine.ast | |
6069 */ | |
6070 class IndexExpression extends Expression { | |
6071 /** | |
6072 * The expression used to compute the object being indexed, or {@code null} if
this index | |
6073 * expression is part of a cascade expression. | |
6074 */ | |
6075 Expression _target; | |
6076 /** | |
6077 * The period ("..") before a cascaded index expression, or {@code null} if th
is index expression | |
6078 * is not part of a cascade expression. | |
6079 */ | |
6080 Token _period; | |
6081 /** | |
6082 * The left square bracket. | |
6083 */ | |
6084 Token _leftBracket; | |
6085 /** | |
6086 * The expression used to compute the index. | |
6087 */ | |
6088 Expression _index; | |
6089 /** | |
6090 * The right square bracket. | |
6091 */ | |
6092 Token _rightBracket; | |
6093 /** | |
6094 * The element associated with the operator, or {@code null} if the AST struct
ure has not been | |
6095 * resolved or if the operator could not be resolved. | |
6096 */ | |
6097 MethodElement _element; | |
6098 /** | |
6099 * Initialize a newly created index expression. | |
6100 * @param target the expression used to compute the object being indexed | |
6101 * @param leftBracket the left square bracket | |
6102 * @param index the expression used to compute the index | |
6103 * @param rightBracket the right square bracket | |
6104 */ | |
6105 IndexExpression.forTarget_full(Expression target3, Token leftBracket4, Express
ion index2, Token rightBracket4) { | |
6106 _jtd_constructor_58_impl(target3, leftBracket4, index2, rightBracket4); | |
6107 } | |
6108 /** | |
6109 * Initialize a newly created index expression. | |
6110 * @param target the expression used to compute the object being indexed | |
6111 * @param leftBracket the left square bracket | |
6112 * @param index the expression used to compute the index | |
6113 * @param rightBracket the right square bracket | |
6114 */ | |
6115 IndexExpression.forTarget({Expression target3, Token leftBracket4, Expression
index2, Token rightBracket4}) : this.forTarget_full(target3, leftBracket4, index
2, rightBracket4); | |
6116 _jtd_constructor_58_impl(Expression target3, Token leftBracket4, Expression in
dex2, Token rightBracket4) { | |
6117 this._target = becomeParentOf(target3); | |
6118 this._leftBracket = leftBracket4; | |
6119 this._index = becomeParentOf(index2); | |
6120 this._rightBracket = rightBracket4; | |
6121 } | |
6122 /** | |
6123 * Initialize a newly created index expression. | |
6124 * @param period the period ("..") before a cascaded index expression | |
6125 * @param leftBracket the left square bracket | |
6126 * @param index the expression used to compute the index | |
6127 * @param rightBracket the right square bracket | |
6128 */ | |
6129 IndexExpression.forCascade_full(Token period7, Token leftBracket5, Expression
index3, Token rightBracket5) { | |
6130 _jtd_constructor_59_impl(period7, leftBracket5, index3, rightBracket5); | |
6131 } | |
6132 /** | |
6133 * Initialize a newly created index expression. | |
6134 * @param period the period ("..") before a cascaded index expression | |
6135 * @param leftBracket the left square bracket | |
6136 * @param index the expression used to compute the index | |
6137 * @param rightBracket the right square bracket | |
6138 */ | |
6139 IndexExpression.forCascade({Token period7, Token leftBracket5, Expression inde
x3, Token rightBracket5}) : this.forCascade_full(period7, leftBracket5, index3,
rightBracket5); | |
6140 _jtd_constructor_59_impl(Token period7, Token leftBracket5, Expression index3,
Token rightBracket5) { | |
6141 this._period = period7; | |
6142 this._leftBracket = leftBracket5; | |
6143 this._index = becomeParentOf(index3); | |
6144 this._rightBracket = rightBracket5; | |
6145 } | |
6146 accept(ASTVisitor visitor) => visitor.visitIndexExpression(this); | |
6147 /** | |
6148 * Return the expression used to compute the object being indexed, or {@code n
ull} if this index | |
6149 * expression is part of a cascade expression. | |
6150 * @return the expression used to compute the object being indexed | |
6151 * @see #getRealTarget() | |
6152 */ | |
6153 Expression get array => _target; | |
6154 Token get beginToken { | |
6155 if (_target != null) { | |
6156 return _target.beginToken; | |
6157 } | |
6158 return _period; | |
6159 } | |
6160 /** | |
6161 * Return the element associated with the operator, or {@code null} if the AST
structure has not | |
6162 * been resolved or if the operator could not be resolved. One example of the
latter case is an | |
6163 * operator that is not defined for the type of the left-hand operand. | |
6164 * @return the element associated with this operator | |
6165 */ | |
6166 MethodElement get element => _element; | |
6167 Token get endToken => _rightBracket; | |
6168 /** | |
6169 * Return the expression used to compute the index. | |
6170 * @return the expression used to compute the index | |
6171 */ | |
6172 Expression get index => _index; | |
6173 /** | |
6174 * Return the left square bracket. | |
6175 * @return the left square bracket | |
6176 */ | |
6177 Token get leftBracket => _leftBracket; | |
6178 /** | |
6179 * Return the period ("..") before a cascaded index expression, or {@code null
} if this index | |
6180 * expression is not part of a cascade expression. | |
6181 * @return the period ("..") before a cascaded index expression | |
6182 */ | |
6183 Token get period => _period; | |
6184 /** | |
6185 * Return the expression used to compute the object being indexed. If this ind
ex expression is not | |
6186 * part of a cascade expression, then this is the same as {@link #getArray()}.
If this index | |
6187 * expression is part of a cascade expression, then the target expression stor
ed with the cascade | |
6188 * expression is returned. | |
6189 * @return the expression used to compute the object being indexed | |
6190 * @see #getArray() | |
6191 */ | |
6192 Expression get realTarget { | |
6193 if (isCascaded()) { | |
6194 ASTNode ancestor = parent; | |
6195 while (ancestor is! CascadeExpression) { | |
6196 if (ancestor == null) { | |
6197 return _target; | |
6198 } | |
6199 ancestor = ancestor.parent; | |
6200 } | |
6201 return ((ancestor as CascadeExpression)).target; | |
6202 } | |
6203 return _target; | |
6204 } | |
6205 /** | |
6206 * Return the right square bracket. | |
6207 * @return the right square bracket | |
6208 */ | |
6209 Token get rightBracket => _rightBracket; | |
6210 /** | |
6211 * Return {@code true} if this expression is computing a right-hand value. | |
6212 * <p> | |
6213 * Note that {@link #inGetterContext()} and {@link #inSetterContext()} are not
opposites, nor are | |
6214 * they mutually exclusive. In other words, it is possible for both methods to
return {@code true}when invoked on the same node. | |
6215 * @return {@code true} if this expression is in a context where the operator
'[]' will be invoked | |
6216 */ | |
6217 bool inGetterContext() { | |
6218 ASTNode parent4 = parent; | |
6219 if (parent4 is AssignmentExpression) { | |
6220 AssignmentExpression assignment = parent4 as AssignmentExpression; | |
6221 if (identical(assignment.leftHandSide, this) && identical(assignment.opera
tor.type, TokenType.EQ)) { | |
6222 return false; | |
6223 } | |
6224 } | |
6225 return true; | |
6226 } | |
6227 /** | |
6228 * Return {@code true} if this expression is computing a left-hand value. | |
6229 * <p> | |
6230 * Note that {@link #inGetterContext()} and {@link #inSetterContext()} are not
opposites, nor are | |
6231 * they mutually exclusive. In other words, it is possible for both methods to
return {@code true}when invoked on the same node. | |
6232 * @return {@code true} if this expression is in a context where the operator
'[]=' will be | |
6233 * invoked | |
6234 */ | |
6235 bool inSetterContext() { | |
6236 ASTNode parent5 = parent; | |
6237 if (parent5 is PrefixExpression) { | |
6238 return ((parent5 as PrefixExpression)).operator.type.isIncrementOperator()
; | |
6239 } else if (parent5 is PostfixExpression) { | |
6240 return true; | |
6241 } else if (parent5 is AssignmentExpression) { | |
6242 return identical(((parent5 as AssignmentExpression)).leftHandSide, this); | |
6243 } | |
6244 return false; | |
6245 } | |
6246 bool isAssignable() => true; | |
6247 /** | |
6248 * Return {@code true} if this expression is cascaded. If it is, then the targ
et of this | |
6249 * expression is not stored locally but is stored in the nearest ancestor that
is a{@link CascadeExpression}. | |
6250 * @return {@code true} if this expression is cascaded | |
6251 */ | |
6252 bool isCascaded() => _period != null; | |
6253 /** | |
6254 * Set the expression used to compute the object being indexed to the given ex
pression. | |
6255 * @param expression the expression used to compute the object being indexed | |
6256 */ | |
6257 void set array(Expression expression) { | |
6258 _target = becomeParentOf(expression); | |
6259 } | |
6260 /** | |
6261 * Set the element associated with the operator to the given element. | |
6262 * @param element the element associated with this operator | |
6263 */ | |
6264 void set element(MethodElement element11) { | |
6265 this._element = element11; | |
6266 } | |
6267 /** | |
6268 * Set the expression used to compute the index to the given expression. | |
6269 * @param expression the expression used to compute the index | |
6270 */ | |
6271 void set index(Expression expression) { | |
6272 _index = becomeParentOf(expression); | |
6273 } | |
6274 /** | |
6275 * Set the left square bracket to the given token. | |
6276 * @param bracket the left square bracket | |
6277 */ | |
6278 void set leftBracket(Token bracket) { | |
6279 _leftBracket = bracket; | |
6280 } | |
6281 /** | |
6282 * Set the period ("..") before a cascaded index expression to the given token
. | |
6283 * @param period the period ("..") before a cascaded index expression | |
6284 */ | |
6285 void set period(Token period8) { | |
6286 this._period = period8; | |
6287 } | |
6288 /** | |
6289 * Set the right square bracket to the given token. | |
6290 * @param bracket the right square bracket | |
6291 */ | |
6292 void set rightBracket(Token bracket) { | |
6293 _rightBracket = bracket; | |
6294 } | |
6295 void visitChildren(ASTVisitor<Object> visitor) { | |
6296 safelyVisitChild(_target, visitor); | |
6297 safelyVisitChild(_index, visitor); | |
6298 } | |
6299 } | |
6300 /** | |
6301 * Instances of the class {@code InstanceCreationExpression} represent an instan
ce creation | |
6302 * expression. | |
6303 * <pre> | |
6304 * newExpression ::= | |
6305 * ('new' | 'const') {@link TypeName type} ('.' {@link SimpleIdentifier identifi
er})? {@link ArgumentList argumentList}</pre> | |
6306 * @coverage dart.engine.ast | |
6307 */ | |
6308 class InstanceCreationExpression extends Expression { | |
6309 /** | |
6310 * The keyword used to indicate how an object should be created. | |
6311 */ | |
6312 Token _keyword; | |
6313 /** | |
6314 * The name of the constructor to be invoked. | |
6315 */ | |
6316 ConstructorName _constructorName; | |
6317 /** | |
6318 * The list of arguments to the constructor. | |
6319 */ | |
6320 ArgumentList _argumentList; | |
6321 /** | |
6322 * The element associated with the constructor, or {@code null} if the AST str
ucture has not been | |
6323 * resolved or if the constructor could not be resolved. | |
6324 */ | |
6325 ConstructorElement _element; | |
6326 /** | |
6327 * Initialize a newly created instance creation expression. | |
6328 * @param keyword the keyword used to indicate how an object should be created | |
6329 * @param constructorName the name of the constructor to be invoked | |
6330 * @param argumentList the list of arguments to the constructor | |
6331 */ | |
6332 InstanceCreationExpression.full(Token keyword, ConstructorName constructorName
, ArgumentList argumentList) { | |
6333 this._keyword = keyword; | |
6334 this._constructorName = becomeParentOf(constructorName); | |
6335 this._argumentList = becomeParentOf(argumentList); | |
6336 } | |
6337 /** | |
6338 * Initialize a newly created instance creation expression. | |
6339 * @param keyword the keyword used to indicate how an object should be created | |
6340 * @param constructorName the name of the constructor to be invoked | |
6341 * @param argumentList the list of arguments to the constructor | |
6342 */ | |
6343 InstanceCreationExpression({Token keyword, ConstructorName constructorName, Ar
gumentList argumentList}) : this.full(keyword, constructorName, argumentList); | |
6344 accept(ASTVisitor visitor) => visitor.visitInstanceCreationExpression(this); | |
6345 /** | |
6346 * Return the list of arguments to the constructor. | |
6347 * @return the list of arguments to the constructor | |
6348 */ | |
6349 ArgumentList get argumentList => _argumentList; | |
6350 Token get beginToken => _keyword; | |
6351 /** | |
6352 * Return the name of the constructor to be invoked. | |
6353 * @return the name of the constructor to be invoked | |
6354 */ | |
6355 ConstructorName get constructorName => _constructorName; | |
6356 /** | |
6357 * Return the element associated with the constructor, or {@code null} if the
AST structure has | |
6358 * not been resolved or if the constructor could not be resolved. | |
6359 * @return the element associated with the constructor | |
6360 */ | |
6361 ConstructorElement get element => _element; | |
6362 Token get endToken => _argumentList.endToken; | |
6363 /** | |
6364 * Return the keyword used to indicate how an object should be created. | |
6365 * @return the keyword used to indicate how an object should be created | |
6366 */ | |
6367 Token get keyword => _keyword; | |
6368 /** | |
6369 * Return {@code true} if this creation expression is used to invoke a constan
t constructor. | |
6370 * @return {@code true} if this creation expression is used to invoke a consta
nt constructor | |
6371 */ | |
6372 bool isConst() => _keyword is KeywordToken && identical(((_keyword as KeywordT
oken)).keyword, Keyword.CONST); | |
6373 /** | |
6374 * Set the list of arguments to the constructor to the given list. | |
6375 * @param argumentList the list of arguments to the constructor | |
6376 */ | |
6377 void set argumentList(ArgumentList argumentList6) { | |
6378 this._argumentList = becomeParentOf(argumentList6); | |
6379 } | |
6380 /** | |
6381 * Set the name of the constructor to be invoked to the given name. | |
6382 * @param constructorName the name of the constructor to be invoked | |
6383 */ | |
6384 void set constructorName(ConstructorName constructorName3) { | |
6385 this._constructorName = constructorName3; | |
6386 } | |
6387 /** | |
6388 * Set the element associated with the constructor to the given element. | |
6389 * @param element the element associated with the constructor | |
6390 */ | |
6391 void set element(ConstructorElement element12) { | |
6392 this._element = element12; | |
6393 } | |
6394 /** | |
6395 * Set the keyword used to indicate how an object should be created to the giv
en keyword. | |
6396 * @param keyword the keyword used to indicate how an object should be created | |
6397 */ | |
6398 void set keyword(Token keyword13) { | |
6399 this._keyword = keyword13; | |
6400 } | |
6401 void visitChildren(ASTVisitor<Object> visitor) { | |
6402 safelyVisitChild(_constructorName, visitor); | |
6403 safelyVisitChild(_argumentList, visitor); | |
6404 } | |
6405 } | |
6406 /** | |
6407 * Instances of the class {@code IntegerLiteral} represent an integer literal ex
pression. | |
6408 * <pre> | |
6409 * integerLiteral ::= | |
6410 * decimalIntegerLiteral | |
6411 * | hexidecimalIntegerLiteral | |
6412 * decimalIntegerLiteral ::= | |
6413 * decimalDigit+ | |
6414 * hexidecimalIntegerLiteral ::= | |
6415 * '0x' hexidecimalDigit+ | |
6416 * | '0X' hexidecimalDigit+ | |
6417 * </pre> | |
6418 * @coverage dart.engine.ast | |
6419 */ | |
6420 class IntegerLiteral extends Literal { | |
6421 /** | |
6422 * The token representing the literal. | |
6423 */ | |
6424 Token _literal; | |
6425 /** | |
6426 * The value of the literal. | |
6427 */ | |
6428 int _value = 0; | |
6429 /** | |
6430 * Initialize a newly created integer literal. | |
6431 * @param literal the token representing the literal | |
6432 * @param value the value of the literal | |
6433 */ | |
6434 IntegerLiteral.full(Token literal, int value) { | |
6435 this._literal = literal; | |
6436 this._value = value; | |
6437 } | |
6438 /** | |
6439 * Initialize a newly created integer literal. | |
6440 * @param literal the token representing the literal | |
6441 * @param value the value of the literal | |
6442 */ | |
6443 IntegerLiteral({Token literal, int value}) : this.full(literal, value); | |
6444 accept(ASTVisitor visitor) => visitor.visitIntegerLiteral(this); | |
6445 Token get beginToken => _literal; | |
6446 Token get endToken => _literal; | |
6447 /** | |
6448 * Return the token representing the literal. | |
6449 * @return the token representing the literal | |
6450 */ | |
6451 Token get literal => _literal; | |
6452 /** | |
6453 * Return the value of the literal. | |
6454 * @return the value of the literal | |
6455 */ | |
6456 int get value => _value; | |
6457 /** | |
6458 * Set the token representing the literal to the given token. | |
6459 * @param literal the token representing the literal | |
6460 */ | |
6461 void set literal(Token literal4) { | |
6462 this._literal = literal4; | |
6463 } | |
6464 /** | |
6465 * Set the value of the literal to the given value. | |
6466 * @param value the value of the literal | |
6467 */ | |
6468 void set value(int value6) { | |
6469 this._value = value6; | |
6470 } | |
6471 void visitChildren(ASTVisitor<Object> visitor) { | |
6472 } | |
6473 } | |
6474 /** | |
6475 * The abstract class {@code InterpolationElement} defines the behavior common t
o elements within a{@link StringInterpolation string interpolation}. | |
6476 * <pre> | |
6477 * interpolationElement ::={@link InterpolationExpression interpolationExpressio
n}| {@link InterpolationString interpolationString}</pre> | |
6478 * @coverage dart.engine.ast | |
6479 */ | |
6480 abstract class InterpolationElement extends ASTNode { | |
6481 } | |
6482 /** | |
6483 * Instances of the class {@code InterpolationExpression} represent an expressio
n embedded in a | |
6484 * string interpolation. | |
6485 * <pre> | |
6486 * interpolationExpression ::= | |
6487 * '$' {@link SimpleIdentifier identifier}| '$' '{' {@link Expression expression
} '}' | |
6488 * </pre> | |
6489 * @coverage dart.engine.ast | |
6490 */ | |
6491 class InterpolationExpression extends InterpolationElement { | |
6492 /** | |
6493 * The token used to introduce the interpolation expression; either '$' if the
expression is a | |
6494 * simple identifier or '${' if the expression is a full expression. | |
6495 */ | |
6496 Token _leftBracket; | |
6497 /** | |
6498 * The expression to be evaluated for the value to be converted into a string. | |
6499 */ | |
6500 Expression _expression; | |
6501 /** | |
6502 * The right curly bracket, or {@code null} if the expression is an identifier
without brackets. | |
6503 */ | |
6504 Token _rightBracket; | |
6505 /** | |
6506 * Initialize a newly created interpolation expression. | |
6507 * @param leftBracket the left curly bracket | |
6508 * @param expression the expression to be evaluated for the value to be conver
ted into a string | |
6509 * @param rightBracket the right curly bracket | |
6510 */ | |
6511 InterpolationExpression.full(Token leftBracket, Expression expression, Token r
ightBracket) { | |
6512 this._leftBracket = leftBracket; | |
6513 this._expression = becomeParentOf(expression); | |
6514 this._rightBracket = rightBracket; | |
6515 } | |
6516 /** | |
6517 * Initialize a newly created interpolation expression. | |
6518 * @param leftBracket the left curly bracket | |
6519 * @param expression the expression to be evaluated for the value to be conver
ted into a string | |
6520 * @param rightBracket the right curly bracket | |
6521 */ | |
6522 InterpolationExpression({Token leftBracket, Expression expression, Token right
Bracket}) : this.full(leftBracket, expression, rightBracket); | |
6523 accept(ASTVisitor visitor) => visitor.visitInterpolationExpression(this); | |
6524 Token get beginToken => _leftBracket; | |
6525 Token get endToken { | |
6526 if (_rightBracket != null) { | |
6527 return _rightBracket; | |
6528 } | |
6529 return _expression.endToken; | |
6530 } | |
6531 /** | |
6532 * Return the expression to be evaluated for the value to be converted into a
string. | |
6533 * @return the expression to be evaluated for the value to be converted into a
string | |
6534 */ | |
6535 Expression get expression => _expression; | |
6536 /** | |
6537 * Return the left curly bracket. | |
6538 * @return the left curly bracket | |
6539 */ | |
6540 Token get leftBracket => _leftBracket; | |
6541 /** | |
6542 * Return the right curly bracket. | |
6543 * @return the right curly bracket | |
6544 */ | |
6545 Token get rightBracket => _rightBracket; | |
6546 /** | |
6547 * Set the expression to be evaluated for the value to be converted into a str
ing to the given | |
6548 * expression. | |
6549 * @param expression the expression to be evaluated for the value to be conver
ted into a string | |
6550 */ | |
6551 void set expression(Expression expression6) { | |
6552 this._expression = becomeParentOf(expression6); | |
6553 } | |
6554 /** | |
6555 * Set the left curly bracket to the given token. | |
6556 * @param leftBracket the left curly bracket | |
6557 */ | |
6558 void set leftBracket(Token leftBracket6) { | |
6559 this._leftBracket = leftBracket6; | |
6560 } | |
6561 /** | |
6562 * Set the right curly bracket to the given token. | |
6563 * @param rightBracket the right curly bracket | |
6564 */ | |
6565 void set rightBracket(Token rightBracket6) { | |
6566 this._rightBracket = rightBracket6; | |
6567 } | |
6568 void visitChildren(ASTVisitor<Object> visitor) { | |
6569 safelyVisitChild(_expression, visitor); | |
6570 } | |
6571 } | |
6572 /** | |
6573 * Instances of the class {@code InterpolationString} represent a non-empty subs
tring of an | |
6574 * interpolated string. | |
6575 * <pre> | |
6576 * interpolationString ::= | |
6577 * characters | |
6578 * </pre> | |
6579 * @coverage dart.engine.ast | |
6580 */ | |
6581 class InterpolationString extends InterpolationElement { | |
6582 /** | |
6583 * The characters that will be added to the string. | |
6584 */ | |
6585 Token _contents; | |
6586 /** | |
6587 * The value of the literal. | |
6588 */ | |
6589 String _value; | |
6590 /** | |
6591 * Initialize a newly created string of characters that are part of a string i
nterpolation. | |
6592 * @param the characters that will be added to the string | |
6593 * @param value the value of the literal | |
6594 */ | |
6595 InterpolationString.full(Token contents, String value) { | |
6596 this._contents = contents; | |
6597 this._value = value; | |
6598 } | |
6599 /** | |
6600 * Initialize a newly created string of characters that are part of a string i
nterpolation. | |
6601 * @param the characters that will be added to the string | |
6602 * @param value the value of the literal | |
6603 */ | |
6604 InterpolationString({Token contents, String value}) : this.full(contents, valu
e); | |
6605 accept(ASTVisitor visitor) => visitor.visitInterpolationString(this); | |
6606 Token get beginToken => _contents; | |
6607 /** | |
6608 * Return the characters that will be added to the string. | |
6609 * @return the characters that will be added to the string | |
6610 */ | |
6611 Token get contents => _contents; | |
6612 Token get endToken => _contents; | |
6613 /** | |
6614 * Return the value of the literal. | |
6615 * @return the value of the literal | |
6616 */ | |
6617 String get value => _value; | |
6618 /** | |
6619 * Set the characters that will be added to the string to those in the given s
tring. | |
6620 * @param string the characters that will be added to the string | |
6621 */ | |
6622 void set contents(Token string) { | |
6623 _contents = string; | |
6624 } | |
6625 /** | |
6626 * Set the value of the literal to the given string. | |
6627 * @param string the value of the literal | |
6628 */ | |
6629 void set value(String string) { | |
6630 _value = string; | |
6631 } | |
6632 void visitChildren(ASTVisitor<Object> visitor) { | |
6633 } | |
6634 } | |
6635 /** | |
6636 * Instances of the class {@code IsExpression} represent an is expression. | |
6637 * <pre> | |
6638 * isExpression ::={@link Expression expression} 'is' '!'? {@link TypeName type}
</pre> | |
6639 * @coverage dart.engine.ast | |
6640 */ | |
6641 class IsExpression extends Expression { | |
6642 /** | |
6643 * The expression used to compute the value whose type is being tested. | |
6644 */ | |
6645 Expression _expression; | |
6646 /** | |
6647 * The is operator. | |
6648 */ | |
6649 Token _isOperator; | |
6650 /** | |
6651 * The not operator, or {@code null} if the sense of the test is not negated. | |
6652 */ | |
6653 Token _notOperator; | |
6654 /** | |
6655 * The name of the type being tested for. | |
6656 */ | |
6657 TypeName _type; | |
6658 /** | |
6659 * Initialize a newly created is expression. | |
6660 * @param expression the expression used to compute the value whose type is be
ing tested | |
6661 * @param isOperator the is operator | |
6662 * @param notOperator the not operator, or {@code null} if the sense of the te
st is not negated | |
6663 * @param type the name of the type being tested for | |
6664 */ | |
6665 IsExpression.full(Expression expression, Token isOperator, Token notOperator,
TypeName type) { | |
6666 this._expression = becomeParentOf(expression); | |
6667 this._isOperator = isOperator; | |
6668 this._notOperator = notOperator; | |
6669 this._type = becomeParentOf(type); | |
6670 } | |
6671 /** | |
6672 * Initialize a newly created is expression. | |
6673 * @param expression the expression used to compute the value whose type is be
ing tested | |
6674 * @param isOperator the is operator | |
6675 * @param notOperator the not operator, or {@code null} if the sense of the te
st is not negated | |
6676 * @param type the name of the type being tested for | |
6677 */ | |
6678 IsExpression({Expression expression, Token isOperator, Token notOperator, Type
Name type}) : this.full(expression, isOperator, notOperator, type); | |
6679 accept(ASTVisitor visitor) => visitor.visitIsExpression(this); | |
6680 Token get beginToken => _expression.beginToken; | |
6681 Token get endToken => _type.endToken; | |
6682 /** | |
6683 * Return the expression used to compute the value whose type is being tested. | |
6684 * @return the expression used to compute the value whose type is being tested | |
6685 */ | |
6686 Expression get expression => _expression; | |
6687 /** | |
6688 * Return the is operator being applied. | |
6689 * @return the is operator being applied | |
6690 */ | |
6691 Token get isOperator => _isOperator; | |
6692 /** | |
6693 * Return the not operator being applied. | |
6694 * @return the not operator being applied | |
6695 */ | |
6696 Token get notOperator => _notOperator; | |
6697 /** | |
6698 * Return the name of the type being tested for. | |
6699 * @return the name of the type being tested for | |
6700 */ | |
6701 TypeName get type => _type; | |
6702 /** | |
6703 * Set the expression used to compute the value whose type is being tested to
the given | |
6704 * expression. | |
6705 * @param expression the expression used to compute the value whose type is be
ing tested | |
6706 */ | |
6707 void set expression(Expression expression7) { | |
6708 this._expression = becomeParentOf(expression7); | |
6709 } | |
6710 /** | |
6711 * Set the is operator being applied to the given operator. | |
6712 * @param isOperator the is operator being applied | |
6713 */ | |
6714 void set isOperator(Token isOperator2) { | |
6715 this._isOperator = isOperator2; | |
6716 } | |
6717 /** | |
6718 * Set the not operator being applied to the given operator. | |
6719 * @param notOperator the is operator being applied | |
6720 */ | |
6721 void set notOperator(Token notOperator2) { | |
6722 this._notOperator = notOperator2; | |
6723 } | |
6724 /** | |
6725 * Set the name of the type being tested for to the given name. | |
6726 * @param name the name of the type being tested for | |
6727 */ | |
6728 void set type(TypeName name) { | |
6729 this._type = becomeParentOf(name); | |
6730 } | |
6731 void visitChildren(ASTVisitor<Object> visitor) { | |
6732 safelyVisitChild(_expression, visitor); | |
6733 safelyVisitChild(_type, visitor); | |
6734 } | |
6735 } | |
6736 /** | |
6737 * Instances of the class {@code Label} represent a label. | |
6738 * <pre> | |
6739 * label ::={@link SimpleIdentifier label} ':' | |
6740 * </pre> | |
6741 * @coverage dart.engine.ast | |
6742 */ | |
6743 class Label extends ASTNode { | |
6744 /** | |
6745 * The label being associated with the statement. | |
6746 */ | |
6747 SimpleIdentifier _label; | |
6748 /** | |
6749 * The colon that separates the label from the statement. | |
6750 */ | |
6751 Token _colon; | |
6752 /** | |
6753 * Initialize a newly created label. | |
6754 * @param label the label being applied | |
6755 * @param colon the colon that separates the label from whatever follows | |
6756 */ | |
6757 Label.full(SimpleIdentifier label, Token colon) { | |
6758 this._label = becomeParentOf(label); | |
6759 this._colon = colon; | |
6760 } | |
6761 /** | |
6762 * Initialize a newly created label. | |
6763 * @param label the label being applied | |
6764 * @param colon the colon that separates the label from whatever follows | |
6765 */ | |
6766 Label({SimpleIdentifier label, Token colon}) : this.full(label, colon); | |
6767 accept(ASTVisitor visitor) => visitor.visitLabel(this); | |
6768 Token get beginToken => _label.beginToken; | |
6769 /** | |
6770 * Return the colon that separates the label from the statement. | |
6771 * @return the colon that separates the label from the statement | |
6772 */ | |
6773 Token get colon => _colon; | |
6774 Token get endToken => _colon; | |
6775 /** | |
6776 * Return the label being associated with the statement. | |
6777 * @return the label being associated with the statement | |
6778 */ | |
6779 SimpleIdentifier get label => _label; | |
6780 /** | |
6781 * Set the colon that separates the label from the statement to the given toke
n. | |
6782 * @param colon the colon that separates the label from the statement | |
6783 */ | |
6784 void set colon(Token colon3) { | |
6785 this._colon = colon3; | |
6786 } | |
6787 /** | |
6788 * Set the label being associated with the statement to the given label. | |
6789 * @param label the label being associated with the statement | |
6790 */ | |
6791 void set label(SimpleIdentifier label3) { | |
6792 this._label = becomeParentOf(label3); | |
6793 } | |
6794 void visitChildren(ASTVisitor<Object> visitor) { | |
6795 safelyVisitChild(_label, visitor); | |
6796 } | |
6797 } | |
6798 /** | |
6799 * Instances of the class {@code LabeledStatement} represent a statement that ha
s a label associated | |
6800 * with them. | |
6801 * <pre> | |
6802 * labeledStatement ::={@link Label label}+ {@link Statement statement}</pre> | |
6803 * @coverage dart.engine.ast | |
6804 */ | |
6805 class LabeledStatement extends Statement { | |
6806 /** | |
6807 * The labels being associated with the statement. | |
6808 */ | |
6809 NodeList<Label> _labels; | |
6810 /** | |
6811 * The statement with which the labels are being associated. | |
6812 */ | |
6813 Statement _statement; | |
6814 /** | |
6815 * Initialize a newly created labeled statement. | |
6816 * @param labels the labels being associated with the statement | |
6817 * @param statement the statement with which the labels are being associated | |
6818 */ | |
6819 LabeledStatement.full(List<Label> labels, Statement statement) { | |
6820 this._labels = new NodeList<Label>(this); | |
6821 this._labels.addAll(labels); | |
6822 this._statement = becomeParentOf(statement); | |
6823 } | |
6824 /** | |
6825 * Initialize a newly created labeled statement. | |
6826 * @param labels the labels being associated with the statement | |
6827 * @param statement the statement with which the labels are being associated | |
6828 */ | |
6829 LabeledStatement({List<Label> labels, Statement statement}) : this.full(labels
, statement); | |
6830 accept(ASTVisitor visitor) => visitor.visitLabeledStatement(this); | |
6831 Token get beginToken { | |
6832 if (!_labels.isEmpty) { | |
6833 return _labels.beginToken; | |
6834 } | |
6835 return _statement.beginToken; | |
6836 } | |
6837 Token get endToken => _statement.endToken; | |
6838 /** | |
6839 * Return the labels being associated with the statement. | |
6840 * @return the labels being associated with the statement | |
6841 */ | |
6842 NodeList<Label> get labels => _labels; | |
6843 /** | |
6844 * Return the statement with which the labels are being associated. | |
6845 * @return the statement with which the labels are being associated | |
6846 */ | |
6847 Statement get statement => _statement; | |
6848 /** | |
6849 * Set the statement with which the labels are being associated to the given s
tatement. | |
6850 * @param statement the statement with which the labels are being associated | |
6851 */ | |
6852 void set statement(Statement statement2) { | |
6853 this._statement = becomeParentOf(statement2); | |
6854 } | |
6855 void visitChildren(ASTVisitor<Object> visitor) { | |
6856 _labels.accept(visitor); | |
6857 safelyVisitChild(_statement, visitor); | |
6858 } | |
6859 } | |
6860 /** | |
6861 * Instances of the class {@code LibraryDirective} represent a library directive
. | |
6862 * <pre> | |
6863 * libraryDirective ::={@link Annotation metadata} 'library' {@link Identifier n
ame} ';' | |
6864 * </pre> | |
6865 * @coverage dart.engine.ast | |
6866 */ | |
6867 class LibraryDirective extends Directive { | |
6868 /** | |
6869 * The token representing the 'library' token. | |
6870 */ | |
6871 Token _libraryToken; | |
6872 /** | |
6873 * The name of the library being defined. | |
6874 */ | |
6875 LibraryIdentifier _name; | |
6876 /** | |
6877 * The semicolon terminating the directive. | |
6878 */ | |
6879 Token _semicolon; | |
6880 /** | |
6881 * Initialize a newly created library directive. | |
6882 * @param comment the documentation comment associated with this directive | |
6883 * @param metadata the annotations associated with the directive | |
6884 * @param libraryToken the token representing the 'library' token | |
6885 * @param name the name of the library being defined | |
6886 * @param semicolon the semicolon terminating the directive | |
6887 */ | |
6888 LibraryDirective.full(Comment comment, List<Annotation> metadata, Token librar
yToken, LibraryIdentifier name, Token semicolon) : super.full(comment, metadata)
{ | |
6889 this._libraryToken = libraryToken; | |
6890 this._name = becomeParentOf(name); | |
6891 this._semicolon = semicolon; | |
6892 } | |
6893 /** | |
6894 * Initialize a newly created library directive. | |
6895 * @param comment the documentation comment associated with this directive | |
6896 * @param metadata the annotations associated with the directive | |
6897 * @param libraryToken the token representing the 'library' token | |
6898 * @param name the name of the library being defined | |
6899 * @param semicolon the semicolon terminating the directive | |
6900 */ | |
6901 LibraryDirective({Comment comment, List<Annotation> metadata, Token libraryTok
en, LibraryIdentifier name, Token semicolon}) : this.full(comment, metadata, lib
raryToken, name, semicolon); | |
6902 accept(ASTVisitor visitor) => visitor.visitLibraryDirective(this); | |
6903 Token get endToken => _semicolon; | |
6904 Token get keyword => _libraryToken; | |
6905 /** | |
6906 * Return the token representing the 'library' token. | |
6907 * @return the token representing the 'library' token | |
6908 */ | |
6909 Token get libraryToken => _libraryToken; | |
6910 /** | |
6911 * Return the name of the library being defined. | |
6912 * @return the name of the library being defined | |
6913 */ | |
6914 LibraryIdentifier get name => _name; | |
6915 /** | |
6916 * Return the semicolon terminating the directive. | |
6917 * @return the semicolon terminating the directive | |
6918 */ | |
6919 Token get semicolon => _semicolon; | |
6920 /** | |
6921 * Set the token representing the 'library' token to the given token. | |
6922 * @param libraryToken the token representing the 'library' token | |
6923 */ | |
6924 void set libraryToken(Token libraryToken2) { | |
6925 this._libraryToken = libraryToken2; | |
6926 } | |
6927 /** | |
6928 * Set the name of the library being defined to the given name. | |
6929 * @param name the name of the library being defined | |
6930 */ | |
6931 void set name(LibraryIdentifier name6) { | |
6932 this._name = becomeParentOf(name6); | |
6933 } | |
6934 /** | |
6935 * Set the semicolon terminating the directive to the given token. | |
6936 * @param semicolon the semicolon terminating the directive | |
6937 */ | |
6938 void set semicolon(Token semicolon11) { | |
6939 this._semicolon = semicolon11; | |
6940 } | |
6941 void visitChildren(ASTVisitor<Object> visitor) { | |
6942 super.visitChildren(visitor); | |
6943 safelyVisitChild(_name, visitor); | |
6944 } | |
6945 Token get firstTokenAfterCommentAndMetadata => _libraryToken; | |
6946 } | |
6947 /** | |
6948 * Instances of the class {@code LibraryIdentifier} represent the identifier for
a library. | |
6949 * <pre> | |
6950 * libraryIdentifier ::={@link SimpleIdentifier component} ('.' {@link SimpleIde
ntifier component}) | |
6951 * </pre> | |
6952 * @coverage dart.engine.ast | |
6953 */ | |
6954 class LibraryIdentifier extends Identifier { | |
6955 /** | |
6956 * The components of the identifier. | |
6957 */ | |
6958 NodeList<SimpleIdentifier> _components; | |
6959 /** | |
6960 * Initialize a newly created prefixed identifier. | |
6961 * @param components the components of the identifier | |
6962 */ | |
6963 LibraryIdentifier.full(List<SimpleIdentifier> components) { | |
6964 this._components = new NodeList<SimpleIdentifier>(this); | |
6965 this._components.addAll(components); | |
6966 } | |
6967 /** | |
6968 * Initialize a newly created prefixed identifier. | |
6969 * @param components the components of the identifier | |
6970 */ | |
6971 LibraryIdentifier({List<SimpleIdentifier> components}) : this.full(components)
; | |
6972 accept(ASTVisitor visitor) => visitor.visitLibraryIdentifier(this); | |
6973 Token get beginToken => _components.beginToken; | |
6974 /** | |
6975 * Return the components of the identifier. | |
6976 * @return the components of the identifier | |
6977 */ | |
6978 NodeList<SimpleIdentifier> get components => _components; | |
6979 Element get element => null; | |
6980 Token get endToken => _components.endToken; | |
6981 String get name { | |
6982 JavaStringBuilder builder = new JavaStringBuilder(); | |
6983 bool needsPeriod = false; | |
6984 for (SimpleIdentifier identifier in _components) { | |
6985 if (needsPeriod) { | |
6986 builder.append("."); | |
6987 } else { | |
6988 needsPeriod = true; | |
6989 } | |
6990 builder.append(identifier.name); | |
6991 } | |
6992 return builder.toString(); | |
6993 } | |
6994 void visitChildren(ASTVisitor<Object> visitor) { | |
6995 _components.accept(visitor); | |
6996 } | |
6997 } | |
6998 /** | |
6999 * Instances of the class {@code ListLiteral} represent a list literal. | |
7000 * <pre> | |
7001 * listLiteral ::= | |
7002 * 'const'? ('<' {@link TypeName type} '>')? '[' ({@link Expression expressionLi
st} ','?)? ']' | |
7003 * </pre> | |
7004 * @coverage dart.engine.ast | |
7005 */ | |
7006 class ListLiteral extends TypedLiteral { | |
7007 /** | |
7008 * The left square bracket. | |
7009 */ | |
7010 Token _leftBracket; | |
7011 /** | |
7012 * The expressions used to compute the elements of the list. | |
7013 */ | |
7014 NodeList<Expression> _elements; | |
7015 /** | |
7016 * The right square bracket. | |
7017 */ | |
7018 Token _rightBracket; | |
7019 /** | |
7020 * Initialize a newly created list literal. | |
7021 * @param modifier the const modifier associated with this literal | |
7022 * @param typeArguments the type argument associated with this literal, or {@c
ode null} if no type | |
7023 * arguments were declared | |
7024 * @param leftBracket the left square bracket | |
7025 * @param elements the expressions used to compute the elements of the list | |
7026 * @param rightBracket the right square bracket | |
7027 */ | |
7028 ListLiteral.full(Token modifier, TypeArgumentList typeArguments, Token leftBra
cket, List<Expression> elements, Token rightBracket) : super.full(modifier, type
Arguments) { | |
7029 this._elements = new NodeList<Expression>(this); | |
7030 this._leftBracket = leftBracket; | |
7031 this._elements.addAll(elements); | |
7032 this._rightBracket = rightBracket; | |
7033 } | |
7034 /** | |
7035 * Initialize a newly created list literal. | |
7036 * @param modifier the const modifier associated with this literal | |
7037 * @param typeArguments the type argument associated with this literal, or {@c
ode null} if no type | |
7038 * arguments were declared | |
7039 * @param leftBracket the left square bracket | |
7040 * @param elements the expressions used to compute the elements of the list | |
7041 * @param rightBracket the right square bracket | |
7042 */ | |
7043 ListLiteral({Token modifier, TypeArgumentList typeArguments, Token leftBracket
, List<Expression> elements, Token rightBracket}) : this.full(modifier, typeArgu
ments, leftBracket, elements, rightBracket); | |
7044 accept(ASTVisitor visitor) => visitor.visitListLiteral(this); | |
7045 Token get beginToken { | |
7046 Token token = modifier; | |
7047 if (token != null) { | |
7048 return token; | |
7049 } | |
7050 TypeArgumentList typeArguments6 = typeArguments; | |
7051 if (typeArguments6 != null) { | |
7052 return typeArguments6.beginToken; | |
7053 } | |
7054 return _leftBracket; | |
7055 } | |
7056 /** | |
7057 * Return the expressions used to compute the elements of the list. | |
7058 * @return the expressions used to compute the elements of the list | |
7059 */ | |
7060 NodeList<Expression> get elements => _elements; | |
7061 Token get endToken => _rightBracket; | |
7062 /** | |
7063 * Return the left square bracket. | |
7064 * @return the left square bracket | |
7065 */ | |
7066 Token get leftBracket => _leftBracket; | |
7067 /** | |
7068 * Return the right square bracket. | |
7069 * @return the right square bracket | |
7070 */ | |
7071 Token get rightBracket => _rightBracket; | |
7072 /** | |
7073 * Set the left square bracket to the given token. | |
7074 * @param bracket the left square bracket | |
7075 */ | |
7076 void set leftBracket(Token bracket) { | |
7077 _leftBracket = bracket; | |
7078 } | |
7079 /** | |
7080 * Set the right square bracket to the given token. | |
7081 * @param bracket the right square bracket | |
7082 */ | |
7083 void set rightBracket(Token bracket) { | |
7084 _rightBracket = bracket; | |
7085 } | |
7086 void visitChildren(ASTVisitor<Object> visitor) { | |
7087 super.visitChildren(visitor); | |
7088 _elements.accept(visitor); | |
7089 } | |
7090 } | |
7091 /** | |
7092 * The abstract class {@code Literal} defines the behavior common to nodes that
represent a literal | |
7093 * expression. | |
7094 * <pre> | |
7095 * literal ::={@link BooleanLiteral booleanLiteral}| {@link DoubleLiteral double
Literal}| {@link IntegerLiteral integerLiteral}| {@link ListLiteral listLiteral}
| {@link MapLiteral mapLiteral}| {@link NullLiteral nullLiteral}| {@link StringL
iteral stringLiteral}</pre> | |
7096 * @coverage dart.engine.ast | |
7097 */ | |
7098 abstract class Literal extends Expression { | |
7099 } | |
7100 /** | |
7101 * Instances of the class {@code MapLiteral} represent a literal map. | |
7102 * <pre> | |
7103 * mapLiteral ::= | |
7104 * 'const'? ('<' {@link TypeName type} '>')? '{' ({@link MapLiteralEntry entry}
(',' {@link MapLiteralEntry entry})* ','?)? '}' | |
7105 * </pre> | |
7106 * @coverage dart.engine.ast | |
7107 */ | |
7108 class MapLiteral extends TypedLiteral { | |
7109 /** | |
7110 * The left curly bracket. | |
7111 */ | |
7112 Token _leftBracket; | |
7113 /** | |
7114 * The entries in the map. | |
7115 */ | |
7116 NodeList<MapLiteralEntry> _entries; | |
7117 /** | |
7118 * The right curly bracket. | |
7119 */ | |
7120 Token _rightBracket; | |
7121 /** | |
7122 * Initialize a newly created map literal. | |
7123 * @param modifier the const modifier associated with this literal | |
7124 * @param typeArguments the type argument associated with this literal, or {@c
ode null} if no type | |
7125 * arguments were declared | |
7126 * @param leftBracket the left curly bracket | |
7127 * @param entries the entries in the map | |
7128 * @param rightBracket the right curly bracket | |
7129 */ | |
7130 MapLiteral.full(Token modifier, TypeArgumentList typeArguments, Token leftBrac
ket, List<MapLiteralEntry> entries, Token rightBracket) : super.full(modifier, t
ypeArguments) { | |
7131 this._entries = new NodeList<MapLiteralEntry>(this); | |
7132 this._leftBracket = leftBracket; | |
7133 this._entries.addAll(entries); | |
7134 this._rightBracket = rightBracket; | |
7135 } | |
7136 /** | |
7137 * Initialize a newly created map literal. | |
7138 * @param modifier the const modifier associated with this literal | |
7139 * @param typeArguments the type argument associated with this literal, or {@c
ode null} if no type | |
7140 * arguments were declared | |
7141 * @param leftBracket the left curly bracket | |
7142 * @param entries the entries in the map | |
7143 * @param rightBracket the right curly bracket | |
7144 */ | |
7145 MapLiteral({Token modifier, TypeArgumentList typeArguments, Token leftBracket,
List<MapLiteralEntry> entries, Token rightBracket}) : this.full(modifier, typeA
rguments, leftBracket, entries, rightBracket); | |
7146 accept(ASTVisitor visitor) => visitor.visitMapLiteral(this); | |
7147 Token get beginToken { | |
7148 Token token = modifier; | |
7149 if (token != null) { | |
7150 return token; | |
7151 } | |
7152 TypeArgumentList typeArguments7 = typeArguments; | |
7153 if (typeArguments7 != null) { | |
7154 return typeArguments7.beginToken; | |
7155 } | |
7156 return _leftBracket; | |
7157 } | |
7158 Token get endToken => _rightBracket; | |
7159 /** | |
7160 * Return the entries in the map. | |
7161 * @return the entries in the map | |
7162 */ | |
7163 NodeList<MapLiteralEntry> get entries => _entries; | |
7164 /** | |
7165 * Return the left curly bracket. | |
7166 * @return the left curly bracket | |
7167 */ | |
7168 Token get leftBracket => _leftBracket; | |
7169 /** | |
7170 * Return the right curly bracket. | |
7171 * @return the right curly bracket | |
7172 */ | |
7173 Token get rightBracket => _rightBracket; | |
7174 /** | |
7175 * Set the left curly bracket to the given token. | |
7176 * @param bracket the left curly bracket | |
7177 */ | |
7178 void set leftBracket(Token bracket) { | |
7179 _leftBracket = bracket; | |
7180 } | |
7181 /** | |
7182 * Set the right curly bracket to the given token. | |
7183 * @param bracket the right curly bracket | |
7184 */ | |
7185 void set rightBracket(Token bracket) { | |
7186 _rightBracket = bracket; | |
7187 } | |
7188 void visitChildren(ASTVisitor<Object> visitor) { | |
7189 super.visitChildren(visitor); | |
7190 _entries.accept(visitor); | |
7191 } | |
7192 } | |
7193 /** | |
7194 * Instances of the class {@code MapLiteralEntry} represent a single key/value p
air in a map | |
7195 * literal. | |
7196 * <pre> | |
7197 * mapLiteralEntry ::={@link StringLiteral key} ':' {@link Expression value}</pr
e> | |
7198 * @coverage dart.engine.ast | |
7199 */ | |
7200 class MapLiteralEntry extends ASTNode { | |
7201 /** | |
7202 * The key with which the value will be associated. | |
7203 */ | |
7204 StringLiteral _key; | |
7205 /** | |
7206 * The colon that separates the key from the value. | |
7207 */ | |
7208 Token _separator; | |
7209 /** | |
7210 * The expression computing the value that will be associated with the key. | |
7211 */ | |
7212 Expression _value; | |
7213 /** | |
7214 * Initialize a newly created map literal entry. | |
7215 * @param key the key with which the value will be associated | |
7216 * @param separator the colon that separates the key from the value | |
7217 * @param value the expression computing the value that will be associated wit
h the key | |
7218 */ | |
7219 MapLiteralEntry.full(StringLiteral key, Token separator, Expression value) { | |
7220 this._key = becomeParentOf(key); | |
7221 this._separator = separator; | |
7222 this._value = becomeParentOf(value); | |
7223 } | |
7224 /** | |
7225 * Initialize a newly created map literal entry. | |
7226 * @param key the key with which the value will be associated | |
7227 * @param separator the colon that separates the key from the value | |
7228 * @param value the expression computing the value that will be associated wit
h the key | |
7229 */ | |
7230 MapLiteralEntry({StringLiteral key, Token separator, Expression value}) : this
.full(key, separator, value); | |
7231 accept(ASTVisitor visitor) => visitor.visitMapLiteralEntry(this); | |
7232 Token get beginToken => _key.beginToken; | |
7233 Token get endToken => _value.endToken; | |
7234 /** | |
7235 * Return the key with which the value will be associated. | |
7236 * @return the key with which the value will be associated | |
7237 */ | |
7238 StringLiteral get key => _key; | |
7239 /** | |
7240 * Return the colon that separates the key from the value. | |
7241 * @return the colon that separates the key from the value | |
7242 */ | |
7243 Token get separator => _separator; | |
7244 /** | |
7245 * Return the expression computing the value that will be associated with the
key. | |
7246 * @return the expression computing the value that will be associated with the
key | |
7247 */ | |
7248 Expression get value => _value; | |
7249 /** | |
7250 * Set the key with which the value will be associated to the given string. | |
7251 * @param string the key with which the value will be associated | |
7252 */ | |
7253 void set key(StringLiteral string) { | |
7254 _key = becomeParentOf(string); | |
7255 } | |
7256 /** | |
7257 * Set the colon that separates the key from the value to the given token. | |
7258 * @param separator the colon that separates the key from the value | |
7259 */ | |
7260 void set separator(Token separator4) { | |
7261 this._separator = separator4; | |
7262 } | |
7263 /** | |
7264 * Set the expression computing the value that will be associated with the key
to the given | |
7265 * expression. | |
7266 * @param expression the expression computing the value that will be associate
d with the key | |
7267 */ | |
7268 void set value(Expression expression) { | |
7269 _value = becomeParentOf(expression); | |
7270 } | |
7271 void visitChildren(ASTVisitor<Object> visitor) { | |
7272 safelyVisitChild(_key, visitor); | |
7273 safelyVisitChild(_value, visitor); | |
7274 } | |
7275 } | |
7276 /** | |
7277 * Instances of the class {@code MethodDeclaration} represent a method declarati
on. | |
7278 * <pre> | |
7279 * methodDeclaration ::= | |
7280 * methodSignature {@link FunctionBody body}methodSignature ::= | |
7281 * 'external'? ('abstract' | 'static')? {@link Type returnType}? ('get' | 'set')
? methodName{@link FormalParameterList formalParameterList}methodName ::={@link
SimpleIdentifier name}| 'operator' {@link SimpleIdentifier operator}</pre> | |
7282 * @coverage dart.engine.ast | |
7283 */ | |
7284 class MethodDeclaration extends ClassMember { | |
7285 /** | |
7286 * The token for the 'external' keyword, or {@code null} if the constructor is
not external. | |
7287 */ | |
7288 Token _externalKeyword; | |
7289 /** | |
7290 * The token representing the 'abstract' or 'static' keyword, or {@code null}
if neither modifier | |
7291 * was specified. | |
7292 */ | |
7293 Token _modifierKeyword; | |
7294 /** | |
7295 * The return type of the method, or {@code null} if no return type was declar
ed. | |
7296 */ | |
7297 TypeName _returnType; | |
7298 /** | |
7299 * The token representing the 'get' or 'set' keyword, or {@code null} if this
is a method | |
7300 * declaration rather than a property declaration. | |
7301 */ | |
7302 Token _propertyKeyword; | |
7303 /** | |
7304 * The token representing the 'operator' keyword, or {@code null} if this meth
od does not declare | |
7305 * an operator. | |
7306 */ | |
7307 Token _operatorKeyword; | |
7308 /** | |
7309 * The name of the method. | |
7310 */ | |
7311 SimpleIdentifier _name; | |
7312 /** | |
7313 * The parameters associated with the method, or {@code null} if this method d
eclares a getter. | |
7314 */ | |
7315 FormalParameterList _parameters; | |
7316 /** | |
7317 * The body of the method. | |
7318 */ | |
7319 FunctionBody _body; | |
7320 /** | |
7321 * Initialize a newly created method declaration. | |
7322 * @param externalKeyword the token for the 'external' keyword | |
7323 * @param comment the documentation comment associated with this method | |
7324 * @param metadata the annotations associated with this method | |
7325 * @param modifierKeyword the token representing the 'abstract' or 'static' ke
yword | |
7326 * @param returnType the return type of the method | |
7327 * @param propertyKeyword the token representing the 'get' or 'set' keyword | |
7328 * @param operatorKeyword the token representing the 'operator' keyword | |
7329 * @param name the name of the method | |
7330 * @param parameters the parameters associated with the method, or {@code null
} if this method | |
7331 * declares a getter | |
7332 * @param body the body of the method | |
7333 */ | |
7334 MethodDeclaration.full(Comment comment, List<Annotation> metadata, Token exter
nalKeyword, Token modifierKeyword, TypeName returnType, Token propertyKeyword, T
oken operatorKeyword, SimpleIdentifier name, FormalParameterList parameters, Fun
ctionBody body) : super.full(comment, metadata) { | |
7335 this._externalKeyword = externalKeyword; | |
7336 this._modifierKeyword = modifierKeyword; | |
7337 this._returnType = becomeParentOf(returnType); | |
7338 this._propertyKeyword = propertyKeyword; | |
7339 this._operatorKeyword = operatorKeyword; | |
7340 this._name = becomeParentOf(name); | |
7341 this._parameters = becomeParentOf(parameters); | |
7342 this._body = becomeParentOf(body); | |
7343 } | |
7344 /** | |
7345 * Initialize a newly created method declaration. | |
7346 * @param externalKeyword the token for the 'external' keyword | |
7347 * @param comment the documentation comment associated with this method | |
7348 * @param metadata the annotations associated with this method | |
7349 * @param modifierKeyword the token representing the 'abstract' or 'static' ke
yword | |
7350 * @param returnType the return type of the method | |
7351 * @param propertyKeyword the token representing the 'get' or 'set' keyword | |
7352 * @param operatorKeyword the token representing the 'operator' keyword | |
7353 * @param name the name of the method | |
7354 * @param parameters the parameters associated with the method, or {@code null
} if this method | |
7355 * declares a getter | |
7356 * @param body the body of the method | |
7357 */ | |
7358 MethodDeclaration({Comment comment, List<Annotation> metadata, Token externalK
eyword, Token modifierKeyword, TypeName returnType, Token propertyKeyword, Token
operatorKeyword, SimpleIdentifier name, FormalParameterList parameters, Functio
nBody body}) : this.full(comment, metadata, externalKeyword, modifierKeyword, re
turnType, propertyKeyword, operatorKeyword, name, parameters, body); | |
7359 accept(ASTVisitor visitor) => visitor.visitMethodDeclaration(this); | |
7360 /** | |
7361 * Return the body of the method. | |
7362 * @return the body of the method | |
7363 */ | |
7364 FunctionBody get body => _body; | |
7365 /** | |
7366 * Return the element associated with this method, or {@code null} if the AST
structure has not | |
7367 * been resolved. The element can either be a {@link MethodElement}, if this r
epresents the | |
7368 * declaration of a normal method, or a {@link PropertyAccessorElement} if thi
s represents the | |
7369 * declaration of either a getter or a setter. | |
7370 * @return the element associated with this method | |
7371 */ | |
7372 ExecutableElement get element => _name != null ? (_name.element as ExecutableE
lement) : null; | |
7373 Token get endToken => _body.endToken; | |
7374 /** | |
7375 * Return the token for the 'external' keyword, or {@code null} if the constru
ctor is not | |
7376 * external. | |
7377 * @return the token for the 'external' keyword | |
7378 */ | |
7379 Token get externalKeyword => _externalKeyword; | |
7380 /** | |
7381 * Return the token representing the 'abstract' or 'static' keyword, or {@code
null} if neither | |
7382 * modifier was specified. | |
7383 * @return the token representing the 'abstract' or 'static' keyword | |
7384 */ | |
7385 Token get modifierKeyword => _modifierKeyword; | |
7386 /** | |
7387 * Return the name of the method. | |
7388 * @return the name of the method | |
7389 */ | |
7390 SimpleIdentifier get name => _name; | |
7391 /** | |
7392 * Return the token representing the 'operator' keyword, or {@code null} if th
is method does not | |
7393 * declare an operator. | |
7394 * @return the token representing the 'operator' keyword | |
7395 */ | |
7396 Token get operatorKeyword => _operatorKeyword; | |
7397 /** | |
7398 * Return the parameters associated with the method, or {@code null} if this m
ethod declares a | |
7399 * getter. | |
7400 * @return the parameters associated with the method | |
7401 */ | |
7402 FormalParameterList get parameters => _parameters; | |
7403 /** | |
7404 * Return the token representing the 'get' or 'set' keyword, or {@code null} i
f this is a method | |
7405 * declaration rather than a property declaration. | |
7406 * @return the token representing the 'get' or 'set' keyword | |
7407 */ | |
7408 Token get propertyKeyword => _propertyKeyword; | |
7409 /** | |
7410 * Return the return type of the method, or {@code null} if no return type was
declared. | |
7411 * @return the return type of the method | |
7412 */ | |
7413 TypeName get returnType => _returnType; | |
7414 /** | |
7415 * Return {@code true} if this method is declared to be an abstract method. | |
7416 * @return {@code true} if this method is declared to be an abstract method | |
7417 */ | |
7418 bool isAbstract() => _modifierKeyword != null && identical(((_modifierKeyword
as KeywordToken)).keyword, Keyword.ABSTRACT); | |
7419 /** | |
7420 * Return {@code true} if this method declares a getter. | |
7421 * @return {@code true} if this method declares a getter | |
7422 */ | |
7423 bool isGetter() => _propertyKeyword != null && identical(((_propertyKeyword as
KeywordToken)).keyword, Keyword.GET); | |
7424 /** | |
7425 * Return {@code true} if this method declares an operator. | |
7426 * @return {@code true} if this method declares an operator | |
7427 */ | |
7428 bool isOperator() => _operatorKeyword != null; | |
7429 /** | |
7430 * Return {@code true} if this method declares a setter. | |
7431 * @return {@code true} if this method declares a setter | |
7432 */ | |
7433 bool isSetter() => _propertyKeyword != null && identical(((_propertyKeyword as
KeywordToken)).keyword, Keyword.SET); | |
7434 /** | |
7435 * Return {@code true} if this method is declared to be a static method. | |
7436 * @return {@code true} if this method is declared to be a static method | |
7437 */ | |
7438 bool isStatic() => _modifierKeyword != null && identical(((_modifierKeyword as
KeywordToken)).keyword, Keyword.STATIC); | |
7439 /** | |
7440 * Set the body of the method to the given function body. | |
7441 * @param functionBody the body of the method | |
7442 */ | |
7443 void set body(FunctionBody functionBody) { | |
7444 _body = becomeParentOf(functionBody); | |
7445 } | |
7446 /** | |
7447 * Set the token for the 'external' keyword to the given token. | |
7448 * @param externalKeyword the token for the 'external' keyword | |
7449 */ | |
7450 void set externalKeyword(Token externalKeyword4) { | |
7451 this._externalKeyword = externalKeyword4; | |
7452 } | |
7453 /** | |
7454 * Set the token representing the 'abstract' or 'static' keyword to the given
token. | |
7455 * @param modifierKeyword the token representing the 'abstract' or 'static' ke
yword | |
7456 */ | |
7457 void set modifierKeyword(Token modifierKeyword2) { | |
7458 this._modifierKeyword = modifierKeyword2; | |
7459 } | |
7460 /** | |
7461 * Set the name of the method to the given identifier. | |
7462 * @param identifier the name of the method | |
7463 */ | |
7464 void set name(SimpleIdentifier identifier) { | |
7465 _name = becomeParentOf(identifier); | |
7466 } | |
7467 /** | |
7468 * Set the token representing the 'operator' keyword to the given token. | |
7469 * @param operatorKeyword the token representing the 'operator' keyword | |
7470 */ | |
7471 void set operatorKeyword(Token operatorKeyword2) { | |
7472 this._operatorKeyword = operatorKeyword2; | |
7473 } | |
7474 /** | |
7475 * Set the parameters associated with the method to the given list of paramete
rs. | |
7476 * @param parameters the parameters associated with the method | |
7477 */ | |
7478 void set parameters(FormalParameterList parameters6) { | |
7479 this._parameters = becomeParentOf(parameters6); | |
7480 } | |
7481 /** | |
7482 * Set the token representing the 'get' or 'set' keyword to the given token. | |
7483 * @param propertyKeyword the token representing the 'get' or 'set' keyword | |
7484 */ | |
7485 void set propertyKeyword(Token propertyKeyword3) { | |
7486 this._propertyKeyword = propertyKeyword3; | |
7487 } | |
7488 /** | |
7489 * Set the return type of the method to the given type name. | |
7490 * @param typeName the return type of the method | |
7491 */ | |
7492 void set returnType(TypeName typeName) { | |
7493 _returnType = becomeParentOf(typeName); | |
7494 } | |
7495 void visitChildren(ASTVisitor<Object> visitor) { | |
7496 super.visitChildren(visitor); | |
7497 safelyVisitChild(_returnType, visitor); | |
7498 safelyVisitChild(_name, visitor); | |
7499 safelyVisitChild(_parameters, visitor); | |
7500 safelyVisitChild(_body, visitor); | |
7501 } | |
7502 Token get firstTokenAfterCommentAndMetadata { | |
7503 if (_modifierKeyword != null) { | |
7504 return _modifierKeyword; | |
7505 } else if (_returnType != null) { | |
7506 return _returnType.beginToken; | |
7507 } else if (_propertyKeyword != null) { | |
7508 return _propertyKeyword; | |
7509 } else if (_operatorKeyword != null) { | |
7510 return _operatorKeyword; | |
7511 } | |
7512 return _name.beginToken; | |
7513 } | |
7514 } | |
7515 /** | |
7516 * Instances of the class {@code MethodInvocation} represent the invocation of e
ither a function or | |
7517 * a method. Invocations of functions resulting from evaluating an expression ar
e represented by{@link FunctionExpressionInvocation function expression invocati
on} nodes. Invocations of getters | |
7518 * and setters are represented by either {@link PrefixedIdentifier prefixed iden
tifier} or{@link PropertyAccess property access} nodes. | |
7519 * <pre> | |
7520 * methodInvoction ::= | |
7521 * ({@link Expression target} '.')? {@link SimpleIdentifier methodName} {@link A
rgumentList argumentList}</pre> | |
7522 * @coverage dart.engine.ast | |
7523 */ | |
7524 class MethodInvocation extends Expression { | |
7525 /** | |
7526 * The expression producing the object on which the method is defined, or {@co
de null} if there is | |
7527 * no target (that is, the target is implicitly {@code this}). | |
7528 */ | |
7529 Expression _target; | |
7530 /** | |
7531 * The period that separates the target from the method name, or {@code null}
if there is no | |
7532 * target. | |
7533 */ | |
7534 Token _period; | |
7535 /** | |
7536 * The name of the method being invoked. | |
7537 */ | |
7538 SimpleIdentifier _methodName; | |
7539 /** | |
7540 * The list of arguments to the method. | |
7541 */ | |
7542 ArgumentList _argumentList; | |
7543 /** | |
7544 * Initialize a newly created method invocation. | |
7545 * @param target the expression producing the object on which the method is de
fined | |
7546 * @param period the period that separates the target from the method name | |
7547 * @param methodName the name of the method being invoked | |
7548 * @param argumentList the list of arguments to the method | |
7549 */ | |
7550 MethodInvocation.full(Expression target, Token period, SimpleIdentifier method
Name, ArgumentList argumentList) { | |
7551 this._target = becomeParentOf(target); | |
7552 this._period = period; | |
7553 this._methodName = becomeParentOf(methodName); | |
7554 this._argumentList = becomeParentOf(argumentList); | |
7555 } | |
7556 /** | |
7557 * Initialize a newly created method invocation. | |
7558 * @param target the expression producing the object on which the method is de
fined | |
7559 * @param period the period that separates the target from the method name | |
7560 * @param methodName the name of the method being invoked | |
7561 * @param argumentList the list of arguments to the method | |
7562 */ | |
7563 MethodInvocation({Expression target, Token period, SimpleIdentifier methodName
, ArgumentList argumentList}) : this.full(target, period, methodName, argumentLi
st); | |
7564 accept(ASTVisitor visitor) => visitor.visitMethodInvocation(this); | |
7565 /** | |
7566 * Return the list of arguments to the method. | |
7567 * @return the list of arguments to the method | |
7568 */ | |
7569 ArgumentList get argumentList => _argumentList; | |
7570 Token get beginToken { | |
7571 if (_target != null) { | |
7572 return _target.beginToken; | |
7573 } | |
7574 return _methodName.beginToken; | |
7575 } | |
7576 Token get endToken => _argumentList.endToken; | |
7577 /** | |
7578 * Return the name of the method being invoked. | |
7579 * @return the name of the method being invoked | |
7580 */ | |
7581 SimpleIdentifier get methodName => _methodName; | |
7582 /** | |
7583 * Return the period that separates the target from the method name, or {@code
null} if there is | |
7584 * no target. | |
7585 * @return the period that separates the target from the method name | |
7586 */ | |
7587 Token get period => _period; | |
7588 /** | |
7589 * Return the expression used to compute the receiver of the invocation. If th
is invocation is not | |
7590 * part of a cascade expression, then this is the same as {@link #getTarget()}
. If this invocation | |
7591 * is part of a cascade expression, then the target stored with the cascade ex
pression is | |
7592 * returned. | |
7593 * @return the expression used to compute the receiver of the invocation | |
7594 * @see #getTarget() | |
7595 */ | |
7596 Expression get realTarget { | |
7597 if (isCascaded()) { | |
7598 ASTNode ancestor = parent; | |
7599 while (ancestor is! CascadeExpression) { | |
7600 if (ancestor == null) { | |
7601 return _target; | |
7602 } | |
7603 ancestor = ancestor.parent; | |
7604 } | |
7605 return ((ancestor as CascadeExpression)).target; | |
7606 } | |
7607 return _target; | |
7608 } | |
7609 /** | |
7610 * Return the expression producing the object on which the method is defined,
or {@code null} if | |
7611 * there is no target (that is, the target is implicitly {@code this}) or if t
his method | |
7612 * invocation is part of a cascade expression. | |
7613 * @return the expression producing the object on which the method is defined | |
7614 * @see #getRealTarget() | |
7615 */ | |
7616 Expression get target => _target; | |
7617 /** | |
7618 * Return {@code true} if this expression is cascaded. If it is, then the targ
et of this | |
7619 * expression is not stored locally but is stored in the nearest ancestor that
is a{@link CascadeExpression}. | |
7620 * @return {@code true} if this expression is cascaded | |
7621 */ | |
7622 bool isCascaded() => _period != null && identical(_period.type, TokenType.PERI
OD_PERIOD); | |
7623 /** | |
7624 * Set the list of arguments to the method to the given list. | |
7625 * @param argumentList the list of arguments to the method | |
7626 */ | |
7627 void set argumentList(ArgumentList argumentList7) { | |
7628 this._argumentList = becomeParentOf(argumentList7); | |
7629 } | |
7630 /** | |
7631 * Set the name of the method being invoked to the given identifier. | |
7632 * @param identifier the name of the method being invoked | |
7633 */ | |
7634 void set methodName(SimpleIdentifier identifier) { | |
7635 _methodName = becomeParentOf(identifier); | |
7636 } | |
7637 /** | |
7638 * Set the period that separates the target from the method name to the given
token. | |
7639 * @param period the period that separates the target from the method name | |
7640 */ | |
7641 void set period(Token period9) { | |
7642 this._period = period9; | |
7643 } | |
7644 /** | |
7645 * Set the expression producing the object on which the method is defined to t
he given expression. | |
7646 * @param expression the expression producing the object on which the method i
s defined | |
7647 */ | |
7648 void set target(Expression expression) { | |
7649 _target = becomeParentOf(expression); | |
7650 } | |
7651 void visitChildren(ASTVisitor<Object> visitor) { | |
7652 safelyVisitChild(_target, visitor); | |
7653 safelyVisitChild(_methodName, visitor); | |
7654 safelyVisitChild(_argumentList, visitor); | |
7655 } | |
7656 } | |
7657 /** | |
7658 * Instances of the class {@code NamedExpression} represent an expression that h
as a name associated | |
7659 * with it. They are used in method invocations when there are named parameters. | |
7660 * <pre> | |
7661 * namedExpression ::={@link Label name} {@link Expression expression}</pre> | |
7662 * @coverage dart.engine.ast | |
7663 */ | |
7664 class NamedExpression extends Expression { | |
7665 /** | |
7666 * The name associated with the expression. | |
7667 */ | |
7668 Label _name; | |
7669 /** | |
7670 * The expression with which the name is associated. | |
7671 */ | |
7672 Expression _expression; | |
7673 /** | |
7674 * Initialize a newly created named expression. | |
7675 * @param name the name associated with the expression | |
7676 * @param expression the expression with which the name is associated | |
7677 */ | |
7678 NamedExpression.full(Label name, Expression expression) { | |
7679 this._name = becomeParentOf(name); | |
7680 this._expression = becomeParentOf(expression); | |
7681 } | |
7682 /** | |
7683 * Initialize a newly created named expression. | |
7684 * @param name the name associated with the expression | |
7685 * @param expression the expression with which the name is associated | |
7686 */ | |
7687 NamedExpression({Label name, Expression expression}) : this.full(name, express
ion); | |
7688 accept(ASTVisitor visitor) => visitor.visitNamedExpression(this); | |
7689 Token get beginToken => _name.beginToken; | |
7690 /** | |
7691 * Return the element representing the parameter being named by this expressio
n, or {@code null}if the AST structure has not been resolved or if there is no p
arameter with the same name as | |
7692 * this expression. | |
7693 * @return the element representing the parameter being named by this expressi
on | |
7694 */ | |
7695 ParameterElement get element { | |
7696 Element element20 = _name.label.element; | |
7697 if (element20 is ParameterElement) { | |
7698 return element20 as ParameterElement; | |
7699 } | |
7700 return null; | |
7701 } | |
7702 Token get endToken => _expression.endToken; | |
7703 /** | |
7704 * Return the expression with which the name is associated. | |
7705 * @return the expression with which the name is associated | |
7706 */ | |
7707 Expression get expression => _expression; | |
7708 /** | |
7709 * Return the name associated with the expression. | |
7710 * @return the name associated with the expression | |
7711 */ | |
7712 Label get name => _name; | |
7713 /** | |
7714 * Set the expression with which the name is associated to the given expressio
n. | |
7715 * @param expression the expression with which the name is associated | |
7716 */ | |
7717 void set expression(Expression expression8) { | |
7718 this._expression = becomeParentOf(expression8); | |
7719 } | |
7720 /** | |
7721 * Set the name associated with the expression to the given identifier. | |
7722 * @param identifier the name associated with the expression | |
7723 */ | |
7724 void set name(Label identifier) { | |
7725 _name = becomeParentOf(identifier); | |
7726 } | |
7727 void visitChildren(ASTVisitor<Object> visitor) { | |
7728 safelyVisitChild(_name, visitor); | |
7729 safelyVisitChild(_expression, visitor); | |
7730 } | |
7731 } | |
7732 /** | |
7733 * The abstract class {@code NamespaceDirective} defines the behavior common to
nodes that represent | |
7734 * a directive that impacts the namespace of a library. | |
7735 * <pre> | |
7736 * directive ::={@link ExportDirective exportDirective}| {@link ImportDirective
importDirective}</pre> | |
7737 * @coverage dart.engine.ast | |
7738 */ | |
7739 abstract class NamespaceDirective extends UriBasedDirective { | |
7740 /** | |
7741 * The token representing the 'import' or 'export' keyword. | |
7742 */ | |
7743 Token _keyword; | |
7744 /** | |
7745 * The combinators used to control which names are imported or exported. | |
7746 */ | |
7747 NodeList<Combinator> _combinators; | |
7748 /** | |
7749 * The semicolon terminating the directive. | |
7750 */ | |
7751 Token _semicolon; | |
7752 /** | |
7753 * Initialize a newly created namespace directive. | |
7754 * @param comment the documentation comment associated with this directive | |
7755 * @param metadata the annotations associated with the directive | |
7756 * @param keyword the token representing the 'import' or 'export' keyword | |
7757 * @param libraryUri the URI of the library being imported or exported | |
7758 * @param combinators the combinators used to control which names are imported
or exported | |
7759 * @param semicolon the semicolon terminating the directive | |
7760 */ | |
7761 NamespaceDirective.full(Comment comment, List<Annotation> metadata, Token keyw
ord, StringLiteral libraryUri, List<Combinator> combinators, Token semicolon) :
super.full(comment, metadata, libraryUri) { | |
7762 this._combinators = new NodeList<Combinator>(this); | |
7763 this._keyword = keyword; | |
7764 this._combinators.addAll(combinators); | |
7765 this._semicolon = semicolon; | |
7766 } | |
7767 /** | |
7768 * Initialize a newly created namespace directive. | |
7769 * @param comment the documentation comment associated with this directive | |
7770 * @param metadata the annotations associated with the directive | |
7771 * @param keyword the token representing the 'import' or 'export' keyword | |
7772 * @param libraryUri the URI of the library being imported or exported | |
7773 * @param combinators the combinators used to control which names are imported
or exported | |
7774 * @param semicolon the semicolon terminating the directive | |
7775 */ | |
7776 NamespaceDirective({Comment comment, List<Annotation> metadata, Token keyword,
StringLiteral libraryUri, List<Combinator> combinators, Token semicolon}) : thi
s.full(comment, metadata, keyword, libraryUri, combinators, semicolon); | |
7777 /** | |
7778 * Return the combinators used to control how names are imported or exported. | |
7779 * @return the combinators used to control how names are imported or exported | |
7780 */ | |
7781 NodeList<Combinator> get combinators => _combinators; | |
7782 Token get endToken => _semicolon; | |
7783 Token get keyword => _keyword; | |
7784 /** | |
7785 * Return the semicolon terminating the directive. | |
7786 * @return the semicolon terminating the directive | |
7787 */ | |
7788 Token get semicolon => _semicolon; | |
7789 /** | |
7790 * Set the token representing the 'import' or 'export' keyword to the given to
ken. | |
7791 * @param exportToken the token representing the 'import' or 'export' keyword | |
7792 */ | |
7793 void set keyword(Token exportToken) { | |
7794 this._keyword = exportToken; | |
7795 } | |
7796 /** | |
7797 * Set the semicolon terminating the directive to the given token. | |
7798 * @param semicolon the semicolon terminating the directive | |
7799 */ | |
7800 void set semicolon(Token semicolon12) { | |
7801 this._semicolon = semicolon12; | |
7802 } | |
7803 Token get firstTokenAfterCommentAndMetadata => _keyword; | |
7804 } | |
7805 /** | |
7806 * The abstract class {@code NormalFormalParameter} defines the behavior common
to formal parameters | |
7807 * that are required (are not optional). | |
7808 * <pre> | |
7809 * normalFormalParameter ::={@link FunctionTypedFormalParameter functionSignatur
e}| {@link FieldFormalParameter fieldFormalParameter}| {@link SimpleFormalParame
ter simpleFormalParameter}</pre> | |
7810 * @coverage dart.engine.ast | |
7811 */ | |
7812 abstract class NormalFormalParameter extends FormalParameter { | |
7813 /** | |
7814 * The documentation comment associated with this parameter, or {@code null} i
f this parameter | |
7815 * does not have a documentation comment associated with it. | |
7816 */ | |
7817 Comment _comment; | |
7818 /** | |
7819 * The annotations associated with this parameter. | |
7820 */ | |
7821 NodeList<Annotation> _metadata; | |
7822 /** | |
7823 * The name of the parameter being declared. | |
7824 */ | |
7825 SimpleIdentifier _identifier; | |
7826 /** | |
7827 * Initialize a newly created formal parameter. | |
7828 * @param comment the documentation comment associated with this parameter | |
7829 * @param metadata the annotations associated with this parameter | |
7830 * @param identifier the name of the parameter being declared | |
7831 */ | |
7832 NormalFormalParameter.full(Comment comment, List<Annotation> metadata, SimpleI
dentifier identifier) { | |
7833 this._metadata = new NodeList<Annotation>(this); | |
7834 this._comment = becomeParentOf(comment); | |
7835 this._metadata.addAll(metadata); | |
7836 this._identifier = becomeParentOf(identifier); | |
7837 } | |
7838 /** | |
7839 * Initialize a newly created formal parameter. | |
7840 * @param comment the documentation comment associated with this parameter | |
7841 * @param metadata the annotations associated with this parameter | |
7842 * @param identifier the name of the parameter being declared | |
7843 */ | |
7844 NormalFormalParameter({Comment comment, List<Annotation> metadata, SimpleIdent
ifier identifier}) : this.full(comment, metadata, identifier); | |
7845 /** | |
7846 * Return the documentation comment associated with this parameter, or {@code
null} if this | |
7847 * parameter does not have a documentation comment associated with it. | |
7848 * @return the documentation comment associated with this parameter | |
7849 */ | |
7850 Comment get documentationComment => _comment; | |
7851 SimpleIdentifier get identifier => _identifier; | |
7852 ParameterKind get kind { | |
7853 ASTNode parent6 = parent; | |
7854 if (parent6 is DefaultFormalParameter) { | |
7855 return ((parent6 as DefaultFormalParameter)).kind; | |
7856 } | |
7857 return ParameterKind.REQUIRED; | |
7858 } | |
7859 /** | |
7860 * Return the annotations associated with this parameter. | |
7861 * @return the annotations associated with this parameter | |
7862 */ | |
7863 NodeList<Annotation> get metadata => _metadata; | |
7864 /** | |
7865 * Return {@code true} if this parameter was declared with the 'const' modifie
r. | |
7866 * @return {@code true} if this parameter was declared with the 'const' modifi
er | |
7867 */ | |
7868 bool isConst(); | |
7869 /** | |
7870 * Return {@code true} if this parameter was declared with the 'final' modifie
r. Parameters that | |
7871 * are declared with the 'const' modifier will return {@code false} even thoug
h they are | |
7872 * implicitly final. | |
7873 * @return {@code true} if this parameter was declared with the 'final' modifi
er | |
7874 */ | |
7875 bool isFinal(); | |
7876 /** | |
7877 * Set the documentation comment associated with this parameter to the given c
omment | |
7878 * @param comment the documentation comment to be associated with this paramet
er | |
7879 */ | |
7880 void set documentationComment(Comment comment3) { | |
7881 this._comment = becomeParentOf(comment3); | |
7882 } | |
7883 /** | |
7884 * Set the name of the parameter being declared to the given identifier. | |
7885 * @param identifier the name of the parameter being declared | |
7886 */ | |
7887 void set identifier(SimpleIdentifier identifier8) { | |
7888 this._identifier = becomeParentOf(identifier8); | |
7889 } | |
7890 void visitChildren(ASTVisitor<Object> visitor) { | |
7891 if (commentIsBeforeAnnotations()) { | |
7892 safelyVisitChild(_comment, visitor); | |
7893 _metadata.accept(visitor); | |
7894 } else { | |
7895 for (ASTNode child in sortedCommentAndAnnotations) { | |
7896 child.accept(visitor); | |
7897 } | |
7898 } | |
7899 } | |
7900 /** | |
7901 * Return {@code true} if the comment is lexically before any annotations. | |
7902 * @return {@code true} if the comment is lexically before any annotations | |
7903 */ | |
7904 bool commentIsBeforeAnnotations() { | |
7905 if (_comment == null || _metadata.isEmpty) { | |
7906 return true; | |
7907 } | |
7908 Annotation firstAnnotation = _metadata[0]; | |
7909 return _comment.offset < firstAnnotation.offset; | |
7910 } | |
7911 /** | |
7912 * Return an array containing the comment and annotations associated with this
parameter, sorted | |
7913 * in lexical order. | |
7914 * @return the comment and annotations associated with this parameter in the o
rder in which they | |
7915 * appeared in the original source | |
7916 */ | |
7917 List<ASTNode> get sortedCommentAndAnnotations { | |
7918 List<ASTNode> childList = new List<ASTNode>(); | |
7919 childList.add(_comment); | |
7920 childList.addAll(_metadata); | |
7921 List<ASTNode> children = new List.from(childList); | |
7922 children.sort(); | |
7923 return children; | |
7924 } | |
7925 } | |
7926 /** | |
7927 * Instances of the class {@code NullLiteral} represent a null literal expressio
n. | |
7928 * <pre> | |
7929 * nullLiteral ::= | |
7930 * 'null' | |
7931 * </pre> | |
7932 * @coverage dart.engine.ast | |
7933 */ | |
7934 class NullLiteral extends Literal { | |
7935 /** | |
7936 * The token representing the literal. | |
7937 */ | |
7938 Token _literal; | |
7939 /** | |
7940 * Initialize a newly created null literal. | |
7941 * @param token the token representing the literal | |
7942 */ | |
7943 NullLiteral.full(Token token) { | |
7944 this._literal = token; | |
7945 } | |
7946 /** | |
7947 * Initialize a newly created null literal. | |
7948 * @param token the token representing the literal | |
7949 */ | |
7950 NullLiteral({Token token}) : this.full(token); | |
7951 accept(ASTVisitor visitor) => visitor.visitNullLiteral(this); | |
7952 Token get beginToken => _literal; | |
7953 Token get endToken => _literal; | |
7954 /** | |
7955 * Return the token representing the literal. | |
7956 * @return the token representing the literal | |
7957 */ | |
7958 Token get literal => _literal; | |
7959 /** | |
7960 * Set the token representing the literal to the given token. | |
7961 * @param literal the token representing the literal | |
7962 */ | |
7963 void set literal(Token literal5) { | |
7964 this._literal = literal5; | |
7965 } | |
7966 void visitChildren(ASTVisitor<Object> visitor) { | |
7967 } | |
7968 } | |
7969 /** | |
7970 * Instances of the class {@code ParenthesizedExpression} represent a parenthesi
zed expression. | |
7971 * <pre> | |
7972 * parenthesizedExpression ::= | |
7973 * '(' {@link Expression expression} ')' | |
7974 * </pre> | |
7975 * @coverage dart.engine.ast | |
7976 */ | |
7977 class ParenthesizedExpression extends Expression { | |
7978 /** | |
7979 * The left parenthesis. | |
7980 */ | |
7981 Token _leftParenthesis; | |
7982 /** | |
7983 * The expression within the parentheses. | |
7984 */ | |
7985 Expression _expression; | |
7986 /** | |
7987 * The right parenthesis. | |
7988 */ | |
7989 Token _rightParenthesis; | |
7990 /** | |
7991 * Initialize a newly created parenthesized expression. | |
7992 * @param leftParenthesis the left parenthesis | |
7993 * @param expression the expression within the parentheses | |
7994 * @param rightParenthesis the right parenthesis | |
7995 */ | |
7996 ParenthesizedExpression.full(Token leftParenthesis, Expression expression, Tok
en rightParenthesis) { | |
7997 this._leftParenthesis = leftParenthesis; | |
7998 this._expression = becomeParentOf(expression); | |
7999 this._rightParenthesis = rightParenthesis; | |
8000 } | |
8001 /** | |
8002 * Initialize a newly created parenthesized expression. | |
8003 * @param leftParenthesis the left parenthesis | |
8004 * @param expression the expression within the parentheses | |
8005 * @param rightParenthesis the right parenthesis | |
8006 */ | |
8007 ParenthesizedExpression({Token leftParenthesis, Expression expression, Token r
ightParenthesis}) : this.full(leftParenthesis, expression, rightParenthesis); | |
8008 accept(ASTVisitor visitor) => visitor.visitParenthesizedExpression(this); | |
8009 Token get beginToken => _leftParenthesis; | |
8010 Token get endToken => _rightParenthesis; | |
8011 /** | |
8012 * Return the expression within the parentheses. | |
8013 * @return the expression within the parentheses | |
8014 */ | |
8015 Expression get expression => _expression; | |
8016 /** | |
8017 * Return the left parenthesis. | |
8018 * @return the left parenthesis | |
8019 */ | |
8020 Token get leftParenthesis => _leftParenthesis; | |
8021 /** | |
8022 * Return the right parenthesis. | |
8023 * @return the right parenthesis | |
8024 */ | |
8025 Token get rightParenthesis => _rightParenthesis; | |
8026 /** | |
8027 * Set the expression within the parentheses to the given expression. | |
8028 * @param expression the expression within the parentheses | |
8029 */ | |
8030 void set expression(Expression expression9) { | |
8031 this._expression = becomeParentOf(expression9); | |
8032 } | |
8033 /** | |
8034 * Set the left parenthesis to the given token. | |
8035 * @param parenthesis the left parenthesis | |
8036 */ | |
8037 void set leftParenthesis(Token parenthesis) { | |
8038 _leftParenthesis = parenthesis; | |
8039 } | |
8040 /** | |
8041 * Set the right parenthesis to the given token. | |
8042 * @param parenthesis the right parenthesis | |
8043 */ | |
8044 void set rightParenthesis(Token parenthesis) { | |
8045 _rightParenthesis = parenthesis; | |
8046 } | |
8047 void visitChildren(ASTVisitor<Object> visitor) { | |
8048 safelyVisitChild(_expression, visitor); | |
8049 } | |
8050 } | |
8051 /** | |
8052 * Instances of the class {@code PartDirective} represent a part directive. | |
8053 * <pre> | |
8054 * partDirective ::={@link Annotation metadata} 'part' {@link StringLiteral part
Uri} ';' | |
8055 * </pre> | |
8056 * @coverage dart.engine.ast | |
8057 */ | |
8058 class PartDirective extends UriBasedDirective { | |
8059 /** | |
8060 * The token representing the 'part' token. | |
8061 */ | |
8062 Token _partToken; | |
8063 /** | |
8064 * The semicolon terminating the directive. | |
8065 */ | |
8066 Token _semicolon; | |
8067 /** | |
8068 * Initialize a newly created part directive. | |
8069 * @param comment the documentation comment associated with this directive | |
8070 * @param metadata the annotations associated with the directive | |
8071 * @param partToken the token representing the 'part' token | |
8072 * @param partUri the URI of the part being included | |
8073 * @param semicolon the semicolon terminating the directive | |
8074 */ | |
8075 PartDirective.full(Comment comment, List<Annotation> metadata, Token partToken
, StringLiteral partUri, Token semicolon) : super.full(comment, metadata, partUr
i) { | |
8076 this._partToken = partToken; | |
8077 this._semicolon = semicolon; | |
8078 } | |
8079 /** | |
8080 * Initialize a newly created part directive. | |
8081 * @param comment the documentation comment associated with this directive | |
8082 * @param metadata the annotations associated with the directive | |
8083 * @param partToken the token representing the 'part' token | |
8084 * @param partUri the URI of the part being included | |
8085 * @param semicolon the semicolon terminating the directive | |
8086 */ | |
8087 PartDirective({Comment comment, List<Annotation> metadata, Token partToken, St
ringLiteral partUri, Token semicolon}) : this.full(comment, metadata, partToken,
partUri, semicolon); | |
8088 accept(ASTVisitor visitor) => visitor.visitPartDirective(this); | |
8089 Token get endToken => _semicolon; | |
8090 Token get keyword => _partToken; | |
8091 /** | |
8092 * Return the token representing the 'part' token. | |
8093 * @return the token representing the 'part' token | |
8094 */ | |
8095 Token get partToken => _partToken; | |
8096 /** | |
8097 * Return the semicolon terminating the directive. | |
8098 * @return the semicolon terminating the directive | |
8099 */ | |
8100 Token get semicolon => _semicolon; | |
8101 /** | |
8102 * Set the token representing the 'part' token to the given token. | |
8103 * @param partToken the token representing the 'part' token | |
8104 */ | |
8105 void set partToken(Token partToken2) { | |
8106 this._partToken = partToken2; | |
8107 } | |
8108 /** | |
8109 * Set the semicolon terminating the directive to the given token. | |
8110 * @param semicolon the semicolon terminating the directive | |
8111 */ | |
8112 void set semicolon(Token semicolon13) { | |
8113 this._semicolon = semicolon13; | |
8114 } | |
8115 Token get firstTokenAfterCommentAndMetadata => _partToken; | |
8116 } | |
8117 /** | |
8118 * Instances of the class {@code PartOfDirective} represent a part-of directive. | |
8119 * <pre> | |
8120 * partOfDirective ::={@link Annotation metadata} 'part' 'of' {@link Identifier
libraryName} ';' | |
8121 * </pre> | |
8122 * @coverage dart.engine.ast | |
8123 */ | |
8124 class PartOfDirective extends Directive { | |
8125 /** | |
8126 * The token representing the 'part' token. | |
8127 */ | |
8128 Token _partToken; | |
8129 /** | |
8130 * The token representing the 'of' token. | |
8131 */ | |
8132 Token _ofToken; | |
8133 /** | |
8134 * The name of the library that the containing compilation unit is part of. | |
8135 */ | |
8136 LibraryIdentifier _libraryName; | |
8137 /** | |
8138 * The semicolon terminating the directive. | |
8139 */ | |
8140 Token _semicolon; | |
8141 /** | |
8142 * Initialize a newly created part-of directive. | |
8143 * @param comment the documentation comment associated with this directive | |
8144 * @param metadata the annotations associated with the directive | |
8145 * @param partToken the token representing the 'part' token | |
8146 * @param ofToken the token representing the 'of' token | |
8147 * @param libraryName the name of the library that the containing compilation
unit is part of | |
8148 * @param semicolon the semicolon terminating the directive | |
8149 */ | |
8150 PartOfDirective.full(Comment comment, List<Annotation> metadata, Token partTok
en, Token ofToken, LibraryIdentifier libraryName, Token semicolon) : super.full(
comment, metadata) { | |
8151 this._partToken = partToken; | |
8152 this._ofToken = ofToken; | |
8153 this._libraryName = becomeParentOf(libraryName); | |
8154 this._semicolon = semicolon; | |
8155 } | |
8156 /** | |
8157 * Initialize a newly created part-of directive. | |
8158 * @param comment the documentation comment associated with this directive | |
8159 * @param metadata the annotations associated with the directive | |
8160 * @param partToken the token representing the 'part' token | |
8161 * @param ofToken the token representing the 'of' token | |
8162 * @param libraryName the name of the library that the containing compilation
unit is part of | |
8163 * @param semicolon the semicolon terminating the directive | |
8164 */ | |
8165 PartOfDirective({Comment comment, List<Annotation> metadata, Token partToken,
Token ofToken, LibraryIdentifier libraryName, Token semicolon}) : this.full(comm
ent, metadata, partToken, ofToken, libraryName, semicolon); | |
8166 accept(ASTVisitor visitor) => visitor.visitPartOfDirective(this); | |
8167 Token get endToken => _semicolon; | |
8168 Token get keyword => _partToken; | |
8169 /** | |
8170 * Return the name of the library that the containing compilation unit is part
of. | |
8171 * @return the name of the library that the containing compilation unit is par
t of | |
8172 */ | |
8173 LibraryIdentifier get libraryName => _libraryName; | |
8174 /** | |
8175 * Return the token representing the 'of' token. | |
8176 * @return the token representing the 'of' token | |
8177 */ | |
8178 Token get ofToken => _ofToken; | |
8179 /** | |
8180 * Return the token representing the 'part' token. | |
8181 * @return the token representing the 'part' token | |
8182 */ | |
8183 Token get partToken => _partToken; | |
8184 /** | |
8185 * Return the semicolon terminating the directive. | |
8186 * @return the semicolon terminating the directive | |
8187 */ | |
8188 Token get semicolon => _semicolon; | |
8189 /** | |
8190 * Set the name of the library that the containing compilation unit is part of
to the given name. | |
8191 * @param libraryName the name of the library that the containing compilation
unit is part of | |
8192 */ | |
8193 void set libraryName(LibraryIdentifier libraryName2) { | |
8194 this._libraryName = becomeParentOf(libraryName2); | |
8195 } | |
8196 /** | |
8197 * Set the token representing the 'of' token to the given token. | |
8198 * @param ofToken the token representing the 'of' token | |
8199 */ | |
8200 void set ofToken(Token ofToken2) { | |
8201 this._ofToken = ofToken2; | |
8202 } | |
8203 /** | |
8204 * Set the token representing the 'part' token to the given token. | |
8205 * @param partToken the token representing the 'part' token | |
8206 */ | |
8207 void set partToken(Token partToken3) { | |
8208 this._partToken = partToken3; | |
8209 } | |
8210 /** | |
8211 * Set the semicolon terminating the directive to the given token. | |
8212 * @param semicolon the semicolon terminating the directive | |
8213 */ | |
8214 void set semicolon(Token semicolon14) { | |
8215 this._semicolon = semicolon14; | |
8216 } | |
8217 void visitChildren(ASTVisitor<Object> visitor) { | |
8218 super.visitChildren(visitor); | |
8219 safelyVisitChild(_libraryName, visitor); | |
8220 } | |
8221 Token get firstTokenAfterCommentAndMetadata => _partToken; | |
8222 } | |
8223 /** | |
8224 * Instances of the class {@code PostfixExpression} represent a postfix unary ex
pression. | |
8225 * <pre> | |
8226 * postfixExpression ::={@link Expression operand} {@link Token operator}</pre> | |
8227 * @coverage dart.engine.ast | |
8228 */ | |
8229 class PostfixExpression extends Expression { | |
8230 /** | |
8231 * The expression computing the operand for the operator. | |
8232 */ | |
8233 Expression _operand; | |
8234 /** | |
8235 * The postfix operator being applied to the operand. | |
8236 */ | |
8237 Token _operator; | |
8238 /** | |
8239 * The element associated with this the operator, or {@code null} if the AST s
tructure has not | |
8240 * been resolved, if the operator is not user definable, or if the operator co
uld not be resolved. | |
8241 */ | |
8242 MethodElement _element; | |
8243 /** | |
8244 * Initialize a newly created postfix expression. | |
8245 * @param operand the expression computing the operand for the operator | |
8246 * @param operator the postfix operator being applied to the operand | |
8247 */ | |
8248 PostfixExpression.full(Expression operand, Token operator) { | |
8249 this._operand = becomeParentOf(operand); | |
8250 this._operator = operator; | |
8251 } | |
8252 /** | |
8253 * Initialize a newly created postfix expression. | |
8254 * @param operand the expression computing the operand for the operator | |
8255 * @param operator the postfix operator being applied to the operand | |
8256 */ | |
8257 PostfixExpression({Expression operand, Token operator}) : this.full(operand, o
perator); | |
8258 accept(ASTVisitor visitor) => visitor.visitPostfixExpression(this); | |
8259 Token get beginToken => _operand.beginToken; | |
8260 /** | |
8261 * Return the element associated with the operator, or {@code null} if the AST
structure has not | |
8262 * been resolved, if the operator is not user definable, or if the operator co
uld not be resolved. | |
8263 * One example of the latter case is an operator that is not defined for the t
ype of the operand. | |
8264 * @return the element associated with the operator | |
8265 */ | |
8266 MethodElement get element => _element; | |
8267 Token get endToken => _operator; | |
8268 /** | |
8269 * Return the expression computing the operand for the operator. | |
8270 * @return the expression computing the operand for the operator | |
8271 */ | |
8272 Expression get operand => _operand; | |
8273 /** | |
8274 * Return the postfix operator being applied to the operand. | |
8275 * @return the postfix operator being applied to the operand | |
8276 */ | |
8277 Token get operator => _operator; | |
8278 /** | |
8279 * Set the element associated with the operator to the given element. | |
8280 * @param element the element associated with the operator | |
8281 */ | |
8282 void set element(MethodElement element13) { | |
8283 this._element = element13; | |
8284 } | |
8285 /** | |
8286 * Set the expression computing the operand for the operator to the given expr
ession. | |
8287 * @param expression the expression computing the operand for the operator | |
8288 */ | |
8289 void set operand(Expression expression) { | |
8290 _operand = becomeParentOf(expression); | |
8291 } | |
8292 /** | |
8293 * Set the postfix operator being applied to the operand to the given operator
. | |
8294 * @param operator the postfix operator being applied to the operand | |
8295 */ | |
8296 void set operator(Token operator4) { | |
8297 this._operator = operator4; | |
8298 } | |
8299 void visitChildren(ASTVisitor<Object> visitor) { | |
8300 safelyVisitChild(_operand, visitor); | |
8301 } | |
8302 } | |
8303 /** | |
8304 * Instances of the class {@code PrefixExpression} represent a prefix unary expr
ession. | |
8305 * <pre> | |
8306 * prefixExpression ::={@link Token operator} {@link Expression operand}</pre> | |
8307 * @coverage dart.engine.ast | |
8308 */ | |
8309 class PrefixExpression extends Expression { | |
8310 /** | |
8311 * The prefix operator being applied to the operand. | |
8312 */ | |
8313 Token _operator; | |
8314 /** | |
8315 * The expression computing the operand for the operator. | |
8316 */ | |
8317 Expression _operand; | |
8318 /** | |
8319 * The element associated with the operator, or {@code null} if the AST struct
ure has not been | |
8320 * resolved, if the operator is not user definable, or if the operator could n
ot be resolved. | |
8321 */ | |
8322 MethodElement _element; | |
8323 /** | |
8324 * Initialize a newly created prefix expression. | |
8325 * @param operator the prefix operator being applied to the operand | |
8326 * @param operand the expression computing the operand for the operator | |
8327 */ | |
8328 PrefixExpression.full(Token operator, Expression operand) { | |
8329 this._operator = operator; | |
8330 this._operand = becomeParentOf(operand); | |
8331 } | |
8332 /** | |
8333 * Initialize a newly created prefix expression. | |
8334 * @param operator the prefix operator being applied to the operand | |
8335 * @param operand the expression computing the operand for the operator | |
8336 */ | |
8337 PrefixExpression({Token operator, Expression operand}) : this.full(operator, o
perand); | |
8338 accept(ASTVisitor visitor) => visitor.visitPrefixExpression(this); | |
8339 Token get beginToken => _operator; | |
8340 /** | |
8341 * Return the element associated with the operator, or {@code null} if the AST
structure has not | |
8342 * been resolved, if the operator is not user definable, or if the operator co
uld not be resolved. | |
8343 * One example of the latter case is an operator that is not defined for the t
ype of the operand. | |
8344 * @return the element associated with the operator | |
8345 */ | |
8346 MethodElement get element => _element; | |
8347 Token get endToken => _operand.endToken; | |
8348 /** | |
8349 * Return the expression computing the operand for the operator. | |
8350 * @return the expression computing the operand for the operator | |
8351 */ | |
8352 Expression get operand => _operand; | |
8353 /** | |
8354 * Return the prefix operator being applied to the operand. | |
8355 * @return the prefix operator being applied to the operand | |
8356 */ | |
8357 Token get operator => _operator; | |
8358 /** | |
8359 * Set the element associated with the operator to the given element. | |
8360 * @param element the element associated with the operator | |
8361 */ | |
8362 void set element(MethodElement element14) { | |
8363 this._element = element14; | |
8364 } | |
8365 /** | |
8366 * Set the expression computing the operand for the operator to the given expr
ession. | |
8367 * @param expression the expression computing the operand for the operator | |
8368 */ | |
8369 void set operand(Expression expression) { | |
8370 _operand = becomeParentOf(expression); | |
8371 } | |
8372 /** | |
8373 * Set the prefix operator being applied to the operand to the given operator. | |
8374 * @param operator the prefix operator being applied to the operand | |
8375 */ | |
8376 void set operator(Token operator5) { | |
8377 this._operator = operator5; | |
8378 } | |
8379 void visitChildren(ASTVisitor<Object> visitor) { | |
8380 safelyVisitChild(_operand, visitor); | |
8381 } | |
8382 } | |
8383 /** | |
8384 * Instances of the class {@code PrefixedIdentifier} represent either an identif
ier that is prefixed | |
8385 * or an access to an object property where the target of the property access is
a simple | |
8386 * identifier. | |
8387 * <pre> | |
8388 * prefixedIdentifier ::={@link SimpleIdentifier prefix} '.' {@link SimpleIdenti
fier identifier}</pre> | |
8389 * @coverage dart.engine.ast | |
8390 */ | |
8391 class PrefixedIdentifier extends Identifier { | |
8392 /** | |
8393 * The prefix associated with the library in which the identifier is defined. | |
8394 */ | |
8395 SimpleIdentifier _prefix; | |
8396 /** | |
8397 * The period used to separate the prefix from the identifier. | |
8398 */ | |
8399 Token _period; | |
8400 /** | |
8401 * The identifier being prefixed. | |
8402 */ | |
8403 SimpleIdentifier _identifier; | |
8404 /** | |
8405 * Initialize a newly created prefixed identifier. | |
8406 * @param prefix the identifier being prefixed | |
8407 * @param period the period used to separate the prefix from the identifier | |
8408 * @param identifier the prefix associated with the library in which the ident
ifier is defined | |
8409 */ | |
8410 PrefixedIdentifier.full(SimpleIdentifier prefix, Token period, SimpleIdentifie
r identifier) { | |
8411 this._prefix = becomeParentOf(prefix); | |
8412 this._period = period; | |
8413 this._identifier = becomeParentOf(identifier); | |
8414 } | |
8415 /** | |
8416 * Initialize a newly created prefixed identifier. | |
8417 * @param prefix the identifier being prefixed | |
8418 * @param period the period used to separate the prefix from the identifier | |
8419 * @param identifier the prefix associated with the library in which the ident
ifier is defined | |
8420 */ | |
8421 PrefixedIdentifier({SimpleIdentifier prefix, Token period, SimpleIdentifier id
entifier}) : this.full(prefix, period, identifier); | |
8422 accept(ASTVisitor visitor) => visitor.visitPrefixedIdentifier(this); | |
8423 Token get beginToken => _prefix.beginToken; | |
8424 Element get element { | |
8425 if (_identifier == null) { | |
8426 return null; | |
8427 } | |
8428 return _identifier.element; | |
8429 } | |
8430 Token get endToken => _identifier.endToken; | |
8431 /** | |
8432 * Return the identifier being prefixed. | |
8433 * @return the identifier being prefixed | |
8434 */ | |
8435 SimpleIdentifier get identifier => _identifier; | |
8436 String get name => "${_prefix.name}.${_identifier.name}"; | |
8437 /** | |
8438 * Return the period used to separate the prefix from the identifier. | |
8439 * @return the period used to separate the prefix from the identifier | |
8440 */ | |
8441 Token get period => _period; | |
8442 /** | |
8443 * Return the prefix associated with the library in which the identifier is de
fined. | |
8444 * @return the prefix associated with the library in which the identifier is d
efined | |
8445 */ | |
8446 SimpleIdentifier get prefix => _prefix; | |
8447 /** | |
8448 * Set the identifier being prefixed to the given identifier. | |
8449 * @param identifier the identifier being prefixed | |
8450 */ | |
8451 void set identifier(SimpleIdentifier identifier9) { | |
8452 this._identifier = becomeParentOf(identifier9); | |
8453 } | |
8454 /** | |
8455 * Set the period used to separate the prefix from the identifier to the given
token. | |
8456 * @param period the period used to separate the prefix from the identifier | |
8457 */ | |
8458 void set period(Token period10) { | |
8459 this._period = period10; | |
8460 } | |
8461 /** | |
8462 * Set the prefix associated with the library in which the identifier is defin
ed to the given | |
8463 * identifier. | |
8464 * @param identifier the prefix associated with the library in which the ident
ifier is defined | |
8465 */ | |
8466 void set prefix(SimpleIdentifier identifier) { | |
8467 _prefix = becomeParentOf(identifier); | |
8468 } | |
8469 void visitChildren(ASTVisitor<Object> visitor) { | |
8470 safelyVisitChild(_prefix, visitor); | |
8471 safelyVisitChild(_identifier, visitor); | |
8472 } | |
8473 } | |
8474 /** | |
8475 * Instances of the class {@code PropertyAccess} represent the access of a prope
rty of an object. | |
8476 * <p> | |
8477 * Note, however, that accesses to properties of objects can also be represented
as{@link PrefixedIdentifier prefixed identifier} nodes in cases where the targe
t is also a simple | |
8478 * identifier. | |
8479 * <pre> | |
8480 * propertyAccess ::={@link Expression target} '.' {@link SimpleIdentifier prope
rtyName}</pre> | |
8481 * @coverage dart.engine.ast | |
8482 */ | |
8483 class PropertyAccess extends Expression { | |
8484 /** | |
8485 * The expression computing the object defining the property being accessed. | |
8486 */ | |
8487 Expression _target; | |
8488 /** | |
8489 * The property access operator. | |
8490 */ | |
8491 Token _operator; | |
8492 /** | |
8493 * The name of the property being accessed. | |
8494 */ | |
8495 SimpleIdentifier _propertyName; | |
8496 /** | |
8497 * Initialize a newly created property access expression. | |
8498 * @param target the expression computing the object defining the property bei
ng accessed | |
8499 * @param operator the property access operator | |
8500 * @param propertyName the name of the property being accessed | |
8501 */ | |
8502 PropertyAccess.full(Expression target, Token operator, SimpleIdentifier proper
tyName) { | |
8503 this._target = becomeParentOf(target); | |
8504 this._operator = operator; | |
8505 this._propertyName = becomeParentOf(propertyName); | |
8506 } | |
8507 /** | |
8508 * Initialize a newly created property access expression. | |
8509 * @param target the expression computing the object defining the property bei
ng accessed | |
8510 * @param operator the property access operator | |
8511 * @param propertyName the name of the property being accessed | |
8512 */ | |
8513 PropertyAccess({Expression target, Token operator, SimpleIdentifier propertyNa
me}) : this.full(target, operator, propertyName); | |
8514 accept(ASTVisitor visitor) => visitor.visitPropertyAccess(this); | |
8515 Token get beginToken { | |
8516 if (_target != null) { | |
8517 return _target.beginToken; | |
8518 } | |
8519 return _operator; | |
8520 } | |
8521 Token get endToken => _propertyName.endToken; | |
8522 /** | |
8523 * Return the property access operator. | |
8524 * @return the property access operator | |
8525 */ | |
8526 Token get operator => _operator; | |
8527 /** | |
8528 * Return the name of the property being accessed. | |
8529 * @return the name of the property being accessed | |
8530 */ | |
8531 SimpleIdentifier get propertyName => _propertyName; | |
8532 /** | |
8533 * Return the expression used to compute the receiver of the invocation. If th
is invocation is not | |
8534 * part of a cascade expression, then this is the same as {@link #getTarget()}
. If this invocation | |
8535 * is part of a cascade expression, then the target stored with the cascade ex
pression is | |
8536 * returned. | |
8537 * @return the expression used to compute the receiver of the invocation | |
8538 * @see #getTarget() | |
8539 */ | |
8540 Expression get realTarget { | |
8541 if (isCascaded()) { | |
8542 ASTNode ancestor = parent; | |
8543 while (ancestor is! CascadeExpression) { | |
8544 if (ancestor == null) { | |
8545 return _target; | |
8546 } | |
8547 ancestor = ancestor.parent; | |
8548 } | |
8549 return ((ancestor as CascadeExpression)).target; | |
8550 } | |
8551 return _target; | |
8552 } | |
8553 /** | |
8554 * Return the expression computing the object defining the property being acce
ssed, or{@code null} if this property access is part of a cascade expression. | |
8555 * @return the expression computing the object defining the property being acc
essed | |
8556 * @see #getRealTarget() | |
8557 */ | |
8558 Expression get target => _target; | |
8559 bool isAssignable() => true; | |
8560 /** | |
8561 * Return {@code true} if this expression is cascaded. If it is, then the targ
et of this | |
8562 * expression is not stored locally but is stored in the nearest ancestor that
is a{@link CascadeExpression}. | |
8563 * @return {@code true} if this expression is cascaded | |
8564 */ | |
8565 bool isCascaded() => _operator != null && identical(_operator.type, TokenType.
PERIOD_PERIOD); | |
8566 /** | |
8567 * Set the property access operator to the given token. | |
8568 * @param operator the property access operator | |
8569 */ | |
8570 void set operator(Token operator6) { | |
8571 this._operator = operator6; | |
8572 } | |
8573 /** | |
8574 * Set the name of the property being accessed to the given identifier. | |
8575 * @param identifier the name of the property being accessed | |
8576 */ | |
8577 void set propertyName(SimpleIdentifier identifier) { | |
8578 _propertyName = becomeParentOf(identifier); | |
8579 } | |
8580 /** | |
8581 * Set the expression computing the object defining the property being accesse
d to the given | |
8582 * expression. | |
8583 * @param expression the expression computing the object defining the property
being accessed | |
8584 */ | |
8585 void set target(Expression expression) { | |
8586 _target = becomeParentOf(expression); | |
8587 } | |
8588 void visitChildren(ASTVisitor<Object> visitor) { | |
8589 safelyVisitChild(_target, visitor); | |
8590 safelyVisitChild(_propertyName, visitor); | |
8591 } | |
8592 } | |
8593 /** | |
8594 * Instances of the class {@code RedirectingConstructorInvocation} represent the
invocation of a | |
8595 * another constructor in the same class from within a constructor's initializat
ion list. | |
8596 * <pre> | |
8597 * redirectingConstructorInvocation ::= | |
8598 * 'this' ('.' identifier)? arguments | |
8599 * </pre> | |
8600 * @coverage dart.engine.ast | |
8601 */ | |
8602 class RedirectingConstructorInvocation extends ConstructorInitializer { | |
8603 /** | |
8604 * The token for the 'this' keyword. | |
8605 */ | |
8606 Token _keyword; | |
8607 /** | |
8608 * The token for the period before the name of the constructor that is being i
nvoked, or{@code null} if the unnamed constructor is being invoked. | |
8609 */ | |
8610 Token _period; | |
8611 /** | |
8612 * The name of the constructor that is being invoked, or {@code null} if the u
nnamed constructor | |
8613 * is being invoked. | |
8614 */ | |
8615 SimpleIdentifier _constructorName; | |
8616 /** | |
8617 * The list of arguments to the constructor. | |
8618 */ | |
8619 ArgumentList _argumentList; | |
8620 /** | |
8621 * The element associated with the constructor, or {@code null} if the AST str
ucture has not been | |
8622 * resolved or if the constructor could not be resolved. | |
8623 */ | |
8624 ConstructorElement _element; | |
8625 /** | |
8626 * Initialize a newly created redirecting invocation to invoke the constructor
with the given name | |
8627 * with the given arguments. | |
8628 * @param keyword the token for the 'this' keyword | |
8629 * @param period the token for the period before the name of the constructor t
hat is being invoked | |
8630 * @param constructorName the name of the constructor that is being invoked | |
8631 * @param argumentList the list of arguments to the constructor | |
8632 */ | |
8633 RedirectingConstructorInvocation.full(Token keyword, Token period, SimpleIdent
ifier constructorName, ArgumentList argumentList) { | |
8634 this._keyword = keyword; | |
8635 this._period = period; | |
8636 this._constructorName = becomeParentOf(constructorName); | |
8637 this._argumentList = becomeParentOf(argumentList); | |
8638 } | |
8639 /** | |
8640 * Initialize a newly created redirecting invocation to invoke the constructor
with the given name | |
8641 * with the given arguments. | |
8642 * @param keyword the token for the 'this' keyword | |
8643 * @param period the token for the period before the name of the constructor t
hat is being invoked | |
8644 * @param constructorName the name of the constructor that is being invoked | |
8645 * @param argumentList the list of arguments to the constructor | |
8646 */ | |
8647 RedirectingConstructorInvocation({Token keyword, Token period, SimpleIdentifie
r constructorName, ArgumentList argumentList}) : this.full(keyword, period, cons
tructorName, argumentList); | |
8648 accept(ASTVisitor visitor) => visitor.visitRedirectingConstructorInvocation(th
is); | |
8649 /** | |
8650 * Return the list of arguments to the constructor. | |
8651 * @return the list of arguments to the constructor | |
8652 */ | |
8653 ArgumentList get argumentList => _argumentList; | |
8654 Token get beginToken => _keyword; | |
8655 /** | |
8656 * Return the name of the constructor that is being invoked, or {@code null} i
f the unnamed | |
8657 * constructor is being invoked. | |
8658 * @return the name of the constructor that is being invoked | |
8659 */ | |
8660 SimpleIdentifier get constructorName => _constructorName; | |
8661 /** | |
8662 * Return the element associated with the constructor, or {@code null} if the
AST structure has | |
8663 * not been resolved or if the constructor could not be resolved. | |
8664 * @return the element associated with the super constructor | |
8665 */ | |
8666 ConstructorElement get element => _element; | |
8667 Token get endToken => _argumentList.endToken; | |
8668 /** | |
8669 * Return the token for the 'this' keyword. | |
8670 * @return the token for the 'this' keyword | |
8671 */ | |
8672 Token get keyword => _keyword; | |
8673 /** | |
8674 * Return the token for the period before the name of the constructor that is
being invoked, or{@code null} if the unnamed constructor is being invoked. | |
8675 * @return the token for the period before the name of the constructor that is
being invoked | |
8676 */ | |
8677 Token get period => _period; | |
8678 /** | |
8679 * Set the list of arguments to the constructor to the given list. | |
8680 * @param argumentList the list of arguments to the constructor | |
8681 */ | |
8682 void set argumentList(ArgumentList argumentList8) { | |
8683 this._argumentList = becomeParentOf(argumentList8); | |
8684 } | |
8685 /** | |
8686 * Set the name of the constructor that is being invoked to the given identifi
er. | |
8687 * @param identifier the name of the constructor that is being invoked | |
8688 */ | |
8689 void set constructorName(SimpleIdentifier identifier) { | |
8690 _constructorName = becomeParentOf(identifier); | |
8691 } | |
8692 /** | |
8693 * Set the element associated with the constructor to the given element. | |
8694 * @param element the element associated with the constructor | |
8695 */ | |
8696 void set element(ConstructorElement element15) { | |
8697 this._element = element15; | |
8698 } | |
8699 /** | |
8700 * Set the token for the 'this' keyword to the given token. | |
8701 * @param keyword the token for the 'this' keyword | |
8702 */ | |
8703 void set keyword(Token keyword14) { | |
8704 this._keyword = keyword14; | |
8705 } | |
8706 /** | |
8707 * Set the token for the period before the name of the constructor that is bei
ng invoked to the | |
8708 * given token. | |
8709 * @param period the token for the period before the name of the constructor t
hat is being invoked | |
8710 */ | |
8711 void set period(Token period11) { | |
8712 this._period = period11; | |
8713 } | |
8714 void visitChildren(ASTVisitor<Object> visitor) { | |
8715 safelyVisitChild(_constructorName, visitor); | |
8716 safelyVisitChild(_argumentList, visitor); | |
8717 } | |
8718 } | |
8719 /** | |
8720 * Instances of the class {@code ReturnStatement} represent a return statement. | |
8721 * <pre> | |
8722 * returnStatement ::= | |
8723 * 'return' {@link Expression expression}? ';' | |
8724 * </pre> | |
8725 * @coverage dart.engine.ast | |
8726 */ | |
8727 class ReturnStatement extends Statement { | |
8728 /** | |
8729 * The token representing the 'return' keyword. | |
8730 */ | |
8731 Token _keyword; | |
8732 /** | |
8733 * The expression computing the value to be returned, or {@code null} if no ex
plicit value was | |
8734 * provided. | |
8735 */ | |
8736 Expression _expression; | |
8737 /** | |
8738 * The semicolon terminating the statement. | |
8739 */ | |
8740 Token _semicolon; | |
8741 /** | |
8742 * Initialize a newly created return statement. | |
8743 * @param keyword the token representing the 'return' keyword | |
8744 * @param expression the expression computing the value to be returned | |
8745 * @param semicolon the semicolon terminating the statement | |
8746 */ | |
8747 ReturnStatement.full(Token keyword, Expression expression, Token semicolon) { | |
8748 this._keyword = keyword; | |
8749 this._expression = becomeParentOf(expression); | |
8750 this._semicolon = semicolon; | |
8751 } | |
8752 /** | |
8753 * Initialize a newly created return statement. | |
8754 * @param keyword the token representing the 'return' keyword | |
8755 * @param expression the expression computing the value to be returned | |
8756 * @param semicolon the semicolon terminating the statement | |
8757 */ | |
8758 ReturnStatement({Token keyword, Expression expression, Token semicolon}) : thi
s.full(keyword, expression, semicolon); | |
8759 accept(ASTVisitor visitor) => visitor.visitReturnStatement(this); | |
8760 Token get beginToken => _keyword; | |
8761 Token get endToken => _semicolon; | |
8762 /** | |
8763 * Return the expression computing the value to be returned, or {@code null} i
f no explicit value | |
8764 * was provided. | |
8765 * @return the expression computing the value to be returned | |
8766 */ | |
8767 Expression get expression => _expression; | |
8768 /** | |
8769 * Return the token representing the 'return' keyword. | |
8770 * @return the token representing the 'return' keyword | |
8771 */ | |
8772 Token get keyword => _keyword; | |
8773 /** | |
8774 * Return the semicolon terminating the statement. | |
8775 * @return the semicolon terminating the statement | |
8776 */ | |
8777 Token get semicolon => _semicolon; | |
8778 /** | |
8779 * Set the expression computing the value to be returned to the given expressi
on. | |
8780 * @param expression the expression computing the value to be returned | |
8781 */ | |
8782 void set expression(Expression expression10) { | |
8783 this._expression = becomeParentOf(expression10); | |
8784 } | |
8785 /** | |
8786 * Set the token representing the 'return' keyword to the given token. | |
8787 * @param keyword the token representing the 'return' keyword | |
8788 */ | |
8789 void set keyword(Token keyword15) { | |
8790 this._keyword = keyword15; | |
8791 } | |
8792 /** | |
8793 * Set the semicolon terminating the statement to the given token. | |
8794 * @param semicolon the semicolon terminating the statement | |
8795 */ | |
8796 void set semicolon(Token semicolon15) { | |
8797 this._semicolon = semicolon15; | |
8798 } | |
8799 void visitChildren(ASTVisitor<Object> visitor) { | |
8800 safelyVisitChild(_expression, visitor); | |
8801 } | |
8802 } | |
8803 /** | |
8804 * Instances of the class {@code ScriptTag} represent the script tag that can op
tionally occur at | |
8805 * the beginning of a compilation unit. | |
8806 * <pre> | |
8807 * scriptTag ::= | |
8808 * '#!' (~NEWLINE)* NEWLINE | |
8809 * </pre> | |
8810 * @coverage dart.engine.ast | |
8811 */ | |
8812 class ScriptTag extends ASTNode { | |
8813 /** | |
8814 * The token representing this script tag. | |
8815 */ | |
8816 Token _scriptTag; | |
8817 /** | |
8818 * Initialize a newly created script tag. | |
8819 * @param scriptTag the token representing this script tag | |
8820 */ | |
8821 ScriptTag.full(Token scriptTag) { | |
8822 this._scriptTag = scriptTag; | |
8823 } | |
8824 /** | |
8825 * Initialize a newly created script tag. | |
8826 * @param scriptTag the token representing this script tag | |
8827 */ | |
8828 ScriptTag({Token scriptTag}) : this.full(scriptTag); | |
8829 accept(ASTVisitor visitor) => visitor.visitScriptTag(this); | |
8830 Token get beginToken => _scriptTag; | |
8831 Token get endToken => _scriptTag; | |
8832 /** | |
8833 * Return the token representing this script tag. | |
8834 * @return the token representing this script tag | |
8835 */ | |
8836 Token get scriptTag => _scriptTag; | |
8837 /** | |
8838 * Set the token representing this script tag to the given script tag. | |
8839 * @param scriptTag the token representing this script tag | |
8840 */ | |
8841 void set scriptTag(Token scriptTag3) { | |
8842 this._scriptTag = scriptTag3; | |
8843 } | |
8844 void visitChildren(ASTVisitor<Object> visitor) { | |
8845 } | |
8846 } | |
8847 /** | |
8848 * Instances of the class {@code ShowCombinator} represent a combinator that res
tricts the names | |
8849 * being imported to those in a given list. | |
8850 * <pre> | |
8851 * showCombinator ::= | |
8852 * 'show' {@link SimpleIdentifier identifier} (',' {@link SimpleIdentifier ident
ifier}) | |
8853 * </pre> | |
8854 * @coverage dart.engine.ast | |
8855 */ | |
8856 class ShowCombinator extends Combinator { | |
8857 /** | |
8858 * The list of names from the library that are made visible by this combinator
. | |
8859 */ | |
8860 NodeList<SimpleIdentifier> _shownNames; | |
8861 /** | |
8862 * Initialize a newly created import show combinator. | |
8863 * @param keyword the comma introducing the combinator | |
8864 * @param shownNames the list of names from the library that are made visible
by this combinator | |
8865 */ | |
8866 ShowCombinator.full(Token keyword, List<SimpleIdentifier> shownNames) : super.
full(keyword) { | |
8867 this._shownNames = new NodeList<SimpleIdentifier>(this); | |
8868 this._shownNames.addAll(shownNames); | |
8869 } | |
8870 /** | |
8871 * Initialize a newly created import show combinator. | |
8872 * @param keyword the comma introducing the combinator | |
8873 * @param shownNames the list of names from the library that are made visible
by this combinator | |
8874 */ | |
8875 ShowCombinator({Token keyword, List<SimpleIdentifier> shownNames}) : this.full
(keyword, shownNames); | |
8876 accept(ASTVisitor visitor) => visitor.visitShowCombinator(this); | |
8877 Token get endToken => _shownNames.endToken; | |
8878 /** | |
8879 * Return the list of names from the library that are made visible by this com
binator. | |
8880 * @return the list of names from the library that are made visible by this co
mbinator | |
8881 */ | |
8882 NodeList<SimpleIdentifier> get shownNames => _shownNames; | |
8883 void visitChildren(ASTVisitor<Object> visitor) { | |
8884 _shownNames.accept(visitor); | |
8885 } | |
8886 } | |
8887 /** | |
8888 * Instances of the class {@code SimpleFormalParameter} represent a simple forma
l parameter. | |
8889 * <pre> | |
8890 * simpleFormalParameter ::= | |
8891 * ('final' {@link TypeName type} | 'var' | {@link TypeName type})? {@link Simpl
eIdentifier identifier}</pre> | |
8892 * @coverage dart.engine.ast | |
8893 */ | |
8894 class SimpleFormalParameter extends NormalFormalParameter { | |
8895 /** | |
8896 * The token representing either the 'final', 'const' or 'var' keyword, or {@c
ode null} if no | |
8897 * keyword was used. | |
8898 */ | |
8899 Token _keyword; | |
8900 /** | |
8901 * The name of the declared type of the parameter, or {@code null} if the para
meter does not have | |
8902 * a declared type. | |
8903 */ | |
8904 TypeName _type; | |
8905 /** | |
8906 * Initialize a newly created formal parameter. | |
8907 * @param comment the documentation comment associated with this parameter | |
8908 * @param metadata the annotations associated with this parameter | |
8909 * @param keyword the token representing either the 'final', 'const' or 'var'
keyword | |
8910 * @param type the name of the declared type of the parameter | |
8911 * @param identifier the name of the parameter being declared | |
8912 */ | |
8913 SimpleFormalParameter.full(Comment comment, List<Annotation> metadata, Token k
eyword, TypeName type, SimpleIdentifier identifier) : super.full(comment, metada
ta, identifier) { | |
8914 this._keyword = keyword; | |
8915 this._type = becomeParentOf(type); | |
8916 } | |
8917 /** | |
8918 * Initialize a newly created formal parameter. | |
8919 * @param comment the documentation comment associated with this parameter | |
8920 * @param metadata the annotations associated with this parameter | |
8921 * @param keyword the token representing either the 'final', 'const' or 'var'
keyword | |
8922 * @param type the name of the declared type of the parameter | |
8923 * @param identifier the name of the parameter being declared | |
8924 */ | |
8925 SimpleFormalParameter({Comment comment, List<Annotation> metadata, Token keywo
rd, TypeName type, SimpleIdentifier identifier}) : this.full(comment, metadata,
keyword, type, identifier); | |
8926 accept(ASTVisitor visitor) => visitor.visitSimpleFormalParameter(this); | |
8927 Token get beginToken { | |
8928 if (_keyword != null) { | |
8929 return _keyword; | |
8930 } else if (_type != null) { | |
8931 return _type.beginToken; | |
8932 } | |
8933 return identifier.beginToken; | |
8934 } | |
8935 Token get endToken => identifier.endToken; | |
8936 /** | |
8937 * Return the token representing either the 'final', 'const' or 'var' keyword. | |
8938 * @return the token representing either the 'final', 'const' or 'var' keyword | |
8939 */ | |
8940 Token get keyword => _keyword; | |
8941 /** | |
8942 * Return the name of the declared type of the parameter, or {@code null} if t
he parameter does | |
8943 * not have a declared type. | |
8944 * @return the name of the declared type of the parameter | |
8945 */ | |
8946 TypeName get type => _type; | |
8947 bool isConst() => (_keyword is KeywordToken) && identical(((_keyword as Keywor
dToken)).keyword, Keyword.CONST); | |
8948 bool isFinal() => (_keyword is KeywordToken) && identical(((_keyword as Keywor
dToken)).keyword, Keyword.FINAL); | |
8949 /** | |
8950 * Set the token representing either the 'final', 'const' or 'var' keyword to
the given token. | |
8951 * @param keyword the token representing either the 'final', 'const' or 'var'
keyword | |
8952 */ | |
8953 void set keyword(Token keyword16) { | |
8954 this._keyword = keyword16; | |
8955 } | |
8956 /** | |
8957 * Set the name of the declared type of the parameter to the given type name. | |
8958 * @param typeName the name of the declared type of the parameter | |
8959 */ | |
8960 void set type(TypeName typeName) { | |
8961 _type = becomeParentOf(typeName); | |
8962 } | |
8963 void visitChildren(ASTVisitor<Object> visitor) { | |
8964 super.visitChildren(visitor); | |
8965 safelyVisitChild(_type, visitor); | |
8966 safelyVisitChild(identifier, visitor); | |
8967 } | |
8968 } | |
8969 /** | |
8970 * Instances of the class {@code SimpleIdentifier} represent a simple identifier
. | |
8971 * <pre> | |
8972 * simpleIdentifier ::= | |
8973 * initialCharacter internalCharacter | |
8974 * initialCharacter ::= '_' | '$' | letter | |
8975 * internalCharacter ::= '_' | '$' | letter | digit | |
8976 * </pre> | |
8977 * @coverage dart.engine.ast | |
8978 */ | |
8979 class SimpleIdentifier extends Identifier { | |
8980 /** | |
8981 * The token representing the identifier. | |
8982 */ | |
8983 Token _token; | |
8984 /** | |
8985 * The element associated with this identifier, or {@code null} if the AST str
ucture has not been | |
8986 * resolved or if this identifier could not be resolved. | |
8987 */ | |
8988 Element _element; | |
8989 /** | |
8990 * Initialize a newly created identifier. | |
8991 * @param token the token representing the identifier | |
8992 */ | |
8993 SimpleIdentifier.full(Token token) { | |
8994 this._token = token; | |
8995 } | |
8996 /** | |
8997 * Initialize a newly created identifier. | |
8998 * @param token the token representing the identifier | |
8999 */ | |
9000 SimpleIdentifier({Token token}) : this.full(token); | |
9001 accept(ASTVisitor visitor) => visitor.visitSimpleIdentifier(this); | |
9002 Token get beginToken => _token; | |
9003 Element get element => _element; | |
9004 Token get endToken => _token; | |
9005 String get name => _token.lexeme; | |
9006 /** | |
9007 * Return the token representing the identifier. | |
9008 * @return the token representing the identifier | |
9009 */ | |
9010 Token get token => _token; | |
9011 /** | |
9012 * Return {@code true} if this identifier is the name being declared in a decl
aration. | |
9013 * @return {@code true} if this identifier is the name being declared in a dec
laration | |
9014 */ | |
9015 bool inDeclarationContext() { | |
9016 ASTNode parent7 = parent; | |
9017 if (parent7 is CatchClause) { | |
9018 CatchClause clause = parent7 as CatchClause; | |
9019 return identical(this, clause.exceptionParameter) || identical(this, claus
e.stackTraceParameter); | |
9020 } else if (parent7 is ClassDeclaration) { | |
9021 return identical(this, ((parent7 as ClassDeclaration)).name); | |
9022 } else if (parent7 is ClassTypeAlias) { | |
9023 return identical(this, ((parent7 as ClassTypeAlias)).name); | |
9024 } else if (parent7 is ConstructorDeclaration) { | |
9025 return identical(this, ((parent7 as ConstructorDeclaration)).name); | |
9026 } else if (parent7 is FunctionDeclaration) { | |
9027 return identical(this, ((parent7 as FunctionDeclaration)).name); | |
9028 } else if (parent7 is FunctionTypeAlias) { | |
9029 return identical(this, ((parent7 as FunctionTypeAlias)).name); | |
9030 } else if (parent7 is Label) { | |
9031 return identical(this, ((parent7 as Label)).label) && (parent7.parent is L
abeledStatement); | |
9032 } else if (parent7 is MethodDeclaration) { | |
9033 return identical(this, ((parent7 as MethodDeclaration)).name); | |
9034 } else if (parent7 is NormalFormalParameter) { | |
9035 return identical(this, ((parent7 as NormalFormalParameter)).identifier); | |
9036 } else if (parent7 is TypeParameter) { | |
9037 return identical(this, ((parent7 as TypeParameter)).name); | |
9038 } else if (parent7 is VariableDeclaration) { | |
9039 return identical(this, ((parent7 as VariableDeclaration)).name); | |
9040 } | |
9041 return false; | |
9042 } | |
9043 /** | |
9044 * Return {@code true} if this expression is computing a right-hand value. | |
9045 * <p> | |
9046 * Note that {@link #inGetterContext()} and {@link #inSetterContext()} are not
opposites, nor are | |
9047 * they mutually exclusive. In other words, it is possible for both methods to
return {@code true}when invoked on the same node. | |
9048 * @return {@code true} if this expression is in a context where a getter will
be invoked | |
9049 */ | |
9050 bool inGetterContext() { | |
9051 ASTNode parent8 = parent; | |
9052 ASTNode target = this; | |
9053 if (parent8 is PrefixedIdentifier) { | |
9054 PrefixedIdentifier prefixed = parent8 as PrefixedIdentifier; | |
9055 if (identical(prefixed.prefix, this)) { | |
9056 return true; | |
9057 } | |
9058 parent8 = prefixed.parent; | |
9059 target = prefixed; | |
9060 } else if (parent8 is PropertyAccess) { | |
9061 PropertyAccess access = parent8 as PropertyAccess; | |
9062 if (identical(access.target, this)) { | |
9063 return true; | |
9064 } | |
9065 parent8 = access.parent; | |
9066 target = access; | |
9067 } | |
9068 if (parent8 is AssignmentExpression) { | |
9069 AssignmentExpression expr = parent8 as AssignmentExpression; | |
9070 if (identical(expr.leftHandSide, target) && identical(expr.operator.type,
TokenType.EQ)) { | |
9071 return false; | |
9072 } | |
9073 } | |
9074 return true; | |
9075 } | |
9076 /** | |
9077 * Return {@code true} if this expression is computing a left-hand value. | |
9078 * <p> | |
9079 * Note that {@link #inGetterContext()} and {@link #inSetterContext()} are not
opposites, nor are | |
9080 * they mutually exclusive. In other words, it is possible for both methods to
return {@code true}when invoked on the same node. | |
9081 * @return {@code true} if this expression is in a context where a setter will
be invoked | |
9082 */ | |
9083 bool inSetterContext() { | |
9084 ASTNode parent9 = parent; | |
9085 ASTNode target = this; | |
9086 if (parent9 is PrefixedIdentifier) { | |
9087 PrefixedIdentifier prefixed = parent9 as PrefixedIdentifier; | |
9088 if (identical(prefixed.prefix, this)) { | |
9089 return false; | |
9090 } | |
9091 parent9 = prefixed.parent; | |
9092 target = prefixed; | |
9093 } else if (parent9 is PropertyAccess) { | |
9094 PropertyAccess access = parent9 as PropertyAccess; | |
9095 if (identical(access.target, this)) { | |
9096 return false; | |
9097 } | |
9098 parent9 = access.parent; | |
9099 target = access; | |
9100 } | |
9101 if (parent9 is PrefixExpression) { | |
9102 return ((parent9 as PrefixExpression)).operator.type.isIncrementOperator()
; | |
9103 } else if (parent9 is PostfixExpression) { | |
9104 return true; | |
9105 } else if (parent9 is AssignmentExpression) { | |
9106 return identical(((parent9 as AssignmentExpression)).leftHandSide, target)
; | |
9107 } | |
9108 return false; | |
9109 } | |
9110 bool isSynthetic() => _token.isSynthetic(); | |
9111 /** | |
9112 * Set the element associated with this identifier to the given element. | |
9113 * @param element the element associated with this identifier | |
9114 */ | |
9115 void set element(Element element16) { | |
9116 this._element = element16; | |
9117 } | |
9118 /** | |
9119 * Set the token representing the identifier to the given token. | |
9120 * @param token the token representing the literal | |
9121 */ | |
9122 void set token(Token token12) { | |
9123 this._token = token12; | |
9124 } | |
9125 void visitChildren(ASTVisitor<Object> visitor) { | |
9126 } | |
9127 } | |
9128 /** | |
9129 * Instances of the class {@code SimpleStringLiteral} represent a string literal
expression that | |
9130 * does not contain any interpolations. | |
9131 * <pre> | |
9132 * simpleStringLiteral ::= | |
9133 * rawStringLiteral | |
9134 * | basicStringLiteral | |
9135 * rawStringLiteral ::= | |
9136 * '@' basicStringLiteral | |
9137 * simpleStringLiteral ::= | |
9138 * multiLineStringLiteral | |
9139 * | singleLineStringLiteral | |
9140 * multiLineStringLiteral ::= | |
9141 * "'''" characters "'''" | |
9142 * | '"""' characters '"""' | |
9143 * singleLineStringLiteral ::= | |
9144 * "'" characters "'" | |
9145 * '"' characters '"' | |
9146 * </pre> | |
9147 * @coverage dart.engine.ast | |
9148 */ | |
9149 class SimpleStringLiteral extends StringLiteral { | |
9150 /** | |
9151 * The token representing the literal. | |
9152 */ | |
9153 Token _literal; | |
9154 /** | |
9155 * The value of the literal. | |
9156 */ | |
9157 String _value; | |
9158 /** | |
9159 * Initialize a newly created simple string literal. | |
9160 * @param literal the token representing the literal | |
9161 * @param value the value of the literal | |
9162 */ | |
9163 SimpleStringLiteral.full(Token literal, String value) { | |
9164 this._literal = literal; | |
9165 this._value = value; | |
9166 } | |
9167 /** | |
9168 * Initialize a newly created simple string literal. | |
9169 * @param literal the token representing the literal | |
9170 * @param value the value of the literal | |
9171 */ | |
9172 SimpleStringLiteral({Token literal, String value}) : this.full(literal, value)
; | |
9173 accept(ASTVisitor visitor) => visitor.visitSimpleStringLiteral(this); | |
9174 Token get beginToken => _literal; | |
9175 Token get endToken => _literal; | |
9176 /** | |
9177 * Return the token representing the literal. | |
9178 * @return the token representing the literal | |
9179 */ | |
9180 Token get literal => _literal; | |
9181 /** | |
9182 * Return the value of the literal. | |
9183 * @return the value of the literal | |
9184 */ | |
9185 String get value => _value; | |
9186 /** | |
9187 * Return {@code true} if this string literal is a multi-line string. | |
9188 * @return {@code true} if this string literal is a multi-line string | |
9189 */ | |
9190 bool isMultiline() { | |
9191 if (_value.length < 6) { | |
9192 return false; | |
9193 } | |
9194 return _value.endsWith("\"\"\"") || _value.endsWith("'''"); | |
9195 } | |
9196 /** | |
9197 * Return {@code true} if this string literal is a raw string. | |
9198 * @return {@code true} if this string literal is a raw string | |
9199 */ | |
9200 bool isRaw() => _value.codeUnitAt(0) == 0x40; | |
9201 bool isSynthetic() => _literal.isSynthetic(); | |
9202 /** | |
9203 * Set the token representing the literal to the given token. | |
9204 * @param literal the token representing the literal | |
9205 */ | |
9206 void set literal(Token literal6) { | |
9207 this._literal = literal6; | |
9208 } | |
9209 /** | |
9210 * Set the value of the literal to the given string. | |
9211 * @param string the value of the literal | |
9212 */ | |
9213 void set value(String string) { | |
9214 _value = string; | |
9215 } | |
9216 void visitChildren(ASTVisitor<Object> visitor) { | |
9217 } | |
9218 } | |
9219 /** | |
9220 * Instances of the class {@code Statement} defines the behavior common to nodes
that represent a | |
9221 * statement. | |
9222 * <pre> | |
9223 * statement ::={@link Block block}| {@link VariableDeclarationStatement initial
izedVariableDeclaration ';'}| {@link ForStatement forStatement}| {@link ForEachS
tatement forEachStatement}| {@link WhileStatement whileStatement}| {@link DoStat
ement doStatement}| {@link SwitchStatement switchStatement}| {@link IfStatement
ifStatement}| {@link TryStatement tryStatement}| {@link BreakStatement breakStat
ement}| {@link ContinueStatement continueStatement}| {@link ReturnStatement retu
rnStatement}| {@link ExpressionStatement expressionStatement}| {@link FunctionDe
clarationStatement functionSignature functionBody}</pre> | |
9224 * @coverage dart.engine.ast | |
9225 */ | |
9226 abstract class Statement extends ASTNode { | |
9227 } | |
9228 /** | |
9229 * Instances of the class {@code StringInterpolation} represent a string interpo
lation literal. | |
9230 * <pre> | |
9231 * stringInterpolation ::= | |
9232 * ''' {@link InterpolationElement interpolationElement}* ''' | |
9233 * | '"' {@link InterpolationElement interpolationElement}* '"' | |
9234 * </pre> | |
9235 * @coverage dart.engine.ast | |
9236 */ | |
9237 class StringInterpolation extends StringLiteral { | |
9238 /** | |
9239 * The elements that will be composed to produce the resulting string. | |
9240 */ | |
9241 NodeList<InterpolationElement> _elements; | |
9242 /** | |
9243 * Initialize a newly created string interpolation expression. | |
9244 * @param elements the elements that will be composed to produce the resulting
string | |
9245 */ | |
9246 StringInterpolation.full(List<InterpolationElement> elements) { | |
9247 this._elements = new NodeList<InterpolationElement>(this); | |
9248 this._elements.addAll(elements); | |
9249 } | |
9250 /** | |
9251 * Initialize a newly created string interpolation expression. | |
9252 * @param elements the elements that will be composed to produce the resulting
string | |
9253 */ | |
9254 StringInterpolation({List<InterpolationElement> elements}) : this.full(element
s); | |
9255 accept(ASTVisitor visitor) => visitor.visitStringInterpolation(this); | |
9256 Token get beginToken => _elements.beginToken; | |
9257 /** | |
9258 * Return the elements that will be composed to produce the resulting string. | |
9259 * @return the elements that will be composed to produce the resulting string | |
9260 */ | |
9261 NodeList<InterpolationElement> get elements => _elements; | |
9262 Token get endToken => _elements.endToken; | |
9263 void visitChildren(ASTVisitor<Object> visitor) { | |
9264 _elements.accept(visitor); | |
9265 } | |
9266 } | |
9267 /** | |
9268 * Instances of the class {@code StringLiteral} represent a string literal expre
ssion. | |
9269 * <pre> | |
9270 * stringLiteral ::={@link SimpleStringLiteral simpleStringLiteral}| {@link Adja
centStrings adjacentStrings}| {@link StringInterpolation stringInterpolation}</p
re> | |
9271 * @coverage dart.engine.ast | |
9272 */ | |
9273 abstract class StringLiteral extends Literal { | |
9274 } | |
9275 /** | |
9276 * Instances of the class {@code SuperConstructorInvocation} represent the invoc
ation of a | |
9277 * superclass' constructor from within a constructor's initialization list. | |
9278 * <pre> | |
9279 * superInvocation ::= | |
9280 * 'super' ('.' {@link SimpleIdentifier name})? {@link ArgumentList argumentList
}</pre> | |
9281 * @coverage dart.engine.ast | |
9282 */ | |
9283 class SuperConstructorInvocation extends ConstructorInitializer { | |
9284 /** | |
9285 * The token for the 'super' keyword. | |
9286 */ | |
9287 Token _keyword; | |
9288 /** | |
9289 * The token for the period before the name of the constructor that is being i
nvoked, or{@code null} if the unnamed constructor is being invoked. | |
9290 */ | |
9291 Token _period; | |
9292 /** | |
9293 * The name of the constructor that is being invoked, or {@code null} if the u
nnamed constructor | |
9294 * is being invoked. | |
9295 */ | |
9296 SimpleIdentifier _constructorName; | |
9297 /** | |
9298 * The list of arguments to the constructor. | |
9299 */ | |
9300 ArgumentList _argumentList; | |
9301 /** | |
9302 * The element associated with the constructor, or {@code null} if the AST str
ucture has not been | |
9303 * resolved or if the constructor could not be resolved. | |
9304 */ | |
9305 ConstructorElement _element; | |
9306 /** | |
9307 * Initialize a newly created super invocation to invoke the inherited constru
ctor with the given | |
9308 * name with the given arguments. | |
9309 * @param keyword the token for the 'super' keyword | |
9310 * @param period the token for the period before the name of the constructor t
hat is being invoked | |
9311 * @param constructorName the name of the constructor that is being invoked | |
9312 * @param argumentList the list of arguments to the constructor | |
9313 */ | |
9314 SuperConstructorInvocation.full(Token keyword, Token period, SimpleIdentifier
constructorName, ArgumentList argumentList) { | |
9315 this._keyword = keyword; | |
9316 this._period = period; | |
9317 this._constructorName = becomeParentOf(constructorName); | |
9318 this._argumentList = becomeParentOf(argumentList); | |
9319 } | |
9320 /** | |
9321 * Initialize a newly created super invocation to invoke the inherited constru
ctor with the given | |
9322 * name with the given arguments. | |
9323 * @param keyword the token for the 'super' keyword | |
9324 * @param period the token for the period before the name of the constructor t
hat is being invoked | |
9325 * @param constructorName the name of the constructor that is being invoked | |
9326 * @param argumentList the list of arguments to the constructor | |
9327 */ | |
9328 SuperConstructorInvocation({Token keyword, Token period, SimpleIdentifier cons
tructorName, ArgumentList argumentList}) : this.full(keyword, period, constructo
rName, argumentList); | |
9329 accept(ASTVisitor visitor) => visitor.visitSuperConstructorInvocation(this); | |
9330 /** | |
9331 * Return the list of arguments to the constructor. | |
9332 * @return the list of arguments to the constructor | |
9333 */ | |
9334 ArgumentList get argumentList => _argumentList; | |
9335 Token get beginToken => _keyword; | |
9336 /** | |
9337 * Return the name of the constructor that is being invoked, or {@code null} i
f the unnamed | |
9338 * constructor is being invoked. | |
9339 * @return the name of the constructor that is being invoked | |
9340 */ | |
9341 SimpleIdentifier get constructorName => _constructorName; | |
9342 /** | |
9343 * Return the element associated with the constructor, or {@code null} if the
AST structure has | |
9344 * not been resolved or if the constructor could not be resolved. | |
9345 * @return the element associated with the super constructor | |
9346 */ | |
9347 ConstructorElement get element => _element; | |
9348 Token get endToken => _argumentList.endToken; | |
9349 /** | |
9350 * Return the token for the 'super' keyword. | |
9351 * @return the token for the 'super' keyword | |
9352 */ | |
9353 Token get keyword => _keyword; | |
9354 /** | |
9355 * Return the token for the period before the name of the constructor that is
being invoked, or{@code null} if the unnamed constructor is being invoked. | |
9356 * @return the token for the period before the name of the constructor that is
being invoked | |
9357 */ | |
9358 Token get period => _period; | |
9359 /** | |
9360 * Set the list of arguments to the constructor to the given list. | |
9361 * @param argumentList the list of arguments to the constructor | |
9362 */ | |
9363 void set argumentList(ArgumentList argumentList9) { | |
9364 this._argumentList = becomeParentOf(argumentList9); | |
9365 } | |
9366 /** | |
9367 * Set the name of the constructor that is being invoked to the given identifi
er. | |
9368 * @param identifier the name of the constructor that is being invoked | |
9369 */ | |
9370 void set constructorName(SimpleIdentifier identifier) { | |
9371 _constructorName = becomeParentOf(identifier); | |
9372 } | |
9373 /** | |
9374 * Set the element associated with the constructor to the given element. | |
9375 * @param element the element associated with the constructor | |
9376 */ | |
9377 void set element(ConstructorElement element17) { | |
9378 this._element = element17; | |
9379 } | |
9380 /** | |
9381 * Set the token for the 'super' keyword to the given token. | |
9382 * @param keyword the token for the 'super' keyword | |
9383 */ | |
9384 void set keyword(Token keyword17) { | |
9385 this._keyword = keyword17; | |
9386 } | |
9387 /** | |
9388 * Set the token for the period before the name of the constructor that is bei
ng invoked to the | |
9389 * given token. | |
9390 * @param period the token for the period before the name of the constructor t
hat is being invoked | |
9391 */ | |
9392 void set period(Token period12) { | |
9393 this._period = period12; | |
9394 } | |
9395 void visitChildren(ASTVisitor<Object> visitor) { | |
9396 safelyVisitChild(_constructorName, visitor); | |
9397 safelyVisitChild(_argumentList, visitor); | |
9398 } | |
9399 } | |
9400 /** | |
9401 * Instances of the class {@code SuperExpression} represent a super expression. | |
9402 * <pre> | |
9403 * superExpression ::= | |
9404 * 'super' | |
9405 * </pre> | |
9406 * @coverage dart.engine.ast | |
9407 */ | |
9408 class SuperExpression extends Expression { | |
9409 /** | |
9410 * The token representing the keyword. | |
9411 */ | |
9412 Token _keyword; | |
9413 /** | |
9414 * Initialize a newly created super expression. | |
9415 * @param keyword the token representing the keyword | |
9416 */ | |
9417 SuperExpression.full(Token keyword) { | |
9418 this._keyword = keyword; | |
9419 } | |
9420 /** | |
9421 * Initialize a newly created super expression. | |
9422 * @param keyword the token representing the keyword | |
9423 */ | |
9424 SuperExpression({Token keyword}) : this.full(keyword); | |
9425 accept(ASTVisitor visitor) => visitor.visitSuperExpression(this); | |
9426 Token get beginToken => _keyword; | |
9427 Token get endToken => _keyword; | |
9428 /** | |
9429 * Return the token representing the keyword. | |
9430 * @return the token representing the keyword | |
9431 */ | |
9432 Token get keyword => _keyword; | |
9433 /** | |
9434 * Set the token representing the keyword to the given token. | |
9435 * @param keyword the token representing the keyword | |
9436 */ | |
9437 void set keyword(Token keyword18) { | |
9438 this._keyword = keyword18; | |
9439 } | |
9440 void visitChildren(ASTVisitor<Object> visitor) { | |
9441 } | |
9442 } | |
9443 /** | |
9444 * Instances of the class {@code SwitchCase} represent the case in a switch stat
ement. | |
9445 * <pre> | |
9446 * switchCase ::={@link SimpleIdentifier label}* 'case' {@link Expression expres
sion} ':' {@link Statement statement}</pre> | |
9447 * @coverage dart.engine.ast | |
9448 */ | |
9449 class SwitchCase extends SwitchMember { | |
9450 /** | |
9451 * The expression controlling whether the statements will be executed. | |
9452 */ | |
9453 Expression _expression; | |
9454 /** | |
9455 * Initialize a newly created switch case. | |
9456 * @param labels the labels associated with the switch member | |
9457 * @param keyword the token representing the 'case' or 'default' keyword | |
9458 * @param expression the expression controlling whether the statements will be
executed | |
9459 * @param colon the colon separating the keyword or the expression from the st
atements | |
9460 * @param statements the statements that will be executed if this switch membe
r is selected | |
9461 */ | |
9462 SwitchCase.full(List<Label> labels, Token keyword, Expression expression, Toke
n colon, List<Statement> statements) : super.full(labels, keyword, colon, statem
ents) { | |
9463 this._expression = becomeParentOf(expression); | |
9464 } | |
9465 /** | |
9466 * Initialize a newly created switch case. | |
9467 * @param labels the labels associated with the switch member | |
9468 * @param keyword the token representing the 'case' or 'default' keyword | |
9469 * @param expression the expression controlling whether the statements will be
executed | |
9470 * @param colon the colon separating the keyword or the expression from the st
atements | |
9471 * @param statements the statements that will be executed if this switch membe
r is selected | |
9472 */ | |
9473 SwitchCase({List<Label> labels, Token keyword, Expression expression, Token co
lon, List<Statement> statements}) : this.full(labels, keyword, expression, colon
, statements); | |
9474 accept(ASTVisitor visitor) => visitor.visitSwitchCase(this); | |
9475 /** | |
9476 * Return the expression controlling whether the statements will be executed. | |
9477 * @return the expression controlling whether the statements will be executed | |
9478 */ | |
9479 Expression get expression => _expression; | |
9480 /** | |
9481 * Set the expression controlling whether the statements will be executed to t
he given expression. | |
9482 * @param expression the expression controlling whether the statements will be
executed | |
9483 */ | |
9484 void set expression(Expression expression11) { | |
9485 this._expression = becomeParentOf(expression11); | |
9486 } | |
9487 void visitChildren(ASTVisitor<Object> visitor) { | |
9488 labels.accept(visitor); | |
9489 safelyVisitChild(_expression, visitor); | |
9490 statements.accept(visitor); | |
9491 } | |
9492 } | |
9493 /** | |
9494 * Instances of the class {@code SwitchDefault} represent the default case in a
switch statement. | |
9495 * <pre> | |
9496 * switchDefault ::={@link SimpleIdentifier label}* 'default' ':' {@link Stateme
nt statement}</pre> | |
9497 * @coverage dart.engine.ast | |
9498 */ | |
9499 class SwitchDefault extends SwitchMember { | |
9500 /** | |
9501 * Initialize a newly created switch default. | |
9502 * @param labels the labels associated with the switch member | |
9503 * @param keyword the token representing the 'case' or 'default' keyword | |
9504 * @param colon the colon separating the keyword or the expression from the st
atements | |
9505 * @param statements the statements that will be executed if this switch membe
r is selected | |
9506 */ | |
9507 SwitchDefault.full(List<Label> labels, Token keyword, Token colon, List<Statem
ent> statements) : super.full(labels, keyword, colon, statements) { | |
9508 } | |
9509 /** | |
9510 * Initialize a newly created switch default. | |
9511 * @param labels the labels associated with the switch member | |
9512 * @param keyword the token representing the 'case' or 'default' keyword | |
9513 * @param colon the colon separating the keyword or the expression from the st
atements | |
9514 * @param statements the statements that will be executed if this switch membe
r is selected | |
9515 */ | |
9516 SwitchDefault({List<Label> labels, Token keyword, Token colon, List<Statement>
statements}) : this.full(labels, keyword, colon, statements); | |
9517 accept(ASTVisitor visitor) => visitor.visitSwitchDefault(this); | |
9518 void visitChildren(ASTVisitor<Object> visitor) { | |
9519 labels.accept(visitor); | |
9520 statements.accept(visitor); | |
9521 } | |
9522 } | |
9523 /** | |
9524 * The abstract class {@code SwitchMember} defines the behavior common to object
s representing | |
9525 * elements within a switch statement. | |
9526 * <pre> | |
9527 * switchMember ::= | |
9528 * switchCase | |
9529 * | switchDefault | |
9530 * </pre> | |
9531 * @coverage dart.engine.ast | |
9532 */ | |
9533 abstract class SwitchMember extends ASTNode { | |
9534 /** | |
9535 * The labels associated with the switch member. | |
9536 */ | |
9537 NodeList<Label> _labels; | |
9538 /** | |
9539 * The token representing the 'case' or 'default' keyword. | |
9540 */ | |
9541 Token _keyword; | |
9542 /** | |
9543 * The colon separating the keyword or the expression from the statements. | |
9544 */ | |
9545 Token _colon; | |
9546 /** | |
9547 * The statements that will be executed if this switch member is selected. | |
9548 */ | |
9549 NodeList<Statement> _statements; | |
9550 /** | |
9551 * Initialize a newly created switch member. | |
9552 * @param labels the labels associated with the switch member | |
9553 * @param keyword the token representing the 'case' or 'default' keyword | |
9554 * @param colon the colon separating the keyword or the expression from the st
atements | |
9555 * @param statements the statements that will be executed if this switch membe
r is selected | |
9556 */ | |
9557 SwitchMember.full(List<Label> labels, Token keyword, Token colon, List<Stateme
nt> statements) { | |
9558 this._labels = new NodeList<Label>(this); | |
9559 this._statements = new NodeList<Statement>(this); | |
9560 this._labels.addAll(labels); | |
9561 this._keyword = keyword; | |
9562 this._colon = colon; | |
9563 this._statements.addAll(statements); | |
9564 } | |
9565 /** | |
9566 * Initialize a newly created switch member. | |
9567 * @param labels the labels associated with the switch member | |
9568 * @param keyword the token representing the 'case' or 'default' keyword | |
9569 * @param colon the colon separating the keyword or the expression from the st
atements | |
9570 * @param statements the statements that will be executed if this switch membe
r is selected | |
9571 */ | |
9572 SwitchMember({List<Label> labels, Token keyword, Token colon, List<Statement>
statements}) : this.full(labels, keyword, colon, statements); | |
9573 Token get beginToken { | |
9574 if (!_labels.isEmpty) { | |
9575 return _labels.beginToken; | |
9576 } | |
9577 return _keyword; | |
9578 } | |
9579 /** | |
9580 * Return the colon separating the keyword or the expression from the statemen
ts. | |
9581 * @return the colon separating the keyword or the expression from the stateme
nts | |
9582 */ | |
9583 Token get colon => _colon; | |
9584 Token get endToken { | |
9585 if (!_statements.isEmpty) { | |
9586 return _statements.endToken; | |
9587 } | |
9588 return _colon; | |
9589 } | |
9590 /** | |
9591 * Return the token representing the 'case' or 'default' keyword. | |
9592 * @return the token representing the 'case' or 'default' keyword | |
9593 */ | |
9594 Token get keyword => _keyword; | |
9595 /** | |
9596 * Return the labels associated with the switch member. | |
9597 * @return the labels associated with the switch member | |
9598 */ | |
9599 NodeList<Label> get labels => _labels; | |
9600 /** | |
9601 * Return the statements that will be executed if this switch member is select
ed. | |
9602 * @return the statements that will be executed if this switch member is selec
ted | |
9603 */ | |
9604 NodeList<Statement> get statements => _statements; | |
9605 /** | |
9606 * Set the colon separating the keyword or the expression from the statements
to the given token. | |
9607 * @param colon the colon separating the keyword or the expression from the st
atements | |
9608 */ | |
9609 void set colon(Token colon4) { | |
9610 this._colon = colon4; | |
9611 } | |
9612 /** | |
9613 * Set the token representing the 'case' or 'default' keyword to the given tok
en. | |
9614 * @param keyword the token representing the 'case' or 'default' keyword | |
9615 */ | |
9616 void set keyword(Token keyword19) { | |
9617 this._keyword = keyword19; | |
9618 } | |
9619 } | |
9620 /** | |
9621 * Instances of the class {@code SwitchStatement} represent a switch statement. | |
9622 * <pre> | |
9623 * switchStatement ::= | |
9624 * 'switch' '(' {@link Expression expression} ')' '{' {@link SwitchCase switchCa
se}* {@link SwitchDefault defaultCase}? '}' | |
9625 * </pre> | |
9626 * @coverage dart.engine.ast | |
9627 */ | |
9628 class SwitchStatement extends Statement { | |
9629 /** | |
9630 * The token representing the 'switch' keyword. | |
9631 */ | |
9632 Token _keyword; | |
9633 /** | |
9634 * The left parenthesis. | |
9635 */ | |
9636 Token _leftParenthesis; | |
9637 /** | |
9638 * The expression used to determine which of the switch members will be select
ed. | |
9639 */ | |
9640 Expression _expression; | |
9641 /** | |
9642 * The right parenthesis. | |
9643 */ | |
9644 Token _rightParenthesis; | |
9645 /** | |
9646 * The left curly bracket. | |
9647 */ | |
9648 Token _leftBracket; | |
9649 /** | |
9650 * The switch members that can be selected by the expression. | |
9651 */ | |
9652 NodeList<SwitchMember> _members; | |
9653 /** | |
9654 * The right curly bracket. | |
9655 */ | |
9656 Token _rightBracket; | |
9657 /** | |
9658 * Initialize a newly created switch statement. | |
9659 * @param keyword the token representing the 'switch' keyword | |
9660 * @param leftParenthesis the left parenthesis | |
9661 * @param expression the expression used to determine which of the switch memb
ers will be selected | |
9662 * @param rightParenthesis the right parenthesis | |
9663 * @param leftBracket the left curly bracket | |
9664 * @param members the switch members that can be selected by the expression | |
9665 * @param rightBracket the right curly bracket | |
9666 */ | |
9667 SwitchStatement.full(Token keyword, Token leftParenthesis, Expression expressi
on, Token rightParenthesis, Token leftBracket, List<SwitchMember> members, Token
rightBracket) { | |
9668 this._members = new NodeList<SwitchMember>(this); | |
9669 this._keyword = keyword; | |
9670 this._leftParenthesis = leftParenthesis; | |
9671 this._expression = becomeParentOf(expression); | |
9672 this._rightParenthesis = rightParenthesis; | |
9673 this._leftBracket = leftBracket; | |
9674 this._members.addAll(members); | |
9675 this._rightBracket = rightBracket; | |
9676 } | |
9677 /** | |
9678 * Initialize a newly created switch statement. | |
9679 * @param keyword the token representing the 'switch' keyword | |
9680 * @param leftParenthesis the left parenthesis | |
9681 * @param expression the expression used to determine which of the switch memb
ers will be selected | |
9682 * @param rightParenthesis the right parenthesis | |
9683 * @param leftBracket the left curly bracket | |
9684 * @param members the switch members that can be selected by the expression | |
9685 * @param rightBracket the right curly bracket | |
9686 */ | |
9687 SwitchStatement({Token keyword, Token leftParenthesis, Expression expression,
Token rightParenthesis, Token leftBracket, List<SwitchMember> members, Token rig
htBracket}) : this.full(keyword, leftParenthesis, expression, rightParenthesis,
leftBracket, members, rightBracket); | |
9688 accept(ASTVisitor visitor) => visitor.visitSwitchStatement(this); | |
9689 Token get beginToken => _keyword; | |
9690 Token get endToken => _rightBracket; | |
9691 /** | |
9692 * Return the expression used to determine which of the switch members will be
selected. | |
9693 * @return the expression used to determine which of the switch members will b
e selected | |
9694 */ | |
9695 Expression get expression => _expression; | |
9696 /** | |
9697 * Return the token representing the 'switch' keyword. | |
9698 * @return the token representing the 'switch' keyword | |
9699 */ | |
9700 Token get keyword => _keyword; | |
9701 /** | |
9702 * Return the left curly bracket. | |
9703 * @return the left curly bracket | |
9704 */ | |
9705 Token get leftBracket => _leftBracket; | |
9706 /** | |
9707 * Return the left parenthesis. | |
9708 * @return the left parenthesis | |
9709 */ | |
9710 Token get leftParenthesis => _leftParenthesis; | |
9711 /** | |
9712 * Return the switch members that can be selected by the expression. | |
9713 * @return the switch members that can be selected by the expression | |
9714 */ | |
9715 NodeList<SwitchMember> get members => _members; | |
9716 /** | |
9717 * Return the right curly bracket. | |
9718 * @return the right curly bracket | |
9719 */ | |
9720 Token get rightBracket => _rightBracket; | |
9721 /** | |
9722 * Return the right parenthesis. | |
9723 * @return the right parenthesis | |
9724 */ | |
9725 Token get rightParenthesis => _rightParenthesis; | |
9726 /** | |
9727 * Set the expression used to determine which of the switch members will be se
lected to the given | |
9728 * expression. | |
9729 * @param expression the expression used to determine which of the switch memb
ers will be selected | |
9730 */ | |
9731 void set expression(Expression expression12) { | |
9732 this._expression = becomeParentOf(expression12); | |
9733 } | |
9734 /** | |
9735 * Set the token representing the 'switch' keyword to the given token. | |
9736 * @param keyword the token representing the 'switch' keyword | |
9737 */ | |
9738 void set keyword(Token keyword20) { | |
9739 this._keyword = keyword20; | |
9740 } | |
9741 /** | |
9742 * Set the left curly bracket to the given token. | |
9743 * @param leftBracket the left curly bracket | |
9744 */ | |
9745 void set leftBracket(Token leftBracket7) { | |
9746 this._leftBracket = leftBracket7; | |
9747 } | |
9748 /** | |
9749 * Set the left parenthesis to the given token. | |
9750 * @param leftParenthesis the left parenthesis | |
9751 */ | |
9752 void set leftParenthesis(Token leftParenthesis6) { | |
9753 this._leftParenthesis = leftParenthesis6; | |
9754 } | |
9755 /** | |
9756 * Set the right curly bracket to the given token. | |
9757 * @param rightBracket the right curly bracket | |
9758 */ | |
9759 void set rightBracket(Token rightBracket7) { | |
9760 this._rightBracket = rightBracket7; | |
9761 } | |
9762 /** | |
9763 * Set the right parenthesis to the given token. | |
9764 * @param rightParenthesis the right parenthesis | |
9765 */ | |
9766 void set rightParenthesis(Token rightParenthesis6) { | |
9767 this._rightParenthesis = rightParenthesis6; | |
9768 } | |
9769 void visitChildren(ASTVisitor<Object> visitor) { | |
9770 safelyVisitChild(_expression, visitor); | |
9771 _members.accept(visitor); | |
9772 } | |
9773 } | |
9774 /** | |
9775 * Instances of the class {@code ThisExpression} represent a this expression. | |
9776 * <pre> | |
9777 * thisExpression ::= | |
9778 * 'this' | |
9779 * </pre> | |
9780 * @coverage dart.engine.ast | |
9781 */ | |
9782 class ThisExpression extends Expression { | |
9783 /** | |
9784 * The token representing the keyword. | |
9785 */ | |
9786 Token _keyword; | |
9787 /** | |
9788 * Initialize a newly created this expression. | |
9789 * @param keyword the token representing the keyword | |
9790 */ | |
9791 ThisExpression.full(Token keyword) { | |
9792 this._keyword = keyword; | |
9793 } | |
9794 /** | |
9795 * Initialize a newly created this expression. | |
9796 * @param keyword the token representing the keyword | |
9797 */ | |
9798 ThisExpression({Token keyword}) : this.full(keyword); | |
9799 accept(ASTVisitor visitor) => visitor.visitThisExpression(this); | |
9800 Token get beginToken => _keyword; | |
9801 Token get endToken => _keyword; | |
9802 /** | |
9803 * Return the token representing the keyword. | |
9804 * @return the token representing the keyword | |
9805 */ | |
9806 Token get keyword => _keyword; | |
9807 /** | |
9808 * Set the token representing the keyword to the given token. | |
9809 * @param keyword the token representing the keyword | |
9810 */ | |
9811 void set keyword(Token keyword21) { | |
9812 this._keyword = keyword21; | |
9813 } | |
9814 void visitChildren(ASTVisitor<Object> visitor) { | |
9815 } | |
9816 } | |
9817 /** | |
9818 * Instances of the class {@code ThrowExpression} represent a throw expression. | |
9819 * <pre> | |
9820 * throwExpression ::= | |
9821 * 'throw' {@link Expression expression}? ';' | |
9822 * </pre> | |
9823 * @coverage dart.engine.ast | |
9824 */ | |
9825 class ThrowExpression extends Expression { | |
9826 /** | |
9827 * The token representing the 'throw' keyword. | |
9828 */ | |
9829 Token _keyword; | |
9830 /** | |
9831 * The expression computing the exception to be thrown, or {@code null} if the
current exception | |
9832 * is to be re-thrown. (The latter case can only occur if the throw statement
is inside a catch | |
9833 * clause.) | |
9834 */ | |
9835 Expression _expression; | |
9836 /** | |
9837 * Initialize a newly created throw expression. | |
9838 * @param keyword the token representing the 'throw' keyword | |
9839 * @param expression the expression computing the exception to be thrown | |
9840 */ | |
9841 ThrowExpression.full(Token keyword, Expression expression) { | |
9842 this._keyword = keyword; | |
9843 this._expression = becomeParentOf(expression); | |
9844 } | |
9845 /** | |
9846 * Initialize a newly created throw expression. | |
9847 * @param keyword the token representing the 'throw' keyword | |
9848 * @param expression the expression computing the exception to be thrown | |
9849 */ | |
9850 ThrowExpression({Token keyword, Expression expression}) : this.full(keyword, e
xpression); | |
9851 accept(ASTVisitor visitor) => visitor.visitThrowExpression(this); | |
9852 Token get beginToken => _keyword; | |
9853 Token get endToken { | |
9854 if (_expression != null) { | |
9855 return _expression.endToken; | |
9856 } | |
9857 return _keyword; | |
9858 } | |
9859 /** | |
9860 * Return the expression computing the exception to be thrown, or {@code null}
if the current | |
9861 * exception is to be re-thrown. (The latter case can only occur if the throw
statement is inside | |
9862 * a catch clause.) | |
9863 * @return the expression computing the exception to be thrown | |
9864 */ | |
9865 Expression get expression => _expression; | |
9866 /** | |
9867 * Return the token representing the 'throw' keyword. | |
9868 * @return the token representing the 'throw' keyword | |
9869 */ | |
9870 Token get keyword => _keyword; | |
9871 /** | |
9872 * Set the expression computing the exception to be thrown to the given expres
sion. | |
9873 * @param expression the expression computing the exception to be thrown | |
9874 */ | |
9875 void set expression(Expression expression13) { | |
9876 this._expression = becomeParentOf(expression13); | |
9877 } | |
9878 /** | |
9879 * Set the token representing the 'throw' keyword to the given token. | |
9880 * @param keyword the token representing the 'throw' keyword | |
9881 */ | |
9882 void set keyword(Token keyword22) { | |
9883 this._keyword = keyword22; | |
9884 } | |
9885 void visitChildren(ASTVisitor<Object> visitor) { | |
9886 safelyVisitChild(_expression, visitor); | |
9887 } | |
9888 } | |
9889 /** | |
9890 * Instances of the class {@code TopLevelVariableDeclaration} represent the decl
aration of one or | |
9891 * more top-level variables of the same type. | |
9892 * <pre> | |
9893 * topLevelVariableDeclaration ::= | |
9894 * ('final' | 'const') type? staticFinalDeclarationList ';' | |
9895 * | variableDeclaration ';' | |
9896 * </pre> | |
9897 * @coverage dart.engine.ast | |
9898 */ | |
9899 class TopLevelVariableDeclaration extends CompilationUnitMember { | |
9900 /** | |
9901 * The top-level variables being declared. | |
9902 */ | |
9903 VariableDeclarationList _variableList; | |
9904 /** | |
9905 * The semicolon terminating the declaration. | |
9906 */ | |
9907 Token _semicolon; | |
9908 /** | |
9909 * Initialize a newly created top-level variable declaration. | |
9910 * @param comment the documentation comment associated with this variable | |
9911 * @param metadata the annotations associated with this variable | |
9912 * @param variableList the top-level variables being declared | |
9913 * @param semicolon the semicolon terminating the declaration | |
9914 */ | |
9915 TopLevelVariableDeclaration.full(Comment comment, List<Annotation> metadata, V
ariableDeclarationList variableList, Token semicolon) : super.full(comment, meta
data) { | |
9916 this._variableList = becomeParentOf(variableList); | |
9917 this._semicolon = semicolon; | |
9918 } | |
9919 /** | |
9920 * Initialize a newly created top-level variable declaration. | |
9921 * @param comment the documentation comment associated with this variable | |
9922 * @param metadata the annotations associated with this variable | |
9923 * @param variableList the top-level variables being declared | |
9924 * @param semicolon the semicolon terminating the declaration | |
9925 */ | |
9926 TopLevelVariableDeclaration({Comment comment, List<Annotation> metadata, Varia
bleDeclarationList variableList, Token semicolon}) : this.full(comment, metadata
, variableList, semicolon); | |
9927 accept(ASTVisitor visitor) => visitor.visitTopLevelVariableDeclaration(this); | |
9928 Element get element => null; | |
9929 Token get endToken => _semicolon; | |
9930 /** | |
9931 * Return the semicolon terminating the declaration. | |
9932 * @return the semicolon terminating the declaration | |
9933 */ | |
9934 Token get semicolon => _semicolon; | |
9935 /** | |
9936 * Return the top-level variables being declared. | |
9937 * @return the top-level variables being declared | |
9938 */ | |
9939 VariableDeclarationList get variables => _variableList; | |
9940 /** | |
9941 * Set the semicolon terminating the declaration to the given token. | |
9942 * @param semicolon the semicolon terminating the declaration | |
9943 */ | |
9944 void set semicolon(Token semicolon16) { | |
9945 this._semicolon = semicolon16; | |
9946 } | |
9947 /** | |
9948 * Set the top-level variables being declared to the given list of variables. | |
9949 * @param variableList the top-level variables being declared | |
9950 */ | |
9951 void set variables(VariableDeclarationList variableList) { | |
9952 variableList = becomeParentOf(variableList); | |
9953 } | |
9954 void visitChildren(ASTVisitor<Object> visitor) { | |
9955 super.visitChildren(visitor); | |
9956 safelyVisitChild(_variableList, visitor); | |
9957 } | |
9958 Token get firstTokenAfterCommentAndMetadata => _variableList.beginToken; | |
9959 } | |
9960 /** | |
9961 * Instances of the class {@code TryStatement} represent a try statement. | |
9962 * <pre> | |
9963 * tryStatement ::= | |
9964 * 'try' {@link Block block} ({@link CatchClause catchClause}+ finallyClause? |
finallyClause) | |
9965 * finallyClause ::= | |
9966 * 'finally' {@link Block block}</pre> | |
9967 * @coverage dart.engine.ast | |
9968 */ | |
9969 class TryStatement extends Statement { | |
9970 /** | |
9971 * The token representing the 'try' keyword. | |
9972 */ | |
9973 Token _tryKeyword; | |
9974 /** | |
9975 * The body of the statement. | |
9976 */ | |
9977 Block _body; | |
9978 /** | |
9979 * The catch clauses contained in the try statement. | |
9980 */ | |
9981 NodeList<CatchClause> _catchClauses; | |
9982 /** | |
9983 * The token representing the 'finally' keyword, or {@code null} if the statem
ent does not contain | |
9984 * a finally clause. | |
9985 */ | |
9986 Token _finallyKeyword; | |
9987 /** | |
9988 * The finally clause contained in the try statement, or {@code null} if the s
tatement does not | |
9989 * contain a finally clause. | |
9990 */ | |
9991 Block _finallyClause; | |
9992 /** | |
9993 * Initialize a newly created try statement. | |
9994 * @param tryKeyword the token representing the 'try' keyword | |
9995 * @param body the body of the statement | |
9996 * @param catchClauses the catch clauses contained in the try statement | |
9997 * @param finallyKeyword the token representing the 'finally' keyword | |
9998 * @param finallyClause the finally clause contained in the try statement | |
9999 */ | |
10000 TryStatement.full(Token tryKeyword, Block body, List<CatchClause> catchClauses
, Token finallyKeyword, Block finallyClause) { | |
10001 this._catchClauses = new NodeList<CatchClause>(this); | |
10002 this._tryKeyword = tryKeyword; | |
10003 this._body = becomeParentOf(body); | |
10004 this._catchClauses.addAll(catchClauses); | |
10005 this._finallyKeyword = finallyKeyword; | |
10006 this._finallyClause = becomeParentOf(finallyClause); | |
10007 } | |
10008 /** | |
10009 * Initialize a newly created try statement. | |
10010 * @param tryKeyword the token representing the 'try' keyword | |
10011 * @param body the body of the statement | |
10012 * @param catchClauses the catch clauses contained in the try statement | |
10013 * @param finallyKeyword the token representing the 'finally' keyword | |
10014 * @param finallyClause the finally clause contained in the try statement | |
10015 */ | |
10016 TryStatement({Token tryKeyword, Block body, List<CatchClause> catchClauses, To
ken finallyKeyword, Block finallyClause}) : this.full(tryKeyword, body, catchCla
uses, finallyKeyword, finallyClause); | |
10017 accept(ASTVisitor visitor) => visitor.visitTryStatement(this); | |
10018 Token get beginToken => _tryKeyword; | |
10019 /** | |
10020 * Return the body of the statement. | |
10021 * @return the body of the statement | |
10022 */ | |
10023 Block get body => _body; | |
10024 /** | |
10025 * Return the catch clauses contained in the try statement. | |
10026 * @return the catch clauses contained in the try statement | |
10027 */ | |
10028 NodeList<CatchClause> get catchClauses => _catchClauses; | |
10029 Token get endToken { | |
10030 if (_finallyClause != null) { | |
10031 return _finallyClause.endToken; | |
10032 } else if (_finallyKeyword != null) { | |
10033 return _finallyKeyword; | |
10034 } else if (!_catchClauses.isEmpty) { | |
10035 return _catchClauses.endToken; | |
10036 } | |
10037 return _body.endToken; | |
10038 } | |
10039 /** | |
10040 * Return the finally clause contained in the try statement, or {@code null} i
f the statement does | |
10041 * not contain a finally clause. | |
10042 * @return the finally clause contained in the try statement | |
10043 */ | |
10044 Block get finallyClause => _finallyClause; | |
10045 /** | |
10046 * Return the token representing the 'finally' keyword, or {@code null} if the
statement does not | |
10047 * contain a finally clause. | |
10048 * @return the token representing the 'finally' keyword | |
10049 */ | |
10050 Token get finallyKeyword => _finallyKeyword; | |
10051 /** | |
10052 * Return the token representing the 'try' keyword. | |
10053 * @return the token representing the 'try' keyword | |
10054 */ | |
10055 Token get tryKeyword => _tryKeyword; | |
10056 /** | |
10057 * Set the body of the statement to the given block. | |
10058 * @param block the body of the statement | |
10059 */ | |
10060 void set body(Block block) { | |
10061 _body = becomeParentOf(block); | |
10062 } | |
10063 /** | |
10064 * Set the finally clause contained in the try statement to the given block. | |
10065 * @param block the finally clause contained in the try statement | |
10066 */ | |
10067 void set finallyClause(Block block) { | |
10068 _finallyClause = becomeParentOf(block); | |
10069 } | |
10070 /** | |
10071 * Set the token representing the 'finally' keyword to the given token. | |
10072 * @param finallyKeyword the token representing the 'finally' keyword | |
10073 */ | |
10074 void set finallyKeyword(Token finallyKeyword2) { | |
10075 this._finallyKeyword = finallyKeyword2; | |
10076 } | |
10077 /** | |
10078 * Set the token representing the 'try' keyword to the given token. | |
10079 * @param tryKeyword the token representing the 'try' keyword | |
10080 */ | |
10081 void set tryKeyword(Token tryKeyword2) { | |
10082 this._tryKeyword = tryKeyword2; | |
10083 } | |
10084 void visitChildren(ASTVisitor<Object> visitor) { | |
10085 safelyVisitChild(_body, visitor); | |
10086 _catchClauses.accept(visitor); | |
10087 safelyVisitChild(_finallyClause, visitor); | |
10088 } | |
10089 } | |
10090 /** | |
10091 * The abstract class {@code TypeAlias} defines the behavior common to declarati
ons of type aliases. | |
10092 * <pre> | |
10093 * typeAlias ::= | |
10094 * 'typedef' typeAliasBody | |
10095 * typeAliasBody ::= | |
10096 * classTypeAlias | |
10097 * | functionTypeAlias | |
10098 * </pre> | |
10099 * @coverage dart.engine.ast | |
10100 */ | |
10101 abstract class TypeAlias extends CompilationUnitMember { | |
10102 /** | |
10103 * The token representing the 'typedef' keyword. | |
10104 */ | |
10105 Token _keyword; | |
10106 /** | |
10107 * The semicolon terminating the declaration. | |
10108 */ | |
10109 Token _semicolon; | |
10110 /** | |
10111 * Initialize a newly created type alias. | |
10112 * @param comment the documentation comment associated with this type alias | |
10113 * @param metadata the annotations associated with this type alias | |
10114 * @param keyword the token representing the 'typedef' keyword | |
10115 * @param semicolon the semicolon terminating the declaration | |
10116 */ | |
10117 TypeAlias.full(Comment comment, List<Annotation> metadata, Token keyword, Toke
n semicolon) : super.full(comment, metadata) { | |
10118 this._keyword = keyword; | |
10119 this._semicolon = semicolon; | |
10120 } | |
10121 /** | |
10122 * Initialize a newly created type alias. | |
10123 * @param comment the documentation comment associated with this type alias | |
10124 * @param metadata the annotations associated with this type alias | |
10125 * @param keyword the token representing the 'typedef' keyword | |
10126 * @param semicolon the semicolon terminating the declaration | |
10127 */ | |
10128 TypeAlias({Comment comment, List<Annotation> metadata, Token keyword, Token se
micolon}) : this.full(comment, metadata, keyword, semicolon); | |
10129 Token get endToken => _semicolon; | |
10130 /** | |
10131 * Return the token representing the 'typedef' keyword. | |
10132 * @return the token representing the 'typedef' keyword | |
10133 */ | |
10134 Token get keyword => _keyword; | |
10135 /** | |
10136 * Return the semicolon terminating the declaration. | |
10137 * @return the semicolon terminating the declaration | |
10138 */ | |
10139 Token get semicolon => _semicolon; | |
10140 /** | |
10141 * Set the token representing the 'typedef' keyword to the given token. | |
10142 * @param keyword the token representing the 'typedef' keyword | |
10143 */ | |
10144 void set keyword(Token keyword23) { | |
10145 this._keyword = keyword23; | |
10146 } | |
10147 /** | |
10148 * Set the semicolon terminating the declaration to the given token. | |
10149 * @param semicolon the semicolon terminating the declaration | |
10150 */ | |
10151 void set semicolon(Token semicolon17) { | |
10152 this._semicolon = semicolon17; | |
10153 } | |
10154 Token get firstTokenAfterCommentAndMetadata => _keyword; | |
10155 } | |
10156 /** | |
10157 * Instances of the class {@code TypeArgumentList} represent a list of type argu
ments. | |
10158 * <pre> | |
10159 * typeArguments ::= | |
10160 * '<' typeName (',' typeName)* '>' | |
10161 * </pre> | |
10162 * @coverage dart.engine.ast | |
10163 */ | |
10164 class TypeArgumentList extends ASTNode { | |
10165 /** | |
10166 * The left bracket. | |
10167 */ | |
10168 Token _leftBracket; | |
10169 /** | |
10170 * The type arguments associated with the type. | |
10171 */ | |
10172 NodeList<TypeName> _arguments; | |
10173 /** | |
10174 * The right bracket. | |
10175 */ | |
10176 Token _rightBracket; | |
10177 /** | |
10178 * Initialize a newly created list of type arguments. | |
10179 * @param leftBracket the left bracket | |
10180 * @param arguments the type arguments associated with the type | |
10181 * @param rightBracket the right bracket | |
10182 */ | |
10183 TypeArgumentList.full(Token leftBracket, List<TypeName> arguments, Token right
Bracket) { | |
10184 this._arguments = new NodeList<TypeName>(this); | |
10185 this._leftBracket = leftBracket; | |
10186 this._arguments.addAll(arguments); | |
10187 this._rightBracket = rightBracket; | |
10188 } | |
10189 /** | |
10190 * Initialize a newly created list of type arguments. | |
10191 * @param leftBracket the left bracket | |
10192 * @param arguments the type arguments associated with the type | |
10193 * @param rightBracket the right bracket | |
10194 */ | |
10195 TypeArgumentList({Token leftBracket, List<TypeName> arguments, Token rightBrac
ket}) : this.full(leftBracket, arguments, rightBracket); | |
10196 accept(ASTVisitor visitor) => visitor.visitTypeArgumentList(this); | |
10197 /** | |
10198 * Return the type arguments associated with the type. | |
10199 * @return the type arguments associated with the type | |
10200 */ | |
10201 NodeList<TypeName> get arguments => _arguments; | |
10202 Token get beginToken => _leftBracket; | |
10203 Token get endToken => _rightBracket; | |
10204 /** | |
10205 * Return the left bracket. | |
10206 * @return the left bracket | |
10207 */ | |
10208 Token get leftBracket => _leftBracket; | |
10209 /** | |
10210 * Return the right bracket. | |
10211 * @return the right bracket | |
10212 */ | |
10213 Token get rightBracket => _rightBracket; | |
10214 /** | |
10215 * Set the left bracket to the given token. | |
10216 * @param leftBracket the left bracket | |
10217 */ | |
10218 void set leftBracket(Token leftBracket8) { | |
10219 this._leftBracket = leftBracket8; | |
10220 } | |
10221 /** | |
10222 * Set the right bracket to the given token. | |
10223 * @param rightBracket the right bracket | |
10224 */ | |
10225 void set rightBracket(Token rightBracket8) { | |
10226 this._rightBracket = rightBracket8; | |
10227 } | |
10228 void visitChildren(ASTVisitor<Object> visitor) { | |
10229 _arguments.accept(visitor); | |
10230 } | |
10231 } | |
10232 /** | |
10233 * Instances of the class {@code TypeName} represent the name of a type, which c
an optionally | |
10234 * include type arguments. | |
10235 * <pre> | |
10236 * typeName ::={@link Identifier identifier} typeArguments? | |
10237 * </pre> | |
10238 * @coverage dart.engine.ast | |
10239 */ | |
10240 class TypeName extends ASTNode { | |
10241 /** | |
10242 * The name of the type. | |
10243 */ | |
10244 Identifier _name; | |
10245 /** | |
10246 * The type arguments associated with the type, or {@code null} if there are n
o type arguments. | |
10247 */ | |
10248 TypeArgumentList _typeArguments; | |
10249 /** | |
10250 * The type being named, or {@code null} if the AST structure has not been res
olved. | |
10251 */ | |
10252 Type2 _type; | |
10253 /** | |
10254 * Initialize a newly created type name. | |
10255 * @param name the name of the type | |
10256 * @param typeArguments the type arguments associated with the type, or {@code
null} if there are | |
10257 * no type arguments | |
10258 */ | |
10259 TypeName.full(Identifier name, TypeArgumentList typeArguments) { | |
10260 this._name = becomeParentOf(name); | |
10261 this._typeArguments = becomeParentOf(typeArguments); | |
10262 } | |
10263 /** | |
10264 * Initialize a newly created type name. | |
10265 * @param name the name of the type | |
10266 * @param typeArguments the type arguments associated with the type, or {@code
null} if there are | |
10267 * no type arguments | |
10268 */ | |
10269 TypeName({Identifier name, TypeArgumentList typeArguments}) : this.full(name,
typeArguments); | |
10270 accept(ASTVisitor visitor) => visitor.visitTypeName(this); | |
10271 Token get beginToken => _name.beginToken; | |
10272 Token get endToken { | |
10273 if (_typeArguments != null) { | |
10274 return _typeArguments.endToken; | |
10275 } | |
10276 return _name.endToken; | |
10277 } | |
10278 /** | |
10279 * Return the name of the type. | |
10280 * @return the name of the type | |
10281 */ | |
10282 Identifier get name => _name; | |
10283 /** | |
10284 * Return the type being named, or {@code null} if the AST structure has not b
een resolved. | |
10285 * @return the type being named | |
10286 */ | |
10287 Type2 get type => _type; | |
10288 /** | |
10289 * Return the type arguments associated with the type, or {@code null} if ther
e are no type | |
10290 * arguments. | |
10291 * @return the type arguments associated with the type | |
10292 */ | |
10293 TypeArgumentList get typeArguments => _typeArguments; | |
10294 bool isSynthetic() => _name.isSynthetic() && _typeArguments == null; | |
10295 /** | |
10296 * Set the name of the type to the given identifier. | |
10297 * @param identifier the name of the type | |
10298 */ | |
10299 void set name(Identifier identifier) { | |
10300 _name = becomeParentOf(identifier); | |
10301 } | |
10302 /** | |
10303 * Set the type being named to the given type. | |
10304 * @param type the type being named | |
10305 */ | |
10306 void set type(Type2 type3) { | |
10307 this._type = type3; | |
10308 } | |
10309 /** | |
10310 * Set the type arguments associated with the type to the given type arguments
. | |
10311 * @param typeArguments the type arguments associated with the type | |
10312 */ | |
10313 void set typeArguments(TypeArgumentList typeArguments2) { | |
10314 this._typeArguments = becomeParentOf(typeArguments2); | |
10315 } | |
10316 void visitChildren(ASTVisitor<Object> visitor) { | |
10317 safelyVisitChild(_name, visitor); | |
10318 safelyVisitChild(_typeArguments, visitor); | |
10319 } | |
10320 } | |
10321 /** | |
10322 * Instances of the class {@code TypeParameter} represent a type parameter. | |
10323 * <pre> | |
10324 * typeParameter ::={@link SimpleIdentifier name} ('extends' {@link TypeName bou
nd})? | |
10325 * </pre> | |
10326 * @coverage dart.engine.ast | |
10327 */ | |
10328 class TypeParameter extends Declaration { | |
10329 /** | |
10330 * The name of the type parameter. | |
10331 */ | |
10332 SimpleIdentifier _name; | |
10333 /** | |
10334 * The token representing the 'extends' keyword, or {@code null} if there was
no explicit upper | |
10335 * bound. | |
10336 */ | |
10337 Token _keyword; | |
10338 /** | |
10339 * The name of the upper bound for legal arguments, or {@code null} if there w
as no explicit upper | |
10340 * bound. | |
10341 */ | |
10342 TypeName _bound; | |
10343 /** | |
10344 * Initialize a newly created type parameter. | |
10345 * @param comment the documentation comment associated with the type parameter | |
10346 * @param metadata the annotations associated with the type parameter | |
10347 * @param name the name of the type parameter | |
10348 * @param keyword the token representing the 'extends' keyword | |
10349 * @param bound the name of the upper bound for legal arguments | |
10350 */ | |
10351 TypeParameter.full(Comment comment, List<Annotation> metadata, SimpleIdentifie
r name, Token keyword, TypeName bound) : super.full(comment, metadata) { | |
10352 this._name = becomeParentOf(name); | |
10353 this._keyword = keyword; | |
10354 this._bound = becomeParentOf(bound); | |
10355 } | |
10356 /** | |
10357 * Initialize a newly created type parameter. | |
10358 * @param comment the documentation comment associated with the type parameter | |
10359 * @param metadata the annotations associated with the type parameter | |
10360 * @param name the name of the type parameter | |
10361 * @param keyword the token representing the 'extends' keyword | |
10362 * @param bound the name of the upper bound for legal arguments | |
10363 */ | |
10364 TypeParameter({Comment comment, List<Annotation> metadata, SimpleIdentifier na
me, Token keyword, TypeName bound}) : this.full(comment, metadata, name, keyword
, bound); | |
10365 accept(ASTVisitor visitor) => visitor.visitTypeParameter(this); | |
10366 /** | |
10367 * Return the name of the upper bound for legal arguments, or {@code null} if
there was no | |
10368 * explicit upper bound. | |
10369 * @return the name of the upper bound for legal arguments | |
10370 */ | |
10371 TypeName get bound => _bound; | |
10372 TypeVariableElement get element => _name != null ? (_name.element as TypeVaria
bleElement) : null; | |
10373 Token get endToken { | |
10374 if (_bound == null) { | |
10375 return _name.endToken; | |
10376 } | |
10377 return _bound.endToken; | |
10378 } | |
10379 /** | |
10380 * Return the token representing the 'assert' keyword. | |
10381 * @return the token representing the 'assert' keyword | |
10382 */ | |
10383 Token get keyword => _keyword; | |
10384 /** | |
10385 * Return the name of the type parameter. | |
10386 * @return the name of the type parameter | |
10387 */ | |
10388 SimpleIdentifier get name => _name; | |
10389 /** | |
10390 * Set the name of the upper bound for legal arguments to the given type name. | |
10391 * @param typeName the name of the upper bound for legal arguments | |
10392 */ | |
10393 void set bound(TypeName typeName) { | |
10394 _bound = becomeParentOf(typeName); | |
10395 } | |
10396 /** | |
10397 * Set the token representing the 'assert' keyword to the given token. | |
10398 * @param keyword the token representing the 'assert' keyword | |
10399 */ | |
10400 void set keyword(Token keyword24) { | |
10401 this._keyword = keyword24; | |
10402 } | |
10403 /** | |
10404 * Set the name of the type parameter to the given identifier. | |
10405 * @param identifier the name of the type parameter | |
10406 */ | |
10407 void set name(SimpleIdentifier identifier) { | |
10408 _name = becomeParentOf(identifier); | |
10409 } | |
10410 void visitChildren(ASTVisitor<Object> visitor) { | |
10411 super.visitChildren(visitor); | |
10412 safelyVisitChild(_name, visitor); | |
10413 safelyVisitChild(_bound, visitor); | |
10414 } | |
10415 Token get firstTokenAfterCommentAndMetadata => _name.beginToken; | |
10416 } | |
10417 /** | |
10418 * Instances of the class {@code TypeParameterList} represent type parameters wi
thin a declaration. | |
10419 * <pre> | |
10420 * typeParameterList ::= | |
10421 * '<' {@link TypeParameter typeParameter} (',' {@link TypeParameter typeParamet
er})* '>' | |
10422 * </pre> | |
10423 * @coverage dart.engine.ast | |
10424 */ | |
10425 class TypeParameterList extends ASTNode { | |
10426 /** | |
10427 * The left angle bracket. | |
10428 */ | |
10429 Token _leftBracket; | |
10430 /** | |
10431 * The type parameters in the list. | |
10432 */ | |
10433 NodeList<TypeParameter> _typeParameters; | |
10434 /** | |
10435 * The right angle bracket. | |
10436 */ | |
10437 Token _rightBracket; | |
10438 /** | |
10439 * Initialize a newly created list of type parameters. | |
10440 * @param leftBracket the left angle bracket | |
10441 * @param typeParameters the type parameters in the list | |
10442 * @param rightBracket the right angle bracket | |
10443 */ | |
10444 TypeParameterList.full(Token leftBracket, List<TypeParameter> typeParameters,
Token rightBracket) { | |
10445 this._typeParameters = new NodeList<TypeParameter>(this); | |
10446 this._leftBracket = leftBracket; | |
10447 this._typeParameters.addAll(typeParameters); | |
10448 this._rightBracket = rightBracket; | |
10449 } | |
10450 /** | |
10451 * Initialize a newly created list of type parameters. | |
10452 * @param leftBracket the left angle bracket | |
10453 * @param typeParameters the type parameters in the list | |
10454 * @param rightBracket the right angle bracket | |
10455 */ | |
10456 TypeParameterList({Token leftBracket, List<TypeParameter> typeParameters, Toke
n rightBracket}) : this.full(leftBracket, typeParameters, rightBracket); | |
10457 accept(ASTVisitor visitor) => visitor.visitTypeParameterList(this); | |
10458 Token get beginToken => _leftBracket; | |
10459 Token get endToken => _rightBracket; | |
10460 /** | |
10461 * Return the left angle bracket. | |
10462 * @return the left angle bracket | |
10463 */ | |
10464 Token get leftBracket => _leftBracket; | |
10465 /** | |
10466 * Return the right angle bracket. | |
10467 * @return the right angle bracket | |
10468 */ | |
10469 Token get rightBracket => _rightBracket; | |
10470 /** | |
10471 * Return the type parameters for the type. | |
10472 * @return the type parameters for the type | |
10473 */ | |
10474 NodeList<TypeParameter> get typeParameters => _typeParameters; | |
10475 void visitChildren(ASTVisitor<Object> visitor) { | |
10476 _typeParameters.accept(visitor); | |
10477 } | |
10478 } | |
10479 /** | |
10480 * The abstract class {@code TypedLiteral} defines the behavior common to litera
ls that have a type | |
10481 * associated with them. | |
10482 * <pre> | |
10483 * listLiteral ::={@link ListLiteral listLiteral}| {@link MapLiteral mapLiteral}
</pre> | |
10484 * @coverage dart.engine.ast | |
10485 */ | |
10486 abstract class TypedLiteral extends Literal { | |
10487 /** | |
10488 * The const modifier associated with this literal, or {@code null} if the lit
eral is not a | |
10489 * constant. | |
10490 */ | |
10491 Token _modifier; | |
10492 /** | |
10493 * The type argument associated with this literal, or {@code null} if no type
arguments were | |
10494 * declared. | |
10495 */ | |
10496 TypeArgumentList _typeArguments; | |
10497 /** | |
10498 * Initialize a newly created typed literal. | |
10499 * @param modifier the const modifier associated with this literal | |
10500 * @param typeArguments the type argument associated with this literal, or {@c
ode null} if no type | |
10501 * arguments were declared | |
10502 */ | |
10503 TypedLiteral.full(Token modifier, TypeArgumentList typeArguments) { | |
10504 this._modifier = modifier; | |
10505 this._typeArguments = becomeParentOf(typeArguments); | |
10506 } | |
10507 /** | |
10508 * Initialize a newly created typed literal. | |
10509 * @param modifier the const modifier associated with this literal | |
10510 * @param typeArguments the type argument associated with this literal, or {@c
ode null} if no type | |
10511 * arguments were declared | |
10512 */ | |
10513 TypedLiteral({Token modifier, TypeArgumentList typeArguments}) : this.full(mod
ifier, typeArguments); | |
10514 /** | |
10515 * Return the const modifier associated with this literal. | |
10516 * @return the const modifier associated with this literal | |
10517 */ | |
10518 Token get modifier => _modifier; | |
10519 /** | |
10520 * Return the type argument associated with this literal, or {@code null} if n
o type arguments | |
10521 * were declared. | |
10522 * @return the type argument associated with this literal | |
10523 */ | |
10524 TypeArgumentList get typeArguments => _typeArguments; | |
10525 /** | |
10526 * Set the modifiers associated with this literal to the given modifiers. | |
10527 * @param modifiers the modifiers associated with this literal | |
10528 */ | |
10529 void set modifier(Token modifier2) { | |
10530 this._modifier = modifier2; | |
10531 } | |
10532 /** | |
10533 * Set the type argument associated with this literal to the given arguments. | |
10534 * @param typeArguments the type argument associated with this literal | |
10535 */ | |
10536 void set typeArguments(TypeArgumentList typeArguments3) { | |
10537 this._typeArguments = typeArguments3; | |
10538 } | |
10539 void visitChildren(ASTVisitor<Object> visitor) { | |
10540 safelyVisitChild(_typeArguments, visitor); | |
10541 } | |
10542 } | |
10543 /** | |
10544 * The abstract class {@code UriBasedDirective} defines the behavior common to n
odes that represent | |
10545 * a directive that references a URI. | |
10546 * <pre> | |
10547 * uriBasedDirective ::={@link ExportDirective exportDirective}| {@link ImportDi
rective importDirective}| {@link PartDirective partDirective}</pre> | |
10548 * @coverage dart.engine.ast | |
10549 */ | |
10550 abstract class UriBasedDirective extends Directive { | |
10551 /** | |
10552 * The URI referenced by this directive. | |
10553 */ | |
10554 StringLiteral _uri; | |
10555 /** | |
10556 * Initialize a newly create URI-based directive. | |
10557 * @param comment the documentation comment associated with this directive | |
10558 * @param metadata the annotations associated with the directive | |
10559 * @param uri the URI referenced by this directive | |
10560 */ | |
10561 UriBasedDirective.full(Comment comment, List<Annotation> metadata, StringLiter
al uri) : super.full(comment, metadata) { | |
10562 this._uri = becomeParentOf(uri); | |
10563 } | |
10564 /** | |
10565 * Initialize a newly create URI-based directive. | |
10566 * @param comment the documentation comment associated with this directive | |
10567 * @param metadata the annotations associated with the directive | |
10568 * @param uri the URI referenced by this directive | |
10569 */ | |
10570 UriBasedDirective({Comment comment, List<Annotation> metadata, StringLiteral u
ri}) : this.full(comment, metadata, uri); | |
10571 /** | |
10572 * Return the URI referenced by this directive. | |
10573 * @return the URI referenced by this directive | |
10574 */ | |
10575 StringLiteral get uri => _uri; | |
10576 /** | |
10577 * Set the URI referenced by this directive to the given URI. | |
10578 * @param uri the URI referenced by this directive | |
10579 */ | |
10580 void set uri(StringLiteral uri2) { | |
10581 this._uri = becomeParentOf(uri2); | |
10582 } | |
10583 void visitChildren(ASTVisitor<Object> visitor) { | |
10584 super.visitChildren(visitor); | |
10585 safelyVisitChild(_uri, visitor); | |
10586 } | |
10587 } | |
10588 /** | |
10589 * Instances of the class {@code VariableDeclaration} represent an identifier th
at has an initial | |
10590 * value associated with it. Instances of this class are always children of the
class{@link VariableDeclarationList}. | |
10591 * <pre> | |
10592 * variableDeclaration ::={@link SimpleIdentifier identifier} ('=' {@link Expres
sion initialValue})? | |
10593 * </pre> | |
10594 * @coverage dart.engine.ast | |
10595 */ | |
10596 class VariableDeclaration extends Declaration { | |
10597 /** | |
10598 * The name of the variable being declared. | |
10599 */ | |
10600 SimpleIdentifier _name; | |
10601 /** | |
10602 * The equal sign separating the variable name from the initial value, or {@co
de null} if the | |
10603 * initial value was not specified. | |
10604 */ | |
10605 Token _equals; | |
10606 /** | |
10607 * The expression used to compute the initial value for the variable, or {@cod
e null} if the | |
10608 * initial value was not specified. | |
10609 */ | |
10610 Expression _initializer; | |
10611 /** | |
10612 * Initialize a newly created variable declaration. | |
10613 * @param comment the documentation comment associated with this declaration | |
10614 * @param metadata the annotations associated with this member | |
10615 * @param name the name of the variable being declared | |
10616 * @param equals the equal sign separating the variable name from the initial
value | |
10617 * @param initializer the expression used to compute the initial value for the
variable | |
10618 */ | |
10619 VariableDeclaration.full(Comment comment, List<Annotation> metadata, SimpleIde
ntifier name, Token equals, Expression initializer) : super.full(comment, metada
ta) { | |
10620 this._name = becomeParentOf(name); | |
10621 this._equals = equals; | |
10622 this._initializer = becomeParentOf(initializer); | |
10623 } | |
10624 /** | |
10625 * Initialize a newly created variable declaration. | |
10626 * @param comment the documentation comment associated with this declaration | |
10627 * @param metadata the annotations associated with this member | |
10628 * @param name the name of the variable being declared | |
10629 * @param equals the equal sign separating the variable name from the initial
value | |
10630 * @param initializer the expression used to compute the initial value for the
variable | |
10631 */ | |
10632 VariableDeclaration({Comment comment, List<Annotation> metadata, SimpleIdentif
ier name, Token equals, Expression initializer}) : this.full(comment, metadata,
name, equals, initializer); | |
10633 accept(ASTVisitor visitor) => visitor.visitVariableDeclaration(this); | |
10634 VariableElement get element => _name != null ? (_name.element as VariableEleme
nt) : null; | |
10635 Token get endToken { | |
10636 if (_initializer != null) { | |
10637 return _initializer.endToken; | |
10638 } | |
10639 return _name.endToken; | |
10640 } | |
10641 /** | |
10642 * Return the equal sign separating the variable name from the initial value,
or {@code null} if | |
10643 * the initial value was not specified. | |
10644 * @return the equal sign separating the variable name from the initial value | |
10645 */ | |
10646 Token get equals => _equals; | |
10647 /** | |
10648 * Return the expression used to compute the initial value for the variable, o
r {@code null} if | |
10649 * the initial value was not specified. | |
10650 * @return the expression used to compute the initial value for the variable | |
10651 */ | |
10652 Expression get initializer => _initializer; | |
10653 /** | |
10654 * Return the name of the variable being declared. | |
10655 * @return the name of the variable being declared | |
10656 */ | |
10657 SimpleIdentifier get name => _name; | |
10658 /** | |
10659 * Return {@code true} if this variable was declared with the 'const' modifier
. | |
10660 * @return {@code true} if this variable was declared with the 'const' modifie
r | |
10661 */ | |
10662 bool isConst() { | |
10663 ASTNode parent10 = parent; | |
10664 return parent10 is VariableDeclarationList && ((parent10 as VariableDeclarat
ionList)).isConst(); | |
10665 } | |
10666 /** | |
10667 * Return {@code true} if this variable was declared with the 'final' modifier
. Variables that are | |
10668 * declared with the 'const' modifier will return {@code false} even though th
ey are implicitly | |
10669 * final. | |
10670 * @return {@code true} if this variable was declared with the 'final' modifie
r | |
10671 */ | |
10672 bool isFinal() { | |
10673 ASTNode parent11 = parent; | |
10674 return parent11 is VariableDeclarationList && ((parent11 as VariableDeclarat
ionList)).isFinal(); | |
10675 } | |
10676 /** | |
10677 * Set the equal sign separating the variable name from the initial value to t
he given token. | |
10678 * @param equals the equal sign separating the variable name from the initial
value | |
10679 */ | |
10680 void set equals(Token equals6) { | |
10681 this._equals = equals6; | |
10682 } | |
10683 /** | |
10684 * Set the expression used to compute the initial value for the variable to th
e given expression. | |
10685 * @param initializer the expression used to compute the initial value for the
variable | |
10686 */ | |
10687 void set initializer(Expression initializer2) { | |
10688 this._initializer = becomeParentOf(initializer2); | |
10689 } | |
10690 /** | |
10691 * Set the name of the variable being declared to the given identifier. | |
10692 * @param name the name of the variable being declared | |
10693 */ | |
10694 void set name(SimpleIdentifier name7) { | |
10695 this._name = becomeParentOf(name7); | |
10696 } | |
10697 void visitChildren(ASTVisitor<Object> visitor) { | |
10698 super.visitChildren(visitor); | |
10699 safelyVisitChild(_name, visitor); | |
10700 safelyVisitChild(_initializer, visitor); | |
10701 } | |
10702 Token get firstTokenAfterCommentAndMetadata => _name.beginToken; | |
10703 } | |
10704 /** | |
10705 * Instances of the class {@code VariableDeclarationList} represent the declarat
ion of one or more | |
10706 * variables of the same type. | |
10707 * <pre> | |
10708 * variableDeclarationList ::= | |
10709 * finalConstVarOrType {@link VariableDeclaration variableDeclaration} (',' {@li
nk VariableDeclaration variableDeclaration}) | |
10710 * finalConstVarOrType ::= | |
10711 * | 'final' {@link TypeName type}? | |
10712 * | 'const' {@link TypeName type}? | |
10713 * | 'var' | |
10714 * | {@link TypeName type}</pre> | |
10715 * @coverage dart.engine.ast | |
10716 */ | |
10717 class VariableDeclarationList extends ASTNode { | |
10718 /** | |
10719 * The token representing the 'final', 'const' or 'var' keyword, or {@code nul
l} if no keyword was | |
10720 * included. | |
10721 */ | |
10722 Token _keyword; | |
10723 /** | |
10724 * The type of the variables being declared, or {@code null} if no type was pr
ovided. | |
10725 */ | |
10726 TypeName _type; | |
10727 /** | |
10728 * A list containing the individual variables being declared. | |
10729 */ | |
10730 NodeList<VariableDeclaration> _variables; | |
10731 /** | |
10732 * Initialize a newly created variable declaration list. | |
10733 * @param keyword the token representing the 'final', 'const' or 'var' keyword | |
10734 * @param type the type of the variables being declared | |
10735 * @param variables a list containing the individual variables being declared | |
10736 */ | |
10737 VariableDeclarationList.full(Token keyword, TypeName type, List<VariableDeclar
ation> variables) { | |
10738 this._variables = new NodeList<VariableDeclaration>(this); | |
10739 this._keyword = keyword; | |
10740 this._type = becomeParentOf(type); | |
10741 this._variables.addAll(variables); | |
10742 } | |
10743 /** | |
10744 * Initialize a newly created variable declaration list. | |
10745 * @param keyword the token representing the 'final', 'const' or 'var' keyword | |
10746 * @param type the type of the variables being declared | |
10747 * @param variables a list containing the individual variables being declared | |
10748 */ | |
10749 VariableDeclarationList({Token keyword, TypeName type, List<VariableDeclaratio
n> variables}) : this.full(keyword, type, variables); | |
10750 accept(ASTVisitor visitor) => visitor.visitVariableDeclarationList(this); | |
10751 Token get beginToken { | |
10752 if (_keyword != null) { | |
10753 return _keyword; | |
10754 } else if (_type != null) { | |
10755 return _type.beginToken; | |
10756 } | |
10757 return _variables.beginToken; | |
10758 } | |
10759 Token get endToken => _variables.endToken; | |
10760 /** | |
10761 * Return the token representing the 'final', 'const' or 'var' keyword, or {@c
ode null} if no | |
10762 * keyword was included. | |
10763 * @return the token representing the 'final', 'const' or 'var' keyword | |
10764 */ | |
10765 Token get keyword => _keyword; | |
10766 /** | |
10767 * Return the type of the variables being declared, or {@code null} if no type
was provided. | |
10768 * @return the type of the variables being declared | |
10769 */ | |
10770 TypeName get type => _type; | |
10771 /** | |
10772 * Return a list containing the individual variables being declared. | |
10773 * @return a list containing the individual variables being declared | |
10774 */ | |
10775 NodeList<VariableDeclaration> get variables => _variables; | |
10776 /** | |
10777 * Return {@code true} if the variables in this list were declared with the 'c
onst' modifier. | |
10778 * @return {@code true} if the variables in this list were declared with the '
const' modifier | |
10779 */ | |
10780 bool isConst() => _keyword is KeywordToken && identical(((_keyword as KeywordT
oken)).keyword, Keyword.CONST); | |
10781 /** | |
10782 * Return {@code true} if the variables in this list were declared with the 'f
inal' modifier. | |
10783 * Variables that are declared with the 'const' modifier will return {@code fa
lse} even though | |
10784 * they are implicitly final. | |
10785 * @return {@code true} if the variables in this list were declared with the '
final' modifier | |
10786 */ | |
10787 bool isFinal() => _keyword is KeywordToken && identical(((_keyword as KeywordT
oken)).keyword, Keyword.FINAL); | |
10788 /** | |
10789 * Set the token representing the 'final', 'const' or 'var' keyword to the giv
en token. | |
10790 * @param keyword the token representing the 'final', 'const' or 'var' keyword | |
10791 */ | |
10792 void set keyword(Token keyword25) { | |
10793 this._keyword = keyword25; | |
10794 } | |
10795 /** | |
10796 * Set the type of the variables being declared to the given type name. | |
10797 * @param typeName the type of the variables being declared | |
10798 */ | |
10799 void set type(TypeName typeName) { | |
10800 _type = becomeParentOf(typeName); | |
10801 } | |
10802 void visitChildren(ASTVisitor<Object> visitor) { | |
10803 safelyVisitChild(_type, visitor); | |
10804 _variables.accept(visitor); | |
10805 } | |
10806 } | |
10807 /** | |
10808 * Instances of the class {@code VariableDeclarationStatement} represent a list
of variables that | |
10809 * are being declared in a context where a statement is required. | |
10810 * <pre> | |
10811 * variableDeclarationStatement ::={@link VariableDeclarationList variableList}
';' | |
10812 * </pre> | |
10813 * @coverage dart.engine.ast | |
10814 */ | |
10815 class VariableDeclarationStatement extends Statement { | |
10816 /** | |
10817 * The variables being declared. | |
10818 */ | |
10819 VariableDeclarationList _variableList; | |
10820 /** | |
10821 * The semicolon terminating the statement. | |
10822 */ | |
10823 Token _semicolon; | |
10824 /** | |
10825 * Initialize a newly created variable declaration statement. | |
10826 * @param variableList the fields being declared | |
10827 * @param semicolon the semicolon terminating the statement | |
10828 */ | |
10829 VariableDeclarationStatement.full(VariableDeclarationList variableList, Token
semicolon) { | |
10830 this._variableList = becomeParentOf(variableList); | |
10831 this._semicolon = semicolon; | |
10832 } | |
10833 /** | |
10834 * Initialize a newly created variable declaration statement. | |
10835 * @param variableList the fields being declared | |
10836 * @param semicolon the semicolon terminating the statement | |
10837 */ | |
10838 VariableDeclarationStatement({VariableDeclarationList variableList, Token semi
colon}) : this.full(variableList, semicolon); | |
10839 accept(ASTVisitor visitor) => visitor.visitVariableDeclarationStatement(this); | |
10840 Token get beginToken => _variableList.beginToken; | |
10841 Token get endToken => _semicolon; | |
10842 /** | |
10843 * Return the semicolon terminating the statement. | |
10844 * @return the semicolon terminating the statement | |
10845 */ | |
10846 Token get semicolon => _semicolon; | |
10847 /** | |
10848 * Return the variables being declared. | |
10849 * @return the variables being declared | |
10850 */ | |
10851 VariableDeclarationList get variables => _variableList; | |
10852 /** | |
10853 * Set the semicolon terminating the statement to the given token. | |
10854 * @param semicolon the semicolon terminating the statement | |
10855 */ | |
10856 void set semicolon(Token semicolon18) { | |
10857 this._semicolon = semicolon18; | |
10858 } | |
10859 /** | |
10860 * Set the variables being declared to the given list of variables. | |
10861 * @param variableList the variables being declared | |
10862 */ | |
10863 void set variables(VariableDeclarationList variableList2) { | |
10864 this._variableList = becomeParentOf(variableList2); | |
10865 } | |
10866 void visitChildren(ASTVisitor<Object> visitor) { | |
10867 safelyVisitChild(_variableList, visitor); | |
10868 } | |
10869 } | |
10870 /** | |
10871 * Instances of the class {@code WhileStatement} represent a while statement. | |
10872 * <pre> | |
10873 * whileStatement ::= | |
10874 * 'while' '(' {@link Expression condition} ')' {@link Statement body}</pre> | |
10875 * @coverage dart.engine.ast | |
10876 */ | |
10877 class WhileStatement extends Statement { | |
10878 /** | |
10879 * The token representing the 'while' keyword. | |
10880 */ | |
10881 Token _keyword; | |
10882 /** | |
10883 * The left parenthesis. | |
10884 */ | |
10885 Token _leftParenthesis; | |
10886 /** | |
10887 * The expression used to determine whether to execute the body of the loop. | |
10888 */ | |
10889 Expression _condition; | |
10890 /** | |
10891 * The right parenthesis. | |
10892 */ | |
10893 Token _rightParenthesis; | |
10894 /** | |
10895 * The body of the loop. | |
10896 */ | |
10897 Statement _body; | |
10898 /** | |
10899 * Initialize a newly created while statement. | |
10900 * @param keyword the token representing the 'while' keyword | |
10901 * @param leftParenthesis the left parenthesis | |
10902 * @param condition the expression used to determine whether to execute the bo
dy of the loop | |
10903 * @param rightParenthesis the right parenthesis | |
10904 * @param body the body of the loop | |
10905 */ | |
10906 WhileStatement.full(Token keyword, Token leftParenthesis, Expression condition
, Token rightParenthesis, Statement body) { | |
10907 this._keyword = keyword; | |
10908 this._leftParenthesis = leftParenthesis; | |
10909 this._condition = becomeParentOf(condition); | |
10910 this._rightParenthesis = rightParenthesis; | |
10911 this._body = becomeParentOf(body); | |
10912 } | |
10913 /** | |
10914 * Initialize a newly created while statement. | |
10915 * @param keyword the token representing the 'while' keyword | |
10916 * @param leftParenthesis the left parenthesis | |
10917 * @param condition the expression used to determine whether to execute the bo
dy of the loop | |
10918 * @param rightParenthesis the right parenthesis | |
10919 * @param body the body of the loop | |
10920 */ | |
10921 WhileStatement({Token keyword, Token leftParenthesis, Expression condition, To
ken rightParenthesis, Statement body}) : this.full(keyword, leftParenthesis, con
dition, rightParenthesis, body); | |
10922 accept(ASTVisitor visitor) => visitor.visitWhileStatement(this); | |
10923 Token get beginToken => _keyword; | |
10924 /** | |
10925 * Return the body of the loop. | |
10926 * @return the body of the loop | |
10927 */ | |
10928 Statement get body => _body; | |
10929 /** | |
10930 * Return the expression used to determine whether to execute the body of the
loop. | |
10931 * @return the expression used to determine whether to execute the body of the
loop | |
10932 */ | |
10933 Expression get condition => _condition; | |
10934 Token get endToken => _body.endToken; | |
10935 /** | |
10936 * Return the token representing the 'while' keyword. | |
10937 * @return the token representing the 'while' keyword | |
10938 */ | |
10939 Token get keyword => _keyword; | |
10940 /** | |
10941 * Return the left parenthesis. | |
10942 * @return the left parenthesis | |
10943 */ | |
10944 Token get leftParenthesis => _leftParenthesis; | |
10945 /** | |
10946 * Return the right parenthesis. | |
10947 * @return the right parenthesis | |
10948 */ | |
10949 Token get rightParenthesis => _rightParenthesis; | |
10950 /** | |
10951 * Set the body of the loop to the given statement. | |
10952 * @param statement the body of the loop | |
10953 */ | |
10954 void set body(Statement statement) { | |
10955 _body = becomeParentOf(statement); | |
10956 } | |
10957 /** | |
10958 * Set the expression used to determine whether to execute the body of the loo
p to the given | |
10959 * expression. | |
10960 * @param expression the expression used to determine whether to execute the b
ody of the loop | |
10961 */ | |
10962 void set condition(Expression expression) { | |
10963 _condition = becomeParentOf(expression); | |
10964 } | |
10965 /** | |
10966 * Set the token representing the 'while' keyword to the given token. | |
10967 * @param keyword the token representing the 'while' keyword | |
10968 */ | |
10969 void set keyword(Token keyword26) { | |
10970 this._keyword = keyword26; | |
10971 } | |
10972 /** | |
10973 * Set the left parenthesis to the given token. | |
10974 * @param leftParenthesis the left parenthesis | |
10975 */ | |
10976 void set leftParenthesis(Token leftParenthesis7) { | |
10977 this._leftParenthesis = leftParenthesis7; | |
10978 } | |
10979 /** | |
10980 * Set the right parenthesis to the given token. | |
10981 * @param rightParenthesis the right parenthesis | |
10982 */ | |
10983 void set rightParenthesis(Token rightParenthesis7) { | |
10984 this._rightParenthesis = rightParenthesis7; | |
10985 } | |
10986 void visitChildren(ASTVisitor<Object> visitor) { | |
10987 safelyVisitChild(_condition, visitor); | |
10988 safelyVisitChild(_body, visitor); | |
10989 } | |
10990 } | |
10991 /** | |
10992 * Instances of the class {@code WithClause} represent the with clause in a clas
s declaration. | |
10993 * <pre> | |
10994 * withClause ::= | |
10995 * 'with' {@link TypeName mixin} (',' {@link TypeName mixin}) | |
10996 * </pre> | |
10997 * @coverage dart.engine.ast | |
10998 */ | |
10999 class WithClause extends ASTNode { | |
11000 /** | |
11001 * The token representing the 'with' keyword. | |
11002 */ | |
11003 Token _withKeyword; | |
11004 /** | |
11005 * The names of the mixins that were specified. | |
11006 */ | |
11007 NodeList<TypeName> _mixinTypes; | |
11008 /** | |
11009 * Initialize a newly created with clause. | |
11010 * @param withKeyword the token representing the 'with' keyword | |
11011 * @param mixinTypes the names of the mixins that were specified | |
11012 */ | |
11013 WithClause.full(Token withKeyword, List<TypeName> mixinTypes) { | |
11014 this._mixinTypes = new NodeList<TypeName>(this); | |
11015 this._withKeyword = withKeyword; | |
11016 this._mixinTypes.addAll(mixinTypes); | |
11017 } | |
11018 /** | |
11019 * Initialize a newly created with clause. | |
11020 * @param withKeyword the token representing the 'with' keyword | |
11021 * @param mixinTypes the names of the mixins that were specified | |
11022 */ | |
11023 WithClause({Token withKeyword, List<TypeName> mixinTypes}) : this.full(withKey
word, mixinTypes); | |
11024 accept(ASTVisitor visitor) => visitor.visitWithClause(this); | |
11025 Token get beginToken => _withKeyword; | |
11026 Token get endToken => _mixinTypes.endToken; | |
11027 /** | |
11028 * Return the names of the mixins that were specified. | |
11029 * @return the names of the mixins that were specified | |
11030 */ | |
11031 NodeList<TypeName> get mixinTypes => _mixinTypes; | |
11032 /** | |
11033 * Return the token representing the 'with' keyword. | |
11034 * @return the token representing the 'with' keyword | |
11035 */ | |
11036 Token get withKeyword => _withKeyword; | |
11037 /** | |
11038 * Set the token representing the 'with' keyword to the given token. | |
11039 * @param withKeyword the token representing the 'with' keyword | |
11040 */ | |
11041 void set mixinKeyword(Token withKeyword2) { | |
11042 this._withKeyword = withKeyword2; | |
11043 } | |
11044 void visitChildren(ASTVisitor<Object> visitor) { | |
11045 _mixinTypes.accept(visitor); | |
11046 } | |
11047 } | |
11048 /** | |
11049 * Instances of the class {@code ConstantEvaluator} evaluate constant expression
s to produce their | |
11050 * compile-time value. According to the Dart Language Specification: <blockquote
> A constant | |
11051 * expression is one of the following: | |
11052 * <ul> | |
11053 * <li>A literal number.</li> | |
11054 * <li>A literal boolean.</li> | |
11055 * <li>A literal string where any interpolated expression is a compile-time cons
tant that evaluates | |
11056 * to a numeric, string or boolean value or to {@code null}.</li> | |
11057 * <li>{@code null}.</li> | |
11058 * <li>A reference to a static constant variable.</li> | |
11059 * <li>An identifier expression that denotes a constant variable, a class or a t
ype variable.</li> | |
11060 * <li>A constant constructor invocation.</li> | |
11061 * <li>A constant list literal.</li> | |
11062 * <li>A constant map literal.</li> | |
11063 * <li>A simple or qualified identifier denoting a top-level function or a stati
c method.</li> | |
11064 * <li>A parenthesized expression {@code (e)} where {@code e} is a constant expr
ession.</li> | |
11065 * <li>An expression of one of the forms {@code identical(e1, e2)}, {@code e1 ==
e2},{@code e1 != e2} where {@code e1} and {@code e2} are constant expressions t
hat evaluate to a | |
11066 * numeric, string or boolean value or to {@code null}.</li> | |
11067 * <li>An expression of one of the forms {@code !e}, {@code e1 && e2} or {@code
e1 || e2}, where{@code e}, {@code e1} and {@code e2} are constant expressions th
at evaluate to a boolean value or | |
11068 * to {@code null}.</li> | |
11069 * <li>An expression of one of the forms {@code ~e}, {@code e1 ^ e2}, {@code e1
& e2},{@code e1 | e2}, {@code e1 >> e2} or {@code e1 << e2}, where {@code e}, {@
code e1} and {@code e2}are constant expressions that evaluate to an integer valu
e or to {@code null}.</li> | |
11070 * <li>An expression of one of the forms {@code -e}, {@code e1 + e2}, {@code e1
- e2},{@code e1 * e2}, {@code e1 / e2}, {@code e1 ~/ e2}, {@code e1 > e2}, {@cod
e e1 < e2},{@code e1 >= e2}, {@code e1 <= e2} or {@code e1 % e2}, where {@code e
}, {@code e1} and {@code e2}are constant expressions that evaluate to a numeric
value or to {@code null}.</li> | |
11071 * </ul> | |
11072 * </blockquote> The values returned by instances of this class are therefore {@
code null} and | |
11073 * instances of the classes {@code Boolean}, {@code BigInteger}, {@code Double},
{@code String}, and{@code DartObject}. | |
11074 * <p> | |
11075 * In addition, this class defines several values that can be returned to indica
te various | |
11076 * conditions encountered during evaluation. These are documented with the stati
c field that define | |
11077 * those values. | |
11078 * @coverage dart.engine.ast | |
11079 */ | |
11080 class ConstantEvaluator extends GeneralizingASTVisitor<Object> { | |
11081 /** | |
11082 * The value returned for expressions (or non-expression nodes) that are not c
ompile-time constant | |
11083 * expressions. | |
11084 */ | |
11085 static Object NOT_A_CONSTANT = new Object(); | |
11086 /** | |
11087 * The error reporter by which errors will be reported. | |
11088 */ | |
11089 ErrorReporter _errorReporter; | |
11090 /** | |
11091 * Initialize a newly created constant evaluator. | |
11092 * @param errorReporter the error reporter by which errors will be reported | |
11093 */ | |
11094 ConstantEvaluator(ErrorReporter errorReporter) { | |
11095 this._errorReporter = errorReporter; | |
11096 } | |
11097 Object visitAdjacentStrings(AdjacentStrings node) { | |
11098 JavaStringBuilder builder = new JavaStringBuilder(); | |
11099 for (StringLiteral string in node.strings) { | |
11100 Object value = string.accept(this); | |
11101 if (identical(value, NOT_A_CONSTANT)) { | |
11102 return value; | |
11103 } | |
11104 builder.append(value); | |
11105 } | |
11106 return builder.toString(); | |
11107 } | |
11108 Object visitBinaryExpression(BinaryExpression node) { | |
11109 Object leftOperand2 = node.leftOperand.accept(this); | |
11110 if (identical(leftOperand2, NOT_A_CONSTANT)) { | |
11111 return leftOperand2; | |
11112 } | |
11113 Object rightOperand2 = node.rightOperand.accept(this); | |
11114 if (identical(rightOperand2, NOT_A_CONSTANT)) { | |
11115 return rightOperand2; | |
11116 } | |
11117 while (true) { | |
11118 if (node.operator.type == TokenType.AMPERSAND) { | |
11119 if (leftOperand2 is int && rightOperand2 is int) { | |
11120 return ((leftOperand2 as int)) & (rightOperand2 as int); | |
11121 } | |
11122 } else if (node.operator.type == TokenType.AMPERSAND_AMPERSAND) { | |
11123 if (leftOperand2 is bool && rightOperand2 is bool) { | |
11124 return ((leftOperand2 as bool)) && ((rightOperand2 as bool)); | |
11125 } | |
11126 } else if (node.operator.type == TokenType.BANG_EQ) { | |
11127 if (leftOperand2 is bool && rightOperand2 is bool) { | |
11128 return ((leftOperand2 as bool)) != ((rightOperand2 as bool)); | |
11129 } else if (leftOperand2 is int && rightOperand2 is int) { | |
11130 return ((leftOperand2 as int)) != rightOperand2; | |
11131 } else if (leftOperand2 is double && rightOperand2 is double) { | |
11132 return ((leftOperand2 as double)) != rightOperand2; | |
11133 } else if (leftOperand2 is String && rightOperand2 is String) { | |
11134 return ((leftOperand2 as String)) != rightOperand2; | |
11135 } | |
11136 } else if (node.operator.type == TokenType.BAR) { | |
11137 if (leftOperand2 is int && rightOperand2 is int) { | |
11138 return ((leftOperand2 as int)) | (rightOperand2 as int); | |
11139 } | |
11140 } else if (node.operator.type == TokenType.BAR_BAR) { | |
11141 if (leftOperand2 is bool && rightOperand2 is bool) { | |
11142 return ((leftOperand2 as bool)) || ((rightOperand2 as bool)); | |
11143 } | |
11144 } else if (node.operator.type == TokenType.CARET) { | |
11145 if (leftOperand2 is int && rightOperand2 is int) { | |
11146 return ((leftOperand2 as int)) ^ (rightOperand2 as int); | |
11147 } | |
11148 } else if (node.operator.type == TokenType.EQ_EQ) { | |
11149 if (leftOperand2 is bool && rightOperand2 is bool) { | |
11150 return identical(((leftOperand2 as bool)), ((rightOperand2 as bool))); | |
11151 } else if (leftOperand2 is int && rightOperand2 is int) { | |
11152 return ((leftOperand2 as int)) == rightOperand2; | |
11153 } else if (leftOperand2 is double && rightOperand2 is double) { | |
11154 return ((leftOperand2 as double)) == rightOperand2; | |
11155 } else if (leftOperand2 is String && rightOperand2 is String) { | |
11156 return ((leftOperand2 as String)) == rightOperand2; | |
11157 } | |
11158 } else if (node.operator.type == TokenType.GT) { | |
11159 if (leftOperand2 is int && rightOperand2 is int) { | |
11160 return ((leftOperand2 as int)).compareTo((rightOperand2 as int)) > 0; | |
11161 } else if (leftOperand2 is double && rightOperand2 is double) { | |
11162 return ((leftOperand2 as double)).compareTo((rightOperand2 as double))
> 0; | |
11163 } | |
11164 } else if (node.operator.type == TokenType.GT_EQ) { | |
11165 if (leftOperand2 is int && rightOperand2 is int) { | |
11166 return ((leftOperand2 as int)).compareTo((rightOperand2 as int)) >= 0; | |
11167 } else if (leftOperand2 is double && rightOperand2 is double) { | |
11168 return ((leftOperand2 as double)).compareTo((rightOperand2 as double))
>= 0; | |
11169 } | |
11170 } else if (node.operator.type == TokenType.GT_GT) { | |
11171 if (leftOperand2 is int && rightOperand2 is int) { | |
11172 return ((leftOperand2 as int)) >> ((rightOperand2 as int)); | |
11173 } | |
11174 } else if (node.operator.type == TokenType.LT) { | |
11175 if (leftOperand2 is int && rightOperand2 is int) { | |
11176 return ((leftOperand2 as int)).compareTo((rightOperand2 as int)) < 0; | |
11177 } else if (leftOperand2 is double && rightOperand2 is double) { | |
11178 return ((leftOperand2 as double)).compareTo((rightOperand2 as double))
< 0; | |
11179 } | |
11180 } else if (node.operator.type == TokenType.LT_EQ) { | |
11181 if (leftOperand2 is int && rightOperand2 is int) { | |
11182 return ((leftOperand2 as int)).compareTo((rightOperand2 as int)) <= 0; | |
11183 } else if (leftOperand2 is double && rightOperand2 is double) { | |
11184 return ((leftOperand2 as double)).compareTo((rightOperand2 as double))
<= 0; | |
11185 } | |
11186 } else if (node.operator.type == TokenType.LT_LT) { | |
11187 if (leftOperand2 is int && rightOperand2 is int) { | |
11188 return ((leftOperand2 as int)) << ((rightOperand2 as int)); | |
11189 } | |
11190 } else if (node.operator.type == TokenType.MINUS) { | |
11191 if (leftOperand2 is int && rightOperand2 is int) { | |
11192 return ((leftOperand2 as int)) - (rightOperand2 as int); | |
11193 } else if (leftOperand2 is double && rightOperand2 is double) { | |
11194 return ((leftOperand2 as double)) - ((rightOperand2 as double)); | |
11195 } | |
11196 } else if (node.operator.type == TokenType.PERCENT) { | |
11197 if (leftOperand2 is int && rightOperand2 is int) { | |
11198 return ((leftOperand2 as int)).remainder((rightOperand2 as int)); | |
11199 } else if (leftOperand2 is double && rightOperand2 is double) { | |
11200 return ((leftOperand2 as double)) % ((rightOperand2 as double)); | |
11201 } | |
11202 } else if (node.operator.type == TokenType.PLUS) { | |
11203 if (leftOperand2 is int && rightOperand2 is int) { | |
11204 return ((leftOperand2 as int)) + (rightOperand2 as int); | |
11205 } else if (leftOperand2 is double && rightOperand2 is double) { | |
11206 return ((leftOperand2 as double)) + ((rightOperand2 as double)); | |
11207 } | |
11208 } else if (node.operator.type == TokenType.STAR) { | |
11209 if (leftOperand2 is int && rightOperand2 is int) { | |
11210 return ((leftOperand2 as int)) * (rightOperand2 as int); | |
11211 } else if (leftOperand2 is double && rightOperand2 is double) { | |
11212 return ((leftOperand2 as double)) * ((rightOperand2 as double)); | |
11213 } | |
11214 } else if (node.operator.type == TokenType.SLASH) { | |
11215 if (leftOperand2 is int && rightOperand2 is int) { | |
11216 if (rightOperand2 != 0) { | |
11217 return ((leftOperand2 as int)) ~/ (rightOperand2 as int); | |
11218 } else { | |
11219 reportDivideByZeroError(node); | |
11220 return 0; | |
11221 } | |
11222 } else if (leftOperand2 is double && rightOperand2 is double) { | |
11223 if (rightOperand2 != 0) { | |
11224 return ((leftOperand2 as double)) / ((rightOperand2 as double)); | |
11225 } else { | |
11226 reportDivideByZeroError(node); | |
11227 return 0; | |
11228 } | |
11229 } | |
11230 } else if (node.operator.type == TokenType.TILDE_SLASH) { | |
11231 if (leftOperand2 is int && rightOperand2 is int) { | |
11232 if (rightOperand2 != 0) { | |
11233 return ((leftOperand2 as int)) ~/ (rightOperand2 as int); | |
11234 } else { | |
11235 reportDivideByZeroError(node); | |
11236 return 0; | |
11237 } | |
11238 } else if (leftOperand2 is double && rightOperand2 is double) { | |
11239 if (rightOperand2 != 0) { | |
11240 return ((leftOperand2 as double)) ~/ ((rightOperand2 as double)); | |
11241 } else { | |
11242 reportDivideByZeroError(node); | |
11243 return 0; | |
11244 } | |
11245 } | |
11246 } | |
11247 break; | |
11248 } | |
11249 return visitExpression(node); | |
11250 } | |
11251 Object visitBooleanLiteral(BooleanLiteral node) => node.value ? true : false; | |
11252 Object visitDoubleLiteral(DoubleLiteral node) => node.value; | |
11253 Object visitIntegerLiteral(IntegerLiteral node) => node.value; | |
11254 Object visitInterpolationExpression(InterpolationExpression node) { | |
11255 Object value = node.expression.accept(this); | |
11256 if (value == null || value is bool || value is String || value is int || val
ue is double) { | |
11257 return value; | |
11258 } | |
11259 return NOT_A_CONSTANT; | |
11260 } | |
11261 Object visitInterpolationString(InterpolationString node) => node.value; | |
11262 Object visitListLiteral(ListLiteral node) { | |
11263 List<Object> list = new List<Object>(); | |
11264 for (Expression element in node.elements) { | |
11265 Object value = element.accept(this); | |
11266 if (identical(value, NOT_A_CONSTANT)) { | |
11267 return value; | |
11268 } | |
11269 list.add(value); | |
11270 } | |
11271 return list; | |
11272 } | |
11273 Object visitMapLiteral(MapLiteral node) { | |
11274 Map<String, Object> map = new Map<String, Object>(); | |
11275 for (MapLiteralEntry entry in node.entries) { | |
11276 Object key2 = entry.key.accept(this); | |
11277 Object value8 = entry.value.accept(this); | |
11278 if (key2 is! String || identical(value8, NOT_A_CONSTANT)) { | |
11279 return NOT_A_CONSTANT; | |
11280 } | |
11281 map[(key2 as String)] = value8; | |
11282 } | |
11283 return map; | |
11284 } | |
11285 Object visitMethodInvocation(MethodInvocation node) => visitNode(node); | |
11286 Object visitNode(ASTNode node) => NOT_A_CONSTANT; | |
11287 Object visitNullLiteral(NullLiteral node) => null; | |
11288 Object visitParenthesizedExpression(ParenthesizedExpression node) => node.expr
ession.accept(this); | |
11289 Object visitPrefixedIdentifier(PrefixedIdentifier node) => getConstantValue(nu
ll); | |
11290 Object visitPrefixExpression(PrefixExpression node) { | |
11291 Object operand2 = node.operand.accept(this); | |
11292 if (identical(operand2, NOT_A_CONSTANT)) { | |
11293 return operand2; | |
11294 } | |
11295 while (true) { | |
11296 if (node.operator.type == TokenType.BANG) { | |
11297 if (identical(operand2, true)) { | |
11298 return false; | |
11299 } else if (identical(operand2, false)) { | |
11300 return true; | |
11301 } | |
11302 } else if (node.operator.type == TokenType.TILDE) { | |
11303 if (operand2 is int) { | |
11304 return ~((operand2 as int)); | |
11305 } | |
11306 } else if (node.operator.type == TokenType.MINUS) { | |
11307 if (operand2 == null) { | |
11308 return null; | |
11309 } else if (operand2 is int) { | |
11310 return -((operand2 as int)); | |
11311 } else if (operand2 is double) { | |
11312 return -((operand2 as double)); | |
11313 } | |
11314 } | |
11315 break; | |
11316 } | |
11317 return NOT_A_CONSTANT; | |
11318 } | |
11319 Object visitPropertyAccess(PropertyAccess node) => getConstantValue(null); | |
11320 Object visitSimpleIdentifier(SimpleIdentifier node) => getConstantValue(null); | |
11321 Object visitSimpleStringLiteral(SimpleStringLiteral node) => node.value; | |
11322 Object visitStringInterpolation(StringInterpolation node) { | |
11323 JavaStringBuilder builder = new JavaStringBuilder(); | |
11324 for (InterpolationElement element in node.elements) { | |
11325 Object value = element.accept(this); | |
11326 if (identical(value, NOT_A_CONSTANT)) { | |
11327 return value; | |
11328 } | |
11329 builder.append(value); | |
11330 } | |
11331 return builder.toString(); | |
11332 } | |
11333 /** | |
11334 * Return the constant value of the static constant represented by the given e
lement. | |
11335 * @param element the element whose value is to be returned | |
11336 * @return the constant value of the static constant | |
11337 */ | |
11338 Object getConstantValue(Element element) { | |
11339 if (element is FieldElement) { | |
11340 FieldElement field = element as FieldElement; | |
11341 if (field.isStatic() && field.isConst()) { | |
11342 } | |
11343 } | |
11344 return NOT_A_CONSTANT; | |
11345 } | |
11346 void reportDivideByZeroError(BinaryExpression node) { | |
11347 _errorReporter.reportError(CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES
_EXCEPTION_DIVIDE_BY_ZERO, node, []); | |
11348 } | |
11349 } | |
11350 /** | |
11351 * Instances of the class {@code ElementLocator} locate the {@link Element Dart
model element}associated with a given {@link ASTNode AST node}. | |
11352 * @coverage dart.engine.ast | |
11353 */ | |
11354 class ElementLocator { | |
11355 /** | |
11356 * Locate the {@link Element Dart model element} associated with the given {@l
ink ASTNode AST | |
11357 * node}. | |
11358 * @param node the node (not {@code null}) | |
11359 * @return the associated element, or {@code null} if none is found | |
11360 */ | |
11361 static Element locate(ASTNode node) { | |
11362 ElementLocator_ElementMapper mapper = new ElementLocator_ElementMapper(); | |
11363 return node.accept(mapper); | |
11364 } | |
11365 /** | |
11366 * Clients should use {@link #locate(ASTNode)}. | |
11367 */ | |
11368 ElementLocator() { | |
11369 } | |
11370 } | |
11371 /** | |
11372 * Visitor that maps nodes to elements. | |
11373 */ | |
11374 class ElementLocator_ElementMapper extends GeneralizingASTVisitor<Element> { | |
11375 Element visitBinaryExpression(BinaryExpression node) => node.element; | |
11376 Element visitIdentifier(Identifier node) => node.element; | |
11377 Element visitImportDirective(ImportDirective node) => node.element; | |
11378 Element visitIndexExpression(IndexExpression node) => node.element; | |
11379 Element visitLibraryDirective(LibraryDirective node) => node.element; | |
11380 Element visitPostfixExpression(PostfixExpression node) => node.element; | |
11381 Element visitPrefixedIdentifier(PrefixedIdentifier node) => node.element; | |
11382 Element visitPrefixExpression(PrefixExpression node) => node.element; | |
11383 Element visitStringLiteral(StringLiteral node) { | |
11384 ASTNode parent12 = node.parent; | |
11385 if (parent12 is UriBasedDirective) { | |
11386 return ((parent12 as UriBasedDirective)).element; | |
11387 } | |
11388 return null; | |
11389 } | |
11390 } | |
11391 /** | |
11392 * Instances of the class {@code GeneralizingASTVisitor} implement an AST visito
r that will | |
11393 * recursively visit all of the nodes in an AST structure (like instances of the
class{@link RecursiveASTVisitor}). In addition, when a node of a specific type
is visited not only | |
11394 * will the visit method for that specific type of node be invoked, but addition
al methods for the | |
11395 * superclasses of that node will also be invoked. For example, using an instanc
e of this class to | |
11396 * visit a {@link Block} will cause the method {@link #visitBlock(Block)} to be
invoked but will | |
11397 * also cause the methods {@link #visitStatement(Statement)} and {@link #visitNo
de(ASTNode)} to be | |
11398 * subsequently invoked. This allows visitors to be written that visit all state
ments without | |
11399 * needing to override the visit method for each of the specific subclasses of {
@link Statement}. | |
11400 * <p> | |
11401 * Subclasses that override a visit method must either invoke the overridden vis
it method or | |
11402 * explicitly invoke the more general visit method. Failure to do so will cause
the visit methods | |
11403 * for superclasses of the node to not be invoked and will cause the children of
the visited node to | |
11404 * not be visited. | |
11405 * @coverage dart.engine.ast | |
11406 */ | |
11407 class GeneralizingASTVisitor<R> implements ASTVisitor<R> { | |
11408 R visitAdjacentStrings(AdjacentStrings node) => visitStringLiteral(node); | |
11409 R visitAnnotatedNode(AnnotatedNode node) => visitNode(node); | |
11410 R visitAnnotation(Annotation node) => visitNode(node); | |
11411 R visitArgumentDefinitionTest(ArgumentDefinitionTest node) => visitExpression(
node); | |
11412 R visitArgumentList(ArgumentList node) => visitNode(node); | |
11413 R visitAsExpression(AsExpression node) => visitExpression(node); | |
11414 R visitAssertStatement(AssertStatement node) => visitStatement(node); | |
11415 R visitAssignmentExpression(AssignmentExpression node) => visitExpression(node
); | |
11416 R visitBinaryExpression(BinaryExpression node) => visitExpression(node); | |
11417 R visitBlock(Block node) => visitStatement(node); | |
11418 R visitBlockFunctionBody(BlockFunctionBody node) => visitFunctionBody(node); | |
11419 R visitBooleanLiteral(BooleanLiteral node) => visitLiteral(node); | |
11420 R visitBreakStatement(BreakStatement node) => visitStatement(node); | |
11421 R visitCascadeExpression(CascadeExpression node) => visitExpression(node); | |
11422 R visitCatchClause(CatchClause node) => visitNode(node); | |
11423 R visitClassDeclaration(ClassDeclaration node) => visitCompilationUnitMember(n
ode); | |
11424 R visitClassMember(ClassMember node) => visitDeclaration(node); | |
11425 R visitClassTypeAlias(ClassTypeAlias node) => visitTypeAlias(node); | |
11426 R visitCombinator(Combinator node) => visitNode(node); | |
11427 R visitComment(Comment node) => visitNode(node); | |
11428 R visitCommentReference(CommentReference node) => visitNode(node); | |
11429 R visitCompilationUnit(CompilationUnit node) => visitNode(node); | |
11430 R visitCompilationUnitMember(CompilationUnitMember node) => visitDeclaration(n
ode); | |
11431 R visitConditionalExpression(ConditionalExpression node) => visitExpression(no
de); | |
11432 R visitConstructorDeclaration(ConstructorDeclaration node) => visitClassMember
(node); | |
11433 R visitConstructorFieldInitializer(ConstructorFieldInitializer node) => visitC
onstructorInitializer(node); | |
11434 R visitConstructorInitializer(ConstructorInitializer node) => visitNode(node); | |
11435 R visitConstructorName(ConstructorName node) => visitNode(node); | |
11436 R visitContinueStatement(ContinueStatement node) => visitStatement(node); | |
11437 R visitDeclaration(Declaration node) => visitAnnotatedNode(node); | |
11438 R visitDeclaredIdentifier(DeclaredIdentifier node) => visitDeclaration(node); | |
11439 R visitDefaultFormalParameter(DefaultFormalParameter node) => visitFormalParam
eter(node); | |
11440 R visitDirective(Directive node) => visitAnnotatedNode(node); | |
11441 R visitDoStatement(DoStatement node) => visitStatement(node); | |
11442 R visitDoubleLiteral(DoubleLiteral node) => visitLiteral(node); | |
11443 R visitEmptyFunctionBody(EmptyFunctionBody node) => visitFunctionBody(node); | |
11444 R visitEmptyStatement(EmptyStatement node) => visitStatement(node); | |
11445 R visitExportDirective(ExportDirective node) => visitNamespaceDirective(node); | |
11446 R visitExpression(Expression node) => visitNode(node); | |
11447 R visitExpressionFunctionBody(ExpressionFunctionBody node) => visitFunctionBod
y(node); | |
11448 R visitExpressionStatement(ExpressionStatement node) => visitStatement(node); | |
11449 R visitExtendsClause(ExtendsClause node) => visitNode(node); | |
11450 R visitFieldDeclaration(FieldDeclaration node) => visitClassMember(node); | |
11451 R visitFieldFormalParameter(FieldFormalParameter node) => visitNormalFormalPar
ameter(node); | |
11452 R visitForEachStatement(ForEachStatement node) => visitStatement(node); | |
11453 R visitFormalParameter(FormalParameter node) => visitNode(node); | |
11454 R visitFormalParameterList(FormalParameterList node) => visitNode(node); | |
11455 R visitForStatement(ForStatement node) => visitStatement(node); | |
11456 R visitFunctionBody(FunctionBody node) => visitNode(node); | |
11457 R visitFunctionDeclaration(FunctionDeclaration node) => visitNode(node); | |
11458 R visitFunctionDeclarationStatement(FunctionDeclarationStatement node) => visi
tStatement(node); | |
11459 R visitFunctionExpression(FunctionExpression node) => visitExpression(node); | |
11460 R visitFunctionExpressionInvocation(FunctionExpressionInvocation node) => visi
tExpression(node); | |
11461 R visitFunctionTypeAlias(FunctionTypeAlias node) => visitTypeAlias(node); | |
11462 R visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) => visi
tNormalFormalParameter(node); | |
11463 R visitHideCombinator(HideCombinator node) => visitCombinator(node); | |
11464 R visitIdentifier(Identifier node) => visitExpression(node); | |
11465 R visitIfStatement(IfStatement node) => visitStatement(node); | |
11466 R visitImplementsClause(ImplementsClause node) => visitNode(node); | |
11467 R visitImportDirective(ImportDirective node) => visitNamespaceDirective(node); | |
11468 R visitIndexExpression(IndexExpression node) => visitExpression(node); | |
11469 R visitInstanceCreationExpression(InstanceCreationExpression node) => visitExp
ression(node); | |
11470 R visitIntegerLiteral(IntegerLiteral node) => visitLiteral(node); | |
11471 R visitInterpolationElement(InterpolationElement node) => visitNode(node); | |
11472 R visitInterpolationExpression(InterpolationExpression node) => visitInterpola
tionElement(node); | |
11473 R visitInterpolationString(InterpolationString node) => visitInterpolationElem
ent(node); | |
11474 R visitIsExpression(IsExpression node) => visitExpression(node); | |
11475 R visitLabel(Label node) => visitNode(node); | |
11476 R visitLabeledStatement(LabeledStatement node) => visitStatement(node); | |
11477 R visitLibraryDirective(LibraryDirective node) => visitDirective(node); | |
11478 R visitLibraryIdentifier(LibraryIdentifier node) => visitIdentifier(node); | |
11479 R visitListLiteral(ListLiteral node) => visitTypedLiteral(node); | |
11480 R visitLiteral(Literal node) => visitExpression(node); | |
11481 R visitMapLiteral(MapLiteral node) => visitTypedLiteral(node); | |
11482 R visitMapLiteralEntry(MapLiteralEntry node) => visitNode(node); | |
11483 R visitMethodDeclaration(MethodDeclaration node) => visitClassMember(node); | |
11484 R visitMethodInvocation(MethodInvocation node) => visitExpression(node); | |
11485 R visitNamedExpression(NamedExpression node) => visitExpression(node); | |
11486 R visitNamespaceDirective(NamespaceDirective node) => visitUriBasedDirective(n
ode); | |
11487 R visitNode(ASTNode node) { | |
11488 node.visitChildren(this); | |
11489 return null; | |
11490 } | |
11491 R visitNormalFormalParameter(NormalFormalParameter node) => visitFormalParamet
er(node); | |
11492 R visitNullLiteral(NullLiteral node) => visitLiteral(node); | |
11493 R visitParenthesizedExpression(ParenthesizedExpression node) => visitExpressio
n(node); | |
11494 R visitPartDirective(PartDirective node) => visitUriBasedDirective(node); | |
11495 R visitPartOfDirective(PartOfDirective node) => visitDirective(node); | |
11496 R visitPostfixExpression(PostfixExpression node) => visitExpression(node); | |
11497 R visitPrefixedIdentifier(PrefixedIdentifier node) => visitIdentifier(node); | |
11498 R visitPrefixExpression(PrefixExpression node) => visitExpression(node); | |
11499 R visitPropertyAccess(PropertyAccess node) => visitExpression(node); | |
11500 R visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node)
=> visitConstructorInitializer(node); | |
11501 R visitReturnStatement(ReturnStatement node) => visitStatement(node); | |
11502 R visitScriptTag(ScriptTag scriptTag) => visitNode(scriptTag); | |
11503 R visitShowCombinator(ShowCombinator node) => visitCombinator(node); | |
11504 R visitSimpleFormalParameter(SimpleFormalParameter node) => visitNormalFormalP
arameter(node); | |
11505 R visitSimpleIdentifier(SimpleIdentifier node) => visitIdentifier(node); | |
11506 R visitSimpleStringLiteral(SimpleStringLiteral node) => visitStringLiteral(nod
e); | |
11507 R visitStatement(Statement node) => visitNode(node); | |
11508 R visitStringInterpolation(StringInterpolation node) => visitStringLiteral(nod
e); | |
11509 R visitStringLiteral(StringLiteral node) => visitLiteral(node); | |
11510 R visitSuperConstructorInvocation(SuperConstructorInvocation node) => visitCon
structorInitializer(node); | |
11511 R visitSuperExpression(SuperExpression node) => visitExpression(node); | |
11512 R visitSwitchCase(SwitchCase node) => visitSwitchMember(node); | |
11513 R visitSwitchDefault(SwitchDefault node) => visitSwitchMember(node); | |
11514 R visitSwitchMember(SwitchMember node) => visitNode(node); | |
11515 R visitSwitchStatement(SwitchStatement node) => visitStatement(node); | |
11516 R visitThisExpression(ThisExpression node) => visitExpression(node); | |
11517 R visitThrowExpression(ThrowExpression node) => visitExpression(node); | |
11518 R visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) => visitC
ompilationUnitMember(node); | |
11519 R visitTryStatement(TryStatement node) => visitStatement(node); | |
11520 R visitTypeAlias(TypeAlias node) => visitCompilationUnitMember(node); | |
11521 R visitTypeArgumentList(TypeArgumentList node) => visitNode(node); | |
11522 R visitTypedLiteral(TypedLiteral node) => visitLiteral(node); | |
11523 R visitTypeName(TypeName node) => visitNode(node); | |
11524 R visitTypeParameter(TypeParameter node) => visitNode(node); | |
11525 R visitTypeParameterList(TypeParameterList node) => visitNode(node); | |
11526 R visitUriBasedDirective(UriBasedDirective node) => visitDirective(node); | |
11527 R visitVariableDeclaration(VariableDeclaration node) => visitDeclaration(node)
; | |
11528 R visitVariableDeclarationList(VariableDeclarationList node) => visitNode(node
); | |
11529 R visitVariableDeclarationStatement(VariableDeclarationStatement node) => visi
tStatement(node); | |
11530 R visitWhileStatement(WhileStatement node) => visitStatement(node); | |
11531 R visitWithClause(WithClause node) => visitNode(node); | |
11532 } | |
11533 /** | |
11534 * Instances of the class {@code NodeLocator} locate the {@link ASTNode AST node
} associated with a | |
11535 * source range, given the AST structure built from the source. More specificall
y, they will return | |
11536 * the {@link ASTNode AST node} with the shortest length whose source range comp
letely encompasses | |
11537 * the specified range. | |
11538 * @coverage dart.engine.ast | |
11539 */ | |
11540 class NodeLocator extends GeneralizingASTVisitor<Object> { | |
11541 /** | |
11542 * The start offset of the range used to identify the node. | |
11543 */ | |
11544 int _startOffset = 0; | |
11545 /** | |
11546 * The end offset of the range used to identify the node. | |
11547 */ | |
11548 int _endOffset = 0; | |
11549 /** | |
11550 * The element that was found that corresponds to the given source range, or {
@code null} if there | |
11551 * is no such element. | |
11552 */ | |
11553 ASTNode _foundNode; | |
11554 /** | |
11555 * Initialize a newly created locator to locate one or more {@link ASTNode AST
nodes} by locating | |
11556 * the node within an AST structure that corresponds to the given offset in th
e source. | |
11557 * @param offset the offset used to identify the node | |
11558 */ | |
11559 NodeLocator.con1(int offset) { | |
11560 _jtd_constructor_118_impl(offset); | |
11561 } | |
11562 _jtd_constructor_118_impl(int offset) { | |
11563 _jtd_constructor_119_impl(offset, offset); | |
11564 } | |
11565 /** | |
11566 * Initialize a newly created locator to locate one or more {@link ASTNode AST
nodes} by locating | |
11567 * the node within an AST structure that corresponds to the given range of cha
racters in the | |
11568 * source. | |
11569 * @param start the start offset of the range used to identify the node | |
11570 * @param end the end offset of the range used to identify the node | |
11571 */ | |
11572 NodeLocator.con2(int start, int end) { | |
11573 _jtd_constructor_119_impl(start, end); | |
11574 } | |
11575 _jtd_constructor_119_impl(int start, int end) { | |
11576 this._startOffset = start; | |
11577 this._endOffset = end; | |
11578 } | |
11579 /** | |
11580 * Return the node that was found that corresponds to the given source range,
or {@code null} if | |
11581 * there is no such node. | |
11582 * @return the node that was found | |
11583 */ | |
11584 ASTNode get foundNode => _foundNode; | |
11585 /** | |
11586 * Search within the given AST node for an identifier representing a {@link Da
rtElement Dart | |
11587 * element} in the specified source range. Return the element that was found,
or {@code null} if | |
11588 * no element was found. | |
11589 * @param node the AST node within which to search | |
11590 * @return the element that was found | |
11591 */ | |
11592 ASTNode searchWithin(ASTNode node) { | |
11593 try { | |
11594 node.accept(this); | |
11595 } on NodeLocator_NodeFoundException catch (exception) { | |
11596 } on JavaException catch (exception) { | |
11597 AnalysisEngine.instance.logger.logInformation2("Unable to locate element a
t offset (${_startOffset} - ${_endOffset})", exception); | |
11598 return null; | |
11599 } | |
11600 return _foundNode; | |
11601 } | |
11602 Object visitNode(ASTNode node) { | |
11603 try { | |
11604 node.visitChildren(this); | |
11605 } on NodeLocator_NodeFoundException catch (exception) { | |
11606 throw exception; | |
11607 } on JavaException catch (exception) { | |
11608 AnalysisEngine.instance.logger.logInformation2("Exception caught while tra
versing an AST structure.", exception); | |
11609 } | |
11610 int start = node.offset; | |
11611 int end = start + node.length; | |
11612 if (start <= _startOffset && _endOffset <= end) { | |
11613 _foundNode = node; | |
11614 throw new NodeLocator_NodeFoundException(); | |
11615 } | |
11616 return null; | |
11617 } | |
11618 } | |
11619 /** | |
11620 * Instances of the class {@code NodeFoundException} are used to cancel visiting
after a node has | |
11621 * been found. | |
11622 */ | |
11623 class NodeLocator_NodeFoundException extends RuntimeException { | |
11624 static int _serialVersionUID = 1; | |
11625 } | |
11626 /** | |
11627 * Instances of the class {@code RecursiveASTVisitor} implement an AST visitor t
hat will recursively | |
11628 * visit all of the nodes in an AST structure. For example, using an instance of
this class to visit | |
11629 * a {@link Block} will also cause all of the statements in the block to be visi
ted. | |
11630 * <p> | |
11631 * Subclasses that override a visit method must either invoke the overridden vis
it method or must | |
11632 * explicitly ask the visited node to visit its children. Failure to do so will
cause the children | |
11633 * of the visited node to not be visited. | |
11634 * @coverage dart.engine.ast | |
11635 */ | |
11636 class RecursiveASTVisitor<R> implements ASTVisitor<R> { | |
11637 R visitAdjacentStrings(AdjacentStrings node) { | |
11638 node.visitChildren(this); | |
11639 return null; | |
11640 } | |
11641 R visitAnnotation(Annotation node) { | |
11642 node.visitChildren(this); | |
11643 return null; | |
11644 } | |
11645 R visitArgumentDefinitionTest(ArgumentDefinitionTest node) { | |
11646 node.visitChildren(this); | |
11647 return null; | |
11648 } | |
11649 R visitArgumentList(ArgumentList node) { | |
11650 node.visitChildren(this); | |
11651 return null; | |
11652 } | |
11653 R visitAsExpression(AsExpression node) { | |
11654 node.visitChildren(this); | |
11655 return null; | |
11656 } | |
11657 R visitAssertStatement(AssertStatement node) { | |
11658 node.visitChildren(this); | |
11659 return null; | |
11660 } | |
11661 R visitAssignmentExpression(AssignmentExpression node) { | |
11662 node.visitChildren(this); | |
11663 return null; | |
11664 } | |
11665 R visitBinaryExpression(BinaryExpression node) { | |
11666 node.visitChildren(this); | |
11667 return null; | |
11668 } | |
11669 R visitBlock(Block node) { | |
11670 node.visitChildren(this); | |
11671 return null; | |
11672 } | |
11673 R visitBlockFunctionBody(BlockFunctionBody node) { | |
11674 node.visitChildren(this); | |
11675 return null; | |
11676 } | |
11677 R visitBooleanLiteral(BooleanLiteral node) { | |
11678 node.visitChildren(this); | |
11679 return null; | |
11680 } | |
11681 R visitBreakStatement(BreakStatement node) { | |
11682 node.visitChildren(this); | |
11683 return null; | |
11684 } | |
11685 R visitCascadeExpression(CascadeExpression node) { | |
11686 node.visitChildren(this); | |
11687 return null; | |
11688 } | |
11689 R visitCatchClause(CatchClause node) { | |
11690 node.visitChildren(this); | |
11691 return null; | |
11692 } | |
11693 R visitClassDeclaration(ClassDeclaration node) { | |
11694 node.visitChildren(this); | |
11695 return null; | |
11696 } | |
11697 R visitClassTypeAlias(ClassTypeAlias node) { | |
11698 node.visitChildren(this); | |
11699 return null; | |
11700 } | |
11701 R visitComment(Comment node) { | |
11702 node.visitChildren(this); | |
11703 return null; | |
11704 } | |
11705 R visitCommentReference(CommentReference node) { | |
11706 node.visitChildren(this); | |
11707 return null; | |
11708 } | |
11709 R visitCompilationUnit(CompilationUnit node) { | |
11710 node.visitChildren(this); | |
11711 return null; | |
11712 } | |
11713 R visitConditionalExpression(ConditionalExpression node) { | |
11714 node.visitChildren(this); | |
11715 return null; | |
11716 } | |
11717 R visitConstructorDeclaration(ConstructorDeclaration node) { | |
11718 node.visitChildren(this); | |
11719 return null; | |
11720 } | |
11721 R visitConstructorFieldInitializer(ConstructorFieldInitializer node) { | |
11722 node.visitChildren(this); | |
11723 return null; | |
11724 } | |
11725 R visitConstructorName(ConstructorName node) { | |
11726 node.visitChildren(this); | |
11727 return null; | |
11728 } | |
11729 R visitContinueStatement(ContinueStatement node) { | |
11730 node.visitChildren(this); | |
11731 return null; | |
11732 } | |
11733 R visitDeclaredIdentifier(DeclaredIdentifier node) { | |
11734 node.visitChildren(this); | |
11735 return null; | |
11736 } | |
11737 R visitDefaultFormalParameter(DefaultFormalParameter node) { | |
11738 node.visitChildren(this); | |
11739 return null; | |
11740 } | |
11741 R visitDoStatement(DoStatement node) { | |
11742 node.visitChildren(this); | |
11743 return null; | |
11744 } | |
11745 R visitDoubleLiteral(DoubleLiteral node) { | |
11746 node.visitChildren(this); | |
11747 return null; | |
11748 } | |
11749 R visitEmptyFunctionBody(EmptyFunctionBody node) { | |
11750 node.visitChildren(this); | |
11751 return null; | |
11752 } | |
11753 R visitEmptyStatement(EmptyStatement node) { | |
11754 node.visitChildren(this); | |
11755 return null; | |
11756 } | |
11757 R visitExportDirective(ExportDirective node) { | |
11758 node.visitChildren(this); | |
11759 return null; | |
11760 } | |
11761 R visitExpressionFunctionBody(ExpressionFunctionBody node) { | |
11762 node.visitChildren(this); | |
11763 return null; | |
11764 } | |
11765 R visitExpressionStatement(ExpressionStatement node) { | |
11766 node.visitChildren(this); | |
11767 return null; | |
11768 } | |
11769 R visitExtendsClause(ExtendsClause node) { | |
11770 node.visitChildren(this); | |
11771 return null; | |
11772 } | |
11773 R visitFieldDeclaration(FieldDeclaration node) { | |
11774 node.visitChildren(this); | |
11775 return null; | |
11776 } | |
11777 R visitFieldFormalParameter(FieldFormalParameter node) { | |
11778 node.visitChildren(this); | |
11779 return null; | |
11780 } | |
11781 R visitForEachStatement(ForEachStatement node) { | |
11782 node.visitChildren(this); | |
11783 return null; | |
11784 } | |
11785 R visitFormalParameterList(FormalParameterList node) { | |
11786 node.visitChildren(this); | |
11787 return null; | |
11788 } | |
11789 R visitForStatement(ForStatement node) { | |
11790 node.visitChildren(this); | |
11791 return null; | |
11792 } | |
11793 R visitFunctionDeclaration(FunctionDeclaration node) { | |
11794 node.visitChildren(this); | |
11795 return null; | |
11796 } | |
11797 R visitFunctionDeclarationStatement(FunctionDeclarationStatement node) { | |
11798 node.visitChildren(this); | |
11799 return null; | |
11800 } | |
11801 R visitFunctionExpression(FunctionExpression node) { | |
11802 node.visitChildren(this); | |
11803 return null; | |
11804 } | |
11805 R visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { | |
11806 node.visitChildren(this); | |
11807 return null; | |
11808 } | |
11809 R visitFunctionTypeAlias(FunctionTypeAlias node) { | |
11810 node.visitChildren(this); | |
11811 return null; | |
11812 } | |
11813 R visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { | |
11814 node.visitChildren(this); | |
11815 return null; | |
11816 } | |
11817 R visitHideCombinator(HideCombinator node) { | |
11818 node.visitChildren(this); | |
11819 return null; | |
11820 } | |
11821 R visitIfStatement(IfStatement node) { | |
11822 node.visitChildren(this); | |
11823 return null; | |
11824 } | |
11825 R visitImplementsClause(ImplementsClause node) { | |
11826 node.visitChildren(this); | |
11827 return null; | |
11828 } | |
11829 R visitImportDirective(ImportDirective node) { | |
11830 node.visitChildren(this); | |
11831 return null; | |
11832 } | |
11833 R visitIndexExpression(IndexExpression node) { | |
11834 node.visitChildren(this); | |
11835 return null; | |
11836 } | |
11837 R visitInstanceCreationExpression(InstanceCreationExpression node) { | |
11838 node.visitChildren(this); | |
11839 return null; | |
11840 } | |
11841 R visitIntegerLiteral(IntegerLiteral node) { | |
11842 node.visitChildren(this); | |
11843 return null; | |
11844 } | |
11845 R visitInterpolationExpression(InterpolationExpression node) { | |
11846 node.visitChildren(this); | |
11847 return null; | |
11848 } | |
11849 R visitInterpolationString(InterpolationString node) { | |
11850 node.visitChildren(this); | |
11851 return null; | |
11852 } | |
11853 R visitIsExpression(IsExpression node) { | |
11854 node.visitChildren(this); | |
11855 return null; | |
11856 } | |
11857 R visitLabel(Label node) { | |
11858 node.visitChildren(this); | |
11859 return null; | |
11860 } | |
11861 R visitLabeledStatement(LabeledStatement node) { | |
11862 node.visitChildren(this); | |
11863 return null; | |
11864 } | |
11865 R visitLibraryDirective(LibraryDirective node) { | |
11866 node.visitChildren(this); | |
11867 return null; | |
11868 } | |
11869 R visitLibraryIdentifier(LibraryIdentifier node) { | |
11870 node.visitChildren(this); | |
11871 return null; | |
11872 } | |
11873 R visitListLiteral(ListLiteral node) { | |
11874 node.visitChildren(this); | |
11875 return null; | |
11876 } | |
11877 R visitMapLiteral(MapLiteral node) { | |
11878 node.visitChildren(this); | |
11879 return null; | |
11880 } | |
11881 R visitMapLiteralEntry(MapLiteralEntry node) { | |
11882 node.visitChildren(this); | |
11883 return null; | |
11884 } | |
11885 R visitMethodDeclaration(MethodDeclaration node) { | |
11886 node.visitChildren(this); | |
11887 return null; | |
11888 } | |
11889 R visitMethodInvocation(MethodInvocation node) { | |
11890 node.visitChildren(this); | |
11891 return null; | |
11892 } | |
11893 R visitNamedExpression(NamedExpression node) { | |
11894 node.visitChildren(this); | |
11895 return null; | |
11896 } | |
11897 R visitNullLiteral(NullLiteral node) { | |
11898 node.visitChildren(this); | |
11899 return null; | |
11900 } | |
11901 R visitParenthesizedExpression(ParenthesizedExpression node) { | |
11902 node.visitChildren(this); | |
11903 return null; | |
11904 } | |
11905 R visitPartDirective(PartDirective node) { | |
11906 node.visitChildren(this); | |
11907 return null; | |
11908 } | |
11909 R visitPartOfDirective(PartOfDirective node) { | |
11910 node.visitChildren(this); | |
11911 return null; | |
11912 } | |
11913 R visitPostfixExpression(PostfixExpression node) { | |
11914 node.visitChildren(this); | |
11915 return null; | |
11916 } | |
11917 R visitPrefixedIdentifier(PrefixedIdentifier node) { | |
11918 node.visitChildren(this); | |
11919 return null; | |
11920 } | |
11921 R visitPrefixExpression(PrefixExpression node) { | |
11922 node.visitChildren(this); | |
11923 return null; | |
11924 } | |
11925 R visitPropertyAccess(PropertyAccess node) { | |
11926 node.visitChildren(this); | |
11927 return null; | |
11928 } | |
11929 R visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node)
{ | |
11930 node.visitChildren(this); | |
11931 return null; | |
11932 } | |
11933 R visitReturnStatement(ReturnStatement node) { | |
11934 node.visitChildren(this); | |
11935 return null; | |
11936 } | |
11937 R visitScriptTag(ScriptTag node) { | |
11938 node.visitChildren(this); | |
11939 return null; | |
11940 } | |
11941 R visitShowCombinator(ShowCombinator node) { | |
11942 node.visitChildren(this); | |
11943 return null; | |
11944 } | |
11945 R visitSimpleFormalParameter(SimpleFormalParameter node) { | |
11946 node.visitChildren(this); | |
11947 return null; | |
11948 } | |
11949 R visitSimpleIdentifier(SimpleIdentifier node) { | |
11950 node.visitChildren(this); | |
11951 return null; | |
11952 } | |
11953 R visitSimpleStringLiteral(SimpleStringLiteral node) { | |
11954 node.visitChildren(this); | |
11955 return null; | |
11956 } | |
11957 R visitStringInterpolation(StringInterpolation node) { | |
11958 node.visitChildren(this); | |
11959 return null; | |
11960 } | |
11961 R visitSuperConstructorInvocation(SuperConstructorInvocation node) { | |
11962 node.visitChildren(this); | |
11963 return null; | |
11964 } | |
11965 R visitSuperExpression(SuperExpression node) { | |
11966 node.visitChildren(this); | |
11967 return null; | |
11968 } | |
11969 R visitSwitchCase(SwitchCase node) { | |
11970 node.visitChildren(this); | |
11971 return null; | |
11972 } | |
11973 R visitSwitchDefault(SwitchDefault node) { | |
11974 node.visitChildren(this); | |
11975 return null; | |
11976 } | |
11977 R visitSwitchStatement(SwitchStatement node) { | |
11978 node.visitChildren(this); | |
11979 return null; | |
11980 } | |
11981 R visitThisExpression(ThisExpression node) { | |
11982 node.visitChildren(this); | |
11983 return null; | |
11984 } | |
11985 R visitThrowExpression(ThrowExpression node) { | |
11986 node.visitChildren(this); | |
11987 return null; | |
11988 } | |
11989 R visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { | |
11990 node.visitChildren(this); | |
11991 return null; | |
11992 } | |
11993 R visitTryStatement(TryStatement node) { | |
11994 node.visitChildren(this); | |
11995 return null; | |
11996 } | |
11997 R visitTypeArgumentList(TypeArgumentList node) { | |
11998 node.visitChildren(this); | |
11999 return null; | |
12000 } | |
12001 R visitTypeName(TypeName node) { | |
12002 node.visitChildren(this); | |
12003 return null; | |
12004 } | |
12005 R visitTypeParameter(TypeParameter node) { | |
12006 node.visitChildren(this); | |
12007 return null; | |
12008 } | |
12009 R visitTypeParameterList(TypeParameterList node) { | |
12010 node.visitChildren(this); | |
12011 return null; | |
12012 } | |
12013 R visitVariableDeclaration(VariableDeclaration node) { | |
12014 node.visitChildren(this); | |
12015 return null; | |
12016 } | |
12017 R visitVariableDeclarationList(VariableDeclarationList node) { | |
12018 node.visitChildren(this); | |
12019 return null; | |
12020 } | |
12021 R visitVariableDeclarationStatement(VariableDeclarationStatement node) { | |
12022 node.visitChildren(this); | |
12023 return null; | |
12024 } | |
12025 R visitWhileStatement(WhileStatement node) { | |
12026 node.visitChildren(this); | |
12027 return null; | |
12028 } | |
12029 R visitWithClause(WithClause node) { | |
12030 node.visitChildren(this); | |
12031 return null; | |
12032 } | |
12033 } | |
12034 /** | |
12035 * Instances of the class {@code SimpleASTVisitor} implement an AST visitor that
will do nothing | |
12036 * when visiting an AST node. It is intended to be a superclass for classes that
use the visitor | |
12037 * pattern primarily as a dispatch mechanism (and hence don't need to recursivel
y visit a whole | |
12038 * structure) and that only need to visit a small number of node types. | |
12039 * @coverage dart.engine.ast | |
12040 */ | |
12041 class SimpleASTVisitor<R> implements ASTVisitor<R> { | |
12042 R visitAdjacentStrings(AdjacentStrings node) => null; | |
12043 R visitAnnotation(Annotation node) => null; | |
12044 R visitArgumentDefinitionTest(ArgumentDefinitionTest node) => null; | |
12045 R visitArgumentList(ArgumentList node) => null; | |
12046 R visitAsExpression(AsExpression node) => null; | |
12047 R visitAssertStatement(AssertStatement node) => null; | |
12048 R visitAssignmentExpression(AssignmentExpression node) => null; | |
12049 R visitBinaryExpression(BinaryExpression node) => null; | |
12050 R visitBlock(Block node) => null; | |
12051 R visitBlockFunctionBody(BlockFunctionBody node) => null; | |
12052 R visitBooleanLiteral(BooleanLiteral node) => null; | |
12053 R visitBreakStatement(BreakStatement node) => null; | |
12054 R visitCascadeExpression(CascadeExpression node) => null; | |
12055 R visitCatchClause(CatchClause node) => null; | |
12056 R visitClassDeclaration(ClassDeclaration node) => null; | |
12057 R visitClassTypeAlias(ClassTypeAlias node) => null; | |
12058 R visitComment(Comment node) => null; | |
12059 R visitCommentReference(CommentReference node) => null; | |
12060 R visitCompilationUnit(CompilationUnit node) => null; | |
12061 R visitConditionalExpression(ConditionalExpression node) => null; | |
12062 R visitConstructorDeclaration(ConstructorDeclaration node) => null; | |
12063 R visitConstructorFieldInitializer(ConstructorFieldInitializer node) => null; | |
12064 R visitConstructorName(ConstructorName node) => null; | |
12065 R visitContinueStatement(ContinueStatement node) => null; | |
12066 R visitDeclaredIdentifier(DeclaredIdentifier node) => null; | |
12067 R visitDefaultFormalParameter(DefaultFormalParameter node) => null; | |
12068 R visitDoStatement(DoStatement node) => null; | |
12069 R visitDoubleLiteral(DoubleLiteral node) => null; | |
12070 R visitEmptyFunctionBody(EmptyFunctionBody node) => null; | |
12071 R visitEmptyStatement(EmptyStatement node) => null; | |
12072 R visitExportDirective(ExportDirective node) => null; | |
12073 R visitExpressionFunctionBody(ExpressionFunctionBody node) => null; | |
12074 R visitExpressionStatement(ExpressionStatement node) => null; | |
12075 R visitExtendsClause(ExtendsClause node) => null; | |
12076 R visitFieldDeclaration(FieldDeclaration node) => null; | |
12077 R visitFieldFormalParameter(FieldFormalParameter node) => null; | |
12078 R visitForEachStatement(ForEachStatement node) => null; | |
12079 R visitFormalParameterList(FormalParameterList node) => null; | |
12080 R visitForStatement(ForStatement node) => null; | |
12081 R visitFunctionDeclaration(FunctionDeclaration node) => null; | |
12082 R visitFunctionDeclarationStatement(FunctionDeclarationStatement node) => null
; | |
12083 R visitFunctionExpression(FunctionExpression node) => null; | |
12084 R visitFunctionExpressionInvocation(FunctionExpressionInvocation node) => null
; | |
12085 R visitFunctionTypeAlias(FunctionTypeAlias node) => null; | |
12086 R visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) => null
; | |
12087 R visitHideCombinator(HideCombinator node) => null; | |
12088 R visitIfStatement(IfStatement node) => null; | |
12089 R visitImplementsClause(ImplementsClause node) => null; | |
12090 R visitImportDirective(ImportDirective node) => null; | |
12091 R visitIndexExpression(IndexExpression node) => null; | |
12092 R visitInstanceCreationExpression(InstanceCreationExpression node) => null; | |
12093 R visitIntegerLiteral(IntegerLiteral node) => null; | |
12094 R visitInterpolationExpression(InterpolationExpression node) => null; | |
12095 R visitInterpolationString(InterpolationString node) => null; | |
12096 R visitIsExpression(IsExpression node) => null; | |
12097 R visitLabel(Label node) => null; | |
12098 R visitLabeledStatement(LabeledStatement node) => null; | |
12099 R visitLibraryDirective(LibraryDirective node) => null; | |
12100 R visitLibraryIdentifier(LibraryIdentifier node) => null; | |
12101 R visitListLiteral(ListLiteral node) => null; | |
12102 R visitMapLiteral(MapLiteral node) => null; | |
12103 R visitMapLiteralEntry(MapLiteralEntry node) => null; | |
12104 R visitMethodDeclaration(MethodDeclaration node) => null; | |
12105 R visitMethodInvocation(MethodInvocation node) => null; | |
12106 R visitNamedExpression(NamedExpression node) => null; | |
12107 R visitNullLiteral(NullLiteral node) => null; | |
12108 R visitParenthesizedExpression(ParenthesizedExpression node) => null; | |
12109 R visitPartDirective(PartDirective node) => null; | |
12110 R visitPartOfDirective(PartOfDirective node) => null; | |
12111 R visitPostfixExpression(PostfixExpression node) => null; | |
12112 R visitPrefixedIdentifier(PrefixedIdentifier node) => null; | |
12113 R visitPrefixExpression(PrefixExpression node) => null; | |
12114 R visitPropertyAccess(PropertyAccess node) => null; | |
12115 R visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node)
=> null; | |
12116 R visitReturnStatement(ReturnStatement node) => null; | |
12117 R visitScriptTag(ScriptTag node) => null; | |
12118 R visitShowCombinator(ShowCombinator node) => null; | |
12119 R visitSimpleFormalParameter(SimpleFormalParameter node) => null; | |
12120 R visitSimpleIdentifier(SimpleIdentifier node) => null; | |
12121 R visitSimpleStringLiteral(SimpleStringLiteral node) => null; | |
12122 R visitStringInterpolation(StringInterpolation node) => null; | |
12123 R visitSuperConstructorInvocation(SuperConstructorInvocation node) => null; | |
12124 R visitSuperExpression(SuperExpression node) => null; | |
12125 R visitSwitchCase(SwitchCase node) => null; | |
12126 R visitSwitchDefault(SwitchDefault node) => null; | |
12127 R visitSwitchStatement(SwitchStatement node) => null; | |
12128 R visitThisExpression(ThisExpression node) => null; | |
12129 R visitThrowExpression(ThrowExpression node) => null; | |
12130 R visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) => null; | |
12131 R visitTryStatement(TryStatement node) => null; | |
12132 R visitTypeArgumentList(TypeArgumentList node) => null; | |
12133 R visitTypeName(TypeName node) => null; | |
12134 R visitTypeParameter(TypeParameter node) => null; | |
12135 R visitTypeParameterList(TypeParameterList node) => null; | |
12136 R visitVariableDeclaration(VariableDeclaration node) => null; | |
12137 R visitVariableDeclarationList(VariableDeclarationList node) => null; | |
12138 R visitVariableDeclarationStatement(VariableDeclarationStatement node) => null
; | |
12139 R visitWhileStatement(WhileStatement node) => null; | |
12140 R visitWithClause(WithClause node) => null; | |
12141 } | |
12142 /** | |
12143 * Instances of the class {@code ToSourceVisitor} write a source representation
of a visited AST | |
12144 * node (and all of it's children) to a writer. | |
12145 * @coverage dart.engine.ast | |
12146 */ | |
12147 class ToSourceVisitor implements ASTVisitor<Object> { | |
12148 /** | |
12149 * The writer to which the source is to be written. | |
12150 */ | |
12151 PrintWriter _writer; | |
12152 /** | |
12153 * Initialize a newly created visitor to write source code representing the vi
sited nodes to the | |
12154 * given writer. | |
12155 * @param writer the writer to which the source is to be written | |
12156 */ | |
12157 ToSourceVisitor(PrintWriter writer) { | |
12158 this._writer = writer; | |
12159 } | |
12160 Object visitAdjacentStrings(AdjacentStrings node) { | |
12161 visitList2(node.strings, " "); | |
12162 return null; | |
12163 } | |
12164 Object visitAnnotation(Annotation node) { | |
12165 _writer.print('@'); | |
12166 visit(node.name); | |
12167 visit3(".", node.constructorName); | |
12168 visit(node.arguments); | |
12169 return null; | |
12170 } | |
12171 Object visitArgumentDefinitionTest(ArgumentDefinitionTest node) { | |
12172 _writer.print('?'); | |
12173 visit(node.identifier); | |
12174 return null; | |
12175 } | |
12176 Object visitArgumentList(ArgumentList node) { | |
12177 _writer.print('('); | |
12178 visitList2(node.arguments, ", "); | |
12179 _writer.print(')'); | |
12180 return null; | |
12181 } | |
12182 Object visitAsExpression(AsExpression node) { | |
12183 visit(node.expression); | |
12184 _writer.print(" as "); | |
12185 visit(node.type); | |
12186 return null; | |
12187 } | |
12188 Object visitAssertStatement(AssertStatement node) { | |
12189 _writer.print("assert ("); | |
12190 visit(node.condition); | |
12191 _writer.print(");"); | |
12192 return null; | |
12193 } | |
12194 Object visitAssignmentExpression(AssignmentExpression node) { | |
12195 visit(node.leftHandSide); | |
12196 _writer.print(' '); | |
12197 _writer.print(node.operator.lexeme); | |
12198 _writer.print(' '); | |
12199 visit(node.rightHandSide); | |
12200 return null; | |
12201 } | |
12202 Object visitBinaryExpression(BinaryExpression node) { | |
12203 visit(node.leftOperand); | |
12204 _writer.print(' '); | |
12205 _writer.print(node.operator.lexeme); | |
12206 _writer.print(' '); | |
12207 visit(node.rightOperand); | |
12208 return null; | |
12209 } | |
12210 Object visitBlock(Block node) { | |
12211 _writer.print('{'); | |
12212 visitList2(node.statements, " "); | |
12213 _writer.print('}'); | |
12214 return null; | |
12215 } | |
12216 Object visitBlockFunctionBody(BlockFunctionBody node) { | |
12217 visit(node.block); | |
12218 return null; | |
12219 } | |
12220 Object visitBooleanLiteral(BooleanLiteral node) { | |
12221 _writer.print(node.literal.lexeme); | |
12222 return null; | |
12223 } | |
12224 Object visitBreakStatement(BreakStatement node) { | |
12225 _writer.print("break"); | |
12226 visit3(" ", node.label); | |
12227 _writer.print(";"); | |
12228 return null; | |
12229 } | |
12230 Object visitCascadeExpression(CascadeExpression node) { | |
12231 visit(node.target); | |
12232 visitList(node.cascadeSections); | |
12233 return null; | |
12234 } | |
12235 Object visitCatchClause(CatchClause node) { | |
12236 visit3("on ", node.exceptionType); | |
12237 if (node.catchKeyword != null) { | |
12238 if (node.exceptionType != null) { | |
12239 _writer.print(' '); | |
12240 } | |
12241 _writer.print("catch ("); | |
12242 visit(node.exceptionParameter); | |
12243 visit3(", ", node.stackTraceParameter); | |
12244 _writer.print(") "); | |
12245 } else { | |
12246 _writer.print(" "); | |
12247 } | |
12248 visit(node.body); | |
12249 return null; | |
12250 } | |
12251 Object visitClassDeclaration(ClassDeclaration node) { | |
12252 visit5(node.abstractKeyword, " "); | |
12253 _writer.print("class "); | |
12254 visit(node.name); | |
12255 visit(node.typeParameters); | |
12256 visit3(" ", node.extendsClause); | |
12257 visit3(" ", node.withClause); | |
12258 visit3(" ", node.implementsClause); | |
12259 _writer.print(" {"); | |
12260 visitList2(node.members, " "); | |
12261 _writer.print("}"); | |
12262 return null; | |
12263 } | |
12264 Object visitClassTypeAlias(ClassTypeAlias node) { | |
12265 _writer.print("typedef "); | |
12266 visit(node.name); | |
12267 visit(node.typeParameters); | |
12268 _writer.print(" = "); | |
12269 if (node.abstractKeyword != null) { | |
12270 _writer.print("abstract "); | |
12271 } | |
12272 visit(node.superclass); | |
12273 visit3(" ", node.withClause); | |
12274 visit3(" ", node.implementsClause); | |
12275 _writer.print(";"); | |
12276 return null; | |
12277 } | |
12278 Object visitComment(Comment node) => null; | |
12279 Object visitCommentReference(CommentReference node) => null; | |
12280 Object visitCompilationUnit(CompilationUnit node) { | |
12281 ScriptTag scriptTag6 = node.scriptTag; | |
12282 NodeList<Directive> directives2 = node.directives; | |
12283 visit(scriptTag6); | |
12284 String prefix = scriptTag6 == null ? "" : " "; | |
12285 visitList4(prefix, directives2, " "); | |
12286 prefix = scriptTag6 == null && directives2.isEmpty ? "" : " "; | |
12287 visitList4(prefix, node.declarations, " "); | |
12288 return null; | |
12289 } | |
12290 Object visitConditionalExpression(ConditionalExpression node) { | |
12291 visit(node.condition); | |
12292 _writer.print(" ? "); | |
12293 visit(node.thenExpression); | |
12294 _writer.print(" : "); | |
12295 visit(node.elseExpression); | |
12296 return null; | |
12297 } | |
12298 Object visitConstructorDeclaration(ConstructorDeclaration node) { | |
12299 visit5(node.externalKeyword, " "); | |
12300 visit5(node.constKeyword, " "); | |
12301 visit5(node.factoryKeyword, " "); | |
12302 visit(node.returnType); | |
12303 visit3(".", node.name); | |
12304 visit(node.parameters); | |
12305 visitList4(" : ", node.initializers, ", "); | |
12306 visit3(" = ", node.redirectedConstructor); | |
12307 visit4(" ", node.body); | |
12308 return null; | |
12309 } | |
12310 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { | |
12311 visit5(node.keyword, "."); | |
12312 visit(node.fieldName); | |
12313 _writer.print(" = "); | |
12314 visit(node.expression); | |
12315 return null; | |
12316 } | |
12317 Object visitConstructorName(ConstructorName node) { | |
12318 visit(node.type); | |
12319 visit3(".", node.name); | |
12320 return null; | |
12321 } | |
12322 Object visitContinueStatement(ContinueStatement node) { | |
12323 _writer.print("continue"); | |
12324 visit3(" ", node.label); | |
12325 _writer.print(";"); | |
12326 return null; | |
12327 } | |
12328 Object visitDeclaredIdentifier(DeclaredIdentifier node) { | |
12329 visit5(node.keyword, " "); | |
12330 visit2(node.type, " "); | |
12331 visit(node.identifier); | |
12332 return null; | |
12333 } | |
12334 Object visitDefaultFormalParameter(DefaultFormalParameter node) { | |
12335 visit(node.parameter); | |
12336 if (node.separator != null) { | |
12337 _writer.print(" "); | |
12338 _writer.print(node.separator.lexeme); | |
12339 visit3(" ", node.defaultValue); | |
12340 } | |
12341 return null; | |
12342 } | |
12343 Object visitDoStatement(DoStatement node) { | |
12344 _writer.print("do "); | |
12345 visit(node.body); | |
12346 _writer.print(" while ("); | |
12347 visit(node.condition); | |
12348 _writer.print(");"); | |
12349 return null; | |
12350 } | |
12351 Object visitDoubleLiteral(DoubleLiteral node) { | |
12352 _writer.print(node.literal.lexeme); | |
12353 return null; | |
12354 } | |
12355 Object visitEmptyFunctionBody(EmptyFunctionBody node) { | |
12356 _writer.print(';'); | |
12357 return null; | |
12358 } | |
12359 Object visitEmptyStatement(EmptyStatement node) { | |
12360 _writer.print(';'); | |
12361 return null; | |
12362 } | |
12363 Object visitExportDirective(ExportDirective node) { | |
12364 _writer.print("export "); | |
12365 visit(node.uri); | |
12366 visitList4(" ", node.combinators, " "); | |
12367 _writer.print(';'); | |
12368 return null; | |
12369 } | |
12370 Object visitExpressionFunctionBody(ExpressionFunctionBody node) { | |
12371 _writer.print("=> "); | |
12372 visit(node.expression); | |
12373 if (node.semicolon != null) { | |
12374 _writer.print(';'); | |
12375 } | |
12376 return null; | |
12377 } | |
12378 Object visitExpressionStatement(ExpressionStatement node) { | |
12379 visit(node.expression); | |
12380 _writer.print(';'); | |
12381 return null; | |
12382 } | |
12383 Object visitExtendsClause(ExtendsClause node) { | |
12384 _writer.print("extends "); | |
12385 visit(node.superclass); | |
12386 return null; | |
12387 } | |
12388 Object visitFieldDeclaration(FieldDeclaration node) { | |
12389 visit5(node.keyword, " "); | |
12390 visit(node.fields); | |
12391 _writer.print(";"); | |
12392 return null; | |
12393 } | |
12394 Object visitFieldFormalParameter(FieldFormalParameter node) { | |
12395 visit5(node.keyword, " "); | |
12396 visit2(node.type, " "); | |
12397 _writer.print("this."); | |
12398 visit(node.identifier); | |
12399 return null; | |
12400 } | |
12401 Object visitForEachStatement(ForEachStatement node) { | |
12402 _writer.print("for ("); | |
12403 visit(node.loopVariable); | |
12404 _writer.print(" in "); | |
12405 visit(node.iterator); | |
12406 _writer.print(") "); | |
12407 visit(node.body); | |
12408 return null; | |
12409 } | |
12410 Object visitFormalParameterList(FormalParameterList node) { | |
12411 String groupEnd = null; | |
12412 _writer.print('('); | |
12413 NodeList<FormalParameter> parameters9 = node.parameters; | |
12414 int size2 = parameters9.length; | |
12415 for (int i = 0; i < size2; i++) { | |
12416 FormalParameter parameter = parameters9[i]; | |
12417 if (i > 0) { | |
12418 _writer.print(", "); | |
12419 } | |
12420 if (groupEnd == null && parameter is DefaultFormalParameter) { | |
12421 if (identical(parameter.kind, ParameterKind.NAMED)) { | |
12422 groupEnd = "}"; | |
12423 _writer.print('{'); | |
12424 } else { | |
12425 groupEnd = "]"; | |
12426 _writer.print('['); | |
12427 } | |
12428 } | |
12429 parameter.accept(this); | |
12430 } | |
12431 if (groupEnd != null) { | |
12432 _writer.print(groupEnd); | |
12433 } | |
12434 _writer.print(')'); | |
12435 return null; | |
12436 } | |
12437 Object visitForStatement(ForStatement node) { | |
12438 Expression initialization3 = node.initialization; | |
12439 _writer.print("for ("); | |
12440 if (initialization3 != null) { | |
12441 visit(initialization3); | |
12442 } else { | |
12443 visit(node.variables); | |
12444 } | |
12445 _writer.print(";"); | |
12446 visit3(" ", node.condition); | |
12447 _writer.print(";"); | |
12448 visitList4(" ", node.updaters, ", "); | |
12449 _writer.print(") "); | |
12450 visit(node.body); | |
12451 return null; | |
12452 } | |
12453 Object visitFunctionDeclaration(FunctionDeclaration node) { | |
12454 visit2(node.returnType, " "); | |
12455 visit5(node.propertyKeyword, " "); | |
12456 visit(node.name); | |
12457 visit(node.functionExpression); | |
12458 return null; | |
12459 } | |
12460 Object visitFunctionDeclarationStatement(FunctionDeclarationStatement node) { | |
12461 visit(node.functionDeclaration); | |
12462 _writer.print(';'); | |
12463 return null; | |
12464 } | |
12465 Object visitFunctionExpression(FunctionExpression node) { | |
12466 visit(node.parameters); | |
12467 _writer.print(' '); | |
12468 visit(node.body); | |
12469 return null; | |
12470 } | |
12471 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { | |
12472 visit(node.function); | |
12473 visit(node.argumentList); | |
12474 return null; | |
12475 } | |
12476 Object visitFunctionTypeAlias(FunctionTypeAlias node) { | |
12477 _writer.print("typedef "); | |
12478 visit2(node.returnType, " "); | |
12479 visit(node.name); | |
12480 visit(node.typeParameters); | |
12481 visit(node.parameters); | |
12482 _writer.print(";"); | |
12483 return null; | |
12484 } | |
12485 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { | |
12486 visit2(node.returnType, " "); | |
12487 visit(node.identifier); | |
12488 visit(node.parameters); | |
12489 return null; | |
12490 } | |
12491 Object visitHideCombinator(HideCombinator node) { | |
12492 _writer.print("hide "); | |
12493 visitList2(node.hiddenNames, ", "); | |
12494 return null; | |
12495 } | |
12496 Object visitIfStatement(IfStatement node) { | |
12497 _writer.print("if ("); | |
12498 visit(node.condition); | |
12499 _writer.print(") "); | |
12500 visit(node.thenStatement); | |
12501 visit3(" else ", node.elseStatement); | |
12502 return null; | |
12503 } | |
12504 Object visitImplementsClause(ImplementsClause node) { | |
12505 _writer.print("implements "); | |
12506 visitList2(node.interfaces, ", "); | |
12507 return null; | |
12508 } | |
12509 Object visitImportDirective(ImportDirective node) { | |
12510 _writer.print("import "); | |
12511 visit(node.uri); | |
12512 visit3(" as ", node.prefix); | |
12513 visitList4(" ", node.combinators, " "); | |
12514 _writer.print(';'); | |
12515 return null; | |
12516 } | |
12517 Object visitIndexExpression(IndexExpression node) { | |
12518 if (node.isCascaded()) { | |
12519 _writer.print(".."); | |
12520 } else { | |
12521 visit(node.array); | |
12522 } | |
12523 _writer.print('['); | |
12524 visit(node.index); | |
12525 _writer.print(']'); | |
12526 return null; | |
12527 } | |
12528 Object visitInstanceCreationExpression(InstanceCreationExpression node) { | |
12529 visit5(node.keyword, " "); | |
12530 visit(node.constructorName); | |
12531 visit(node.argumentList); | |
12532 return null; | |
12533 } | |
12534 Object visitIntegerLiteral(IntegerLiteral node) { | |
12535 _writer.print(node.literal.lexeme); | |
12536 return null; | |
12537 } | |
12538 Object visitInterpolationExpression(InterpolationExpression node) { | |
12539 if (node.rightBracket != null) { | |
12540 _writer.print("\${"); | |
12541 visit(node.expression); | |
12542 _writer.print("}"); | |
12543 } else { | |
12544 _writer.print("\$"); | |
12545 visit(node.expression); | |
12546 } | |
12547 return null; | |
12548 } | |
12549 Object visitInterpolationString(InterpolationString node) { | |
12550 _writer.print(node.contents.lexeme); | |
12551 return null; | |
12552 } | |
12553 Object visitIsExpression(IsExpression node) { | |
12554 visit(node.expression); | |
12555 if (node.notOperator == null) { | |
12556 _writer.print(" is "); | |
12557 } else { | |
12558 _writer.print(" is! "); | |
12559 } | |
12560 visit(node.type); | |
12561 return null; | |
12562 } | |
12563 Object visitLabel(Label node) { | |
12564 visit(node.label); | |
12565 _writer.print(":"); | |
12566 return null; | |
12567 } | |
12568 Object visitLabeledStatement(LabeledStatement node) { | |
12569 visitList3(node.labels, " ", " "); | |
12570 visit(node.statement); | |
12571 return null; | |
12572 } | |
12573 Object visitLibraryDirective(LibraryDirective node) { | |
12574 _writer.print("library "); | |
12575 visit(node.name); | |
12576 _writer.print(';'); | |
12577 return null; | |
12578 } | |
12579 Object visitLibraryIdentifier(LibraryIdentifier node) { | |
12580 _writer.print(node.name); | |
12581 return null; | |
12582 } | |
12583 Object visitListLiteral(ListLiteral node) { | |
12584 if (node.modifier != null) { | |
12585 _writer.print(node.modifier.lexeme); | |
12586 _writer.print(' '); | |
12587 } | |
12588 visit2(node.typeArguments, " "); | |
12589 _writer.print("["); | |
12590 visitList2(node.elements, ", "); | |
12591 _writer.print("]"); | |
12592 return null; | |
12593 } | |
12594 Object visitMapLiteral(MapLiteral node) { | |
12595 if (node.modifier != null) { | |
12596 _writer.print(node.modifier.lexeme); | |
12597 _writer.print(' '); | |
12598 } | |
12599 visit2(node.typeArguments, " "); | |
12600 _writer.print("{"); | |
12601 visitList2(node.entries, ", "); | |
12602 _writer.print("}"); | |
12603 return null; | |
12604 } | |
12605 Object visitMapLiteralEntry(MapLiteralEntry node) { | |
12606 visit(node.key); | |
12607 _writer.print(" : "); | |
12608 visit(node.value); | |
12609 return null; | |
12610 } | |
12611 Object visitMethodDeclaration(MethodDeclaration node) { | |
12612 visit5(node.externalKeyword, " "); | |
12613 visit5(node.modifierKeyword, " "); | |
12614 visit2(node.returnType, " "); | |
12615 visit5(node.propertyKeyword, " "); | |
12616 visit5(node.operatorKeyword, " "); | |
12617 visit(node.name); | |
12618 if (!node.isGetter()) { | |
12619 visit(node.parameters); | |
12620 } | |
12621 visit4(" ", node.body); | |
12622 return null; | |
12623 } | |
12624 Object visitMethodInvocation(MethodInvocation node) { | |
12625 if (node.isCascaded()) { | |
12626 _writer.print(".."); | |
12627 } else { | |
12628 visit2(node.target, "."); | |
12629 } | |
12630 visit(node.methodName); | |
12631 visit(node.argumentList); | |
12632 return null; | |
12633 } | |
12634 Object visitNamedExpression(NamedExpression node) { | |
12635 visit(node.name); | |
12636 visit3(" ", node.expression); | |
12637 return null; | |
12638 } | |
12639 Object visitNullLiteral(NullLiteral node) { | |
12640 _writer.print("null"); | |
12641 return null; | |
12642 } | |
12643 Object visitParenthesizedExpression(ParenthesizedExpression node) { | |
12644 _writer.print('('); | |
12645 visit(node.expression); | |
12646 _writer.print(')'); | |
12647 return null; | |
12648 } | |
12649 Object visitPartDirective(PartDirective node) { | |
12650 _writer.print("part "); | |
12651 visit(node.uri); | |
12652 _writer.print(';'); | |
12653 return null; | |
12654 } | |
12655 Object visitPartOfDirective(PartOfDirective node) { | |
12656 _writer.print("part of "); | |
12657 visit(node.libraryName); | |
12658 _writer.print(';'); | |
12659 return null; | |
12660 } | |
12661 Object visitPostfixExpression(PostfixExpression node) { | |
12662 visit(node.operand); | |
12663 _writer.print(node.operator.lexeme); | |
12664 return null; | |
12665 } | |
12666 Object visitPrefixedIdentifier(PrefixedIdentifier node) { | |
12667 visit(node.prefix); | |
12668 _writer.print('.'); | |
12669 visit(node.identifier); | |
12670 return null; | |
12671 } | |
12672 Object visitPrefixExpression(PrefixExpression node) { | |
12673 _writer.print(node.operator.lexeme); | |
12674 visit(node.operand); | |
12675 return null; | |
12676 } | |
12677 Object visitPropertyAccess(PropertyAccess node) { | |
12678 if (node.isCascaded()) { | |
12679 _writer.print(".."); | |
12680 } else { | |
12681 visit(node.target); | |
12682 _writer.print('.'); | |
12683 } | |
12684 visit(node.propertyName); | |
12685 return null; | |
12686 } | |
12687 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation
node) { | |
12688 _writer.print("this"); | |
12689 visit3(".", node.constructorName); | |
12690 visit(node.argumentList); | |
12691 return null; | |
12692 } | |
12693 Object visitReturnStatement(ReturnStatement node) { | |
12694 Expression expression14 = node.expression; | |
12695 if (expression14 == null) { | |
12696 _writer.print("return;"); | |
12697 } else { | |
12698 _writer.print("return "); | |
12699 expression14.accept(this); | |
12700 _writer.print(";"); | |
12701 } | |
12702 return null; | |
12703 } | |
12704 Object visitScriptTag(ScriptTag node) { | |
12705 _writer.print(node.scriptTag.lexeme); | |
12706 return null; | |
12707 } | |
12708 Object visitShowCombinator(ShowCombinator node) { | |
12709 _writer.print("show "); | |
12710 visitList2(node.shownNames, ", "); | |
12711 return null; | |
12712 } | |
12713 Object visitSimpleFormalParameter(SimpleFormalParameter node) { | |
12714 visit5(node.keyword, " "); | |
12715 visit2(node.type, " "); | |
12716 visit(node.identifier); | |
12717 return null; | |
12718 } | |
12719 Object visitSimpleIdentifier(SimpleIdentifier node) { | |
12720 _writer.print(node.token.lexeme); | |
12721 return null; | |
12722 } | |
12723 Object visitSimpleStringLiteral(SimpleStringLiteral node) { | |
12724 _writer.print(node.literal.lexeme); | |
12725 return null; | |
12726 } | |
12727 Object visitStringInterpolation(StringInterpolation node) { | |
12728 visitList(node.elements); | |
12729 return null; | |
12730 } | |
12731 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { | |
12732 _writer.print("super"); | |
12733 visit3(".", node.constructorName); | |
12734 visit(node.argumentList); | |
12735 return null; | |
12736 } | |
12737 Object visitSuperExpression(SuperExpression node) { | |
12738 _writer.print("super"); | |
12739 return null; | |
12740 } | |
12741 Object visitSwitchCase(SwitchCase node) { | |
12742 visitList3(node.labels, " ", " "); | |
12743 _writer.print("case "); | |
12744 visit(node.expression); | |
12745 _writer.print(": "); | |
12746 visitList2(node.statements, " "); | |
12747 return null; | |
12748 } | |
12749 Object visitSwitchDefault(SwitchDefault node) { | |
12750 visitList3(node.labels, " ", " "); | |
12751 _writer.print("default: "); | |
12752 visitList2(node.statements, " "); | |
12753 return null; | |
12754 } | |
12755 Object visitSwitchStatement(SwitchStatement node) { | |
12756 _writer.print("switch ("); | |
12757 visit(node.expression); | |
12758 _writer.print(") {"); | |
12759 visitList2(node.members, " "); | |
12760 _writer.print("}"); | |
12761 return null; | |
12762 } | |
12763 Object visitThisExpression(ThisExpression node) { | |
12764 _writer.print("this"); | |
12765 return null; | |
12766 } | |
12767 Object visitThrowExpression(ThrowExpression node) { | |
12768 _writer.print("throw "); | |
12769 visit(node.expression); | |
12770 return null; | |
12771 } | |
12772 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { | |
12773 visit2(node.variables, ";"); | |
12774 return null; | |
12775 } | |
12776 Object visitTryStatement(TryStatement node) { | |
12777 _writer.print("try "); | |
12778 visit(node.body); | |
12779 visitList4(" ", node.catchClauses, " "); | |
12780 visit3(" finally ", node.finallyClause); | |
12781 return null; | |
12782 } | |
12783 Object visitTypeArgumentList(TypeArgumentList node) { | |
12784 _writer.print('<'); | |
12785 visitList2(node.arguments, ", "); | |
12786 _writer.print('>'); | |
12787 return null; | |
12788 } | |
12789 Object visitTypeName(TypeName node) { | |
12790 visit(node.name); | |
12791 visit(node.typeArguments); | |
12792 return null; | |
12793 } | |
12794 Object visitTypeParameter(TypeParameter node) { | |
12795 visit(node.name); | |
12796 visit3(" extends ", node.bound); | |
12797 return null; | |
12798 } | |
12799 Object visitTypeParameterList(TypeParameterList node) { | |
12800 _writer.print('<'); | |
12801 visitList2(node.typeParameters, ", "); | |
12802 _writer.print('>'); | |
12803 return null; | |
12804 } | |
12805 Object visitVariableDeclaration(VariableDeclaration node) { | |
12806 visit(node.name); | |
12807 visit3(" = ", node.initializer); | |
12808 return null; | |
12809 } | |
12810 Object visitVariableDeclarationList(VariableDeclarationList node) { | |
12811 visit5(node.keyword, " "); | |
12812 visit2(node.type, " "); | |
12813 visitList2(node.variables, ", "); | |
12814 return null; | |
12815 } | |
12816 Object visitVariableDeclarationStatement(VariableDeclarationStatement node) { | |
12817 visit(node.variables); | |
12818 _writer.print(";"); | |
12819 return null; | |
12820 } | |
12821 Object visitWhileStatement(WhileStatement node) { | |
12822 _writer.print("while ("); | |
12823 visit(node.condition); | |
12824 _writer.print(") "); | |
12825 visit(node.body); | |
12826 return null; | |
12827 } | |
12828 Object visitWithClause(WithClause node) { | |
12829 _writer.print("with "); | |
12830 visitList2(node.mixinTypes, ", "); | |
12831 return null; | |
12832 } | |
12833 /** | |
12834 * Safely visit the given node. | |
12835 * @param node the node to be visited | |
12836 */ | |
12837 void visit(ASTNode node) { | |
12838 if (node != null) { | |
12839 node.accept(this); | |
12840 } | |
12841 } | |
12842 /** | |
12843 * Safely visit the given node, printing the suffix after the node if it is no
n-{@code null}. | |
12844 * @param suffix the suffix to be printed if there is a node to visit | |
12845 * @param node the node to be visited | |
12846 */ | |
12847 void visit2(ASTNode node, String suffix) { | |
12848 if (node != null) { | |
12849 node.accept(this); | |
12850 _writer.print(suffix); | |
12851 } | |
12852 } | |
12853 /** | |
12854 * Safely visit the given node, printing the prefix before the node if it is n
on-{@code null}. | |
12855 * @param prefix the prefix to be printed if there is a node to visit | |
12856 * @param node the node to be visited | |
12857 */ | |
12858 void visit3(String prefix, ASTNode node) { | |
12859 if (node != null) { | |
12860 _writer.print(prefix); | |
12861 node.accept(this); | |
12862 } | |
12863 } | |
12864 /** | |
12865 * Visit the given function body, printing the prefix before if given body is
not empty. | |
12866 * @param prefix the prefix to be printed if there is a node to visit | |
12867 * @param body the function body to be visited | |
12868 */ | |
12869 void visit4(String prefix, FunctionBody body) { | |
12870 if (body is! EmptyFunctionBody) { | |
12871 _writer.print(prefix); | |
12872 } | |
12873 visit(body); | |
12874 } | |
12875 /** | |
12876 * Safely visit the given node, printing the suffix after the node if it is no
n-{@code null}. | |
12877 * @param suffix the suffix to be printed if there is a node to visit | |
12878 * @param node the node to be visited | |
12879 */ | |
12880 void visit5(Token token, String suffix) { | |
12881 if (token != null) { | |
12882 _writer.print(token.lexeme); | |
12883 _writer.print(suffix); | |
12884 } | |
12885 } | |
12886 /** | |
12887 * Print a list of nodes without any separation. | |
12888 * @param nodes the nodes to be printed | |
12889 * @param separator the separator to be printed between adjacent nodes | |
12890 */ | |
12891 void visitList(NodeList<ASTNode> nodes) { | |
12892 visitList2(nodes, ""); | |
12893 } | |
12894 /** | |
12895 * Print a list of nodes, separated by the given separator. | |
12896 * @param nodes the nodes to be printed | |
12897 * @param separator the separator to be printed between adjacent nodes | |
12898 */ | |
12899 void visitList2(NodeList<ASTNode> nodes, String separator) { | |
12900 if (nodes != null) { | |
12901 int size3 = nodes.length; | |
12902 for (int i = 0; i < size3; i++) { | |
12903 if (i > 0) { | |
12904 _writer.print(separator); | |
12905 } | |
12906 nodes[i].accept(this); | |
12907 } | |
12908 } | |
12909 } | |
12910 /** | |
12911 * Print a list of nodes, separated by the given separator. | |
12912 * @param nodes the nodes to be printed | |
12913 * @param separator the separator to be printed between adjacent nodes | |
12914 * @param suffix the suffix to be printed if the list is not empty | |
12915 */ | |
12916 void visitList3(NodeList<ASTNode> nodes, String separator, String suffix) { | |
12917 if (nodes != null) { | |
12918 int size4 = nodes.length; | |
12919 if (size4 > 0) { | |
12920 for (int i = 0; i < size4; i++) { | |
12921 if (i > 0) { | |
12922 _writer.print(separator); | |
12923 } | |
12924 nodes[i].accept(this); | |
12925 } | |
12926 _writer.print(suffix); | |
12927 } | |
12928 } | |
12929 } | |
12930 /** | |
12931 * Print a list of nodes, separated by the given separator. | |
12932 * @param prefix the prefix to be printed if the list is not empty | |
12933 * @param nodes the nodes to be printed | |
12934 * @param separator the separator to be printed between adjacent nodes | |
12935 */ | |
12936 void visitList4(String prefix, NodeList<ASTNode> nodes, String separator) { | |
12937 if (nodes != null) { | |
12938 int size5 = nodes.length; | |
12939 if (size5 > 0) { | |
12940 _writer.print(prefix); | |
12941 for (int i = 0; i < size5; i++) { | |
12942 if (i > 0) { | |
12943 _writer.print(separator); | |
12944 } | |
12945 nodes[i].accept(this); | |
12946 } | |
12947 } | |
12948 } | |
12949 } | |
12950 } | |
12951 /** | |
12952 * Instances of the class {@code NodeList} represent a list of AST nodes that ha
ve a common parent. | |
12953 */ | |
12954 class NodeList<E extends ASTNode> extends ListWrapper<E> { | |
12955 /** | |
12956 * The node that is the parent of each of the elements in the list. | |
12957 */ | |
12958 ASTNode owner; | |
12959 /** | |
12960 * The elements of the list. | |
12961 */ | |
12962 List<E> elements = new List<E>(); | |
12963 /** | |
12964 * Initialize a newly created list of nodes to be empty. | |
12965 * @param owner the node that is the parent of each of the elements in the lis
t | |
12966 */ | |
12967 NodeList(ASTNode this.owner); | |
12968 /** | |
12969 * Use the given visitor to visit each of the nodes in this list. | |
12970 * @param visitor the visitor to be used to visit the elements of this list | |
12971 */ | |
12972 accept(ASTVisitor visitor) { | |
12973 for (E element in elements) { | |
12974 element.accept(visitor); | |
12975 } | |
12976 } | |
12977 void add(E node) { | |
12978 owner.becomeParentOf(node); | |
12979 elements.add(node); | |
12980 } | |
12981 bool addAll(Collection<E> nodes) { | |
12982 if (nodes != null) { | |
12983 for (E node in nodes) { | |
12984 add(node); | |
12985 } | |
12986 return true; | |
12987 } | |
12988 return false; | |
12989 } | |
12990 /** | |
12991 * Return the first token included in this node's source range. | |
12992 * @return the first token included in this node's source range | |
12993 */ | |
12994 Token get beginToken { | |
12995 if (elements.isEmpty) { | |
12996 return null; | |
12997 } | |
12998 return elements[0].beginToken; | |
12999 } | |
13000 /** | |
13001 * Return the last token included in this node list's source range. | |
13002 * @return the last token included in this node list's source range | |
13003 */ | |
13004 Token get endToken { | |
13005 if (elements.isEmpty) { | |
13006 return null; | |
13007 } | |
13008 return elements[elements.length - 1].endToken; | |
13009 } | |
13010 /** | |
13011 * Return the node that is the parent of each of the elements in the list. | |
13012 * @return the node that is the parent of each of the elements in the list | |
13013 */ | |
13014 ASTNode getOwner() { | |
13015 return owner; | |
13016 } | |
13017 } | |
OLD | NEW |