Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Side by Side Diff: pkg/analyzer-experimental/lib/src/generated/ast.dart

Issue 12197019: Drop of generated scanner and example scanner driver. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 'scanner.dart';
11 import 'package:analyzer-experimental/src/generated/utilities_dart.dart';
12 import 'element.dart' hide Annotation;
13
14 /**
15 * The abstract class {@code ASTNode} defines the behavior common to all nodes i n the AST structure
16 * for a Dart program.
17 */
18 abstract class ASTNode {
19 /**
20 * The parent of the node, or {@code null} if the node is the root of an AST s tructure.
21 */
22 ASTNode _parent;
23 /**
24 * 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
25 * offset of the second node, zero (0) if the nodes have the same offset, and a positive value if
26 * if the offset of the first node is greater than the offset of the second no de.
27 */
28 static Comparator<ASTNode> LEXICAL_ORDER = (ASTNode first, ASTNode second) => second.offset - first.offset;
29 /**
30 * Use the given visitor to visit this node.
31 * @param visitor the visitor that will visit this node
32 * @return the value returned by the visitor as a result of visiting this node
33 */
34 accept(ASTVisitor visitor);
35 /**
36 * Return the first token included in this node's source range.
37 * @return the first token included in this node's source range
38 */
39 Token get beginToken;
40 /**
41 * Return the offset of the character immediately following the last character of this node's
42 * source range. This is equivalent to {@code node.getOffset() + node.getLengt h()}. For a
43 * compilation unit this will be equal to the length of the unit's source. For synthetic nodes
44 * this will be equivalent to the node's offset (because the length is zero (0 ) by definition).
45 * @return the offset of the character just past the node's source range
46 */
47 int get end => offset + length;
48 /**
49 * Return the last token included in this node's source range.
50 * @return the last token included in this node's source range
51 */
52 Token get endToken;
53 /**
54 * Return the number of characters in the node's source range.
55 * @return the number of characters in the node's source range
56 */
57 int get length {
58 Token beginToken2 = beginToken;
59 Token endToken3 = endToken;
60 if (beginToken2 == null || endToken3 == null) {
61 return -1;
62 }
63 return endToken3.offset + endToken3.length - beginToken2.offset;
64 }
65 /**
66 * Return the offset from the beginning of the file to the first character in the node's source
67 * range.
68 * @return the offset from the beginning of the file to the first character in the node's source
69 * range
70 */
71 int get offset {
72 Token beginToken3 = beginToken;
73 if (beginToken3 == null) {
74 return -1;
75 }
76 return beginToken.offset;
77 }
78 /**
79 * Return this node's parent node, or {@code null} if this node is the root of an AST structure.
80 * <p>
81 * Note that the relationship between an AST node and its parent node may chan ge over the lifetime
82 * of a node.
83 * @return the parent of this node, or {@code null} if none
84 */
85 ASTNode get parent => _parent;
86 /**
87 * Return the node at the root of this node's AST structure. Note that this me thod's performance
88 * is linear with respect to the depth of the node in the AST structure (O(dep th)).
89 * @return the node at the root of this node's AST structure
90 */
91 ASTNode get root {
92 ASTNode root = this;
93 ASTNode parent3 = parent;
94 while (parent3 != null) {
95 root = parent3;
96 parent3 = root.parent;
97 }
98 return root;
99 }
100 /**
101 * Return {@code true} if this node is a synthetic node. A synthetic node is a node that was
102 * introduced by the parser in order to recover from an error in the code. Syn thetic nodes always
103 * have a length of zero ({@code 0}).
104 * @return {@code true} if this node is a synthetic node
105 */
106 bool isSynthetic() => false;
107 /**
108 * Return a textual description of this node in a form approximating valid sou rce. The returned
109 * string will not be valid source primarily in the case where the node itself is not well-formed.
110 * @return the source code equivalent of this node
111 */
112 String toSource() {
113 PrintStringWriter writer = new PrintStringWriter();
114 accept(new ToSourceVisitor(writer));
115 return writer.toString();
116 }
117 String toString() => toSource();
118 /**
119 * Use the given visitor to visit all of the children of this node. The childr en will be visited
120 * in source order.
121 * @param visitor the visitor that will be used to visit the children of this node
122 */
123 void visitChildren(ASTVisitor<Object> visitor);
124 /**
125 * Make this node the parent of the given child node.
126 * @param child the node that will become a child of this node
127 * @return the node that was made a child of this node
128 */
129 ASTNode becomeParentOf(ASTNode child) {
130 if (child != null) {
131 ASTNode node = child;
132 node.parent2 = this;
133 }
134 return child;
135 }
136 /**
137 * If the given child is not {@code null}, use the given visitor to visit it.
138 * @param child the child to be visited
139 * @param visitor the visitor that will be used to visit the child
140 */
141 void safelyVisitChild(ASTNode child, ASTVisitor<Object> visitor) {
142 if (child != null) {
143 child.accept(visitor);
144 }
145 }
146 /**
147 * Set the parent of this node to the given node.
148 * @param newParent the node that is to be made the parent of this node
149 */
150 void set parent2(ASTNode newParent) {
151 _parent = newParent;
152 }
153 }
154 /**
155 * The interface {@code ASTVisitor} defines the behavior of objects that can be used to visit an AST
156 * structure.
157 */
158 abstract class ASTVisitor<R> {
159 R visitAdjacentStrings(AdjacentStrings node);
160 R visitAnnotation(Annotation node);
161 R visitArgumentDefinitionTest(ArgumentDefinitionTest node);
162 R visitArgumentList(ArgumentList node);
163 R visitAsExpression(AsExpression node);
164 R visitAssertStatement(AssertStatement assertStatement);
165 R visitAssignmentExpression(AssignmentExpression node);
166 R visitBinaryExpression(BinaryExpression node);
167 R visitBlock(Block node);
168 R visitBlockFunctionBody(BlockFunctionBody node);
169 R visitBooleanLiteral(BooleanLiteral node);
170 R visitBreakStatement(BreakStatement node);
171 R visitCascadeExpression(CascadeExpression node);
172 R visitCatchClause(CatchClause node);
173 R visitClassDeclaration(ClassDeclaration node);
174 R visitClassTypeAlias(ClassTypeAlias node);
175 R visitComment(Comment node);
176 R visitCommentReference(CommentReference node);
177 R visitCompilationUnit(CompilationUnit node);
178 R visitConditionalExpression(ConditionalExpression node);
179 R visitConstructorDeclaration(ConstructorDeclaration node);
180 R visitConstructorFieldInitializer(ConstructorFieldInitializer node);
181 R visitConstructorName(ConstructorName node);
182 R visitContinueStatement(ContinueStatement node);
183 R visitDefaultFormalParameter(DefaultFormalParameter node);
184 R visitDoStatement(DoStatement node);
185 R visitDoubleLiteral(DoubleLiteral node);
186 R visitEmptyFunctionBody(EmptyFunctionBody node);
187 R visitEmptyStatement(EmptyStatement node);
188 R visitExportDirective(ExportDirective node);
189 R visitExpressionFunctionBody(ExpressionFunctionBody node);
190 R visitExpressionStatement(ExpressionStatement node);
191 R visitExtendsClause(ExtendsClause node);
192 R visitFieldDeclaration(FieldDeclaration node);
193 R visitFieldFormalParameter(FieldFormalParameter node);
194 R visitForEachStatement(ForEachStatement node);
195 R visitFormalParameterList(FormalParameterList node);
196 R visitForStatement(ForStatement node);
197 R visitFunctionDeclaration(FunctionDeclaration node);
198 R visitFunctionDeclarationStatement(FunctionDeclarationStatement node);
199 R visitFunctionExpression(FunctionExpression node);
200 R visitFunctionExpressionInvocation(FunctionExpressionInvocation node);
201 R visitFunctionTypeAlias(FunctionTypeAlias functionTypeAlias);
202 R visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node);
203 R visitHideCombinator(HideCombinator node);
204 R visitIfStatement(IfStatement node);
205 R visitImplementsClause(ImplementsClause node);
206 R visitImportDirective(ImportDirective node);
207 R visitIndexExpression(IndexExpression node);
208 R visitInstanceCreationExpression(InstanceCreationExpression node);
209 R visitIntegerLiteral(IntegerLiteral node);
210 R visitInterpolationExpression(InterpolationExpression node);
211 R visitInterpolationString(InterpolationString node);
212 R visitIsExpression(IsExpression node);
213 R visitLabel(Label node);
214 R visitLabeledStatement(LabeledStatement node);
215 R visitLibraryDirective(LibraryDirective node);
216 R visitLibraryIdentifier(LibraryIdentifier node);
217 R visitListLiteral(ListLiteral node);
218 R visitMapLiteral(MapLiteral node);
219 R visitMapLiteralEntry(MapLiteralEntry node);
220 R visitMethodDeclaration(MethodDeclaration node);
221 R visitMethodInvocation(MethodInvocation node);
222 R visitNamedExpression(NamedExpression node);
223 R visitNullLiteral(NullLiteral node);
224 R visitParenthesizedExpression(ParenthesizedExpression node);
225 R visitPartDirective(PartDirective node);
226 R visitPartOfDirective(PartOfDirective node);
227 R visitPostfixExpression(PostfixExpression node);
228 R visitPrefixedIdentifier(PrefixedIdentifier node);
229 R visitPrefixExpression(PrefixExpression node);
230 R visitPropertyAccess(PropertyAccess node);
231 R visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) ;
232 R visitReturnStatement(ReturnStatement node);
233 R visitScriptTag(ScriptTag node);
234 R visitShowCombinator(ShowCombinator node);
235 R visitSimpleFormalParameter(SimpleFormalParameter node);
236 R visitSimpleIdentifier(SimpleIdentifier node);
237 R visitSimpleStringLiteral(SimpleStringLiteral node);
238 R visitStringInterpolation(StringInterpolation node);
239 R visitSuperConstructorInvocation(SuperConstructorInvocation node);
240 R visitSuperExpression(SuperExpression node);
241 R visitSwitchCase(SwitchCase node);
242 R visitSwitchDefault(SwitchDefault node);
243 R visitSwitchStatement(SwitchStatement node);
244 R visitThisExpression(ThisExpression node);
245 R visitThrowExpression(ThrowExpression node);
246 R visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node);
247 R visitTryStatement(TryStatement node);
248 R visitTypeArgumentList(TypeArgumentList node);
249 R visitTypeName(TypeName node);
250 R visitTypeParameter(TypeParameter node);
251 R visitTypeParameterList(TypeParameterList node);
252 R visitVariableDeclaration(VariableDeclaration node);
253 R visitVariableDeclarationList(VariableDeclarationList node);
254 R visitVariableDeclarationStatement(VariableDeclarationStatement node);
255 R visitWhileStatement(WhileStatement node);
256 R visitWithClause(WithClause node);
257 }
258 /**
259 * Instances of the class {@code AdjacentStrings} represents two or more string literals that are
260 * implicitly concatenated because of being adjacent (separated only by whitespa ce).
261 * <p>
262 * While the grammar only allows adjacent strings when all of the strings are of the same kind
263 * (single line or multi-line), this class doesn't enforce that restriction.
264 * <pre>
265 * adjacentStrings ::={@link StringLiteral string} {@link StringLiteral string}+
266 * </pre>
267 */
268 class AdjacentStrings extends StringLiteral {
269 /**
270 * The strings that are implicitly concatenated.
271 */
272 NodeList<StringLiteral> _strings;
273 /**
274 * Initialize a newly created list of adjacent strings.
275 * @param strings the strings that are implicitly concatenated
276 */
277 AdjacentStrings(List<StringLiteral> strings) {
278 this._strings = new NodeList<StringLiteral>(this);
279 this._strings.addAll(strings);
280 }
281 accept(ASTVisitor visitor) => visitor.visitAdjacentStrings(this);
282 Token get beginToken => _strings.beginToken;
283 Token get endToken => _strings.endToken;
284 /**
285 * Return the strings that are implicitly concatenated.
286 * @return the strings that are implicitly concatenated
287 */
288 NodeList<StringLiteral> get strings => _strings;
289 void visitChildren(ASTVisitor<Object> visitor) {
290 _strings.accept(visitor);
291 }
292 }
293 /**
294 * The abstract class {@code AnnotatedNode} defines the behavior of nodes that c an be annotated with
295 * both a comment and metadata.
296 */
297 abstract class AnnotatedNode extends ASTNode {
298 /**
299 * The documentation comment associated with this node, or {@code null} if thi s node does not have
300 * a documentation comment associated with it.
301 */
302 Comment _comment;
303 /**
304 * The annotations associated with this node.
305 */
306 NodeList<Annotation> _metadata;
307 /**
308 * Initialize a newly created node.
309 * @param comment the documentation comment associated with this node
310 * @param metadata the annotations associated with this node
311 */
312 AnnotatedNode(Comment comment, List<Annotation> metadata) {
313 this._metadata = new NodeList<Annotation>(this);
314 this._comment = becomeParentOf(comment);
315 this._metadata.addAll(metadata);
316 }
317 Token get beginToken {
318 if (_comment == null) {
319 if (_metadata.isEmpty) {
320 return firstTokenAfterCommentAndMetadata;
321 } else {
322 return _metadata.beginToken;
323 }
324 } else if (_metadata.isEmpty) {
325 return _comment.beginToken;
326 }
327 Token commentToken = _comment.beginToken;
328 Token metadataToken = _metadata.beginToken;
329 if (commentToken.offset < metadataToken.offset) {
330 return commentToken;
331 }
332 return metadataToken;
333 }
334 /**
335 * Return the documentation comment associated with this node, or {@code null} if this node does
336 * not have a documentation comment associated with it.
337 * @return the documentation comment associated with this node
338 */
339 Comment get documentationComment => _comment;
340 /**
341 * Return the annotations associated with this node.
342 * @return the annotations associated with this node
343 */
344 NodeList<Annotation> get metadata => _metadata;
345 /**
346 * Set the documentation comment associated with this node to the given commen t
347 * @param comment the documentation comment to be associated with this node
348 */
349 void set documentationComment(Comment comment) {
350 this._comment = becomeParentOf(comment);
351 }
352 void visitChildren(ASTVisitor<Object> visitor) {
353 if (commentIsBeforeAnnotations()) {
354 safelyVisitChild(_comment, visitor);
355 _metadata.accept(visitor);
356 } else {
357 for (ASTNode child in sortedCommentAndAnnotations) {
358 child.accept(visitor);
359 }
360 }
361 }
362 /**
363 * Return the first token following the comment and metadata.
364 * @return the first token following the comment and metadata
365 */
366 Token get firstTokenAfterCommentAndMetadata;
367 /**
368 * Return {@code true} if the comment is lexically before any annotations.
369 * @return {@code true} if the comment is lexically before any annotations
370 */
371 bool commentIsBeforeAnnotations() {
372 if (_comment == null || _metadata.isEmpty) {
373 return true;
374 }
375 Annotation firstAnnotation = _metadata[0];
376 return _comment.offset < firstAnnotation.offset;
377 }
378 /**
379 * Return an array containing the comment and annotations associated with this node, sorted in
380 * lexical order.
381 * @return the comment and annotations associated with this node in the order in which they
382 * appeared in the original source
383 */
384 List<ASTNode> get sortedCommentAndAnnotations {
385 List<ASTNode> childList = new List<ASTNode>();
386 childList.add(_comment);
387 childList.addAll(_metadata);
388 List<ASTNode> children = new List.from(childList);
389 children.sort();
390 return children;
391 }
392 }
393 /**
394 * Instances of the class {@code Annotation} represent an annotation that can be associated with an
395 * AST node.
396 * <pre>
397 * metadata ::=
398 * annotation
399 * annotation ::=
400 * '@' {@link Identifier qualified} (‘.’ {@link SimpleIdentifier identifier} )? {@link ArgumentList arguments}?
401 * </pre>
402 */
403 class Annotation extends ASTNode {
404 /**
405 * The at sign that introduced the annotation.
406 */
407 Token _atSign;
408 /**
409 * The name of the class defining the constructor that is being invoked or the name of the field
410 * that is being referenced.
411 */
412 Identifier _name;
413 /**
414 * The period before the constructor name, or {@code null} if this annotation is not the
415 * invocation of a named constructor.
416 */
417 Token _period;
418 /**
419 * The name of the constructor being invoked, or {@code null} if this annotati on is not the
420 * invocation of a named constructor.
421 */
422 SimpleIdentifier _constructorName;
423 /**
424 * The arguments to the constructor being invoked, or {@code null} if this ann otation is not the
425 * invocation of a constructor.
426 */
427 ArgumentList _arguments;
428 /**
429 * Initialize a newly created annotation.
430 * @param atSign the at sign that introduced the annotation
431 * @param name the name of the class defining the constructor that is being in voked or the name of
432 * the field that is being referenced
433 * @param period the period before the constructor name, or {@code null} if th is annotation is not
434 * the invocation of a named constructor
435 * @param constructorName the name of the constructor being invoked, or {@code null} if this
436 * annotation is not the invocation of a named constructor
437 * @param arguments the arguments to the constructor being invoked, or {@code null} if this
438 * annotation is not the invocation of a constructor
439 */
440 Annotation(Token atSign, Identifier name, Token period, SimpleIdentifier const ructorName, ArgumentList arguments) {
441 this._atSign = atSign;
442 this._name = becomeParentOf(name);
443 this._period = period;
444 this._constructorName = becomeParentOf(constructorName);
445 this._arguments = becomeParentOf(arguments);
446 }
447 accept(ASTVisitor visitor) => visitor.visitAnnotation(this);
448 /**
449 * Return the arguments to the constructor being invoked, or {@code null} if t his annotation is
450 * not the invocation of a constructor.
451 * @return the arguments to the constructor being invoked
452 */
453 ArgumentList get arguments => _arguments;
454 /**
455 * Return the at sign that introduced the annotation.
456 * @return the at sign that introduced the annotation
457 */
458 Token get atSign => _atSign;
459 Token get beginToken => _atSign;
460 /**
461 * Return the name of the constructor being invoked, or {@code null} if this a nnotation is not the
462 * invocation of a named constructor.
463 * @return the name of the constructor being invoked
464 */
465 SimpleIdentifier get constructorName => _constructorName;
466 Token get endToken {
467 if (_arguments != null) {
468 return _arguments.endToken;
469 } else if (_constructorName != null) {
470 return _constructorName.endToken;
471 }
472 return _name.endToken;
473 }
474 /**
475 * Return the name of the class defining the constructor that is being invoked or the name of the
476 * field that is being referenced.
477 * @return the name of the constructor being invoked or the name of the field being referenced
478 */
479 Identifier get name => _name;
480 /**
481 * Return the period before the constructor name, or {@code null} if this anno tation is not the
482 * invocation of a named constructor.
483 * @return the period before the constructor name
484 */
485 Token get period => _period;
486 /**
487 * Set the arguments to the constructor being invoked to the given arguments.
488 * @param arguments the arguments to the constructor being invoked
489 */
490 void set arguments2(ArgumentList arguments) {
491 this._arguments = becomeParentOf(arguments);
492 }
493 /**
494 * Set the at sign that introduced the annotation to the given token.
495 * @param atSign the at sign that introduced the annotation
496 */
497 void set atSign2(Token atSign) {
498 this._atSign = atSign;
499 }
500 /**
501 * Set the name of the constructor being invoked to the given name.
502 * @param constructorName the name of the constructor being invoked
503 */
504 void set constructorName2(SimpleIdentifier constructorName) {
505 this._constructorName = becomeParentOf(constructorName);
506 }
507 /**
508 * Set the name of the class defining the constructor that is being invoked or the name of the
509 * field that is being referenced to the given name.
510 * @param name the name of the constructor being invoked or the name of the fi eld being referenced
511 */
512 void set name2(Identifier name) {
513 this._name = becomeParentOf(name);
514 }
515 /**
516 * Set the period before the constructor name to the given token.
517 * @param period the period before the constructor name
518 */
519 void set period2(Token period) {
520 this._period = period;
521 }
522 void visitChildren(ASTVisitor<Object> visitor) {
523 safelyVisitChild(_name, visitor);
524 safelyVisitChild(_constructorName, visitor);
525 safelyVisitChild(_arguments, visitor);
526 }
527 }
528 /**
529 * Instances of the class {@code ArgumentDefinitionTest} represent an argument d efinition test.
530 * <pre>
531 * argumentDefinitionTest ::=
532 * '?' {@link SimpleIdentifier identifier}</pre>
533 */
534 class ArgumentDefinitionTest extends Expression {
535 /**
536 * The token representing the question mark.
537 */
538 Token _question;
539 /**
540 * The identifier representing the argument being tested.
541 */
542 SimpleIdentifier _identifier;
543 /**
544 * Initialize a newly created argument definition test.
545 * @param question the token representing the question mark
546 * @param identifier the identifier representing the argument being tested
547 */
548 ArgumentDefinitionTest(Token question, SimpleIdentifier identifier) {
549 this._question = question;
550 this._identifier = becomeParentOf(identifier);
551 }
552 accept(ASTVisitor visitor) => visitor.visitArgumentDefinitionTest(this);
553 Token get beginToken => _question;
554 Token get endToken => _identifier.endToken;
555 /**
556 * Return the identifier representing the argument being tested.
557 * @return the identifier representing the argument being tested
558 */
559 SimpleIdentifier get identifier => _identifier;
560 /**
561 * Return the token representing the question mark.
562 * @return the token representing the question mark
563 */
564 Token get question => _question;
565 /**
566 * Set the identifier representing the argument being tested to the given iden tifier.
567 * @param identifier the identifier representing the argument being tested
568 */
569 void set identifier2(SimpleIdentifier identifier) {
570 this._identifier = becomeParentOf(identifier);
571 }
572 /**
573 * Set the token representing the question mark to the given token.
574 * @param question the token representing the question mark
575 */
576 void set question2(Token question) {
577 this._question = question;
578 }
579 void visitChildren(ASTVisitor<Object> visitor) {
580 safelyVisitChild(_identifier, visitor);
581 }
582 }
583 /**
584 * Instances of the class {@code ArgumentList} represent a list of arguments in the invocation of a
585 * executable element: a function, method, or constructor.
586 * <pre>
587 * argumentList ::=
588 * '(' arguments? ')'
589 * arguments ::={@link NamedExpression namedArgument} (',' {@link NamedExpressio n namedArgument})
590 * | {@link Expression expressionList} (',' {@link NamedExpression namedArgument })
591 * </pre>
592 */
593 class ArgumentList extends ASTNode {
594 /**
595 * The left parenthesis.
596 */
597 Token _leftParenthesis;
598 /**
599 * The expressions producing the values of the arguments.
600 */
601 NodeList<Expression> _arguments;
602 /**
603 * The right parenthesis.
604 */
605 Token _rightParenthesis;
606 /**
607 * Initialize a newly created list of arguments.
608 * @param leftParenthesis the left parenthesis
609 * @param arguments the expressions producing the values of the arguments
610 * @param rightParenthesis the right parenthesis
611 */
612 ArgumentList(Token leftParenthesis, List<Expression> arguments, Token rightPar enthesis) {
613 this._arguments = new NodeList<Expression>(this);
614 this._leftParenthesis = leftParenthesis;
615 this._arguments.addAll(arguments);
616 this._rightParenthesis = rightParenthesis;
617 }
618 accept(ASTVisitor visitor) => visitor.visitArgumentList(this);
619 /**
620 * Return the expressions producing the values of the arguments. Although the language requires
621 * that positional arguments appear before named arguments, this class allows them to be
622 * intermixed.
623 * @return the expressions producing the values of the arguments
624 */
625 NodeList<Expression> get arguments => _arguments;
626 Token get beginToken => _leftParenthesis;
627 Token get endToken => _rightParenthesis;
628 /**
629 * Return the left parenthesis.
630 * @return the left parenthesis
631 */
632 Token get leftParenthesis => _leftParenthesis;
633 /**
634 * Return the right parenthesis.
635 * @return the right parenthesis
636 */
637 Token get rightParenthesis => _rightParenthesis;
638 /**
639 * Set the left parenthesis to the given token.
640 * @param parenthesis the left parenthesis
641 */
642 void set leftParenthesis2(Token parenthesis) {
643 _leftParenthesis = parenthesis;
644 }
645 /**
646 * Set the right parenthesis to the given token.
647 * @param parenthesis the right parenthesis
648 */
649 void set rightParenthesis2(Token parenthesis) {
650 _rightParenthesis = parenthesis;
651 }
652 void visitChildren(ASTVisitor<Object> visitor) {
653 _arguments.accept(visitor);
654 }
655 }
656 /**
657 * Instances of the class {@code AsExpression} represent an 'as' expression.
658 * <pre>
659 * asExpression ::={@link Expression expression} 'as' {@link TypeName type}</pre >
660 */
661 class AsExpression extends Expression {
662 /**
663 * The expression used to compute the value being cast.
664 */
665 Expression _expression;
666 /**
667 * The as operator.
668 */
669 Token _asOperator;
670 /**
671 * The name of the type being cast to.
672 */
673 TypeName _type;
674 /**
675 * Initialize a newly created as expression.
676 * @param expression the expression used to compute the value being cast
677 * @param isOperator the is operator
678 * @param type the name of the type being cast to
679 */
680 AsExpression(Expression expression, Token isOperator, TypeName type) {
681 this._expression = becomeParentOf(expression);
682 this._asOperator = isOperator;
683 this._type = becomeParentOf(type);
684 }
685 accept(ASTVisitor visitor) => visitor.visitAsExpression(this);
686 /**
687 * Return the is operator being applied.
688 * @return the is operator being applied
689 */
690 Token get asOperator => _asOperator;
691 Token get beginToken => _expression.beginToken;
692 Token get endToken => _type.endToken;
693 /**
694 * Return the expression used to compute the value being cast.
695 * @return the expression used to compute the value being cast
696 */
697 Expression get expression => _expression;
698 /**
699 * Return the name of the type being cast to.
700 * @return the name of the type being cast to
701 */
702 TypeName get type => _type;
703 /**
704 * Set the is operator being applied to the given operator.
705 * @param asOperator the is operator being applied
706 */
707 void set asOperator2(Token asOperator) {
708 this._asOperator = asOperator;
709 }
710 /**
711 * Set the expression used to compute the value being cast to the given expres sion.
712 * @param expression the expression used to compute the value being cast
713 */
714 void set expression2(Expression expression) {
715 this._expression = becomeParentOf(expression);
716 }
717 /**
718 * Set the name of the type being cast to to the given name.
719 * @param name the name of the type being cast to
720 */
721 void set type2(TypeName name) {
722 this._type = becomeParentOf(name);
723 }
724 void visitChildren(ASTVisitor<Object> visitor) {
725 safelyVisitChild(_expression, visitor);
726 safelyVisitChild(_type, visitor);
727 }
728 }
729 /**
730 * Instances of the class {@code AssertStatement} represent an assert statement.
731 * <pre>
732 * assertStatement ::=
733 * 'assert' '(' {@link Expression conditionalExpression} ')' ';'
734 * </pre>
735 */
736 class AssertStatement extends Statement {
737 /**
738 * The token representing the 'assert' keyword.
739 */
740 Token _keyword;
741 /**
742 * The left parenthesis.
743 */
744 Token _leftParenthesis;
745 /**
746 * The condition that is being asserted to be {@code true}.
747 */
748 Expression _condition;
749 /**
750 * The right parenthesis.
751 */
752 Token _rightParenthesis;
753 /**
754 * The semicolon terminating the statement.
755 */
756 Token _semicolon;
757 /**
758 * Initialize a newly created assert statement.
759 * @param keyword the token representing the 'assert' keyword
760 * @param leftParenthesis the left parenthesis
761 * @param condition the condition that is being asserted to be {@code true}
762 * @param rightParenthesis the right parenthesis
763 * @param semicolon the semicolon terminating the statement
764 */
765 AssertStatement(Token keyword, Token leftParenthesis, Expression condition, To ken rightParenthesis, Token semicolon) {
766 this._keyword = keyword;
767 this._leftParenthesis = leftParenthesis;
768 this._condition = becomeParentOf(condition);
769 this._rightParenthesis = rightParenthesis;
770 this._semicolon = semicolon;
771 }
772 accept(ASTVisitor visitor) => visitor.visitAssertStatement(this);
773 Token get beginToken => _keyword;
774 /**
775 * Return the condition that is being asserted to be {@code true}.
776 * @return the condition that is being asserted to be {@code true}
777 */
778 Expression get condition => _condition;
779 Token get endToken => _semicolon;
780 /**
781 * Return the token representing the 'assert' keyword.
782 * @return the token representing the 'assert' keyword
783 */
784 Token get keyword => _keyword;
785 /**
786 * Return the left parenthesis.
787 * @return the left parenthesis
788 */
789 Token get leftParenthesis => _leftParenthesis;
790 /**
791 * Return the right parenthesis.
792 * @return the right parenthesis
793 */
794 Token get rightParenthesis => _rightParenthesis;
795 /**
796 * Return the semicolon terminating the statement.
797 * @return the semicolon terminating the statement
798 */
799 Token get semicolon => _semicolon;
800 /**
801 * Set the condition that is being asserted to be {@code true} to the given ex pression.
802 * @param the condition that is being asserted to be {@code true}
803 */
804 void set condition2(Expression condition) {
805 this._condition = becomeParentOf(condition);
806 }
807 /**
808 * Set the token representing the 'assert' keyword to the given token.
809 * @param keyword the token representing the 'assert' keyword
810 */
811 void set keyword3(Token keyword) {
812 this._keyword = keyword;
813 }
814 /**
815 * Set the left parenthesis to the given token.
816 * @param the left parenthesis
817 */
818 void set leftParenthesis3(Token leftParenthesis) {
819 this._leftParenthesis = leftParenthesis;
820 }
821 /**
822 * Set the right parenthesis to the given token.
823 * @param rightParenthesis the right parenthesis
824 */
825 void set rightParenthesis3(Token rightParenthesis) {
826 this._rightParenthesis = rightParenthesis;
827 }
828 /**
829 * Set the semicolon terminating the statement to the given token.
830 * @param semicolon the semicolon terminating the statement
831 */
832 void set semicolon2(Token semicolon) {
833 this._semicolon = semicolon;
834 }
835 void visitChildren(ASTVisitor<Object> visitor) {
836 safelyVisitChild(_condition, visitor);
837 }
838 }
839 /**
840 * Instances of the class {@code AssignmentExpression} represent an assignment e xpression.
841 * <pre>
842 * assignmentExpression ::={@link Expression leftHandSide} {@link Token operator } {@link Expression rightHandSide}</pre>
843 */
844 class AssignmentExpression extends Expression {
845 /**
846 * The expression used to compute the left hand side.
847 */
848 Expression _leftHandSide;
849 /**
850 * The assignment operator being applied.
851 */
852 Token _operator;
853 /**
854 * The expression used to compute the right hand side.
855 */
856 Expression _rightHandSide;
857 /**
858 * The element associated with the operator, or {@code null} if the AST struct ure has not been
859 * resolved, if the operator is not a compound operator, or if the operator co uld not be resolved.
860 */
861 MethodElement _element;
862 /**
863 * Initialize a newly created assignment expression.
864 * @param leftHandSide the expression used to compute the left hand side
865 * @param operator the assignment operator being applied
866 * @param rightHandSide the expression used to compute the right hand side
867 */
868 AssignmentExpression(Expression leftHandSide, Token operator, Expression right HandSide) {
869 this._leftHandSide = becomeParentOf(leftHandSide);
870 this._operator = operator;
871 this._rightHandSide = becomeParentOf(rightHandSide);
872 }
873 accept(ASTVisitor visitor) => visitor.visitAssignmentExpression(this);
874 Token get beginToken => _leftHandSide.beginToken;
875 /**
876 * Return the element associated with the operator, or {@code null} if the AST structure has not
877 * been resolved, if the operator is not a compound operator, or if the operat or could not be
878 * resolved. One example of the latter case is an operator that is not defined for the type of the
879 * left-hand operand.
880 * @return the element associated with the operator
881 */
882 MethodElement get element => _element;
883 Token get endToken => _rightHandSide.endToken;
884 /**
885 * Set the expression used to compute the left hand side to the given expressi on.
886 * @return the expression used to compute the left hand side
887 */
888 Expression get leftHandSide => _leftHandSide;
889 /**
890 * Return the assignment operator being applied.
891 * @return the assignment operator being applied
892 */
893 Token get operator => _operator;
894 /**
895 * Return the expression used to compute the right hand side.
896 * @return the expression used to compute the right hand side
897 */
898 Expression get rightHandSide => _rightHandSide;
899 /**
900 * Set the element associated with the operator to the given element.
901 * @param element the element associated with the operator
902 */
903 void set element2(MethodElement element) {
904 this._element = element;
905 }
906 /**
907 * Return the expression used to compute the left hand side.
908 * @param expression the expression used to compute the left hand side
909 */
910 void set leftHandSide2(Expression expression) {
911 _leftHandSide = becomeParentOf(expression);
912 }
913 /**
914 * Set the assignment operator being applied to the given operator.
915 * @param operator the assignment operator being applied
916 */
917 void set operator2(Token operator) {
918 this._operator = operator;
919 }
920 /**
921 * Set the expression used to compute the left hand side to the given expressi on.
922 * @param expression the expression used to compute the left hand side
923 */
924 void set rightHandSide2(Expression expression) {
925 _rightHandSide = becomeParentOf(expression);
926 }
927 void visitChildren(ASTVisitor<Object> visitor) {
928 safelyVisitChild(_leftHandSide, visitor);
929 safelyVisitChild(_rightHandSide, visitor);
930 }
931 }
932 /**
933 * Instances of the class {@code BinaryExpression} represent a binary (infix) ex pression.
934 * <pre>
935 * binaryExpression ::={@link Expression leftOperand} {@link Token operator} {@l ink Expression rightOperand}</pre>
936 */
937 class BinaryExpression extends Expression {
938 /**
939 * The expression used to compute the left operand.
940 */
941 Expression _leftOperand;
942 /**
943 * The binary operator being applied.
944 */
945 Token _operator;
946 /**
947 * The expression used to compute the right operand.
948 */
949 Expression _rightOperand;
950 /**
951 * The element associated with the operator, or {@code null} if the AST struct ure has not been
952 * resolved, if the operator is not user definable, or if the operator could n ot be resolved.
953 */
954 MethodElement _element;
955 /**
956 * Initialize a newly created binary expression.
957 * @param leftOperand the expression used to compute the left operand
958 * @param operator the binary operator being applied
959 * @param rightOperand the expression used to compute the right operand
960 */
961 BinaryExpression(Expression leftOperand, Token operator, Expression rightOpera nd) {
962 this._leftOperand = becomeParentOf(leftOperand);
963 this._operator = operator;
964 this._rightOperand = becomeParentOf(rightOperand);
965 }
966 accept(ASTVisitor visitor) => visitor.visitBinaryExpression(this);
967 Token get beginToken => _leftOperand.beginToken;
968 /**
969 * Return the element associated with the operator, or {@code null} if the AST structure has not
970 * been resolved, if the operator is not user definable, or if the operator co uld not be resolved.
971 * One example of the latter case is an operator that is not defined for the t ype of the left-hand
972 * operand.
973 * @return the element associated with the operator
974 */
975 MethodElement get element => _element;
976 Token get endToken => _rightOperand.endToken;
977 /**
978 * Return the expression used to compute the left operand.
979 * @return the expression used to compute the left operand
980 */
981 Expression get leftOperand => _leftOperand;
982 /**
983 * Return the binary operator being applied.
984 * @return the binary operator being applied
985 */
986 Token get operator => _operator;
987 /**
988 * Return the expression used to compute the right operand.
989 * @return the expression used to compute the right operand
990 */
991 Expression get rightOperand => _rightOperand;
992 /**
993 * Set the element associated with the operator to the given element.
994 * @param element the element associated with the operator
995 */
996 void set element3(MethodElement element) {
997 this._element = element;
998 }
999 /**
1000 * Set the expression used to compute the left operand to the given expression .
1001 * @param expression the expression used to compute the left operand
1002 */
1003 void set leftOperand2(Expression expression) {
1004 _leftOperand = becomeParentOf(expression);
1005 }
1006 /**
1007 * Set the binary operator being applied to the given operator.
1008 * @return the binary operator being applied
1009 */
1010 void set operator3(Token operator) {
1011 this._operator = operator;
1012 }
1013 /**
1014 * Set the expression used to compute the right operand to the given expressio n.
1015 * @param expression the expression used to compute the right operand
1016 */
1017 void set rightOperand2(Expression expression) {
1018 _rightOperand = becomeParentOf(expression);
1019 }
1020 void visitChildren(ASTVisitor<Object> visitor) {
1021 safelyVisitChild(_leftOperand, visitor);
1022 safelyVisitChild(_rightOperand, visitor);
1023 }
1024 }
1025 /**
1026 * Instances of the class {@code Block} represent a sequence of statements.
1027 * <pre>
1028 * block ::=
1029 * '{' statement* '}'
1030 * </pre>
1031 */
1032 class Block extends Statement {
1033 /**
1034 * The left curly bracket.
1035 */
1036 Token _leftBracket;
1037 /**
1038 * The statements contained in the block.
1039 */
1040 NodeList<Statement> _statements;
1041 /**
1042 * The right curly bracket.
1043 */
1044 Token _rightBracket;
1045 /**
1046 * Initialize a newly created block of code.
1047 * @param leftBracket the left curly bracket
1048 * @param statements the statements contained in the block
1049 * @param rightBracket the right curly bracket
1050 */
1051 Block(Token leftBracket, List<Statement> statements, Token rightBracket) {
1052 this._statements = new NodeList<Statement>(this);
1053 this._leftBracket = leftBracket;
1054 this._statements.addAll(statements);
1055 this._rightBracket = rightBracket;
1056 }
1057 accept(ASTVisitor visitor) => visitor.visitBlock(this);
1058 Token get beginToken => _leftBracket;
1059 Token get endToken => _rightBracket;
1060 /**
1061 * Return the left curly bracket.
1062 * @return the left curly bracket
1063 */
1064 Token get leftBracket => _leftBracket;
1065 /**
1066 * Return the right curly bracket.
1067 * @return the right curly bracket
1068 */
1069 Token get rightBracket => _rightBracket;
1070 /**
1071 * Return the statements contained in the block.
1072 * @return the statements contained in the block
1073 */
1074 NodeList<Statement> get statements => _statements;
1075 /**
1076 * Set the left curly bracket to the given token.
1077 * @param leftBracket the left curly bracket
1078 */
1079 void set leftBracket2(Token leftBracket) {
1080 this._leftBracket = leftBracket;
1081 }
1082 /**
1083 * Set the right curly bracket to the given token.
1084 * @param rightBracket the right curly bracket
1085 */
1086 void set rightBracket2(Token rightBracket) {
1087 this._rightBracket = rightBracket;
1088 }
1089 void visitChildren(ASTVisitor<Object> visitor) {
1090 _statements.accept(visitor);
1091 }
1092 }
1093 /**
1094 * Instances of the class {@code BlockFunctionBody} represent a function body th at consists of a
1095 * block of statements.
1096 * <pre>
1097 * blockFunctionBody ::={@link Block block}</pre>
1098 */
1099 class BlockFunctionBody extends FunctionBody {
1100 /**
1101 * The block representing the body of the function.
1102 */
1103 Block _block;
1104 /**
1105 * Initialize a newly created function body consisting of a block of statement s.
1106 * @param block the block representing the body of the function
1107 */
1108 BlockFunctionBody(Block block) {
1109 this._block = becomeParentOf(block);
1110 }
1111 accept(ASTVisitor visitor) => visitor.visitBlockFunctionBody(this);
1112 Token get beginToken => _block.beginToken;
1113 /**
1114 * Return the block representing the body of the function.
1115 * @return the block representing the body of the function
1116 */
1117 Block get block => _block;
1118 Token get endToken => _block.endToken;
1119 /**
1120 * Set the block representing the body of the function to the given block.
1121 * @param block the block representing the body of the function
1122 */
1123 void set block2(Block block) {
1124 this._block = becomeParentOf(block);
1125 }
1126 void visitChildren(ASTVisitor<Object> visitor) {
1127 safelyVisitChild(_block, visitor);
1128 }
1129 }
1130 /**
1131 * Instances of the class {@code BooleanLiteral} represent a boolean literal exp ression.
1132 * <pre>
1133 * booleanLiteral ::=
1134 * 'false' | 'true'
1135 * </pre>
1136 */
1137 class BooleanLiteral extends Literal {
1138 /**
1139 * The token representing the literal.
1140 */
1141 Token _literal;
1142 /**
1143 * The value of the literal.
1144 */
1145 bool _value = false;
1146 /**
1147 * Initialize a newly created boolean literal.
1148 * @param literal the token representing the literal
1149 * @param value the value of the literal
1150 */
1151 BooleanLiteral(Token literal, bool value) {
1152 this._literal = literal;
1153 this._value = value;
1154 }
1155 accept(ASTVisitor visitor) => visitor.visitBooleanLiteral(this);
1156 Token get beginToken => _literal;
1157 Token get endToken => _literal;
1158 /**
1159 * Return the token representing the literal.
1160 * @return the token representing the literal
1161 */
1162 Token get literal => _literal;
1163 /**
1164 * Return the value of the literal.
1165 * @return the value of the literal
1166 */
1167 bool get value => _value;
1168 bool isSynthetic() => _literal.isSynthetic();
1169 /**
1170 * Set the token representing the literal to the given token.
1171 * @param literal the token representing the literal
1172 */
1173 void set literal2(Token literal) {
1174 this._literal = literal;
1175 }
1176 /**
1177 * Set the value of the literal to the given value.
1178 * @param value the value of the literal
1179 */
1180 void set value4(bool value) {
1181 this._value = value;
1182 }
1183 void visitChildren(ASTVisitor<Object> visitor) {
1184 }
1185 }
1186 /**
1187 * Instances of the class {@code BreakStatement} represent a break statement.
1188 * <pre>
1189 * breakStatement ::=
1190 * 'break' {@link SimpleIdentifier label}? ';'
1191 * </pre>
1192 */
1193 class BreakStatement extends Statement {
1194 /**
1195 * The token representing the 'break' keyword.
1196 */
1197 Token _keyword;
1198 /**
1199 * The label associated with the statement, or {@code null} if there is no lab el.
1200 */
1201 SimpleIdentifier _label;
1202 /**
1203 * The semicolon terminating the statement.
1204 */
1205 Token _semicolon;
1206 /**
1207 * Initialize a newly created break statement.
1208 * @param keyword the token representing the 'break' keyword
1209 * @param label the label associated with the statement
1210 * @param semicolon the semicolon terminating the statement
1211 */
1212 BreakStatement(Token keyword, SimpleIdentifier label, Token semicolon) {
1213 this._keyword = keyword;
1214 this._label = becomeParentOf(label);
1215 this._semicolon = semicolon;
1216 }
1217 accept(ASTVisitor visitor) => visitor.visitBreakStatement(this);
1218 Token get beginToken => _keyword;
1219 Token get endToken => _semicolon;
1220 /**
1221 * Return the token representing the 'break' keyword.
1222 * @return the token representing the 'break' keyword
1223 */
1224 Token get keyword => _keyword;
1225 /**
1226 * Return the label associated with the statement, or {@code null} if there is no label.
1227 * @return the label associated with the statement
1228 */
1229 SimpleIdentifier get label => _label;
1230 /**
1231 * Return the semicolon terminating the statement.
1232 * @return the semicolon terminating the statement
1233 */
1234 Token get semicolon => _semicolon;
1235 /**
1236 * Set the token representing the 'break' keyword to the given token.
1237 * @param keyword the token representing the 'break' keyword
1238 */
1239 void set keyword4(Token keyword) {
1240 this._keyword = keyword;
1241 }
1242 /**
1243 * Set the label associated with the statement to the given identifier.
1244 * @param identifier the label associated with the statement
1245 */
1246 void set label2(SimpleIdentifier identifier) {
1247 _label = becomeParentOf(identifier);
1248 }
1249 /**
1250 * Set the semicolon terminating the statement to the given token.
1251 * @param semicolon the semicolon terminating the statement
1252 */
1253 void set semicolon3(Token semicolon) {
1254 this._semicolon = semicolon;
1255 }
1256 void visitChildren(ASTVisitor<Object> visitor) {
1257 safelyVisitChild(_label, visitor);
1258 }
1259 }
1260 /**
1261 * Instances of the class {@code CascadeExpression} represent a sequence of casc aded expressions:
1262 * expressions that share a common target. There are three kinds of expressions that can be used in
1263 * a cascade expression: {@link IndexExpression}, {@link MethodInvocation} and{@ link PropertyAccess}.
1264 * <pre>
1265 * cascadeExpression ::={@link Expression conditionalExpression} cascadeSection
1266 * cascadeSection ::=
1267 * '..' (cascadeSelector arguments*) (assignableSelector arguments*)* (assignme ntOperator expressionWithoutCascade)?
1268 * cascadeSelector ::=
1269 * '[ ' expression '] '
1270 * | identifier
1271 * </pre>
1272 */
1273 class CascadeExpression extends Expression {
1274 /**
1275 * The target of the cascade sections.
1276 */
1277 Expression _target;
1278 /**
1279 * The cascade sections sharing the common target.
1280 */
1281 NodeList<Expression> _cascadeSections;
1282 /**
1283 * Initialize a newly created cascade expression.
1284 * @param target the target of the cascade sections
1285 * @param cascadeSections the cascade sections sharing the common target
1286 */
1287 CascadeExpression(Expression target, List<Expression> cascadeSections) {
1288 this._cascadeSections = new NodeList<Expression>(this);
1289 this._target = becomeParentOf(target);
1290 this._cascadeSections.addAll(cascadeSections);
1291 }
1292 accept(ASTVisitor visitor) => visitor.visitCascadeExpression(this);
1293 Token get beginToken => _target.beginToken;
1294 /**
1295 * Return the cascade sections sharing the common target.
1296 * @return the cascade sections sharing the common target
1297 */
1298 NodeList<Expression> get cascadeSections => _cascadeSections;
1299 Token get endToken => _cascadeSections.endToken;
1300 /**
1301 * Return the target of the cascade sections.
1302 * @return the target of the cascade sections
1303 */
1304 Expression get target => _target;
1305 /**
1306 * Set the target of the cascade sections to the given expression.
1307 * @param target the target of the cascade sections
1308 */
1309 void set target2(Expression target) {
1310 this._target = becomeParentOf(target);
1311 }
1312 void visitChildren(ASTVisitor<Object> visitor) {
1313 safelyVisitChild(_target, visitor);
1314 _cascadeSections.accept(visitor);
1315 }
1316 }
1317 /**
1318 * Instances of the class {@code CatchClause} represent a catch clause within a try statement.
1319 * <pre>
1320 * onPart ::=
1321 * catchPart {@link Block block}| 'on' type catchPart? {@link Block block}catchP art ::=
1322 * 'catch' '(' {@link SimpleIdentifier exceptionParameter} (',' {@link SimpleIde ntifier stackTraceParameter})? ')'
1323 * </pre>
1324 */
1325 class CatchClause extends ASTNode {
1326 /**
1327 * The token representing the 'on' keyword, or {@code null} if there is no 'on ' keyword.
1328 */
1329 Token _onKeyword;
1330 /**
1331 * The type of exceptions caught by this catch clause, or {@code null} if this catch clause
1332 * catches every type of exception.
1333 */
1334 TypeName _exceptionType;
1335 /**
1336 * The token representing the 'catch' keyword, or {@code null} if there is no 'catch' keyword.
1337 */
1338 Token _catchKeyword;
1339 /**
1340 * The left parenthesis.
1341 */
1342 Token _leftParenthesis;
1343 /**
1344 * The parameter whose value will be the exception that was thrown.
1345 */
1346 SimpleIdentifier _exceptionParameter;
1347 /**
1348 * The comma separating the exception parameter from the stack trace parameter .
1349 */
1350 Token _comma;
1351 /**
1352 * The parameter whose value will be the stack trace associated with the excep tion.
1353 */
1354 SimpleIdentifier _stackTraceParameter;
1355 /**
1356 * The right parenthesis.
1357 */
1358 Token _rightParenthesis;
1359 /**
1360 * The body of the catch block.
1361 */
1362 Block _body;
1363 /**
1364 * Initialize a newly created catch clause.
1365 * @param onKeyword the token representing the 'on' keyword
1366 * @param exceptionType the type of exceptions caught by this catch clause
1367 * @param leftParenthesis the left parenthesis
1368 * @param exceptionParameter the parameter whose value will be the exception t hat was thrown
1369 * @param comma the comma separating the exception parameter from the stack tr ace parameter
1370 * @param stackTraceParameter the parameter whose value will be the stack trac e associated with
1371 * the exception
1372 * @param rightParenthesis the right parenthesis
1373 * @param body the body of the catch block
1374 */
1375 CatchClause(Token onKeyword, TypeName exceptionType, Token catchKeyword, Token leftParenthesis, SimpleIdentifier exceptionParameter, Token comma, SimpleIdenti fier stackTraceParameter, Token rightParenthesis, Block body) {
1376 this._onKeyword = onKeyword;
1377 this._exceptionType = becomeParentOf(exceptionType);
1378 this._catchKeyword = catchKeyword;
1379 this._leftParenthesis = leftParenthesis;
1380 this._exceptionParameter = becomeParentOf(exceptionParameter);
1381 this._comma = comma;
1382 this._stackTraceParameter = becomeParentOf(stackTraceParameter);
1383 this._rightParenthesis = rightParenthesis;
1384 this._body = becomeParentOf(body);
1385 }
1386 accept(ASTVisitor visitor) => visitor.visitCatchClause(this);
1387 Token get beginToken {
1388 if (_onKeyword != null) {
1389 return _onKeyword;
1390 }
1391 return _catchKeyword;
1392 }
1393 /**
1394 * Return the body of the catch block.
1395 * @return the body of the catch block
1396 */
1397 Block get body => _body;
1398 /**
1399 * Return the token representing the 'catch' keyword, or {@code null} if there is no 'catch'
1400 * keyword.
1401 * @return the token representing the 'catch' keyword
1402 */
1403 Token get catchKeyword => _catchKeyword;
1404 /**
1405 * Return the comma.
1406 * @return the comma
1407 */
1408 Token get comma => _comma;
1409 Token get endToken => _body.endToken;
1410 /**
1411 * Return the parameter whose value will be the exception that was thrown.
1412 * @return the parameter whose value will be the exception that was thrown
1413 */
1414 SimpleIdentifier get exceptionParameter => _exceptionParameter;
1415 /**
1416 * Return the type of exceptions caught by this catch clause, or {@code null} if this catch clause
1417 * catches every type of exception.
1418 * @return the type of exceptions caught by this catch clause
1419 */
1420 TypeName get exceptionType => _exceptionType;
1421 /**
1422 * Return the left parenthesis.
1423 * @return the left parenthesis
1424 */
1425 Token get leftParenthesis => _leftParenthesis;
1426 /**
1427 * Return the token representing the 'on' keyword, or {@code null} if there is no 'on' keyword.
1428 * @return the token representing the 'on' keyword
1429 */
1430 Token get onKeyword => _onKeyword;
1431 /**
1432 * Return the right parenthesis.
1433 * @return the right parenthesis
1434 */
1435 Token get rightParenthesis => _rightParenthesis;
1436 /**
1437 * Return the parameter whose value will be the stack trace associated with th e exception.
1438 * @return the parameter whose value will be the stack trace associated with t he exception
1439 */
1440 SimpleIdentifier get stackTraceParameter => _stackTraceParameter;
1441 /**
1442 * Set the body of the catch block to the given block.
1443 * @param block the body of the catch block
1444 */
1445 void set body2(Block block) {
1446 _body = becomeParentOf(block);
1447 }
1448 /**
1449 * Set the token representing the 'catch' keyword to the given token.
1450 * @param catchKeyword the token representing the 'catch' keyword
1451 */
1452 void set catchKeyword2(Token catchKeyword) {
1453 this._catchKeyword = catchKeyword;
1454 }
1455 /**
1456 * Set the comma to the given token.
1457 * @param comma the comma
1458 */
1459 void set comma2(Token comma) {
1460 this._comma = comma;
1461 }
1462 /**
1463 * Set the parameter whose value will be the exception that was thrown to the given parameter.
1464 * @param parameter the parameter whose value will be the exception that was t hrown
1465 */
1466 void set exceptionParameter2(SimpleIdentifier parameter) {
1467 _exceptionParameter = becomeParentOf(parameter);
1468 }
1469 /**
1470 * Set the type of exceptions caught by this catch clause to the given type.
1471 * @param exceptionType the type of exceptions caught by this catch clause
1472 */
1473 void set exceptionType2(TypeName exceptionType) {
1474 this._exceptionType = exceptionType;
1475 }
1476 /**
1477 * Set the left parenthesis to the given token.
1478 * @param parenthesis the left parenthesis
1479 */
1480 void set leftParenthesis4(Token parenthesis) {
1481 _leftParenthesis = parenthesis;
1482 }
1483 /**
1484 * Set the token representing the 'on' keyword to the given keyword.
1485 * @param onKeyword the token representing the 'on' keyword
1486 */
1487 void set onKeyword2(Token onKeyword) {
1488 this._onKeyword = onKeyword;
1489 }
1490 /**
1491 * Set the right parenthesis to the given token.
1492 * @param parenthesis the right parenthesis
1493 */
1494 void set rightParenthesis4(Token parenthesis) {
1495 _rightParenthesis = parenthesis;
1496 }
1497 /**
1498 * Set the parameter whose value will be the stack trace associated with the e xception to the
1499 * given parameter.
1500 * @param parameter the parameter whose value will be the stack trace associat ed with the
1501 * exception
1502 */
1503 void set stackTraceParameter2(SimpleIdentifier parameter) {
1504 _stackTraceParameter = becomeParentOf(parameter);
1505 }
1506 void visitChildren(ASTVisitor<Object> visitor) {
1507 safelyVisitChild(_exceptionType, visitor);
1508 safelyVisitChild(_exceptionParameter, visitor);
1509 safelyVisitChild(_stackTraceParameter, visitor);
1510 safelyVisitChild(_body, visitor);
1511 }
1512 }
1513 /**
1514 * Instances of the class {@code ClassDeclaration} represent the declaration of a class.
1515 * <pre>
1516 * classDeclaration ::=
1517 * 'abstract'? 'class' {@link SimpleIdentifier name} {@link TypeParameterList ty peParameterList}?
1518 * ({@link ExtendsClause extendsClause} {@link WithClause withClause}?)?{@link I mplementsClause implementsClause}?
1519 * '{' {@link ClassMember classMember}* '}'
1520 * </pre>
1521 */
1522 class ClassDeclaration extends CompilationUnitMember {
1523 /**
1524 * The 'abstract' keyword, or {@code null} if the keyword was absent.
1525 */
1526 Token _abstractKeyword;
1527 /**
1528 * The token representing the 'class' keyword.
1529 */
1530 Token _classKeyword;
1531 /**
1532 * The name of the class being declared.
1533 */
1534 SimpleIdentifier _name;
1535 /**
1536 * The type parameters for the class, or {@code null} if the class does not ha ve any type
1537 * parameters.
1538 */
1539 TypeParameterList _typeParameters;
1540 /**
1541 * The extends clause for the class, or {@code null} if the class does not ext end any other class.
1542 */
1543 ExtendsClause _extendsClause;
1544 /**
1545 * The with clause for the class, or {@code null} if the class does not have a with clause.
1546 */
1547 WithClause _withClause;
1548 /**
1549 * The implements clause for the class, or {@code null} if the class does not implement any
1550 * interfaces.
1551 */
1552 ImplementsClause _implementsClause;
1553 /**
1554 * The left curly bracket.
1555 */
1556 Token _leftBracket;
1557 /**
1558 * The members defined by the class.
1559 */
1560 NodeList<ClassMember> _members;
1561 /**
1562 * The right curly bracket.
1563 */
1564 Token _rightBracket;
1565 /**
1566 * Initialize a newly created class declaration.
1567 * @param comment the documentation comment associated with this class
1568 * @param metadata the annotations associated with this class
1569 * @param abstractKeyword the 'abstract' keyword, or {@code null} if the keywo rd was absent
1570 * @param classKeyword the token representing the 'class' keyword
1571 * @param name the name of the class being declared
1572 * @param typeParameters the type parameters for the class
1573 * @param extendsClause the extends clause for the class
1574 * @param withClause the with clause for the class
1575 * @param implementsClause the implements clause for the class
1576 * @param leftBracket the left curly bracket
1577 * @param members the members defined by the class
1578 * @param rightBracket the right curly bracket
1579 */
1580 ClassDeclaration(Comment comment, List<Annotation> metadata, Token abstractKey word, Token classKeyword, SimpleIdentifier name, TypeParameterList typeParameter s, ExtendsClause extendsClause, WithClause withClause, ImplementsClause implemen tsClause, Token leftBracket, List<ClassMember> members, Token rightBracket) : su per(comment, metadata) {
1581 this._members = new NodeList<ClassMember>(this);
1582 this._abstractKeyword = abstractKeyword;
1583 this._classKeyword = classKeyword;
1584 this._name = becomeParentOf(name);
1585 this._typeParameters = becomeParentOf(typeParameters);
1586 this._extendsClause = becomeParentOf(extendsClause);
1587 this._withClause = becomeParentOf(withClause);
1588 this._implementsClause = becomeParentOf(implementsClause);
1589 this._leftBracket = leftBracket;
1590 this._members.addAll(members);
1591 this._rightBracket = rightBracket;
1592 }
1593 accept(ASTVisitor visitor) => visitor.visitClassDeclaration(this);
1594 /**
1595 * Return the 'abstract' keyword, or {@code null} if the keyword was absent.
1596 * @return the 'abstract' keyword
1597 */
1598 Token get abstractKeyword => _abstractKeyword;
1599 /**
1600 * Return the token representing the 'class' keyword.
1601 * @return the token representing the 'class' keyword
1602 */
1603 Token get classKeyword => _classKeyword;
1604 /**
1605 * @return the {@link ClassElement} associated with this identifier, or {@code null} if the AST
1606 * structure has not been resolved or if this identifier could not be resolved .
1607 */
1608 ClassElement get element => _name != null ? _name.element as ClassElement : nu ll;
1609 Token get endToken => _rightBracket;
1610 /**
1611 * Return the extends clause for this class, or {@code null} if the class does not extend any
1612 * other class.
1613 * @return the extends clause for this class
1614 */
1615 ExtendsClause get extendsClause => _extendsClause;
1616 /**
1617 * Return the implements clause for the class, or {@code null} if the class do es not implement any
1618 * interfaces.
1619 * @return the implements clause for the class
1620 */
1621 ImplementsClause get implementsClause => _implementsClause;
1622 /**
1623 * Return the left curly bracket.
1624 * @return the left curly bracket
1625 */
1626 Token get leftBracket => _leftBracket;
1627 /**
1628 * Return the members defined by the class.
1629 * @return the members defined by the class
1630 */
1631 NodeList<ClassMember> get members => _members;
1632 /**
1633 * Return the name of the class being declared.
1634 * @return the name of the class being declared
1635 */
1636 SimpleIdentifier get name => _name;
1637 /**
1638 * Return the right curly bracket.
1639 * @return the right curly bracket
1640 */
1641 Token get rightBracket => _rightBracket;
1642 /**
1643 * Return the type parameters for the class, or {@code null} if the class does not have any type
1644 * parameters.
1645 * @return the type parameters for the class
1646 */
1647 TypeParameterList get typeParameters => _typeParameters;
1648 /**
1649 * Return the with clause for the class, or {@code null} if the class does not have a with clause.
1650 * @return the with clause for the class
1651 */
1652 WithClause get withClause => _withClause;
1653 /**
1654 * Set the 'abstract' keyword to the given keyword.
1655 * @param abstractKeyword the 'abstract' keyword
1656 */
1657 void set abstractKeyword2(Token abstractKeyword) {
1658 this._abstractKeyword = abstractKeyword;
1659 }
1660 /**
1661 * Set the token representing the 'class' keyword to the given token.
1662 * @param classKeyword the token representing the 'class' keyword
1663 */
1664 void set classKeyword2(Token classKeyword) {
1665 this._classKeyword = classKeyword;
1666 }
1667 /**
1668 * Set the extends clause for this class to the given clause.
1669 * @param extendsClause the extends clause for this class
1670 */
1671 void set extendsClause2(ExtendsClause extendsClause) {
1672 this._extendsClause = becomeParentOf(extendsClause);
1673 }
1674 /**
1675 * Set the implements clause for the class to the given clause.
1676 * @param implementsClause the implements clause for the class
1677 */
1678 void set implementsClause2(ImplementsClause implementsClause) {
1679 this._implementsClause = becomeParentOf(implementsClause);
1680 }
1681 /**
1682 * Set the left curly bracket to the given token.
1683 * @param leftBracket the left curly bracket
1684 */
1685 void set leftBracket3(Token leftBracket) {
1686 this._leftBracket = leftBracket;
1687 }
1688 /**
1689 * Set the name of the class being declared to the given identifier.
1690 * @param identifier the name of the class being declared
1691 */
1692 void set name3(SimpleIdentifier identifier) {
1693 _name = becomeParentOf(identifier);
1694 }
1695 /**
1696 * Set the right curly bracket to the given token.
1697 * @param rightBracket the right curly bracket
1698 */
1699 void set rightBracket3(Token rightBracket) {
1700 this._rightBracket = rightBracket;
1701 }
1702 /**
1703 * Set the type parameters for the class to the given list of type parameters.
1704 * @param typeParameters the type parameters for the class
1705 */
1706 void set typeParameters2(TypeParameterList typeParameters) {
1707 this._typeParameters = typeParameters;
1708 }
1709 /**
1710 * Set the with clause for the class to the given clause.
1711 * @param withClause the with clause for the class
1712 */
1713 void set withClause2(WithClause withClause) {
1714 this._withClause = becomeParentOf(withClause);
1715 }
1716 void visitChildren(ASTVisitor<Object> visitor) {
1717 safelyVisitChild(documentationComment, visitor);
1718 safelyVisitChild(_name, visitor);
1719 safelyVisitChild(_typeParameters, visitor);
1720 safelyVisitChild(_extendsClause, visitor);
1721 safelyVisitChild(_withClause, visitor);
1722 safelyVisitChild(_implementsClause, visitor);
1723 members.accept(visitor);
1724 }
1725 Token get firstTokenAfterCommentAndMetadata {
1726 if (_abstractKeyword != null) {
1727 return _abstractKeyword;
1728 }
1729 return _classKeyword;
1730 }
1731 }
1732 /**
1733 * The abstract class {@code ClassMember} defines the behavior common to nodes t hat declare a name
1734 * within the scope of a class.
1735 */
1736 abstract class ClassMember extends Declaration {
1737 /**
1738 * Initialize a newly created member of a class.
1739 * @param comment the documentation comment associated with this member
1740 * @param metadata the annotations associated with this member
1741 */
1742 ClassMember(Comment comment, List<Annotation> metadata) : super(comment, metad ata) {
1743 }
1744 }
1745 /**
1746 * Instances of the class {@code ClassTypeAlias} represent a class type alias.
1747 * <pre>
1748 * classTypeAlias ::={@link SimpleIdentifier identifier} {@link TypeParameterLis t typeParameters}? '=' 'abstract'? mixinApplication
1749 * mixinApplication ::={@link TypeName superclass} {@link WithClause withClause} {@link ImplementsClause implementsClause}? ';'
1750 * </pre>
1751 */
1752 class ClassTypeAlias extends TypeAlias {
1753 /**
1754 * The name of the class being declared.
1755 */
1756 SimpleIdentifier _name;
1757 /**
1758 * The type parameters for the class, or {@code null} if the class does not ha ve any type
1759 * parameters.
1760 */
1761 TypeParameterList _typeParameters;
1762 /**
1763 * The token for the '=' separating the name from the definition.
1764 */
1765 Token _equals;
1766 /**
1767 * The token for the 'abstract' keyword, or {@code null} if this is not defini ng an abstract
1768 * class.
1769 */
1770 Token _abstractKeyword;
1771 /**
1772 * The name of the superclass of the class being declared.
1773 */
1774 TypeName _superclass;
1775 /**
1776 * The with clause for this class.
1777 */
1778 WithClause _withClause;
1779 /**
1780 * The implements clause for this class, or {@code null} if there is no implem ents clause.
1781 */
1782 ImplementsClause _implementsClause;
1783 /**
1784 * Initialize a newly created class type alias.
1785 * @param comment the documentation comment associated with this type alias
1786 * @param metadata the annotations associated with this type alias
1787 * @param keyword the token representing the 'typedef' keyword
1788 * @param name the name of the class being declared
1789 * @param typeParameters the type parameters for the class
1790 * @param equals the token for the '=' separating the name from the definition
1791 * @param abstractKeyword the token for the 'abstract' keyword
1792 * @param superclass the name of the superclass of the class being declared
1793 * @param withClause the with clause for this class
1794 * @param implementsClause the implements clause for this class
1795 * @param semicolon the semicolon terminating the declaration
1796 */
1797 ClassTypeAlias(Comment comment, List<Annotation> metadata, Token keyword, Simp leIdentifier name, TypeParameterList typeParameters, Token equals, Token abstrac tKeyword, TypeName superclass, WithClause withClause, ImplementsClause implement sClause, Token semicolon) : super(comment, metadata, keyword, semicolon) {
1798 this._name = becomeParentOf(name);
1799 this._typeParameters = becomeParentOf(typeParameters);
1800 this._equals = equals;
1801 this._abstractKeyword = abstractKeyword;
1802 this._superclass = becomeParentOf(superclass);
1803 this._withClause = becomeParentOf(withClause);
1804 this._implementsClause = becomeParentOf(implementsClause);
1805 }
1806 accept(ASTVisitor visitor) => visitor.visitClassTypeAlias(this);
1807 /**
1808 * Return the token for the 'abstract' keyword, or {@code null} if this is not defining an
1809 * abstract class.
1810 * @return the token for the 'abstract' keyword
1811 */
1812 Token get abstractKeyword => _abstractKeyword;
1813 /**
1814 * Return the {@link ClassElement} associated with this type alias, or {@code null} if the AST
1815 * structure has not been resolved.
1816 * @return the {@link ClassElement} associated with this type alias
1817 */
1818 ClassElement get element => _name != null ? _name.element as ClassElement : nu ll;
1819 /**
1820 * Return the token for the '=' separating the name from the definition.
1821 * @return the token for the '=' separating the name from the definition
1822 */
1823 Token get equals => _equals;
1824 /**
1825 * Return the implements clause for this class, or {@code null} if there is no implements clause.
1826 * @return the implements clause for this class
1827 */
1828 ImplementsClause get implementsClause => _implementsClause;
1829 /**
1830 * Return the name of the class being declared.
1831 * @return the name of the class being declared
1832 */
1833 SimpleIdentifier get name => _name;
1834 /**
1835 * Return the name of the superclass of the class being declared.
1836 * @return the name of the superclass of the class being declared
1837 */
1838 TypeName get superclass => _superclass;
1839 /**
1840 * Return the type parameters for the class, or {@code null} if the class does not have any type
1841 * parameters.
1842 * @return the type parameters for the class
1843 */
1844 TypeParameterList get typeParameters => _typeParameters;
1845 /**
1846 * Return the with clause for this class.
1847 * @return the with clause for this class
1848 */
1849 WithClause get withClause => _withClause;
1850 /**
1851 * Set the token for the 'abstract' keyword to the given token.
1852 * @param abstractKeyword the token for the 'abstract' keyword
1853 */
1854 void set abstractKeyword3(Token abstractKeyword) {
1855 this._abstractKeyword = abstractKeyword;
1856 }
1857 /**
1858 * Set the token for the '=' separating the name from the definition to the gi ven token.
1859 * @param equals the token for the '=' separating the name from the definition
1860 */
1861 void set equals4(Token equals) {
1862 this._equals = equals;
1863 }
1864 /**
1865 * Set the implements clause for this class to the given implements clause.
1866 * @param implementsClause the implements clause for this class
1867 */
1868 void set implementsClause3(ImplementsClause implementsClause) {
1869 this._implementsClause = becomeParentOf(implementsClause);
1870 }
1871 /**
1872 * Set the name of the class being declared to the given identifier.
1873 * @param name the name of the class being declared
1874 */
1875 void set name4(SimpleIdentifier name) {
1876 this._name = becomeParentOf(name);
1877 }
1878 /**
1879 * Set the name of the superclass of the class being declared to the given nam e.
1880 * @param superclass the name of the superclass of the class being declared
1881 */
1882 void set superclass2(TypeName superclass) {
1883 this._superclass = becomeParentOf(superclass);
1884 }
1885 /**
1886 * Set the type parameters for the class to the given list of parameters.
1887 * @param typeParameters the type parameters for the class
1888 */
1889 void set typeParameters3(TypeParameterList typeParameters) {
1890 this._typeParameters = becomeParentOf(typeParameters);
1891 }
1892 /**
1893 * Set the with clause for this class to the given with clause.
1894 * @param withClause the with clause for this class
1895 */
1896 void set withClause3(WithClause withClause) {
1897 this._withClause = becomeParentOf(withClause);
1898 }
1899 void visitChildren(ASTVisitor<Object> visitor) {
1900 super.visitChildren(visitor);
1901 safelyVisitChild(_name, visitor);
1902 safelyVisitChild(_typeParameters, visitor);
1903 safelyVisitChild(_superclass, visitor);
1904 safelyVisitChild(_withClause, visitor);
1905 safelyVisitChild(_implementsClause, visitor);
1906 }
1907 }
1908 /**
1909 * Instances of the class {@code Combinator} represent the combinator associated with an import
1910 * directive.
1911 * <pre>
1912 * combinator ::={@link HideCombinator hideCombinator}| {@link ShowCombinator sh owCombinator}</pre>
1913 */
1914 abstract class Combinator extends ASTNode {
1915 /**
1916 * The keyword specifying what kind of processing is to be done on the importe d names.
1917 */
1918 Token _keyword;
1919 /**
1920 * Initialize a newly created import combinator.
1921 * @param keyword the keyword specifying what kind of processing is to be done on the imported
1922 * names
1923 */
1924 Combinator(Token keyword) {
1925 this._keyword = keyword;
1926 }
1927 Token get beginToken => _keyword;
1928 /**
1929 * Return the keyword specifying what kind of processing is to be done on the imported names.
1930 * @return the keyword specifying what kind of processing is to be done on the imported names
1931 */
1932 Token get keyword => _keyword;
1933 /**
1934 * Set the keyword specifying what kind of processing is to be done on the imp orted names to the
1935 * given token.
1936 * @param keyword the keyword specifying what kind of processing is to be done on the imported
1937 * names
1938 */
1939 void set keyword5(Token keyword) {
1940 this._keyword = keyword;
1941 }
1942 }
1943 /**
1944 * Instances of the class {@code Comment} represent a comment within the source code.
1945 * <pre>
1946 * comment ::=
1947 * endOfLineComment
1948 * | blockComment
1949 * | documentationComment
1950 * endOfLineComment ::=
1951 * '//' (CHARACTER - EOL)* EOL
1952 * blockComment ::=
1953 * '/ *' CHARACTER* '&#42;/'
1954 * documentationComment ::=
1955 * '/ **' (CHARACTER | {@link CommentReference commentReference})* '&#42;/'
1956 * | ('///' (CHARACTER - EOL)* EOL)+
1957 * </pre>
1958 */
1959 class Comment extends ASTNode {
1960 /**
1961 * Create a block comment.
1962 * @param tokens the tokens representing the comment
1963 * @return the block comment that was created
1964 */
1965 static Comment createBlockComment(List<Token> tokens) => new Comment(tokens, C ommentType.BLOCK, null);
1966 /**
1967 * Create a documentation comment.
1968 * @param tokens the tokens representing the comment
1969 * @return the documentation comment that was created
1970 */
1971 static Comment createDocumentationComment(List<Token> tokens) => new Comment(t okens, CommentType.DOCUMENTATION, new List<CommentReference>());
1972 /**
1973 * Create a documentation comment.
1974 * @param tokens the tokens representing the comment
1975 * @param references the references embedded within the documentation comment
1976 * @return the documentation comment that was created
1977 */
1978 static Comment createDocumentationComment2(List<Token> tokens, List<CommentRef erence> references) => new Comment(tokens, CommentType.DOCUMENTATION, references );
1979 /**
1980 * Create an end-of-line comment.
1981 * @param tokens the tokens representing the comment
1982 * @return the end-of-line comment that was created
1983 */
1984 static Comment createEndOfLineComment(List<Token> tokens) => new Comment(token s, CommentType.END_OF_LINE, null);
1985 /**
1986 * The tokens representing the comment.
1987 */
1988 List<Token> _tokens;
1989 /**
1990 * The type of the comment.
1991 */
1992 CommentType _type;
1993 /**
1994 * The references embedded within the documentation comment. This list will be empty unless this
1995 * is a documentation comment that has references embedded within it.
1996 */
1997 NodeList<CommentReference> _references;
1998 /**
1999 * Initialize a newly created comment.
2000 * @param tokens the tokens representing the comment
2001 * @param type the type of the comment
2002 * @param references the references embedded within the documentation comment
2003 */
2004 Comment(List<Token> tokens, CommentType type, List<CommentReference> reference s) {
2005 this._references = new NodeList<CommentReference>(this);
2006 this._tokens = tokens;
2007 this._type = type;
2008 this._references.addAll(references);
2009 }
2010 accept(ASTVisitor visitor) => visitor.visitComment(this);
2011 Token get beginToken => _tokens[0];
2012 Token get endToken => _tokens[_tokens.length - 1];
2013 /**
2014 * Return the references embedded within the documentation comment.
2015 * @return the references embedded within the documentation comment
2016 */
2017 NodeList<CommentReference> get references => _references;
2018 /**
2019 * Return {@code true} if this is a block comment.
2020 * @return {@code true} if this is a block comment
2021 */
2022 bool isBlock() => _type == CommentType.BLOCK;
2023 /**
2024 * Return {@code true} if this is a documentation comment.
2025 * @return {@code true} if this is a documentation comment
2026 */
2027 bool isDocumentation() => _type == CommentType.DOCUMENTATION;
2028 /**
2029 * Return {@code true} if this is an end-of-line comment.
2030 * @return {@code true} if this is an end-of-line comment
2031 */
2032 bool isEndOfLine() => _type == CommentType.END_OF_LINE;
2033 void visitChildren(ASTVisitor<Object> visitor) {
2034 _references.accept(visitor);
2035 }
2036 }
2037 /**
2038 * The enumeration {@code CommentType} encodes all the different types of commen ts that are
2039 * recognized by the parser.
2040 */
2041 class CommentType {
2042 /**
2043 * An end-of-line comment.
2044 */
2045 static final CommentType END_OF_LINE = new CommentType('END_OF_LINE', 0);
2046 /**
2047 * A block comment.
2048 */
2049 static final CommentType BLOCK = new CommentType('BLOCK', 1);
2050 /**
2051 * A documentation comment.
2052 */
2053 static final CommentType DOCUMENTATION = new CommentType('DOCUMENTATION', 2);
2054 static final List<CommentType> values = [END_OF_LINE, BLOCK, DOCUMENTATION];
2055 final String __name;
2056 final int __ordinal;
2057 CommentType(this.__name, this.__ordinal) {
2058 }
2059 String toString() => __name;
2060 }
2061 /**
2062 * Instances of the class {@code CommentReference} represent a reference to a Da rt element that is
2063 * found within a documentation comment.
2064 * <pre>
2065 * commentReference ::=
2066 * '[' 'new'? {@link Identifier identifier} ']'
2067 * </pre>
2068 */
2069 class CommentReference extends ASTNode {
2070 /**
2071 * The token representing the 'new' keyword, or {@code null} if there was no ' new' keyword.
2072 */
2073 Token _newKeyword;
2074 /**
2075 * The identifier being referenced.
2076 */
2077 Identifier _identifier;
2078 /**
2079 * Initialize a newly created reference to a Dart element.
2080 * @param newKeyword the token representing the 'new' keyword
2081 * @param identifier the identifier being referenced
2082 */
2083 CommentReference(Token newKeyword, Identifier identifier) {
2084 this._newKeyword = newKeyword;
2085 this._identifier = becomeParentOf(identifier);
2086 }
2087 accept(ASTVisitor visitor) => visitor.visitCommentReference(this);
2088 Token get beginToken => _identifier.beginToken;
2089 Token get endToken => _identifier.endToken;
2090 /**
2091 * Return the identifier being referenced.
2092 * @return the identifier being referenced
2093 */
2094 Identifier get identifier => _identifier;
2095 /**
2096 * Return the token representing the 'new' keyword, or {@code null} if there w as no 'new' keyword.
2097 * @return the token representing the 'new' keyword
2098 */
2099 Token get newKeyword => _newKeyword;
2100 /**
2101 * Set the identifier being referenced to the given identifier.
2102 * @param identifier the identifier being referenced
2103 */
2104 void set identifier3(Identifier identifier) {
2105 identifier = becomeParentOf(identifier);
2106 }
2107 /**
2108 * Set the token representing the 'new' keyword to the given token.
2109 * @param newKeyword the token representing the 'new' keyword
2110 */
2111 void set newKeyword2(Token newKeyword) {
2112 this._newKeyword = newKeyword;
2113 }
2114 void visitChildren(ASTVisitor<Object> visitor) {
2115 safelyVisitChild(_identifier, visitor);
2116 }
2117 }
2118 /**
2119 * Instances of the class {@code CompilationUnit} represent a compilation unit.
2120 * <p>
2121 * While the grammar restricts the order of the directives and declarations with in a compilation
2122 * unit, this class does not enforce those restrictions. In particular, the chil dren of a
2123 * compilation unit will be visited in lexical order even if lexical order does not conform to the
2124 * restrictions of the grammar.
2125 * <pre>
2126 * compilationUnit ::=
2127 * directives declarations
2128 * 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>
2129 */
2130 class CompilationUnit extends ASTNode {
2131 /**
2132 * The first token in the token stream that was parsed to form this compilatio n unit.
2133 */
2134 Token _beginToken;
2135 /**
2136 * The script tag at the beginning of the compilation unit, or {@code null} if there is no script
2137 * tag in this compilation unit.
2138 */
2139 ScriptTag _scriptTag;
2140 /**
2141 * The directives contained in this compilation unit.
2142 */
2143 NodeList<Directive> _directives;
2144 /**
2145 * The declarations contained in this compilation unit.
2146 */
2147 NodeList<CompilationUnitMember> _declarations;
2148 /**
2149 * The last token in the token stream that was parsed to form this compilation unit. This token
2150 * should always have a type of {@link TokenType.EOF}.
2151 */
2152 Token _endToken;
2153 /**
2154 * The element associated with this compilation unit, or {@code null} if the A ST structure has not
2155 * been resolved.
2156 */
2157 CompilationUnitElement _element;
2158 /**
2159 * The syntax errors encountered when the receiver was parsed.
2160 */
2161 List<AnalysisError> _syntacticErrors;
2162 /**
2163 * Initialize a newly created compilation unit to have the given directives an d declarations.
2164 * @param beginToken the first token in the token stream
2165 * @param scriptTag the script tag at the beginning of the compilation unit
2166 * @param directives the directives contained in this compilation unit
2167 * @param declarations the declarations contained in this compilation unit
2168 * @param endToken the last token in the token stream
2169 */
2170 CompilationUnit(Token beginToken, ScriptTag scriptTag, List<Directive> directi ves, List<CompilationUnitMember> declarations, Token endToken) {
2171 this._directives = new NodeList<Directive>(this);
2172 this._declarations = new NodeList<CompilationUnitMember>(this);
2173 this._beginToken = beginToken;
2174 this._scriptTag = becomeParentOf(scriptTag);
2175 this._directives.addAll(directives);
2176 this._declarations.addAll(declarations);
2177 this._endToken = endToken;
2178 }
2179 accept(ASTVisitor visitor) => visitor.visitCompilationUnit(this);
2180 Token get beginToken => _beginToken;
2181 /**
2182 * Return the declarations contained in this compilation unit.
2183 * @return the declarations contained in this compilation unit
2184 */
2185 NodeList<CompilationUnitMember> get declarations => _declarations;
2186 /**
2187 * Return the directives contained in this compilation unit.
2188 * @return the directives contained in this compilation unit
2189 */
2190 NodeList<Directive> get directives => _directives;
2191 /**
2192 * Return the element associated with this compilation unit, or {@code null} i f the AST structure
2193 * has not been resolved.
2194 * @return the element associated with this compilation unit
2195 */
2196 CompilationUnitElement get element => _element;
2197 Token get endToken => _endToken;
2198 /**
2199 * Return an array containing all of the errors associated with the receiver. If the receiver has
2200 * not been resolved, then return {@code null}.
2201 * @return an array of errors (contains no {@code null}s) or {@code null} if t he receiver has not
2202 * been resolved
2203 */
2204 List<AnalysisError> get errors {
2205 throw new UnsupportedOperationException();
2206 }
2207 int get length {
2208 Token endToken4 = endToken;
2209 if (endToken4 == null) {
2210 return 0;
2211 }
2212 return endToken4.offset + endToken4.length - beginToken.offset;
2213 }
2214 int get offset {
2215 Token beginToken4 = beginToken;
2216 if (beginToken4 == null) {
2217 return 0;
2218 }
2219 return beginToken4.offset;
2220 }
2221 /**
2222 * Return the script tag at the beginning of the compilation unit, or {@code n ull} if there is no
2223 * script tag in this compilation unit.
2224 * @return the script tag at the beginning of the compilation unit
2225 */
2226 ScriptTag get scriptTag => _scriptTag;
2227 /**
2228 * Return an array containing all of the semantic errors associated with the r eceiver. If the
2229 * receiver has not been resolved, then return {@code null}.
2230 * @return an array of errors (contains no {@code null}s) or {@code null} if t he receiver has not
2231 * been resolved
2232 */
2233 List<AnalysisError> get semanticErrors {
2234 throw new UnsupportedOperationException();
2235 }
2236 /**
2237 * Return an array containing all of the syntactic errors associated with the receiver.
2238 * @return an array of errors (not {@code null}, contains no {@code null}s).
2239 */
2240 List<AnalysisError> get syntacticErrors => _syntacticErrors;
2241 /**
2242 * Set the element associated with this compilation unit to the given element.
2243 * @param element the element associated with this compilation unit
2244 */
2245 void set element4(CompilationUnitElement element) {
2246 this._element = element;
2247 }
2248 /**
2249 * Set the script tag at the beginning of the compilation unit to the given sc ript tag.
2250 * @param scriptTag the script tag at the beginning of the compilation unit
2251 */
2252 void set scriptTag2(ScriptTag scriptTag) {
2253 this._scriptTag = becomeParentOf(scriptTag);
2254 }
2255 /**
2256 * Called by the {@link AnalysisContext} to cache the syntax errors when the u nit is parsed.
2257 * @param errors an array of syntax errors (not {@code null}, contains no {@co de null}s)
2258 */
2259 void set syntacticErrors2(List<AnalysisError> errors) {
2260 this._syntacticErrors = errors;
2261 }
2262 void visitChildren(ASTVisitor<Object> visitor) {
2263 safelyVisitChild(_scriptTag, visitor);
2264 if (directivesAreBeforeDeclarations()) {
2265 _directives.accept(visitor);
2266 _declarations.accept(visitor);
2267 } else {
2268 for (ASTNode child in sortedDirectivesAndDeclarations) {
2269 child.accept(visitor);
2270 }
2271 }
2272 }
2273 /**
2274 * Return {@code true} if all of the directives are lexically before any decla rations.
2275 * @return {@code true} if all of the directives are lexically before any decl arations
2276 */
2277 bool directivesAreBeforeDeclarations() {
2278 if (_directives.isEmpty || _declarations.isEmpty) {
2279 return true;
2280 }
2281 Directive lastDirective = _directives[_directives.length - 1];
2282 CompilationUnitMember firstDeclaration = _declarations[0];
2283 return lastDirective.offset < firstDeclaration.offset;
2284 }
2285 /**
2286 * Return an array containing all of the directives and declarations in this c ompilation unit,
2287 * sorted in lexical order.
2288 * @return the directives and declarations in this compilation unit in the ord er in which they
2289 * appeared in the original source
2290 */
2291 List<ASTNode> get sortedDirectivesAndDeclarations {
2292 List<ASTNode> childList = new List<ASTNode>();
2293 childList.addAll(_directives);
2294 childList.addAll(_declarations);
2295 List<ASTNode> children = new List.from(childList);
2296 children.sort();
2297 return children;
2298 }
2299 }
2300 /**
2301 * Instances of the class {@code CompilationUnitMember} defines the behavior com mon to nodes that
2302 * declare a name within the scope of a compilation unit.
2303 * <pre>
2304 * compilationUnitMember ::={@link ClassDeclaration classDeclaration}| {@link Ty peAlias typeAlias}| {@link FunctionDeclaration functionDeclaration}| {@link Meth odDeclaration getOrSetDeclaration}| {@link VariableDeclaration constantsDeclarat ion}| {@link VariableDeclaration variablesDeclaration}</pre>
2305 */
2306 abstract class CompilationUnitMember extends Declaration {
2307 /**
2308 * Initialize a newly created generic compilation unit member.
2309 * @param comment the documentation comment associated with this member
2310 * @param metadata the annotations associated with this member
2311 */
2312 CompilationUnitMember(Comment comment, List<Annotation> metadata) : super(comm ent, metadata) {
2313 }
2314 }
2315 /**
2316 * Instances of the class {@code ConditionalExpression} represent a conditional expression.
2317 * <pre>
2318 * conditionalExpression ::={@link Expression condition} '?' {@link Expression t henExpression} ':' {@link Expression elseExpression}</pre>
2319 */
2320 class ConditionalExpression extends Expression {
2321 /**
2322 * The condition used to determine which of the expressions is executed next.
2323 */
2324 Expression _condition;
2325 /**
2326 * The token used to separate the condition from the then expression.
2327 */
2328 Token _question;
2329 /**
2330 * The expression that is executed if the condition evaluates to {@code true}.
2331 */
2332 Expression _thenExpression;
2333 /**
2334 * The token used to separate the then expression from the else expression.
2335 */
2336 Token _colon;
2337 /**
2338 * The expression that is executed if the condition evaluates to {@code false} .
2339 */
2340 Expression _elseExpression;
2341 /**
2342 * Initialize a newly created conditional expression.
2343 * @param condition the condition used to determine which expression is execut ed next
2344 * @param question the token used to separate the condition from the then expr ession
2345 * @param thenExpression the expression that is executed if the condition eval uates to{@code true}
2346 * @param colon the token used to separate the then expression from the else e xpression
2347 * @param elseExpression the expression that is executed if the condition eval uates to{@code false}
2348 */
2349 ConditionalExpression(Expression condition, Token question, Expression thenExp ression, Token colon, Expression elseExpression) {
2350 this._condition = becomeParentOf(condition);
2351 this._question = question;
2352 this._thenExpression = becomeParentOf(thenExpression);
2353 this._colon = colon;
2354 this._elseExpression = becomeParentOf(elseExpression);
2355 }
2356 accept(ASTVisitor visitor) => visitor.visitConditionalExpression(this);
2357 Token get beginToken => _condition.beginToken;
2358 /**
2359 * Return the token used to separate the then expression from the else express ion.
2360 * @return the token used to separate the then expression from the else expres sion
2361 */
2362 Token get colon => _colon;
2363 /**
2364 * Return the condition used to determine which of the expressions is executed next.
2365 * @return the condition used to determine which expression is executed next
2366 */
2367 Expression get condition => _condition;
2368 /**
2369 * Return the expression that is executed if the condition evaluates to {@code false}.
2370 * @return the expression that is executed if the condition evaluates to {@cod e false}
2371 */
2372 Expression get elseExpression => _elseExpression;
2373 Token get endToken => _elseExpression.endToken;
2374 /**
2375 * Return the token used to separate the condition from the then expression.
2376 * @return the token used to separate the condition from the then expression
2377 */
2378 Token get question => _question;
2379 /**
2380 * Return the expression that is executed if the condition evaluates to {@code true}.
2381 * @return the expression that is executed if the condition evaluates to {@cod e true}
2382 */
2383 Expression get thenExpression => _thenExpression;
2384 /**
2385 * Set the token used to separate the then expression from the else expression to the given token.
2386 * @param colon the token used to separate the then expression from the else e xpression
2387 */
2388 void set colon2(Token colon) {
2389 this._colon = colon;
2390 }
2391 /**
2392 * Set the condition used to determine which of the expressions is executed ne xt to the given
2393 * expression.
2394 * @param expression the condition used to determine which expression is execu ted next
2395 */
2396 void set condition3(Expression expression) {
2397 _condition = becomeParentOf(expression);
2398 }
2399 /**
2400 * Set the expression that is executed if the condition evaluates to {@code fa lse} to the given
2401 * expression.
2402 * @param expression the expression that is executed if the condition evaluate s to {@code false}
2403 */
2404 void set elseExpression2(Expression expression) {
2405 _elseExpression = becomeParentOf(expression);
2406 }
2407 /**
2408 * Set the token used to separate the condition from the then expression to th e given token.
2409 * @param question the token used to separate the condition from the then expr ession
2410 */
2411 void set question3(Token question) {
2412 this._question = question;
2413 }
2414 /**
2415 * Set the expression that is executed if the condition evaluates to {@code tr ue} to the given
2416 * expression.
2417 * @param expression the expression that is executed if the condition evaluate s to {@code true}
2418 */
2419 void set thenExpression2(Expression expression) {
2420 _thenExpression = becomeParentOf(expression);
2421 }
2422 void visitChildren(ASTVisitor<Object> visitor) {
2423 safelyVisitChild(_condition, visitor);
2424 safelyVisitChild(_thenExpression, visitor);
2425 safelyVisitChild(_elseExpression, visitor);
2426 }
2427 }
2428 /**
2429 * Instances of the class {@code ConstructorDeclaration} represent a constructor declaration.
2430 * <pre>
2431 * constructorDeclaration ::=
2432 * constructorSignature {@link FunctionBody body}?
2433 * | constructorName formalParameterList ':' 'this' ('.' {@link SimpleIdentifier name})? arguments
2434 * constructorSignature ::=
2435 * 'external'? constructorName formalParameterList initializerList?
2436 * | 'external'? 'factory' factoryName formalParameterList initializerList?
2437 * | 'external'? 'const' constructorName formalParameterList initializerList?
2438 * constructorName ::={@link SimpleIdentifier returnType} ('.' {@link SimpleIden tifier name})?
2439 * factoryName ::={@link Identifier returnType} ('.' {@link SimpleIdentifier nam e})?
2440 * initializerList ::=
2441 * ':' {@link ConstructorInitializer initializer} (',' {@link ConstructorInitial izer initializer})
2442 * </pre>
2443 */
2444 class ConstructorDeclaration extends ClassMember {
2445 /**
2446 * The token for the 'external' keyword, or {@code null} if the constructor is not external.
2447 */
2448 Token _externalKeyword;
2449 /**
2450 * The token for the 'const' keyword.
2451 */
2452 Token _constKeyword;
2453 /**
2454 * The token for the 'factory' keyword.
2455 */
2456 Token _factoryKeyword;
2457 /**
2458 * The type of object being created. This can be different than the type in wh ich the constructor
2459 * is being declared if the constructor is the implementation of a factory con structor.
2460 */
2461 Identifier _returnType;
2462 /**
2463 * The token for the period before the constructor name, or {@code null} if th e constructor being
2464 * declared is unnamed.
2465 */
2466 Token _period;
2467 /**
2468 * The name of the constructor, or {@code null} if the constructor being decla red is unnamed.
2469 */
2470 SimpleIdentifier _name;
2471 /**
2472 * The element associated with this constructor, or {@code null} if the AST st ructure has not been
2473 * resolved or if this constructor could not be resolved.
2474 */
2475 ConstructorElement _element;
2476 /**
2477 * The parameters associated with the constructor.
2478 */
2479 FormalParameterList _parameters;
2480 /**
2481 * The token for the separator (colon or equals) before the initializers, or { @code null} if there
2482 * are no initializers.
2483 */
2484 Token _separator;
2485 /**
2486 * The initializers associated with the constructor.
2487 */
2488 NodeList<ConstructorInitializer> _initializers;
2489 /**
2490 * The name of the constructor to which this constructor will be redirected, o r {@code null} if
2491 * this is not a redirecting factory constructor.
2492 */
2493 ConstructorName _redirectedConstructor;
2494 /**
2495 * The body of the constructor, or {@code null} if the constructor does not ha ve a body.
2496 */
2497 FunctionBody _body;
2498 /**
2499 * Initialize a newly created constructor declaration.
2500 * @param externalKeyword the token for the 'external' keyword
2501 * @param comment the documentation comment associated with this constructor
2502 * @param metadata the annotations associated with this constructor
2503 * @param constKeyword the token for the 'const' keyword
2504 * @param factoryKeyword the token for the 'factory' keyword
2505 * @param returnType the return type of the constructor
2506 * @param period the token for the period before the constructor name
2507 * @param name the name of the constructor
2508 * @param parameters the parameters associated with the constructor
2509 * @param separator the token for the colon or equals before the initializers
2510 * @param initializers the initializers associated with the constructor
2511 * @param redirectedConstructor the name of the constructor to which this cons tructor will be
2512 * redirected
2513 * @param body the body of the constructor
2514 */
2515 ConstructorDeclaration(Comment comment, List<Annotation> metadata, Token exter nalKeyword, Token constKeyword, Token factoryKeyword, Identifier returnType, Tok en period, SimpleIdentifier name, FormalParameterList parameters, Token separato r, List<ConstructorInitializer> initializers, ConstructorName redirectedConstruc tor, FunctionBody body) : super(comment, metadata) {
2516 this._initializers = new NodeList<ConstructorInitializer>(this);
2517 this._externalKeyword = externalKeyword;
2518 this._constKeyword = constKeyword;
2519 this._factoryKeyword = factoryKeyword;
2520 this._returnType = becomeParentOf(returnType);
2521 this._period = period;
2522 this._name = becomeParentOf(name);
2523 this._parameters = becomeParentOf(parameters);
2524 this._separator = separator;
2525 this._initializers.addAll(initializers);
2526 this._redirectedConstructor = becomeParentOf(redirectedConstructor);
2527 this._body = becomeParentOf(body);
2528 }
2529 accept(ASTVisitor visitor) => visitor.visitConstructorDeclaration(this);
2530 /**
2531 * Return the body of the constructor, or {@code null} if the constructor does not have a body.
2532 * @return the body of the constructor
2533 */
2534 FunctionBody get body => _body;
2535 /**
2536 * Return the token for the 'const' keyword.
2537 * @return the token for the 'const' keyword
2538 */
2539 Token get constKeyword => _constKeyword;
2540 /**
2541 * Return the element associated with this constructor , or {@code null} if th e AST structure has
2542 * not been resolved or if this constructor could not be resolved.
2543 * @return the element associated with this constructor
2544 */
2545 ConstructorElement get element => _element;
2546 Token get endToken {
2547 if (_body != null) {
2548 return _body.endToken;
2549 } else if (!_initializers.isEmpty) {
2550 return _initializers.endToken;
2551 }
2552 return _parameters.endToken;
2553 }
2554 /**
2555 * Return the token for the 'external' keyword, or {@code null} if the constru ctor is not
2556 * external.
2557 * @return the token for the 'external' keyword
2558 */
2559 Token get externalKeyword => _externalKeyword;
2560 /**
2561 * Return the token for the 'factory' keyword.
2562 * @return the token for the 'factory' keyword
2563 */
2564 Token get factoryKeyword => _factoryKeyword;
2565 /**
2566 * Return the initializers associated with the constructor.
2567 * @return the initializers associated with the constructor
2568 */
2569 NodeList<ConstructorInitializer> get initializers => _initializers;
2570 /**
2571 * Return the name of the constructor, or {@code null} if the constructor bein g declared is
2572 * unnamed.
2573 * @return the name of the constructor
2574 */
2575 SimpleIdentifier get name => _name;
2576 /**
2577 * Return the parameters associated with the constructor.
2578 * @return the parameters associated with the constructor
2579 */
2580 FormalParameterList get parameters => _parameters;
2581 /**
2582 * Return the token for the period before the constructor name, or {@code null } if the constructor
2583 * being declared is unnamed.
2584 * @return the token for the period before the constructor name
2585 */
2586 Token get period => _period;
2587 /**
2588 * 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.
2589 * @return the name of the constructor to which this constructor will be redir ected
2590 */
2591 ConstructorName get redirectedConstructor => _redirectedConstructor;
2592 /**
2593 * Return the type of object being created. This can be different than the typ e in which the
2594 * constructor is being declared if the constructor is the implementation of a factory
2595 * constructor.
2596 * @return the type of object being created
2597 */
2598 Identifier get returnType => _returnType;
2599 /**
2600 * Return the token for the separator (colon or equals) before the initializer s, or {@code null}if there are no initializers.
2601 * @return the token for the separator (colon or equals) before the initialize rs
2602 */
2603 Token get separator => _separator;
2604 /**
2605 * Set the body of the constructor to the given function body.
2606 * @param functionBody the body of the constructor
2607 */
2608 void set body3(FunctionBody functionBody) {
2609 _body = becomeParentOf(functionBody);
2610 }
2611 /**
2612 * Set the token for the 'const' keyword to the given token.
2613 * @param constKeyword the token for the 'const' keyword
2614 */
2615 void set constKeyword2(Token constKeyword) {
2616 this._constKeyword = constKeyword;
2617 }
2618 /**
2619 * Set the element associated with this constructor to the given element.
2620 * @param element the element associated with this constructor
2621 */
2622 void set element5(ConstructorElement element) {
2623 this._element = element;
2624 }
2625 /**
2626 * Set the token for the 'external' keyword to the given token.
2627 * @param externalKeyword the token for the 'external' keyword
2628 */
2629 void set externalKeyword2(Token externalKeyword) {
2630 this._externalKeyword = externalKeyword;
2631 }
2632 /**
2633 * Set the token for the 'factory' keyword to the given token.
2634 * @param factoryKeyword the token for the 'factory' keyword
2635 */
2636 void set factoryKeyword2(Token factoryKeyword) {
2637 this._factoryKeyword = factoryKeyword;
2638 }
2639 /**
2640 * Set the name of the constructor to the given identifier.
2641 * @param identifier the name of the constructor
2642 */
2643 void set name5(SimpleIdentifier identifier) {
2644 _name = becomeParentOf(identifier);
2645 }
2646 /**
2647 * Set the parameters associated with the constructor to the given list of par ameters.
2648 * @param parameters the parameters associated with the constructor
2649 */
2650 void set parameters2(FormalParameterList parameters) {
2651 this._parameters = becomeParentOf(parameters);
2652 }
2653 /**
2654 * Set the token for the period before the constructor name to the given token .
2655 * @param period the token for the period before the constructor name
2656 */
2657 void set period3(Token period) {
2658 this._period = period;
2659 }
2660 /**
2661 * Set the name of the constructor to which this constructor will be redirecte d to the given
2662 * constructor name.
2663 * @param redirectedConstructor the name of the constructor to which this cons tructor will be
2664 * redirected
2665 */
2666 void set redirectedConstructor2(ConstructorName redirectedConstructor) {
2667 this._redirectedConstructor = becomeParentOf(redirectedConstructor);
2668 }
2669 /**
2670 * Set the type of object being created to the given type name.
2671 * @param typeName the type of object being created
2672 */
2673 void set returnType2(Identifier typeName) {
2674 _returnType = becomeParentOf(typeName);
2675 }
2676 /**
2677 * Set the token for the separator (colon or equals) before the initializers t o the given token.
2678 * @param separator the token for the separator (colon or equals) before the i nitializers
2679 */
2680 void set separator2(Token separator) {
2681 this._separator = separator;
2682 }
2683 void visitChildren(ASTVisitor<Object> visitor) {
2684 super.visitChildren(visitor);
2685 safelyVisitChild(_returnType, visitor);
2686 safelyVisitChild(_name, visitor);
2687 safelyVisitChild(_parameters, visitor);
2688 _initializers.accept(visitor);
2689 safelyVisitChild(_body, visitor);
2690 }
2691 Token get firstTokenAfterCommentAndMetadata {
2692 Token leftMost2 = leftMost([_externalKeyword, _constKeyword, _factoryKeyword ]);
2693 if (leftMost2 != null) {
2694 return leftMost2;
2695 }
2696 return _returnType.beginToken;
2697 }
2698 /**
2699 * Return the left-most of the given tokens, or {@code null} if there are no t okens given or if
2700 * all of the given tokens are {@code null}.
2701 * @param tokens the tokens being compared to find the left-most token
2702 * @return the left-most of the given tokens
2703 */
2704 Token leftMost(List<Token> tokens) {
2705 Token leftMost = null;
2706 int offset = 2147483647;
2707 for (Token token in tokens) {
2708 if (token != null && token.offset < offset) {
2709 leftMost = token;
2710 }
2711 }
2712 return leftMost;
2713 }
2714 }
2715 /**
2716 * Instances of the class {@code ConstructorFieldInitializer} represent the init ialization of a
2717 * field within a constructor's initialization list.
2718 * <pre>
2719 * fieldInitializer ::=
2720 * ('this' '.')? {@link SimpleIdentifier fieldName} '=' {@link Expression condit ionalExpression cascadeSection*}</pre>
2721 */
2722 class ConstructorFieldInitializer extends ConstructorInitializer {
2723 /**
2724 * The token for the 'this' keyword, or {@code null} if there is no 'this' key word.
2725 */
2726 Token _keyword;
2727 /**
2728 * The token for the period after the 'this' keyword, or {@code null} if there is no 'this'
2729 * keyword.
2730 */
2731 Token _period;
2732 /**
2733 * The name of the field being initialized.
2734 */
2735 SimpleIdentifier _fieldName;
2736 /**
2737 * The token for the equal sign between the field name and the expression.
2738 */
2739 Token _equals;
2740 /**
2741 * The expression computing the value to which the field will be initialized.
2742 */
2743 Expression _expression;
2744 /**
2745 * Initialize a newly created field initializer to initialize the field with t he given name to the
2746 * value of the given expression.
2747 * @param keyword the token for the 'this' keyword
2748 * @param period the token for the period after the 'this' keyword
2749 * @param fieldName the name of the field being initialized
2750 * @param equals the token for the equal sign between the field name and the e xpression
2751 * @param expression the expression computing the value to which the field wil l be initialized
2752 */
2753 ConstructorFieldInitializer(Token keyword, Token period, SimpleIdentifier fiel dName, Token equals, Expression expression) {
2754 this._keyword = keyword;
2755 this._period = period;
2756 this._fieldName = becomeParentOf(fieldName);
2757 this._equals = equals;
2758 this._expression = becomeParentOf(expression);
2759 }
2760 accept(ASTVisitor visitor) => visitor.visitConstructorFieldInitializer(this);
2761 Token get beginToken {
2762 if (_keyword != null) {
2763 return _keyword;
2764 }
2765 return _fieldName.beginToken;
2766 }
2767 Token get endToken => _expression.endToken;
2768 /**
2769 * Return the token for the equal sign between the field name and the expressi on.
2770 * @return the token for the equal sign between the field name and the express ion
2771 */
2772 Token get equals => _equals;
2773 /**
2774 * Return the expression computing the value to which the field will be initia lized.
2775 * @return the expression computing the value to which the field will be initi alized
2776 */
2777 Expression get expression => _expression;
2778 /**
2779 * Return the name of the field being initialized.
2780 * @return the name of the field being initialized
2781 */
2782 SimpleIdentifier get fieldName => _fieldName;
2783 /**
2784 * Return the token for the 'this' keyword, or {@code null} if there is no 'th is' keyword.
2785 * @return the token for the 'this' keyword
2786 */
2787 Token get keyword => _keyword;
2788 /**
2789 * Return the token for the period after the 'this' keyword, or {@code null} i f there is no 'this'
2790 * keyword.
2791 * @return the token for the period after the 'this' keyword
2792 */
2793 Token get period => _period;
2794 /**
2795 * Set the token for the equal sign between the field name and the expression to the given token.
2796 * @param equals the token for the equal sign between the field name and the e xpression
2797 */
2798 void set equals5(Token equals) {
2799 this._equals = equals;
2800 }
2801 /**
2802 * Set the expression computing the value to which the field will be initializ ed to the given
2803 * expression.
2804 * @param expression the expression computing the value to which the field wil l be initialized
2805 */
2806 void set expression3(Expression expression) {
2807 this._expression = becomeParentOf(expression);
2808 }
2809 /**
2810 * Set the name of the field being initialized to the given identifier.
2811 * @param identifier the name of the field being initialized
2812 */
2813 void set fieldName2(SimpleIdentifier identifier) {
2814 _fieldName = becomeParentOf(identifier);
2815 }
2816 /**
2817 * Set the token for the 'this' keyword to the given token.
2818 * @param keyword the token for the 'this' keyword
2819 */
2820 void set keyword6(Token keyword) {
2821 this._keyword = keyword;
2822 }
2823 /**
2824 * Set the token for the period after the 'this' keyword to the given token.
2825 * @param period the token for the period after the 'this' keyword
2826 */
2827 void set period4(Token period) {
2828 this._period = period;
2829 }
2830 void visitChildren(ASTVisitor<Object> visitor) {
2831 safelyVisitChild(_fieldName, visitor);
2832 safelyVisitChild(_expression, visitor);
2833 }
2834 }
2835 /**
2836 * Instances of the class {@code ConstructorInitializer} defines the behavior of nodes that can
2837 * occur in the initializer list of a constructor declaration.
2838 * <pre>
2839 * constructorInitializer ::={@link SuperConstructorInvocation superInvocation}| {@link ConstructorFieldInitializer fieldInitializer}</pre>
2840 */
2841 abstract class ConstructorInitializer extends ASTNode {
2842 }
2843 /**
2844 * Instances of the class {@code ConstructorName} represent the name of the cons tructor.
2845 * <pre>
2846 * constructorName:
2847 * type ('.' identifier)?
2848 * </pre>
2849 */
2850 class ConstructorName extends ASTNode {
2851 /**
2852 * The name of the type defining the constructor.
2853 */
2854 TypeName _type;
2855 /**
2856 * The token for the period before the constructor name, or {@code null} if th e specified
2857 * constructor is the unnamed constructor.
2858 */
2859 Token _period;
2860 /**
2861 * The name of the constructor, or {@code null} if the specified constructor i s the unnamed
2862 * constructor.
2863 */
2864 SimpleIdentifier _name;
2865 /**
2866 * The element associated with this constructor name, or {@code null} if the A ST structure has not
2867 * been resolved or if this constructor name could not be resolved.
2868 */
2869 ConstructorElement _element;
2870 /**
2871 * Initialize a newly created constructor name.
2872 * @param type the name of the type defining the constructor
2873 * @param period the token for the period before the constructor name
2874 * @param name the name of the constructor
2875 */
2876 ConstructorName(TypeName type, Token period, SimpleIdentifier name) {
2877 this._type = becomeParentOf(type);
2878 this._period = period;
2879 this._name = becomeParentOf(name);
2880 }
2881 accept(ASTVisitor visitor) => visitor.visitConstructorName(this);
2882 Token get beginToken => _type.beginToken;
2883 /**
2884 * Return the element associated with this constructor name, or {@code null} i f the AST structure
2885 * has not been resolved or if this constructor name could not be resolved.
2886 * @return the element associated with this constructor name
2887 */
2888 ConstructorElement get element => _element;
2889 Token get endToken {
2890 if (_name != null) {
2891 return _name.endToken;
2892 }
2893 return _type.endToken;
2894 }
2895 /**
2896 * Return the name of the constructor, or {@code null} if the specified constr uctor is the unnamed
2897 * constructor.
2898 * @return the name of the constructor
2899 */
2900 SimpleIdentifier get name => _name;
2901 /**
2902 * Return the token for the period before the constructor name, or {@code null } if the specified
2903 * constructor is the unnamed constructor.
2904 * @return the token for the period before the constructor name
2905 */
2906 Token get period => _period;
2907 /**
2908 * Return the name of the type defining the constructor.
2909 * @return the name of the type defining the constructor
2910 */
2911 TypeName get type => _type;
2912 /**
2913 * Set the element associated with this constructor name to the given element.
2914 * @param element the element associated with this constructor name
2915 */
2916 void set element6(ConstructorElement element) {
2917 this._element = element;
2918 }
2919 /**
2920 * Set the name of the constructor to the given name.
2921 * @param name the name of the constructor
2922 */
2923 void set name6(SimpleIdentifier name) {
2924 this._name = becomeParentOf(name);
2925 }
2926 /**
2927 * Return the token for the period before the constructor name to the given to ken.
2928 * @param period the token for the period before the constructor name
2929 */
2930 void set period5(Token period) {
2931 this._period = period;
2932 }
2933 /**
2934 * Set the name of the type defining the constructor to the given type name.
2935 * @param type the name of the type defining the constructor
2936 */
2937 void set type3(TypeName type) {
2938 this._type = becomeParentOf(type);
2939 }
2940 void visitChildren(ASTVisitor<Object> visitor) {
2941 safelyVisitChild(_type, visitor);
2942 safelyVisitChild(_name, visitor);
2943 }
2944 }
2945 /**
2946 * Instances of the class {@code ContinueStatement} represent a continue stateme nt.
2947 * <pre>
2948 * continueStatement ::=
2949 * 'continue' {@link SimpleIdentifier label}? ';'
2950 * </pre>
2951 */
2952 class ContinueStatement extends Statement {
2953 /**
2954 * The token representing the 'continue' keyword.
2955 */
2956 Token _keyword;
2957 /**
2958 * The label associated with the statement, or {@code null} if there is no lab el.
2959 */
2960 SimpleIdentifier _label;
2961 /**
2962 * The semicolon terminating the statement.
2963 */
2964 Token _semicolon;
2965 /**
2966 * Initialize a newly created continue statement.
2967 * @param keyword the token representing the 'continue' keyword
2968 * @param label the label associated with the statement
2969 * @param semicolon the semicolon terminating the statement
2970 */
2971 ContinueStatement(Token keyword, SimpleIdentifier label, Token semicolon) {
2972 this._keyword = keyword;
2973 this._label = becomeParentOf(label);
2974 this._semicolon = semicolon;
2975 }
2976 accept(ASTVisitor visitor) => visitor.visitContinueStatement(this);
2977 Token get beginToken => _keyword;
2978 Token get endToken => _semicolon;
2979 /**
2980 * Return the token representing the 'continue' keyword.
2981 * @return the token representing the 'continue' keyword
2982 */
2983 Token get keyword => _keyword;
2984 /**
2985 * Return the label associated with the statement, or {@code null} if there is no label.
2986 * @return the label associated with the statement
2987 */
2988 SimpleIdentifier get label => _label;
2989 /**
2990 * Return the semicolon terminating the statement.
2991 * @return the semicolon terminating the statement
2992 */
2993 Token get semicolon => _semicolon;
2994 /**
2995 * Set the token representing the 'continue' keyword to the given token.
2996 * @param keyword the token representing the 'continue' keyword
2997 */
2998 void set keyword7(Token keyword) {
2999 this._keyword = keyword;
3000 }
3001 /**
3002 * Set the label associated with the statement to the given label.
3003 * @param identifier the label associated with the statement
3004 */
3005 void set label3(SimpleIdentifier identifier) {
3006 _label = becomeParentOf(identifier);
3007 }
3008 /**
3009 * Set the semicolon terminating the statement to the given token.
3010 * @param semicolon the semicolon terminating the statement
3011 */
3012 void set semicolon4(Token semicolon) {
3013 this._semicolon = semicolon;
3014 }
3015 void visitChildren(ASTVisitor<Object> visitor) {
3016 safelyVisitChild(_label, visitor);
3017 }
3018 }
3019 /**
3020 * The abstract class {@code Declaration} defines the behavior common to nodes t hat represent the
3021 * declaration of a name. Each declared name is visible within a name scope.
3022 */
3023 abstract class Declaration extends AnnotatedNode {
3024 /**
3025 * Initialize a newly created declaration.
3026 * @param comment the documentation comment associated with this declaration
3027 * @param metadata the annotations associated with this declaration
3028 */
3029 Declaration(Comment comment, List<Annotation> metadata) : super(comment, metad ata) {
3030 }
3031 }
3032 /**
3033 * Instances of the class {@code DefaultFormalParameter} represent a formal para meter with a default
3034 * value. There are two kinds of parameters that are both represented by this cl ass: named formal
3035 * parameters and positional formal parameters.
3036 * <pre>
3037 * defaultFormalParameter ::={@link NormalFormalParameter normalFormalParameter} ('=' {@link Expression defaultValue})?
3038 * defaultNamedParameter ::={@link NormalFormalParameter normalFormalParameter} (':' {@link Expression defaultValue})?
3039 * </pre>
3040 */
3041 class DefaultFormalParameter extends FormalParameter {
3042 /**
3043 * The formal parameter with which the default value is associated.
3044 */
3045 NormalFormalParameter _parameter;
3046 /**
3047 * The kind of this parameter.
3048 */
3049 ParameterKind _kind;
3050 /**
3051 * The token separating the parameter from the default value, or {@code null} if there is no
3052 * default value.
3053 */
3054 Token _separator;
3055 /**
3056 * The expression computing the default value for the parameter, or {@code nul l} if there is no
3057 * default value.
3058 */
3059 Expression _defaultValue;
3060 /**
3061 * Initialize a newly created default formal parameter.
3062 * @param parameter the formal parameter with which the default value is assoc iated
3063 * @param kind the kind of this parameter
3064 * @param separator the token separating the parameter from the default value
3065 * @param defaultValue the expression computing the default value for the para meter
3066 */
3067 DefaultFormalParameter(NormalFormalParameter parameter, ParameterKind kind, To ken separator, Expression defaultValue) {
3068 this._parameter = becomeParentOf(parameter);
3069 this._kind = kind;
3070 this._separator = separator;
3071 this._defaultValue = becomeParentOf(defaultValue);
3072 }
3073 accept(ASTVisitor visitor) => visitor.visitDefaultFormalParameter(this);
3074 Token get beginToken => _parameter.beginToken;
3075 /**
3076 * Return the expression computing the default value for the parameter, or {@c ode null} if there
3077 * is no default value.
3078 * @return the expression computing the default value for the parameter
3079 */
3080 Expression get defaultValue => _defaultValue;
3081 Token get endToken {
3082 if (_defaultValue != null) {
3083 return _defaultValue.endToken;
3084 }
3085 return _parameter.endToken;
3086 }
3087 SimpleIdentifier get identifier => _parameter.identifier;
3088 ParameterKind get kind => _kind;
3089 /**
3090 * Return the formal parameter with which the default value is associated.
3091 * @return the formal parameter with which the default value is associated
3092 */
3093 NormalFormalParameter get parameter => _parameter;
3094 /**
3095 * Return the token separating the parameter from the default value, or {@code null} if there is
3096 * no default value.
3097 * @return the token separating the parameter from the default value
3098 */
3099 Token get separator => _separator;
3100 /**
3101 * Return {@code true} if this parameter is a const parameter.
3102 * @return {@code true} if this parameter is a const parameter
3103 */
3104 bool isConst() => _parameter != null && _parameter.isConst();
3105 /**
3106 * Return {@code true} if this parameter is a final parameter.
3107 * @return {@code true} if this parameter is a final parameter
3108 */
3109 bool isFinal() => _parameter != null && _parameter.isFinal();
3110 /**
3111 * Set the expression computing the default value for the parameter to the giv en expression.
3112 * @param expression the expression computing the default value for the parame ter
3113 */
3114 void set defaultValue2(Expression expression) {
3115 _defaultValue = becomeParentOf(expression);
3116 }
3117 /**
3118 * Set the kind of this parameter to the given kind.
3119 * @param kind the kind of this parameter
3120 */
3121 void set kind2(ParameterKind kind) {
3122 this._kind = kind;
3123 }
3124 /**
3125 * Set the formal parameter with which the default value is associated to the given parameter.
3126 * @param formalParameter the formal parameter with which the default value is associated
3127 */
3128 void set parameter2(NormalFormalParameter formalParameter) {
3129 _parameter = becomeParentOf(formalParameter);
3130 }
3131 /**
3132 * Set the token separating the parameter from the default value to the given token.
3133 * @param separator the token separating the parameter from the default value
3134 */
3135 void set separator3(Token separator) {
3136 this._separator = separator;
3137 }
3138 void visitChildren(ASTVisitor<Object> visitor) {
3139 safelyVisitChild(_parameter, visitor);
3140 safelyVisitChild(_defaultValue, visitor);
3141 }
3142 }
3143 /**
3144 * The abstract class {@code Directive} defines the behavior common to nodes tha t represent a
3145 * directive.
3146 * <pre>
3147 * directive ::={@link ExportDirective exportDirective}| {@link ImportDirective importDirective}| {@link LibraryDirective libraryDirective}| {@link PartDirectiv e partDirective}| {@link PartOfDirective partOfDirective}</pre>
3148 */
3149 abstract class Directive extends AnnotatedNode {
3150 /**
3151 * The element associated with this directive, or {@code null} if the AST stru cture has not been
3152 * resolved or if this directive could not be resolved.
3153 */
3154 Element _element;
3155 /**
3156 * Initialize a newly create directive.
3157 * @param comment the documentation comment associated with this directive
3158 * @param metadata the annotations associated with the directive
3159 */
3160 Directive(Comment comment, List<Annotation> metadata) : super(comment, metadat a) {
3161 }
3162 /**
3163 * Return the element associated with this directive, or {@code null} if the A ST structure has not
3164 * been resolved or if this directive could not be resolved. Examples of the l atter case include a
3165 * directive that contains an invalid URL or a URL that does not exist.
3166 * @return the element associated with this directive
3167 */
3168 Element get element => _element;
3169 /**
3170 * Return the token representing the keyword that introduces this directive (' import', 'export',
3171 * 'library' or 'part').
3172 * @return the token representing the keyword that introduces this directive
3173 */
3174 Token get keyword;
3175 /**
3176 * Set the element associated with this directive to the given element.
3177 * @param element the element associated with this directive
3178 */
3179 void set element7(Element element) {
3180 this._element = element;
3181 }
3182 }
3183 /**
3184 * Instances of the class {@code DoStatement} represent a do statement.
3185 * <pre>
3186 * doStatement ::=
3187 * 'do' {@link Statement body} 'while' '(' {@link Expression condition} ')' ';'
3188 * </pre>
3189 */
3190 class DoStatement extends Statement {
3191 /**
3192 * The token representing the 'do' keyword.
3193 */
3194 Token _doKeyword;
3195 /**
3196 * The body of the loop.
3197 */
3198 Statement _body;
3199 /**
3200 * The token representing the 'while' keyword.
3201 */
3202 Token _whileKeyword;
3203 /**
3204 * The left parenthesis.
3205 */
3206 Token _leftParenthesis;
3207 /**
3208 * The condition that determines when the loop will terminate.
3209 */
3210 Expression _condition;
3211 /**
3212 * The right parenthesis.
3213 */
3214 Token _rightParenthesis;
3215 /**
3216 * The semicolon terminating the statement.
3217 */
3218 Token _semicolon;
3219 /**
3220 * Initialize a newly created do loop.
3221 * @param doKeyword the token representing the 'do' keyword
3222 * @param body the body of the loop
3223 * @param whileKeyword the token representing the 'while' keyword
3224 * @param leftParenthesis the left parenthesis
3225 * @param condition the condition that determines when the loop will terminate
3226 * @param rightParenthesis the right parenthesis
3227 * @param semicolon the semicolon terminating the statement
3228 */
3229 DoStatement(Token doKeyword, Statement body, Token whileKeyword, Token leftPar enthesis, Expression condition, Token rightParenthesis, Token semicolon) {
3230 this._doKeyword = doKeyword;
3231 this._body = becomeParentOf(body);
3232 this._whileKeyword = whileKeyword;
3233 this._leftParenthesis = leftParenthesis;
3234 this._condition = becomeParentOf(condition);
3235 this._rightParenthesis = rightParenthesis;
3236 this._semicolon = semicolon;
3237 }
3238 accept(ASTVisitor visitor) => visitor.visitDoStatement(this);
3239 Token get beginToken => _doKeyword;
3240 /**
3241 * Return the body of the loop.
3242 * @return the body of the loop
3243 */
3244 Statement get body => _body;
3245 /**
3246 * Return the condition that determines when the loop will terminate.
3247 * @return the condition that determines when the loop will terminate
3248 */
3249 Expression get condition => _condition;
3250 /**
3251 * Return the token representing the 'do' keyword.
3252 * @return the token representing the 'do' keyword
3253 */
3254 Token get doKeyword => _doKeyword;
3255 Token get endToken => _semicolon;
3256 /**
3257 * Return the left parenthesis.
3258 * @return the left parenthesis
3259 */
3260 Token get leftParenthesis => _leftParenthesis;
3261 /**
3262 * Return the right parenthesis.
3263 * @return the right parenthesis
3264 */
3265 Token get rightParenthesis => _rightParenthesis;
3266 /**
3267 * Return the semicolon terminating the statement.
3268 * @return the semicolon terminating the statement
3269 */
3270 Token get semicolon => _semicolon;
3271 /**
3272 * Return the token representing the 'while' keyword.
3273 * @return the token representing the 'while' keyword
3274 */
3275 Token get whileKeyword => _whileKeyword;
3276 /**
3277 * Set the body of the loop to the given statement.
3278 * @param statement the body of the loop
3279 */
3280 void set body4(Statement statement) {
3281 _body = becomeParentOf(statement);
3282 }
3283 /**
3284 * Set the condition that determines when the loop will terminate to the given expression.
3285 * @param expression the condition that determines when the loop will terminat e
3286 */
3287 void set condition4(Expression expression) {
3288 _condition = becomeParentOf(expression);
3289 }
3290 /**
3291 * Set the token representing the 'do' keyword to the given token.
3292 * @param doKeyword the token representing the 'do' keyword
3293 */
3294 void set doKeyword2(Token doKeyword) {
3295 this._doKeyword = doKeyword;
3296 }
3297 /**
3298 * Set the left parenthesis to the given token.
3299 * @param parenthesis the left parenthesis
3300 */
3301 void set leftParenthesis5(Token parenthesis) {
3302 _leftParenthesis = parenthesis;
3303 }
3304 /**
3305 * Set the right parenthesis to the given token.
3306 * @param parenthesis the right parenthesis
3307 */
3308 void set rightParenthesis5(Token parenthesis) {
3309 _rightParenthesis = parenthesis;
3310 }
3311 /**
3312 * Set the semicolon terminating the statement to the given token.
3313 * @param semicolon the semicolon terminating the statement
3314 */
3315 void set semicolon5(Token semicolon) {
3316 this._semicolon = semicolon;
3317 }
3318 /**
3319 * Set the token representing the 'while' keyword to the given token.
3320 * @param whileKeyword the token representing the 'while' keyword
3321 */
3322 void set whileKeyword2(Token whileKeyword) {
3323 this._whileKeyword = whileKeyword;
3324 }
3325 void visitChildren(ASTVisitor<Object> visitor) {
3326 safelyVisitChild(_body, visitor);
3327 safelyVisitChild(_condition, visitor);
3328 }
3329 }
3330 /**
3331 * Instances of the class {@code DoubleLiteral} represent a floating point liter al expression.
3332 * <pre>
3333 * doubleLiteral ::=
3334 * decimalDigit+ ('.' decimalDigit*)? exponent?
3335 * | '.' decimalDigit+ exponent?
3336 * exponent ::=
3337 * ('e' | 'E') ('+' | '-')? decimalDigit+
3338 * </pre>
3339 */
3340 class DoubleLiteral extends Literal {
3341 /**
3342 * The token representing the literal.
3343 */
3344 Token _literal;
3345 /**
3346 * The value of the literal.
3347 */
3348 double _value = 0.0;
3349 /**
3350 * Initialize a newly created floating point literal.
3351 * @param literal the token representing the literal
3352 * @param value the value of the literal
3353 */
3354 DoubleLiteral(Token literal, double value) {
3355 this._literal = literal;
3356 this._value = value;
3357 }
3358 accept(ASTVisitor visitor) => visitor.visitDoubleLiteral(this);
3359 Token get beginToken => _literal;
3360 Token get endToken => _literal;
3361 /**
3362 * Return the token representing the literal.
3363 * @return the token representing the literal
3364 */
3365 Token get literal => _literal;
3366 /**
3367 * Return the value of the literal.
3368 * @return the value of the literal
3369 */
3370 double get value => _value;
3371 /**
3372 * Set the token representing the literal to the given token.
3373 * @param literal the token representing the literal
3374 */
3375 void set literal3(Token literal) {
3376 this._literal = literal;
3377 }
3378 /**
3379 * Set the value of the literal to the given value.
3380 * @param value the value of the literal
3381 */
3382 void set value5(double value) {
3383 this._value = value;
3384 }
3385 void visitChildren(ASTVisitor<Object> visitor) {
3386 }
3387 }
3388 /**
3389 * Instances of the class {@code EmptyFunctionBody} represent an empty function body, which can only
3390 * appear in constructors or abstract methods.
3391 * <pre>
3392 * emptyFunctionBody ::=
3393 * ';'
3394 * </pre>
3395 */
3396 class EmptyFunctionBody extends FunctionBody {
3397 /**
3398 * The token representing the semicolon that marks the end of the function bod y.
3399 */
3400 Token _semicolon;
3401 /**
3402 * Initialize a newly created function body.
3403 * @param semicolon the token representing the semicolon that marks the end of the function body
3404 */
3405 EmptyFunctionBody(Token semicolon) {
3406 this._semicolon = semicolon;
3407 }
3408 accept(ASTVisitor visitor) => visitor.visitEmptyFunctionBody(this);
3409 Token get beginToken => _semicolon;
3410 Token get endToken => _semicolon;
3411 /**
3412 * Return the token representing the semicolon that marks the end of the funct ion body.
3413 * @return the token representing the semicolon that marks the end of the func tion body
3414 */
3415 Token get semicolon => _semicolon;
3416 /**
3417 * Set the token representing the semicolon that marks the end of the function body to the given
3418 * token.
3419 * @param semicolon the token representing the semicolon that marks the end of the function body
3420 */
3421 void set semicolon6(Token semicolon) {
3422 this._semicolon = semicolon;
3423 }
3424 void visitChildren(ASTVisitor<Object> visitor) {
3425 }
3426 }
3427 /**
3428 * Instances of the class {@code EmptyStatement} represent an empty statement.
3429 * <pre>
3430 * emptyStatement ::=
3431 * ';'
3432 * </pre>
3433 */
3434 class EmptyStatement extends Statement {
3435 /**
3436 * The semicolon terminating the statement.
3437 */
3438 Token _semicolon;
3439 /**
3440 * Initialize a newly created empty statement.
3441 * @param semicolon the semicolon terminating the statement
3442 */
3443 EmptyStatement(Token semicolon) {
3444 this._semicolon = semicolon;
3445 }
3446 accept(ASTVisitor visitor) => visitor.visitEmptyStatement(this);
3447 Token get beginToken => _semicolon;
3448 Token get endToken => _semicolon;
3449 /**
3450 * Return the semicolon terminating the statement.
3451 * @return the semicolon terminating the statement
3452 */
3453 Token get semicolon => _semicolon;
3454 /**
3455 * Set the semicolon terminating the statement to the given token.
3456 * @param semicolon the semicolon terminating the statement
3457 */
3458 void set semicolon7(Token semicolon) {
3459 this._semicolon = semicolon;
3460 }
3461 void visitChildren(ASTVisitor<Object> visitor) {
3462 }
3463 }
3464 /**
3465 * Instances of the class {@code ExportDirective} represent an export directive.
3466 * <pre>
3467 * exportDirective ::={@link Annotation metadata} 'export' {@link StringLiteral libraryUri} {@link Combinator combinator}* ';'
3468 * </pre>
3469 */
3470 class ExportDirective extends NamespaceDirective {
3471 /**
3472 * Initialize a newly created export directive.
3473 * @param comment the documentation comment associated with this directive
3474 * @param metadata the annotations associated with the directive
3475 * @param keyword the token representing the 'export' keyword
3476 * @param libraryUri the URI of the library being exported
3477 * @param combinators the combinators used to control which names are exported
3478 * @param semicolon the semicolon terminating the directive
3479 */
3480 ExportDirective(Comment comment, List<Annotation> metadata, Token keyword, Str ingLiteral libraryUri, List<Combinator> combinators, Token semicolon) : super(co mment, metadata, keyword, libraryUri, combinators, semicolon) {
3481 }
3482 accept(ASTVisitor visitor) => visitor.visitExportDirective(this);
3483 void visitChildren(ASTVisitor<Object> visitor) {
3484 super.visitChildren(visitor);
3485 safelyVisitChild(libraryUri, visitor);
3486 combinators.accept(visitor);
3487 }
3488 }
3489 /**
3490 * Instances of the class {@code Expression} defines the behavior common to node s that represent an
3491 * expression.
3492 * <pre>
3493 * expression ::={@link AssignmentExpression assignmentExpression}| {@link Condi tionalExpression conditionalExpression} cascadeSection
3494 * | {@link ThrowExpression throwExpression}</pre>
3495 */
3496 abstract class Expression extends ASTNode {
3497 /**
3498 * The static type of this expression, or {@code null} if the AST structure ha s not been resolved.
3499 */
3500 Type2 _staticType;
3501 /**
3502 * The propagated type of this expression, or {@code null} if type propagation has not been
3503 * performed on the AST structure.
3504 */
3505 Type2 _propagatedType;
3506 /**
3507 * Return the propagated type of this expression, or {@code null} if type prop agation has not been
3508 * performed on the AST structure.
3509 * @return the propagated type of this expression
3510 */
3511 Type2 get propagatedType => _propagatedType;
3512 /**
3513 * Return the static type of this expression, or {@code null} if the AST struc ture has not been
3514 * resolved.
3515 * @return the static type of this expression
3516 */
3517 Type2 get staticType => _staticType;
3518 /**
3519 * Return {@code true} if this expression is syntactically valid for the LHS o f an{@link AssignmentExpression assignment expression}.
3520 * @return {@code true} if this expression matches the {@code assignableExpres sion} production
3521 */
3522 bool isAssignable() => false;
3523 /**
3524 * Set the propagated type of this expression to the given type.
3525 * @param propagatedType the propagated type of this expression
3526 */
3527 void set propagatedType2(Type2 propagatedType) {
3528 this._propagatedType = propagatedType;
3529 }
3530 /**
3531 * Set the static type of this expression to the given type.
3532 * @param staticType the static type of this expression
3533 */
3534 void set staticType2(Type2 staticType) {
3535 this._staticType = staticType;
3536 }
3537 }
3538 /**
3539 * Instances of the class {@code ExpressionFunctionBody} represent a function bo dy consisting of a
3540 * single expression.
3541 * <pre>
3542 * expressionFunctionBody ::=
3543 * '=>' {@link Expression expression} ';'
3544 * </pre>
3545 */
3546 class ExpressionFunctionBody extends FunctionBody {
3547 /**
3548 * The token introducing the expression that represents the body of the functi on.
3549 */
3550 Token _functionDefinition;
3551 /**
3552 * The expression representing the body of the function.
3553 */
3554 Expression _expression;
3555 /**
3556 * The semicolon terminating the statement.
3557 */
3558 Token _semicolon;
3559 /**
3560 * Initialize a newly created function body consisting of a block of statement s.
3561 * @param functionDefinition the token introducing the expression that represe nts the body of the
3562 * function
3563 * @param expression the expression representing the body of the function
3564 * @param semicolon the semicolon terminating the statement
3565 */
3566 ExpressionFunctionBody(Token functionDefinition, Expression expression, Token semicolon) {
3567 this._functionDefinition = functionDefinition;
3568 this._expression = becomeParentOf(expression);
3569 this._semicolon = semicolon;
3570 }
3571 accept(ASTVisitor visitor) => visitor.visitExpressionFunctionBody(this);
3572 Token get beginToken => _functionDefinition;
3573 Token get endToken {
3574 if (_semicolon != null) {
3575 return _semicolon;
3576 }
3577 return _expression.endToken;
3578 }
3579 /**
3580 * Return the expression representing the body of the function.
3581 * @return the expression representing the body of the function
3582 */
3583 Expression get expression => _expression;
3584 /**
3585 * Return the token introducing the expression that represents the body of the function.
3586 * @return the function definition token
3587 */
3588 Token get functionDefinition => _functionDefinition;
3589 /**
3590 * Return the semicolon terminating the statement.
3591 * @return the semicolon terminating the statement
3592 */
3593 Token get semicolon => _semicolon;
3594 /**
3595 * Set the expression representing the body of the function to the given expre ssion.
3596 * @param expression the expression representing the body of the function
3597 */
3598 void set expression4(Expression expression) {
3599 this._expression = becomeParentOf(expression);
3600 }
3601 /**
3602 * Set the token introducing the expression that represents the body of the fu nction to the given
3603 * token.
3604 * @param functionDefinition the function definition token
3605 */
3606 void set functionDefinition2(Token functionDefinition) {
3607 this._functionDefinition = functionDefinition;
3608 }
3609 /**
3610 * Set the semicolon terminating the statement to the given token.
3611 * @param semicolon the semicolon terminating the statement
3612 */
3613 void set semicolon8(Token semicolon) {
3614 this._semicolon = semicolon;
3615 }
3616 void visitChildren(ASTVisitor<Object> visitor) {
3617 safelyVisitChild(_expression, visitor);
3618 }
3619 }
3620 /**
3621 * Instances of the class {@code ExpressionStatement} wrap an expression as a st atement.
3622 * <pre>
3623 * expressionStatement ::={@link Expression expression}? ';'
3624 * </pre>
3625 */
3626 class ExpressionStatement extends Statement {
3627 /**
3628 * The expression that comprises the statement.
3629 */
3630 Expression _expression;
3631 /**
3632 * The semicolon terminating the statement, or {@code null} if the expression is a function
3633 * expression and isn't followed by a semicolon.
3634 */
3635 Token _semicolon;
3636 /**
3637 * Initialize a newly created expression statement.
3638 * @param expression the expression that comprises the statement
3639 * @param semicolon the semicolon terminating the statement
3640 */
3641 ExpressionStatement(Expression expression, Token semicolon) {
3642 this._expression = becomeParentOf(expression);
3643 this._semicolon = semicolon;
3644 }
3645 accept(ASTVisitor visitor) => visitor.visitExpressionStatement(this);
3646 Token get beginToken => _expression.beginToken;
3647 Token get endToken {
3648 if (_semicolon != null) {
3649 return _semicolon;
3650 }
3651 return _expression.endToken;
3652 }
3653 /**
3654 * Return the expression that comprises the statement.
3655 * @return the expression that comprises the statement
3656 */
3657 Expression get expression => _expression;
3658 /**
3659 * Return the semicolon terminating the statement.
3660 * @return the semicolon terminating the statement
3661 */
3662 Token get semicolon => _semicolon;
3663 bool isSynthetic() => _expression.isSynthetic() && _semicolon.isSynthetic();
3664 /**
3665 * Set the expression that comprises the statement to the given expression.
3666 * @param expression the expression that comprises the statement
3667 */
3668 void set expression5(Expression expression) {
3669 this._expression = becomeParentOf(expression);
3670 }
3671 /**
3672 * Set the semicolon terminating the statement to the given token.
3673 * @param semicolon the semicolon terminating the statement
3674 */
3675 void set semicolon9(Token semicolon) {
3676 this._semicolon = semicolon;
3677 }
3678 void visitChildren(ASTVisitor<Object> visitor) {
3679 safelyVisitChild(_expression, visitor);
3680 }
3681 }
3682 /**
3683 * Instances of the class {@code ExtendsClause} represent the "extends" clause i n a class
3684 * declaration.
3685 * <pre>
3686 * extendsClause ::=
3687 * 'extends' {@link TypeName superclass}</pre>
3688 */
3689 class ExtendsClause extends ASTNode {
3690 /**
3691 * The token representing the 'extends' keyword.
3692 */
3693 Token _keyword;
3694 /**
3695 * The name of the class that is being extended.
3696 */
3697 TypeName _superclass;
3698 /**
3699 * Initialize a newly created extends clause.
3700 * @param keyword the token representing the 'extends' keyword
3701 * @param superclass the name of the class that is being extended
3702 */
3703 ExtendsClause(Token keyword, TypeName superclass) {
3704 this._keyword = keyword;
3705 this._superclass = becomeParentOf(superclass);
3706 }
3707 accept(ASTVisitor visitor) => visitor.visitExtendsClause(this);
3708 Token get beginToken => _keyword;
3709 Token get endToken => _superclass.endToken;
3710 /**
3711 * Return the token representing the 'extends' keyword.
3712 * @return the token representing the 'extends' keyword
3713 */
3714 Token get keyword => _keyword;
3715 /**
3716 * Return the name of the class that is being extended.
3717 * @return the name of the class that is being extended
3718 */
3719 TypeName get superclass => _superclass;
3720 /**
3721 * Set the token representing the 'extends' keyword to the given token.
3722 * @param keyword the token representing the 'extends' keyword
3723 */
3724 void set keyword8(Token keyword) {
3725 this._keyword = keyword;
3726 }
3727 /**
3728 * Set the name of the class that is being extended to the given name.
3729 * @param name the name of the class that is being extended
3730 */
3731 void set superclass3(TypeName name) {
3732 _superclass = becomeParentOf(name);
3733 }
3734 void visitChildren(ASTVisitor<Object> visitor) {
3735 safelyVisitChild(_superclass, visitor);
3736 }
3737 }
3738 /**
3739 * Instances of the class {@code FieldDeclaration} represent the declaration of one or more fields
3740 * of the same type.
3741 * <pre>
3742 * fieldDeclaration ::=
3743 * 'static'? {@link VariableDeclarationList fieldList} ';'
3744 * </pre>
3745 */
3746 class FieldDeclaration extends ClassMember {
3747 /**
3748 * The token representing the 'static' keyword, or {@code null} if the fields are not static.
3749 */
3750 Token _keyword;
3751 /**
3752 * The fields being declared.
3753 */
3754 VariableDeclarationList _fieldList;
3755 /**
3756 * The semicolon terminating the declaration.
3757 */
3758 Token _semicolon;
3759 /**
3760 * Initialize a newly created field declaration.
3761 * @param comment the documentation comment associated with this field
3762 * @param metadata the annotations associated with this field
3763 * @param keyword the token representing the 'static' keyword
3764 * @param fieldList the fields being declared
3765 * @param semicolon the semicolon terminating the declaration
3766 */
3767 FieldDeclaration(Comment comment, List<Annotation> metadata, Token keyword, Va riableDeclarationList fieldList, Token semicolon) : super(comment, metadata) {
3768 this._keyword = keyword;
3769 this._fieldList = becomeParentOf(fieldList);
3770 this._semicolon = semicolon;
3771 }
3772 accept(ASTVisitor visitor) => visitor.visitFieldDeclaration(this);
3773 Token get endToken => _semicolon;
3774 /**
3775 * Return the fields being declared.
3776 * @return the fields being declared
3777 */
3778 VariableDeclarationList get fields => _fieldList;
3779 /**
3780 * Return the token representing the 'static' keyword, or {@code null} if the fields are not
3781 * static.
3782 * @return the token representing the 'static' keyword
3783 */
3784 Token get keyword => _keyword;
3785 /**
3786 * Return the semicolon terminating the declaration.
3787 * @return the semicolon terminating the declaration
3788 */
3789 Token get semicolon => _semicolon;
3790 /**
3791 * Set the fields being declared to the given list of variables.
3792 * @param fieldList the fields being declared
3793 */
3794 void set fields2(VariableDeclarationList fieldList) {
3795 fieldList = becomeParentOf(fieldList);
3796 }
3797 /**
3798 * Set the token representing the 'static' keyword to the given token.
3799 * @param keyword the token representing the 'static' keyword
3800 */
3801 void set keyword9(Token keyword) {
3802 this._keyword = keyword;
3803 }
3804 /**
3805 * Set the semicolon terminating the declaration to the given token.
3806 * @param semicolon the semicolon terminating the declaration
3807 */
3808 void set semicolon10(Token semicolon) {
3809 this._semicolon = semicolon;
3810 }
3811 void visitChildren(ASTVisitor<Object> visitor) {
3812 super.visitChildren(visitor);
3813 safelyVisitChild(_fieldList, visitor);
3814 }
3815 Token get firstTokenAfterCommentAndMetadata {
3816 if (_keyword != null) {
3817 return _keyword;
3818 }
3819 return _fieldList.beginToken;
3820 }
3821 }
3822 /**
3823 * Instances of the class {@code FieldFormalParameter} represent a field formal parameter.
3824 * <pre>
3825 * fieldFormalParameter ::=
3826 * ('final' {@link TypeName type} | 'const' {@link TypeName type} | 'var' | {@li nk TypeName type})? 'this' '.' {@link SimpleIdentifier identifier}</pre>
3827 */
3828 class FieldFormalParameter extends NormalFormalParameter {
3829 /**
3830 * The token representing either the 'final', 'const' or 'var' keyword, or {@c ode null} if no
3831 * keyword was used.
3832 */
3833 Token _keyword;
3834 /**
3835 * The name of the declared type of the parameter, or {@code null} if the para meter does not have
3836 * a declared type.
3837 */
3838 TypeName _type;
3839 /**
3840 * The token representing the 'this' keyword.
3841 */
3842 Token _thisToken;
3843 /**
3844 * The token representing the period.
3845 */
3846 Token _period;
3847 /**
3848 * Initialize a newly created formal parameter.
3849 * @param comment the documentation comment associated with this parameter
3850 * @param metadata the annotations associated with this parameter
3851 * @param keyword the token representing either the 'final', 'const' or 'var' keyword
3852 * @param type the name of the declared type of the parameter
3853 * @param thisToken the token representing the 'this' keyword
3854 * @param period the token representing the period
3855 * @param identifier the name of the parameter being declared
3856 */
3857 FieldFormalParameter(Comment comment, List<Annotation> metadata, Token keyword , TypeName type, Token thisToken, Token period, SimpleIdentifier identifier) : s uper(comment, metadata, identifier) {
3858 this._keyword = keyword;
3859 this._type = becomeParentOf(type);
3860 this._thisToken = thisToken;
3861 this._period = period;
3862 }
3863 accept(ASTVisitor visitor) => visitor.visitFieldFormalParameter(this);
3864 Token get beginToken {
3865 if (_keyword != null) {
3866 return _keyword;
3867 } else if (_type != null) {
3868 return _type.beginToken;
3869 }
3870 return _thisToken;
3871 }
3872 Token get endToken => identifier.endToken;
3873 /**
3874 * Return the token representing either the 'final', 'const' or 'var' keyword.
3875 * @return the token representing either the 'final', 'const' or 'var' keyword
3876 */
3877 Token get keyword => _keyword;
3878 /**
3879 * Return the token representing the period.
3880 * @return the token representing the period
3881 */
3882 Token get period => _period;
3883 /**
3884 * Return the token representing the 'this' keyword.
3885 * @return the token representing the 'this' keyword
3886 */
3887 Token get thisToken => _thisToken;
3888 /**
3889 * Return the name of the declared type of the parameter, or {@code null} if t he parameter does
3890 * not have a declared type.
3891 * @return the name of the declared type of the parameter
3892 */
3893 TypeName get type => _type;
3894 bool isConst() => (_keyword is KeywordToken) && (_keyword as KeywordToken).key word == Keyword.CONST;
3895 bool isFinal() => (_keyword is KeywordToken) && (_keyword as KeywordToken).key word == Keyword.FINAL;
3896 /**
3897 * Set the token representing either the 'final', 'const' or 'var' keyword to the given token.
3898 * @param keyword the token representing either the 'final', 'const' or 'var' keyword
3899 */
3900 void set keyword10(Token keyword) {
3901 this._keyword = keyword;
3902 }
3903 /**
3904 * Set the token representing the period to the given token.
3905 * @param period the token representing the period
3906 */
3907 void set period6(Token period) {
3908 this._period = period;
3909 }
3910 /**
3911 * Set the token representing the 'this' keyword to the given token.
3912 * @param thisToken the token representing the 'this' keyword
3913 */
3914 void set thisToken2(Token thisToken) {
3915 this._thisToken = thisToken;
3916 }
3917 /**
3918 * Set the name of the declared type of the parameter to the given type name.
3919 * @param typeName the name of the declared type of the parameter
3920 */
3921 void set type4(TypeName typeName) {
3922 _type = becomeParentOf(typeName);
3923 }
3924 void visitChildren(ASTVisitor<Object> visitor) {
3925 super.visitChildren(visitor);
3926 safelyVisitChild(_type, visitor);
3927 safelyVisitChild(identifier, visitor);
3928 }
3929 }
3930 /**
3931 * Instances of the class {@code ForEachStatement} represent a for-each statemen t.
3932 * <pre>
3933 * forEachStatement ::=
3934 * 'for' '(' {@link SimpleFormalParameter loopParameter} 'in' {@link Expression iterator} ')' {@link Block body}</pre>
3935 */
3936 class ForEachStatement extends Statement {
3937 /**
3938 * The token representing the 'for' keyword.
3939 */
3940 Token _forKeyword;
3941 /**
3942 * The left parenthesis.
3943 */
3944 Token _leftParenthesis;
3945 /**
3946 * The declaration of the loop variable.
3947 */
3948 SimpleFormalParameter _loopParameter;
3949 /**
3950 * The token representing the 'in' keyword.
3951 */
3952 Token _inKeyword;
3953 /**
3954 * The expression evaluated to produce the iterator.
3955 */
3956 Expression _iterator;
3957 /**
3958 * The right parenthesis.
3959 */
3960 Token _rightParenthesis;
3961 /**
3962 * The body of the loop.
3963 */
3964 Statement _body;
3965 /**
3966 * Initialize a newly created for-each statement.
3967 * @param forKeyword the token representing the 'for' keyword
3968 * @param leftParenthesis the left parenthesis
3969 * @param loopParameter the declaration of the loop variable
3970 * @param iterator the expression evaluated to produce the iterator
3971 * @param rightParenthesis the right parenthesis
3972 * @param body the body of the loop
3973 */
3974 ForEachStatement(Token forKeyword, Token leftParenthesis, SimpleFormalParamete r loopParameter, Token inKeyword, Expression iterator, Token rightParenthesis, S tatement body) {
3975 this._forKeyword = forKeyword;
3976 this._leftParenthesis = leftParenthesis;
3977 this._loopParameter = becomeParentOf(loopParameter);
3978 this._inKeyword = inKeyword;
3979 this._iterator = becomeParentOf(iterator);
3980 this._rightParenthesis = rightParenthesis;
3981 this._body = becomeParentOf(body);
3982 }
3983 accept(ASTVisitor visitor) => visitor.visitForEachStatement(this);
3984 Token get beginToken => _forKeyword;
3985 /**
3986 * Return the body of the loop.
3987 * @return the body of the loop
3988 */
3989 Statement get body => _body;
3990 Token get endToken => _body.endToken;
3991 /**
3992 * Return the token representing the 'for' keyword.
3993 * @return the token representing the 'for' keyword
3994 */
3995 Token get forKeyword => _forKeyword;
3996 /**
3997 * Return the token representing the 'in' keyword.
3998 * @return the token representing the 'in' keyword
3999 */
4000 Token get inKeyword => _inKeyword;
4001 /**
4002 * Return the expression evaluated to produce the iterator.
4003 * @return the expression evaluated to produce the iterator
4004 */
4005 Expression get iterator => _iterator;
4006 /**
4007 * Return the left parenthesis.
4008 * @return the left parenthesis
4009 */
4010 Token get leftParenthesis => _leftParenthesis;
4011 /**
4012 * Return the declaration of the loop variable.
4013 * @return the declaration of the loop variable
4014 */
4015 SimpleFormalParameter get loopParameter => _loopParameter;
4016 /**
4017 * Return the right parenthesis.
4018 * @return the right parenthesis
4019 */
4020 Token get rightParenthesis => _rightParenthesis;
4021 /**
4022 * Set the body of the loop to the given block.
4023 * @param body the body of the loop
4024 */
4025 void set body5(Statement body) {
4026 this._body = becomeParentOf(body);
4027 }
4028 /**
4029 * Set the token representing the 'for' keyword to the given token.
4030 * @param forKeyword the token representing the 'for' keyword
4031 */
4032 void set forKeyword2(Token forKeyword) {
4033 this._forKeyword = forKeyword;
4034 }
4035 /**
4036 * Set the token representing the 'in' keyword to the given token.
4037 * @param inKeyword the token representing the 'in' keyword
4038 */
4039 void set inKeyword2(Token inKeyword) {
4040 this._inKeyword = inKeyword;
4041 }
4042 /**
4043 * Set the expression evaluated to produce the iterator to the given expressio n.
4044 * @param expression the expression evaluated to produce the iterator
4045 */
4046 void set iterator2(Expression expression) {
4047 _iterator = becomeParentOf(expression);
4048 }
4049 /**
4050 * Set the left parenthesis to the given token.
4051 * @param leftParenthesis the left parenthesis
4052 */
4053 void set leftParenthesis6(Token leftParenthesis) {
4054 this._leftParenthesis = leftParenthesis;
4055 }
4056 /**
4057 * Set the declaration of the loop variable to the given parameter.
4058 * @param parameter the declaration of the loop variable
4059 */
4060 void set loopParameter2(SimpleFormalParameter parameter) {
4061 _loopParameter = becomeParentOf(parameter);
4062 }
4063 /**
4064 * Set the right parenthesis to the given token.
4065 * @param rightParenthesis the right parenthesis
4066 */
4067 void set rightParenthesis6(Token rightParenthesis) {
4068 this._rightParenthesis = rightParenthesis;
4069 }
4070 void visitChildren(ASTVisitor<Object> visitor) {
4071 safelyVisitChild(_loopParameter, visitor);
4072 safelyVisitChild(_iterator, visitor);
4073 safelyVisitChild(_body, visitor);
4074 }
4075 }
4076 /**
4077 * Instances of the class {@code ForStatement} represent a for statement.
4078 * <pre>
4079 * forStatement ::=
4080 * 'for' '(' forLoopParts ')' {@link Statement statement}forLoopParts ::=
4081 * forInitializerStatement ';' {@link Expression expression}? ';' {@link Express ion expressionList}?
4082 * forInitializerStatement ::={@link DefaultFormalParameter initializedVariableD eclaration}| {@link Expression expression}?
4083 * </pre>
4084 */
4085 class ForStatement extends Statement {
4086 /**
4087 * The token representing the 'for' keyword.
4088 */
4089 Token _forKeyword;
4090 /**
4091 * The left parenthesis.
4092 */
4093 Token _leftParenthesis;
4094 /**
4095 * The declaration of the loop variables, or {@code null} if there are no vari ables. Note that a
4096 * for statement cannot have both a variable list and an initialization expres sion, but can
4097 * validly have neither.
4098 */
4099 VariableDeclarationList _variableList;
4100 /**
4101 * The initialization expression, or {@code null} if there is no initializatio n expression. Note
4102 * that a for statement cannot have both a variable list and an initialization expression, but can
4103 * validly have neither.
4104 */
4105 Expression _initialization;
4106 /**
4107 * The semicolon separating the initializer and the condition.
4108 */
4109 Token _leftSeparator;
4110 /**
4111 * The condition used to determine when to terminate the loop.
4112 */
4113 Expression _condition;
4114 /**
4115 * The semicolon separating the condition and the updater.
4116 */
4117 Token _rightSeparator;
4118 /**
4119 * The list of expressions run after each execution of the loop body.
4120 */
4121 NodeList<Expression> _updaters;
4122 /**
4123 * The right parenthesis.
4124 */
4125 Token _rightParenthesis;
4126 /**
4127 * The body of the loop.
4128 */
4129 Statement _body;
4130 /**
4131 * Initialize a newly created for statement.
4132 * @param forKeyword the token representing the 'for' keyword
4133 * @param leftParenthesis the left parenthesis
4134 * @param variableList the declaration of the loop variables
4135 * @param initialization the initialization expression
4136 * @param leftSeparator the semicolon separating the initializer and the condi tion
4137 * @param condition the condition used to determine when to terminate the loop
4138 * @param rightSeparator the semicolon separating the condition and the update r
4139 * @param updaters the list of expressions run after each execution of the loo p body
4140 * @param rightParenthesis the right parenthesis
4141 * @param body the body of the loop
4142 */
4143 ForStatement(Token forKeyword, Token leftParenthesis, VariableDeclarationList variableList, Expression initialization, Token leftSeparator, Expression conditi on, Token rightSeparator, List<Expression> updaters, Token rightParenthesis, Sta tement body) {
4144 this._updaters = new NodeList<Expression>(this);
4145 this._forKeyword = forKeyword;
4146 this._leftParenthesis = leftParenthesis;
4147 this._variableList = becomeParentOf(variableList);
4148 this._initialization = becomeParentOf(initialization);
4149 this._leftSeparator = leftSeparator;
4150 this._condition = becomeParentOf(condition);
4151 this._rightSeparator = rightSeparator;
4152 this._updaters.addAll(updaters);
4153 this._rightParenthesis = rightParenthesis;
4154 this._body = becomeParentOf(body);
4155 }
4156 accept(ASTVisitor visitor) => visitor.visitForStatement(this);
4157 Token get beginToken => _forKeyword;
4158 /**
4159 * Return the body of the loop.
4160 * @return the body of the loop
4161 */
4162 Statement get body => _body;
4163 /**
4164 * Return the condition used to determine when to terminate the loop.
4165 * @return the condition used to determine when to terminate the loop
4166 */
4167 Expression get condition => _condition;
4168 Token get endToken => _body.endToken;
4169 /**
4170 * Return the token representing the 'for' keyword.
4171 * @return the token representing the 'for' keyword
4172 */
4173 Token get forKeyword => _forKeyword;
4174 /**
4175 * Return the initialization expression, or {@code null} if there is no initia lization expression.
4176 * @return the initialization expression
4177 */
4178 Expression get initialization => _initialization;
4179 /**
4180 * Return the left parenthesis.
4181 * @return the left parenthesis
4182 */
4183 Token get leftParenthesis => _leftParenthesis;
4184 /**
4185 * Return the semicolon separating the initializer and the condition.
4186 * @return the semicolon separating the initializer and the condition
4187 */
4188 Token get leftSeparator => _leftSeparator;
4189 /**
4190 * Return the right parenthesis.
4191 * @return the right parenthesis
4192 */
4193 Token get rightParenthesis => _rightParenthesis;
4194 /**
4195 * Return the semicolon separating the condition and the updater.
4196 * @return the semicolon separating the condition and the updater
4197 */
4198 Token get rightSeparator => _rightSeparator;
4199 /**
4200 * Return the list of expressions run after each execution of the loop body.
4201 * @return the list of expressions run after each execution of the loop body
4202 */
4203 NodeList<Expression> get updaters => _updaters;
4204 /**
4205 * Return the declaration of the loop variables, or {@code null} if there are no variables.
4206 * @return the declaration of the loop variables, or {@code null} if there are no variables
4207 */
4208 VariableDeclarationList get variables => _variableList;
4209 /**
4210 * Set the body of the loop to the given statement.
4211 * @param body the body of the loop
4212 */
4213 void set body6(Statement body) {
4214 this._body = becomeParentOf(body);
4215 }
4216 /**
4217 * Set the condition used to determine when to terminate the loop to the given expression.
4218 * @param expression the condition used to determine when to terminate the loo p
4219 */
4220 void set condition5(Expression expression) {
4221 _condition = becomeParentOf(expression);
4222 }
4223 /**
4224 * Set the token representing the 'for' keyword to the given token.
4225 * @param forKeyword the token representing the 'for' keyword
4226 */
4227 void set forKeyword3(Token forKeyword) {
4228 this._forKeyword = forKeyword;
4229 }
4230 /**
4231 * Set the initialization expression to the given expression.
4232 * @param initialization the initialization expression
4233 */
4234 void set initialization2(Expression initialization) {
4235 this._initialization = becomeParentOf(initialization);
4236 }
4237 /**
4238 * Set the left parenthesis to the given token.
4239 * @param leftParenthesis the left parenthesis
4240 */
4241 void set leftParenthesis7(Token leftParenthesis) {
4242 this._leftParenthesis = leftParenthesis;
4243 }
4244 /**
4245 * Set the semicolon separating the initializer and the condition to the given token.
4246 * @param leftSeparator the semicolon separating the initializer and the condi tion
4247 */
4248 void set leftSeparator2(Token leftSeparator) {
4249 this._leftSeparator = leftSeparator;
4250 }
4251 /**
4252 * Set the right parenthesis to the given token.
4253 * @param rightParenthesis the right parenthesis
4254 */
4255 void set rightParenthesis7(Token rightParenthesis) {
4256 this._rightParenthesis = rightParenthesis;
4257 }
4258 /**
4259 * Set the semicolon separating the condition and the updater to the given tok en.
4260 * @param rightSeparator the semicolon separating the condition and the update r
4261 */
4262 void set rightSeparator2(Token rightSeparator) {
4263 this._rightSeparator = rightSeparator;
4264 }
4265 /**
4266 * Set the declaration of the loop variables to the given parameter.
4267 * @param variableList the declaration of the loop variables
4268 */
4269 void set variables2(VariableDeclarationList variableList) {
4270 variableList = becomeParentOf(variableList);
4271 }
4272 void visitChildren(ASTVisitor<Object> visitor) {
4273 safelyVisitChild(_variableList, visitor);
4274 safelyVisitChild(_initialization, visitor);
4275 safelyVisitChild(_condition, visitor);
4276 _updaters.accept(visitor);
4277 safelyVisitChild(_body, visitor);
4278 }
4279 }
4280 /**
4281 * The abstract class {@code FormalParameter} defines the behavior of objects re presenting a
4282 * parameter to a function.
4283 * <pre>
4284 * formalParameter ::={@link NormalFormalParameter normalFormalParameter}| {@lin k DefaultFormalParameter namedFormalParameter}| {@link DefaultFormalParameter op tionalFormalParameter}</pre>
4285 */
4286 abstract class FormalParameter extends ASTNode {
4287 /**
4288 * Return the element representing this parameter, or {@code null} if this par ameter has not been
4289 * resolved.
4290 * @return the element representing this parameter
4291 */
4292 ParameterElement get element {
4293 SimpleIdentifier identifier6 = identifier;
4294 if (identifier6 == null) {
4295 return null;
4296 }
4297 return identifier6.element as ParameterElement;
4298 }
4299 /**
4300 * Return the name of the parameter being declared.
4301 * @return the name of the parameter being declared
4302 */
4303 SimpleIdentifier get identifier;
4304 /**
4305 * Return the kind of this parameter.
4306 * @return the kind of this parameter
4307 */
4308 ParameterKind get kind;
4309 }
4310 /**
4311 * Instances of the class {@code FormalParameterList} represent the formal param eter list of a
4312 * method declaration, function declaration, or function type alias.
4313 * <p>
4314 * While the grammar requires all optional formal parameters to follow all of th e normal formal
4315 * parameters and at most one grouping of optional formal parameters, this class does not enforce
4316 * those constraints. All parameters are flattened into a single list, which can have any or all
4317 * kinds of parameters (normal, named, and positional) in any order.
4318 * <pre>
4319 * formalParameterList ::=
4320 * '(' ')'
4321 * | '(' normalFormalParameters (',' optionalFormalParameters)? ')'
4322 * | '(' optionalFormalParameters ')'
4323 * normalFormalParameters ::={@link NormalFormalParameter normalFormalParameter} (',' {@link NormalFormalParameter normalFormalParameter})
4324 * optionalFormalParameters ::=
4325 * optionalPositionalFormalParameters
4326 * | namedFormalParameters
4327 * optionalPositionalFormalParameters ::=
4328 * '[' {@link DefaultFormalParameter positionalFormalParameter} (',' {@link Defa ultFormalParameter positionalFormalParameter})* ']'
4329 * namedFormalParameters ::=
4330 * '{' {@link DefaultFormalParameter namedFormalParameter} (',' {@link DefaultFo rmalParameter namedFormalParameter})* '}'
4331 * </pre>
4332 */
4333 class FormalParameterList extends ASTNode {
4334 /**
4335 * The left parenthesis.
4336 */
4337 Token _leftParenthesis;
4338 /**
4339 * The parameters associated with the method.
4340 */
4341 NodeList<FormalParameter> _parameters;
4342 /**
4343 * The left square bracket ('[') or left curly brace ('{') introducing the opt ional parameters.
4344 */
4345 Token _leftDelimiter;
4346 /**
4347 * The right square bracket (']') or right curly brace ('}') introducing the o ptional parameters.
4348 */
4349 Token _rightDelimiter;
4350 /**
4351 * The right parenthesis.
4352 */
4353 Token _rightParenthesis;
4354 /**
4355 * Initialize a newly created parameter list.
4356 * @param leftParenthesis the left parenthesis
4357 * @param parameters the parameters associated with the method
4358 * @param leftDelimiter the left delimiter introducing the optional parameters
4359 * @param rightDelimiter the right delimiter introducing the optional paramete rs
4360 * @param rightParenthesis the right parenthesis
4361 */
4362 FormalParameterList(Token leftParenthesis, List<FormalParameter> parameters, T oken leftDelimiter, Token rightDelimiter, Token rightParenthesis) {
4363 this._parameters = new NodeList<FormalParameter>(this);
4364 this._leftParenthesis = leftParenthesis;
4365 this._parameters.addAll(parameters);
4366 this._leftDelimiter = leftDelimiter;
4367 this._rightDelimiter = rightDelimiter;
4368 this._rightParenthesis = rightParenthesis;
4369 }
4370 accept(ASTVisitor visitor) => visitor.visitFormalParameterList(this);
4371 Token get beginToken => _leftParenthesis;
4372 /**
4373 * Return an array containing the elements representing the parameters in this list. The array
4374 * will contain {@code null}s if the parameters in this list have not been res olved.
4375 * @return the elements representing the parameters in this list
4376 */
4377 List<ParameterElement> get elements {
4378 int count = _parameters.length;
4379 List<ParameterElement> types = new List<ParameterElement>.fixedLength(count) ;
4380 for (int i = 0; i < count; i++) {
4381 types[i] = _parameters[i].element;
4382 }
4383 return types;
4384 }
4385 Token get endToken => _rightParenthesis;
4386 /**
4387 * Return the left square bracket ('[') or left curly brace ('{') introducing the optional
4388 * parameters.
4389 * @return the left square bracket ('[') or left curly brace ('{') introducing the optional
4390 * parameters
4391 */
4392 Token get leftDelimiter => _leftDelimiter;
4393 /**
4394 * Return the left parenthesis.
4395 * @return the left parenthesis
4396 */
4397 Token get leftParenthesis => _leftParenthesis;
4398 /**
4399 * Return the parameters associated with the method.
4400 * @return the parameters associated with the method
4401 */
4402 NodeList<FormalParameter> get parameters => _parameters;
4403 /**
4404 * Return the right square bracket (']') or right curly brace ('}') introducin g the optional
4405 * parameters.
4406 * @return the right square bracket (']') or right curly brace ('}') introduci ng the optional
4407 * parameters
4408 */
4409 Token get rightDelimiter => _rightDelimiter;
4410 /**
4411 * Return the right parenthesis.
4412 * @return the right parenthesis
4413 */
4414 Token get rightParenthesis => _rightParenthesis;
4415 /**
4416 * Set the left square bracket ('[') or left curly brace ('{') introducing the optional parameters
4417 * to the given token.
4418 * @param bracket the left delimiter introducing the optional parameters
4419 */
4420 void set leftDelimiter2(Token bracket) {
4421 _leftDelimiter = bracket;
4422 }
4423 /**
4424 * Set the left parenthesis to the given token.
4425 * @param parenthesis the left parenthesis
4426 */
4427 void set leftParenthesis8(Token parenthesis) {
4428 _leftParenthesis = parenthesis;
4429 }
4430 /**
4431 * Set the right square bracket (']') or right curly brace ('}') introducing t he optional
4432 * parameters to the given token.
4433 * @param bracket the right delimiter introducing the optional parameters
4434 */
4435 void set rightDelimiter2(Token bracket) {
4436 _rightDelimiter = bracket;
4437 }
4438 /**
4439 * Set the right parenthesis to the given token.
4440 * @param parenthesis the right parenthesis
4441 */
4442 void set rightParenthesis8(Token parenthesis) {
4443 _rightParenthesis = parenthesis;
4444 }
4445 void visitChildren(ASTVisitor<Object> visitor) {
4446 _parameters.accept(visitor);
4447 }
4448 }
4449 /**
4450 * The abstract class {@code FunctionBody} defines the behavior common to object s representing the
4451 * body of a function or method.
4452 * <pre>
4453 * functionBody ::={@link BlockFunctionBody blockFunctionBody}| {@link EmptyFunc tionBody emptyFunctionBody}| {@link ExpressionFunctionBody expressionFunctionBod y}</pre>
4454 */
4455 abstract class FunctionBody extends ASTNode {
4456 }
4457 /**
4458 * Instances of the class {@code FunctionDeclaration} wrap a {@link FunctionExpr ession function
4459 * expression} as a top-level declaration.
4460 * <pre>
4461 * functionDeclaration ::=
4462 * 'external' functionSignature
4463 * | functionSignature {@link FunctionBody functionBody}functionSignature ::={@l ink Type returnType}? ('get' | 'set')? {@link SimpleIdentifier functionName} {@l ink FormalParameterList formalParameterList}</pre>
4464 */
4465 class FunctionDeclaration extends CompilationUnitMember {
4466 /**
4467 * The token representing the 'external' keyword, or {@code null} if this is n ot an external
4468 * function.
4469 */
4470 Token _externalKeyword;
4471 /**
4472 * The return type of the function, or {@code null} if no return type was decl ared.
4473 */
4474 TypeName _returnType;
4475 /**
4476 * The token representing the 'get' or 'set' keyword, or {@code null} if this is a function
4477 * declaration rather than a property declaration.
4478 */
4479 Token _propertyKeyword;
4480 /**
4481 * The name of the function, or {@code null} if the function is not named.
4482 */
4483 SimpleIdentifier _name;
4484 /**
4485 * The function expression being wrapped.
4486 */
4487 FunctionExpression _functionExpression;
4488 /**
4489 * Initialize a newly created function declaration.
4490 * @param comment the documentation comment associated with this function
4491 * @param metadata the annotations associated with this function
4492 * @param externalKeyword the token representing the 'external' keyword
4493 * @param returnType the return type of the function
4494 * @param propertyKeyword the token representing the 'get' or 'set' keyword
4495 * @param name the name of the function
4496 * @param functionExpression the function expression being wrapped
4497 */
4498 FunctionDeclaration(Comment comment, List<Annotation> metadata, Token external Keyword, TypeName returnType, Token propertyKeyword, SimpleIdentifier name, Func tionExpression functionExpression) : super(comment, metadata) {
4499 this._externalKeyword = externalKeyword;
4500 this._returnType = becomeParentOf(returnType);
4501 this._propertyKeyword = propertyKeyword;
4502 this._name = becomeParentOf(name);
4503 this._functionExpression = becomeParentOf(functionExpression);
4504 }
4505 accept(ASTVisitor visitor) => visitor.visitFunctionDeclaration(this);
4506 /**
4507 * Return the {@link FunctionElement} associated with this function, or {@code null} if the AST
4508 * structure has not been resolved.
4509 * @return the {@link FunctionElement} associated with this function
4510 */
4511 FunctionElement get element => _name != null ? _name.element as FunctionElemen t : null;
4512 Token get endToken => _functionExpression.endToken;
4513 /**
4514 * Return the token representing the 'external' keyword, or {@code null} if th is is not an
4515 * external function.
4516 * @return the token representing the 'external' keyword
4517 */
4518 Token get externalKeyword => _externalKeyword;
4519 /**
4520 * Return the function expression being wrapped.
4521 * @return the function expression being wrapped
4522 */
4523 FunctionExpression get functionExpression => _functionExpression;
4524 /**
4525 * Return the name of the function, or {@code null} if the function is not nam ed.
4526 * @return the name of the function
4527 */
4528 SimpleIdentifier get name => _name;
4529 /**
4530 * Return the token representing the 'get' or 'set' keyword, or {@code null} i f this is a function
4531 * declaration rather than a property declaration.
4532 * @return the token representing the 'get' or 'set' keyword
4533 */
4534 Token get propertyKeyword => _propertyKeyword;
4535 /**
4536 * Return the return type of the function, or {@code null} if no return type w as declared.
4537 * @return the return type of the function
4538 */
4539 TypeName get returnType => _returnType;
4540 /**
4541 * Set the token representing the 'external' keyword to the given token.
4542 * @param externalKeyword the token representing the 'external' keyword
4543 */
4544 void set externalKeyword3(Token externalKeyword) {
4545 this._externalKeyword = externalKeyword;
4546 }
4547 /**
4548 * Set the function expression being wrapped to the given function expression.
4549 * @param functionExpression the function expression being wrapped
4550 */
4551 void set functionExpression2(FunctionExpression functionExpression) {
4552 functionExpression = becomeParentOf(functionExpression);
4553 }
4554 /**
4555 * Set the name of the function to the given identifier.
4556 * @param identifier the name of the function
4557 */
4558 void set name7(SimpleIdentifier identifier) {
4559 _name = becomeParentOf(identifier);
4560 }
4561 /**
4562 * Set the token representing the 'get' or 'set' keyword to the given token.
4563 * @param propertyKeyword the token representing the 'get' or 'set' keyword
4564 */
4565 void set propertyKeyword2(Token propertyKeyword) {
4566 this._propertyKeyword = propertyKeyword;
4567 }
4568 /**
4569 * Set the return type of the function to the given name.
4570 * @param name the return type of the function
4571 */
4572 void set returnType3(TypeName name) {
4573 _returnType = becomeParentOf(name);
4574 }
4575 void visitChildren(ASTVisitor<Object> visitor) {
4576 super.visitChildren(visitor);
4577 safelyVisitChild(_returnType, visitor);
4578 safelyVisitChild(_name, visitor);
4579 safelyVisitChild(_functionExpression, visitor);
4580 }
4581 Token get firstTokenAfterCommentAndMetadata {
4582 if (_externalKeyword != null) {
4583 return _externalKeyword;
4584 }
4585 if (_returnType != null) {
4586 return _returnType.beginToken;
4587 } else if (_propertyKeyword != null) {
4588 return _propertyKeyword;
4589 } else if (_name != null) {
4590 return _name.beginToken;
4591 }
4592 return _functionExpression.beginToken;
4593 }
4594 }
4595 /**
4596 * Instances of the class {@code FunctionDeclarationStatement} wrap a {@link Fun ctionDeclarationfunction declaration} as a statement.
4597 */
4598 class FunctionDeclarationStatement extends Statement {
4599 /**
4600 * The function declaration being wrapped.
4601 */
4602 FunctionDeclaration _functionDeclaration;
4603 /**
4604 * Initialize a newly created function declaration statement.
4605 * @param functionDeclaration the the function declaration being wrapped
4606 */
4607 FunctionDeclarationStatement(FunctionDeclaration functionDeclaration) {
4608 this._functionDeclaration = becomeParentOf(functionDeclaration);
4609 }
4610 accept(ASTVisitor visitor) => visitor.visitFunctionDeclarationStatement(this);
4611 Token get beginToken => _functionDeclaration.beginToken;
4612 Token get endToken => _functionDeclaration.endToken;
4613 /**
4614 * Return the function declaration being wrapped.
4615 * @return the function declaration being wrapped
4616 */
4617 FunctionDeclaration get functionDeclaration => _functionDeclaration;
4618 /**
4619 * Set the function declaration being wrapped to the given function declaratio n.
4620 * @param functionDeclaration the function declaration being wrapped
4621 */
4622 void set functionExpression(FunctionDeclaration functionDeclaration) {
4623 this._functionDeclaration = becomeParentOf(functionDeclaration);
4624 }
4625 void visitChildren(ASTVisitor<Object> visitor) {
4626 safelyVisitChild(_functionDeclaration, visitor);
4627 }
4628 }
4629 /**
4630 * Instances of the class {@code FunctionExpression} represent a function expres sion.
4631 * <pre>
4632 * functionExpression ::={@link FormalParameterList formalParameterList} {@link FunctionBody functionBody}</pre>
4633 */
4634 class FunctionExpression extends Expression {
4635 /**
4636 * The parameters associated with the function.
4637 */
4638 FormalParameterList _parameters;
4639 /**
4640 * The body of the function, or {@code null} if this is an external function.
4641 */
4642 FunctionBody _body;
4643 /**
4644 * The element associated with the function, or {@code null} if the AST struct ure has not been
4645 * resolved.
4646 */
4647 ExecutableElement _element;
4648 /**
4649 * Initialize a newly created function declaration.
4650 * @param parameters the parameters associated with the function
4651 * @param body the body of the function
4652 */
4653 FunctionExpression(FormalParameterList parameters, FunctionBody body) {
4654 this._parameters = becomeParentOf(parameters);
4655 this._body = becomeParentOf(body);
4656 }
4657 accept(ASTVisitor visitor) => visitor.visitFunctionExpression(this);
4658 Token get beginToken {
4659 if (_parameters != null) {
4660 return _parameters.beginToken;
4661 } else if (_body != null) {
4662 return _body.beginToken;
4663 }
4664 throw new IllegalStateException("Non-external functions must have a body");
4665 }
4666 /**
4667 * Return the body of the function, or {@code null} if this is an external fun ction.
4668 * @return the body of the function
4669 */
4670 FunctionBody get body => _body;
4671 /**
4672 * Return the element associated with this function, or {@code null} if the AS T structure has not
4673 * been resolved.
4674 * @return the element associated with this function
4675 */
4676 ExecutableElement get element => _element;
4677 Token get endToken {
4678 if (_body != null) {
4679 return _body.endToken;
4680 } else if (_parameters != null) {
4681 return _parameters.endToken;
4682 }
4683 throw new IllegalStateException("Non-external functions must have a body");
4684 }
4685 /**
4686 * Return the parameters associated with the function.
4687 * @return the parameters associated with the function
4688 */
4689 FormalParameterList get parameters => _parameters;
4690 /**
4691 * Set the body of the function to the given function body.
4692 * @param functionBody the body of the function
4693 */
4694 void set body7(FunctionBody functionBody) {
4695 _body = becomeParentOf(functionBody);
4696 }
4697 /**
4698 * Set the element associated with this function to the given element.
4699 * @param element the element associated with this function
4700 */
4701 void set element8(ExecutableElement element) {
4702 this._element = element;
4703 }
4704 /**
4705 * Set the parameters associated with the function to the given list of parame ters.
4706 * @param parameters the parameters associated with the function
4707 */
4708 void set parameters3(FormalParameterList parameters) {
4709 this._parameters = becomeParentOf(parameters);
4710 }
4711 void visitChildren(ASTVisitor<Object> visitor) {
4712 safelyVisitChild(_parameters, visitor);
4713 safelyVisitChild(_body, visitor);
4714 }
4715 }
4716 /**
4717 * Instances of the class {@code FunctionExpressionInvocation} represent the inv ocation of a
4718 * function resulting from evaluating an expression. Invocations of methods and other forms of
4719 * functions are represented by {@link MethodInvocation method invocation} nodes . Invocations of
4720 * getters and setters are represented by either {@link PrefixedIdentifier prefi xed identifier} or{@link PropertyAccess property access} nodes.
4721 * <pre>
4722 * functionExpressionInvoction ::={@link Expression function} {@link ArgumentLis t argumentList}</pre>
4723 */
4724 class FunctionExpressionInvocation extends Expression {
4725 /**
4726 * The expression producing the function being invoked.
4727 */
4728 Expression _function;
4729 /**
4730 * The list of arguments to the function.
4731 */
4732 ArgumentList _argumentList;
4733 /**
4734 * The element associated with the function being invoked, or {@code null} if the AST structure
4735 * has not been resolved or the function could not be resolved.
4736 */
4737 ExecutableElement _element;
4738 /**
4739 * Initialize a newly created function expression invocation.
4740 * @param function the expression producing the function being invoked
4741 * @param argumentList the list of arguments to the method
4742 */
4743 FunctionExpressionInvocation(Expression function, ArgumentList argumentList) {
4744 this._function = becomeParentOf(function);
4745 this._argumentList = becomeParentOf(argumentList);
4746 }
4747 accept(ASTVisitor visitor) => visitor.visitFunctionExpressionInvocation(this);
4748 /**
4749 * Return the list of arguments to the method.
4750 * @return the list of arguments to the method
4751 */
4752 ArgumentList get argumentList => _argumentList;
4753 Token get beginToken => _function.beginToken;
4754 /**
4755 * Return the element associated with the function being invoked, or {@code nu ll} if the AST
4756 * structure has not been resolved or the function could not be resolved. One common example of
4757 * the latter case is an expression whose value can change over time.
4758 * @return the element associated with the function being invoked
4759 */
4760 ExecutableElement get element => _element;
4761 Token get endToken => _argumentList.endToken;
4762 /**
4763 * Return the expression producing the function being invoked.
4764 * @return the expression producing the function being invoked
4765 */
4766 Expression get function => _function;
4767 /**
4768 * Set the list of arguments to the method to the given list.
4769 * @param argumentList the list of arguments to the method
4770 */
4771 void set argumentList5(ArgumentList argumentList) {
4772 this._argumentList = becomeParentOf(argumentList);
4773 }
4774 /**
4775 * Set the element associated with the function being invoked to the given ele ment.
4776 * @param element the element associated with the function being invoked
4777 */
4778 void set element9(ExecutableElement element) {
4779 this._element = element;
4780 }
4781 /**
4782 * Set the expression producing the function being invoked to the given expres sion.
4783 * @param function the expression producing the function being invoked
4784 */
4785 void set function2(Expression function) {
4786 function = becomeParentOf(function);
4787 }
4788 void visitChildren(ASTVisitor<Object> visitor) {
4789 safelyVisitChild(_function, visitor);
4790 safelyVisitChild(_argumentList, visitor);
4791 }
4792 }
4793 /**
4794 * Instances of the class {@code FunctionTypeAlias} represent a function type al ias.
4795 * <pre>
4796 * functionTypeAlias ::=
4797 * functionPrefix {@link TypeParameterList typeParameterList}? {@link FormalPara meterList formalParameterList} ';'
4798 * functionPrefix ::={@link TypeName returnType}? {@link SimpleIdentifier name}< /pre>
4799 */
4800 class FunctionTypeAlias extends TypeAlias {
4801 /**
4802 * The name of the return type of the function type being defined, or {@code n ull} if no return
4803 * type was given.
4804 */
4805 TypeName _returnType;
4806 /**
4807 * The name of the function type being declared.
4808 */
4809 SimpleIdentifier _name;
4810 /**
4811 * The type parameters for the function type, or {@code null} if the function type does not have
4812 * any type parameters.
4813 */
4814 TypeParameterList _typeParameters;
4815 /**
4816 * The parameters associated with the function type.
4817 */
4818 FormalParameterList _parameters;
4819 /**
4820 * Initialize a newly created function type alias.
4821 * @param comment the documentation comment associated with this type alias
4822 * @param metadata the annotations associated with this type alias
4823 * @param keyword the token representing the 'typedef' keyword
4824 * @param returnType the name of the return type of the function type being de fined
4825 * @param name the name of the type being declared
4826 * @param typeParameters the type parameters for the type
4827 * @param parameters the parameters associated with the function
4828 * @param semicolon the semicolon terminating the declaration
4829 */
4830 FunctionTypeAlias(Comment comment, List<Annotation> metadata, Token keyword, T ypeName returnType, SimpleIdentifier name, TypeParameterList typeParameters, For malParameterList parameters, Token semicolon) : super(comment, metadata, keyword , semicolon) {
4831 this._returnType = becomeParentOf(returnType);
4832 this._name = becomeParentOf(name);
4833 this._typeParameters = becomeParentOf(typeParameters);
4834 this._parameters = becomeParentOf(parameters);
4835 }
4836 accept(ASTVisitor visitor) => visitor.visitFunctionTypeAlias(this);
4837 /**
4838 * Return the {@link TypeAliasElement} associated with this type alias, or {@c ode null} if the AST
4839 * structure has not been resolved.
4840 * @return the {@link TypeAliasElement} associated with this type alias
4841 */
4842 TypeAliasElement get element => _name != null ? _name.element as TypeAliasElem ent : null;
4843 /**
4844 * Return the name of the function type being declared.
4845 * @return the name of the function type being declared
4846 */
4847 SimpleIdentifier get name => _name;
4848 /**
4849 * Return the parameters associated with the function type.
4850 * @return the parameters associated with the function type
4851 */
4852 FormalParameterList get parameters => _parameters;
4853 /**
4854 * Return the name of the return type of the function type being defined, or { @code null} if no
4855 * return type was given.
4856 * @return the name of the return type of the function type being defined
4857 */
4858 TypeName get returnType => _returnType;
4859 /**
4860 * Return the type parameters for the function type, or {@code null} if the fu nction type does not
4861 * have any type parameters.
4862 * @return the type parameters for the function type
4863 */
4864 TypeParameterList get typeParameters => _typeParameters;
4865 /**
4866 * Set the name of the function type being declared to the given identifier.
4867 * @param name the name of the function type being declared
4868 */
4869 void set name8(SimpleIdentifier name) {
4870 this._name = becomeParentOf(name);
4871 }
4872 /**
4873 * Set the parameters associated with the function type to the given list of p arameters.
4874 * @param parameters the parameters associated with the function type
4875 */
4876 void set parameters4(FormalParameterList parameters) {
4877 this._parameters = becomeParentOf(parameters);
4878 }
4879 /**
4880 * Set the name of the return type of the function type being defined to the g iven type name.
4881 * @param typeName the name of the return type of the function type being defi ned
4882 */
4883 void set returnType4(TypeName typeName) {
4884 _returnType = becomeParentOf(typeName);
4885 }
4886 /**
4887 * Set the type parameters for the function type to the given list of paramete rs.
4888 * @param typeParameters the type parameters for the function type
4889 */
4890 void set typeParameters4(TypeParameterList typeParameters) {
4891 this._typeParameters = becomeParentOf(typeParameters);
4892 }
4893 void visitChildren(ASTVisitor<Object> visitor) {
4894 super.visitChildren(visitor);
4895 safelyVisitChild(_returnType, visitor);
4896 safelyVisitChild(_name, visitor);
4897 safelyVisitChild(_typeParameters, visitor);
4898 safelyVisitChild(_parameters, visitor);
4899 }
4900 }
4901 /**
4902 * Instances of the class {@code FunctionTypedFormalParameter} represent a funct ion-typed formal
4903 * parameter.
4904 * <pre>
4905 * functionSignature ::={@link TypeName returnType}? {@link SimpleIdentifier ide ntifier} {@link FormalParameterList formalParameterList}</pre>
4906 */
4907 class FunctionTypedFormalParameter extends NormalFormalParameter {
4908 /**
4909 * The return type of the function, or {@code null} if the function does not h ave a return type.
4910 */
4911 TypeName _returnType;
4912 /**
4913 * The parameters of the function-typed parameter.
4914 */
4915 FormalParameterList _parameters;
4916 /**
4917 * Initialize a newly created formal parameter.
4918 * @param comment the documentation comment associated with this parameter
4919 * @param metadata the annotations associated with this parameter
4920 * @param returnType the return type of the function, or {@code null} if the f unction does not
4921 * have a return type
4922 * @param identifier the name of the function-typed parameter
4923 * @param parameters the parameters of the function-typed parameter
4924 */
4925 FunctionTypedFormalParameter(Comment comment, List<Annotation> metadata, TypeN ame returnType, SimpleIdentifier identifier, FormalParameterList parameters) : s uper(comment, metadata, identifier) {
4926 this._returnType = becomeParentOf(returnType);
4927 this._parameters = becomeParentOf(parameters);
4928 }
4929 accept(ASTVisitor visitor) => visitor.visitFunctionTypedFormalParameter(this);
4930 Token get beginToken {
4931 if (_returnType != null) {
4932 return _returnType.beginToken;
4933 }
4934 return identifier.beginToken;
4935 }
4936 Token get endToken => _parameters.endToken;
4937 /**
4938 * Return the parameters of the function-typed parameter.
4939 * @return the parameters of the function-typed parameter
4940 */
4941 FormalParameterList get parameters => _parameters;
4942 /**
4943 * Return the return type of the function, or {@code null} if the function doe s not have a return
4944 * type.
4945 * @return the return type of the function
4946 */
4947 TypeName get returnType => _returnType;
4948 bool isConst() => false;
4949 bool isFinal() => false;
4950 /**
4951 * Set the parameters of the function-typed parameter to the given parameters.
4952 * @param parameters the parameters of the function-typed parameter
4953 */
4954 void set parameters5(FormalParameterList parameters) {
4955 this._parameters = becomeParentOf(parameters);
4956 }
4957 /**
4958 * Set the return type of the function to the given type.
4959 * @param returnType the return type of the function
4960 */
4961 void set returnType5(TypeName returnType) {
4962 this._returnType = becomeParentOf(returnType);
4963 }
4964 void visitChildren(ASTVisitor<Object> visitor) {
4965 super.visitChildren(visitor);
4966 safelyVisitChild(_returnType, visitor);
4967 safelyVisitChild(identifier, visitor);
4968 safelyVisitChild(_parameters, visitor);
4969 }
4970 }
4971 /**
4972 * Instances of the class {@code HideCombinator} represent a combinator that res tricts the names
4973 * being imported to those that are not in a given list.
4974 * <pre>
4975 * hideCombinator ::=
4976 * 'hide' {@link SimpleIdentifier identifier} (',' {@link SimpleIdentifier ident ifier})
4977 * </pre>
4978 */
4979 class HideCombinator extends Combinator {
4980 /**
4981 * The list of names from the library that are hidden by this combinator.
4982 */
4983 NodeList<SimpleIdentifier> _hiddenNames;
4984 /**
4985 * Initialize a newly created import show combinator.
4986 * @param keyword the comma introducing the combinator
4987 * @param hiddenNames the list of names from the library that are hidden by th is combinator
4988 */
4989 HideCombinator(Token keyword, List<SimpleIdentifier> hiddenNames) : super(keyw ord) {
4990 this._hiddenNames = new NodeList<SimpleIdentifier>(this);
4991 this._hiddenNames.addAll(hiddenNames);
4992 }
4993 accept(ASTVisitor visitor) => visitor.visitHideCombinator(this);
4994 Token get endToken => _hiddenNames.endToken;
4995 /**
4996 * Return the list of names from the library that are hidden by this combinato r.
4997 * @return the list of names from the library that are hidden by this combinat or
4998 */
4999 NodeList<SimpleIdentifier> get hiddenNames => _hiddenNames;
5000 void visitChildren(ASTVisitor<Object> visitor) {
5001 _hiddenNames.accept(visitor);
5002 }
5003 }
5004 /**
5005 * The abstract class {@code Identifier} defines the behavior common to nodes th at represent an
5006 * identifier.
5007 * <pre>
5008 * identifier ::={@link SimpleIdentifier simpleIdentifier}| {@link PrefixedIdent ifier prefixedIdentifier}</pre>
5009 */
5010 abstract class Identifier extends Expression {
5011 /**
5012 * Return {@code true} if the given name is visible only within the library in which it is
5013 * declared.
5014 * @param name the name being tested
5015 * @return {@code true} if the given name is private
5016 */
5017 static bool isPrivateName(String name) => name.startsWith("_");
5018 /**
5019 * The element associated with this identifier, or {@code null} if the AST str ucture has not been
5020 * resolved or if this identifier could not be resolved.
5021 */
5022 Element _element;
5023 /**
5024 * Return the element associated with this identifier, or {@code null} if the AST structure has
5025 * not been resolved or if this identifier could not be resolved. One example of the latter case
5026 * is an identifier that is not defined within the scope in which it appears.
5027 * @return the element associated with this identifier
5028 */
5029 Element get element => _element;
5030 /**
5031 * Return the lexical representation of the identifier.
5032 * @return the lexical representation of the identifier
5033 */
5034 String get name;
5035 bool isAssignable() => true;
5036 /**
5037 * Set the element associated with this identifier to the given element.
5038 * @param element the element associated with this identifier
5039 */
5040 void set element10(Element element) {
5041 this._element = element;
5042 }
5043 }
5044 /**
5045 * Instances of the class {@code IfStatement} represent an if statement.
5046 * <pre>
5047 * ifStatement ::=
5048 * 'if' '(' {@link Expression expression} ')' {@link Statement thenStatement} (' else' {@link Statement elseStatement})?
5049 * </pre>
5050 */
5051 class IfStatement extends Statement {
5052 /**
5053 * The token representing the 'if' keyword.
5054 */
5055 Token _ifKeyword;
5056 /**
5057 * The left parenthesis.
5058 */
5059 Token _leftParenthesis;
5060 /**
5061 * The condition used to determine which of the statements is executed next.
5062 */
5063 Expression _condition;
5064 /**
5065 * The right parenthesis.
5066 */
5067 Token _rightParenthesis;
5068 /**
5069 * The statement that is executed if the condition evaluates to {@code true}.
5070 */
5071 Statement _thenStatement;
5072 /**
5073 * The token representing the 'else' keyword.
5074 */
5075 Token _elseKeyword;
5076 /**
5077 * The statement that is executed if the condition evaluates to {@code false}, or {@code null} if
5078 * there is no else statement.
5079 */
5080 Statement _elseStatement;
5081 /**
5082 * Initialize a newly created if statement.
5083 * @param ifKeyword the token representing the 'if' keyword
5084 * @param leftParenthesis the left parenthesis
5085 * @param condition the condition used to determine which of the statements is executed next
5086 * @param rightParenthesis the right parenthesis
5087 * @param thenStatement the statement that is executed if the condition evalua tes to {@code true}
5088 * @param elseKeyword the token representing the 'else' keyword
5089 * @param elseStatement the statement that is executed if the condition evalua tes to {@code false}
5090 */
5091 IfStatement(Token ifKeyword, Token leftParenthesis, Expression condition, Toke n rightParenthesis, Statement thenStatement, Token elseKeyword, Statement elseSt atement) {
5092 this._ifKeyword = ifKeyword;
5093 this._leftParenthesis = leftParenthesis;
5094 this._condition = becomeParentOf(condition);
5095 this._rightParenthesis = rightParenthesis;
5096 this._thenStatement = becomeParentOf(thenStatement);
5097 this._elseKeyword = elseKeyword;
5098 this._elseStatement = becomeParentOf(elseStatement);
5099 }
5100 accept(ASTVisitor visitor) => visitor.visitIfStatement(this);
5101 Token get beginToken => _ifKeyword;
5102 /**
5103 * Return the condition used to determine which of the statements is executed next.
5104 * @return the condition used to determine which statement is executed next
5105 */
5106 Expression get condition => _condition;
5107 /**
5108 * Return the token representing the 'else' keyword.
5109 * @return the token representing the 'else' keyword
5110 */
5111 Token get elseKeyword => _elseKeyword;
5112 /**
5113 * Return the statement that is executed if the condition evaluates to {@code false}, or{@code null} if there is no else statement.
5114 * @return the statement that is executed if the condition evaluates to {@code false}
5115 */
5116 Statement get elseStatement => _elseStatement;
5117 Token get endToken {
5118 if (_elseStatement != null) {
5119 return _elseStatement.endToken;
5120 }
5121 return _thenStatement.endToken;
5122 }
5123 /**
5124 * Return the token representing the 'if' keyword.
5125 * @return the token representing the 'if' keyword
5126 */
5127 Token get ifKeyword => _ifKeyword;
5128 /**
5129 * Return the left parenthesis.
5130 * @return the left parenthesis
5131 */
5132 Token get leftParenthesis => _leftParenthesis;
5133 /**
5134 * Return the right parenthesis.
5135 * @return the right parenthesis
5136 */
5137 Token get rightParenthesis => _rightParenthesis;
5138 /**
5139 * Return the statement that is executed if the condition evaluates to {@code true}.
5140 * @return the statement that is executed if the condition evaluates to {@code true}
5141 */
5142 Statement get thenStatement => _thenStatement;
5143 /**
5144 * Set the condition used to determine which of the statements is executed nex t to the given
5145 * expression.
5146 * @param expression the condition used to determine which statement is execut ed next
5147 */
5148 void set condition6(Expression expression) {
5149 _condition = becomeParentOf(expression);
5150 }
5151 /**
5152 * Set the token representing the 'else' keyword to the given token.
5153 * @param elseKeyword the token representing the 'else' keyword
5154 */
5155 void set elseKeyword2(Token elseKeyword) {
5156 this._elseKeyword = elseKeyword;
5157 }
5158 /**
5159 * Set the statement that is executed if the condition evaluates to {@code fal se} to the given
5160 * statement.
5161 * @param statement the statement that is executed if the condition evaluates to {@code false}
5162 */
5163 void set elseStatement2(Statement statement) {
5164 _elseStatement = becomeParentOf(statement);
5165 }
5166 /**
5167 * Set the token representing the 'if' keyword to the given token.
5168 * @param ifKeyword the token representing the 'if' keyword
5169 */
5170 void set ifKeyword2(Token ifKeyword) {
5171 this._ifKeyword = ifKeyword;
5172 }
5173 /**
5174 * Set the left parenthesis to the given token.
5175 * @param leftParenthesis the left parenthesis
5176 */
5177 void set leftParenthesis9(Token leftParenthesis) {
5178 this._leftParenthesis = leftParenthesis;
5179 }
5180 /**
5181 * Set the right parenthesis to the given token.
5182 * @param rightParenthesis the right parenthesis
5183 */
5184 void set rightParenthesis9(Token rightParenthesis) {
5185 this._rightParenthesis = rightParenthesis;
5186 }
5187 /**
5188 * Set the statement that is executed if the condition evaluates to {@code tru e} to the given
5189 * statement.
5190 * @param statement the statement that is executed if the condition evaluates to {@code true}
5191 */
5192 void set thenStatement2(Statement statement) {
5193 _thenStatement = becomeParentOf(statement);
5194 }
5195 void visitChildren(ASTVisitor<Object> visitor) {
5196 safelyVisitChild(_condition, visitor);
5197 safelyVisitChild(_thenStatement, visitor);
5198 safelyVisitChild(_elseStatement, visitor);
5199 }
5200 }
5201 /**
5202 * Instances of the class {@code ImplementsClause} represent the "implements" cl ause in an class
5203 * declaration.
5204 * <pre>
5205 * implementsClause ::=
5206 * 'implements' {@link TypeName superclass} (',' {@link TypeName superclass})
5207 * </pre>
5208 */
5209 class ImplementsClause extends ASTNode {
5210 /**
5211 * The token representing the 'implements' keyword.
5212 */
5213 Token _keyword;
5214 /**
5215 * The interfaces that are being implemented.
5216 */
5217 NodeList<TypeName> _interfaces;
5218 /**
5219 * Initialize a newly created extends clause.
5220 * @param keyword the token representing the 'implements' keyword
5221 * @param interfaces the interfaces that are being implemented
5222 */
5223 ImplementsClause(Token keyword, List<TypeName> interfaces) {
5224 this._interfaces = new NodeList<TypeName>(this);
5225 this._keyword = keyword;
5226 this._interfaces.addAll(interfaces);
5227 }
5228 accept(ASTVisitor visitor) => visitor.visitImplementsClause(this);
5229 Token get beginToken => _keyword;
5230 Token get endToken => _interfaces.endToken;
5231 /**
5232 * Return the list of the interfaces that are being implemented.
5233 * @return the list of the interfaces that are being implemented
5234 */
5235 NodeList<TypeName> get interfaces => _interfaces;
5236 /**
5237 * Return the token representing the 'implements' keyword.
5238 * @return the token representing the 'implements' keyword
5239 */
5240 Token get keyword => _keyword;
5241 /**
5242 * Set the token representing the 'implements' keyword to the given token.
5243 * @param keyword the token representing the 'implements' keyword
5244 */
5245 void set keyword11(Token keyword) {
5246 this._keyword = keyword;
5247 }
5248 void visitChildren(ASTVisitor<Object> visitor) {
5249 _interfaces.accept(visitor);
5250 }
5251 }
5252 /**
5253 * Instances of the class {@code ImportDirective} represent an import directive.
5254 * <pre>
5255 * importDirective ::={@link Annotation metadata} 'import' {@link StringLiteral libraryUri} ('as' identifier)? {@link Combinator combinator}* ';'
5256 * </pre>
5257 */
5258 class ImportDirective extends NamespaceDirective {
5259 /**
5260 * The token representing the 'as' token, or {@code null} if the imported name s are not prefixed.
5261 */
5262 Token _asToken;
5263 /**
5264 * The prefix to be used with the imported names, or {@code null} if the impor ted names are not
5265 * prefixed.
5266 */
5267 SimpleIdentifier _prefix;
5268 /**
5269 * Initialize a newly created import directive.
5270 * @param comment the documentation comment associated with this directive
5271 * @param metadata the annotations associated with the directive
5272 * @param keyword the token representing the 'import' keyword
5273 * @param libraryUri the URI of the library being imported
5274 * @param asToken the token representing the 'as' token
5275 * @param prefix the prefix to be used with the imported names
5276 * @param combinators the combinators used to control how names are imported
5277 * @param semicolon the semicolon terminating the directive
5278 */
5279 ImportDirective(Comment comment, List<Annotation> metadata, Token keyword, Str ingLiteral libraryUri, Token asToken, SimpleIdentifier prefix, List<Combinator> combinators, Token semicolon) : super(comment, metadata, keyword, libraryUri, co mbinators, semicolon) {
5280 this._asToken = asToken;
5281 this._prefix = becomeParentOf(prefix);
5282 }
5283 accept(ASTVisitor visitor) => visitor.visitImportDirective(this);
5284 /**
5285 * Return the token representing the 'as' token, or {@code null} if the import ed names are not
5286 * prefixed.
5287 * @return the token representing the 'as' token
5288 */
5289 Token get asToken => _asToken;
5290 /**
5291 * Return the prefix to be used with the imported names, or {@code null} if th e imported names are
5292 * not prefixed.
5293 * @return the prefix to be used with the imported names
5294 */
5295 SimpleIdentifier get prefix => _prefix;
5296 /**
5297 * Set the token representing the 'as' token to the given token.
5298 * @param asToken the token representing the 'as' token
5299 */
5300 void set asToken2(Token asToken) {
5301 this._asToken = asToken;
5302 }
5303 /**
5304 * Set the prefix to be used with the imported names to the given identifier.
5305 * @param prefix the prefix to be used with the imported names
5306 */
5307 void set prefix2(SimpleIdentifier prefix) {
5308 this._prefix = becomeParentOf(prefix);
5309 }
5310 void visitChildren(ASTVisitor<Object> visitor) {
5311 super.visitChildren(visitor);
5312 safelyVisitChild(libraryUri, visitor);
5313 safelyVisitChild(_prefix, visitor);
5314 combinators.accept(visitor);
5315 }
5316 }
5317 /**
5318 * Instances of the class {@code IndexExpression} represent an index expression.
5319 * <pre>
5320 * indexExpression ::={@link Expression target} '[' {@link Expression index} ']'
5321 * </pre>
5322 */
5323 class IndexExpression extends Expression {
5324 /**
5325 * The expression used to compute the object being indexed, or {@code null} if this index
5326 * expression is part of a cascade expression.
5327 */
5328 Expression _target;
5329 /**
5330 * The period ("..") before a cascaded index expression, or {@code null} if th is index expression
5331 * is not part of a cascade expression.
5332 */
5333 Token _period;
5334 /**
5335 * The left square bracket.
5336 */
5337 Token _leftBracket;
5338 /**
5339 * The expression used to compute the index.
5340 */
5341 Expression _index;
5342 /**
5343 * The right square bracket.
5344 */
5345 Token _rightBracket;
5346 /**
5347 * The element associated with the operator, or {@code null} if the AST struct ure has not been
5348 * resolved or if the operator could not be resolved.
5349 */
5350 MethodElement _element;
5351 /**
5352 * Initialize a newly created index expression.
5353 * @param target the expression used to compute the object being indexed
5354 * @param leftBracket the left square bracket
5355 * @param index the expression used to compute the index
5356 * @param rightBracket the right square bracket
5357 */
5358 IndexExpression.con1(Expression target, Token leftBracket, Expression index, T oken rightBracket) {
5359 _jtd_constructor_55_impl(target, leftBracket, index, rightBracket);
5360 }
5361 _jtd_constructor_55_impl(Expression target, Token leftBracket, Expression inde x, Token rightBracket) {
5362 this._target = becomeParentOf(target);
5363 this._leftBracket = leftBracket;
5364 this._index = becomeParentOf(index);
5365 this._rightBracket = rightBracket;
5366 }
5367 /**
5368 * Initialize a newly created index expression.
5369 * @param period the period ("..") before a cascaded index expression
5370 * @param leftBracket the left square bracket
5371 * @param index the expression used to compute the index
5372 * @param rightBracket the right square bracket
5373 */
5374 IndexExpression.con2(Token period, Token leftBracket, Expression index, Token rightBracket) {
5375 _jtd_constructor_56_impl(period, leftBracket, index, rightBracket);
5376 }
5377 _jtd_constructor_56_impl(Token period, Token leftBracket, Expression index, To ken rightBracket) {
5378 this._period = period;
5379 this._leftBracket = leftBracket;
5380 this._index = becomeParentOf(index);
5381 this._rightBracket = rightBracket;
5382 }
5383 accept(ASTVisitor visitor) => visitor.visitIndexExpression(this);
5384 /**
5385 * Return the expression used to compute the object being indexed, or {@code n ull} if this index
5386 * expression is part of a cascade expression.
5387 * @return the expression used to compute the object being indexed
5388 * @see #getRealTarget()
5389 */
5390 Expression get array => _target;
5391 Token get beginToken {
5392 if (_target != null) {
5393 return _target.beginToken;
5394 }
5395 return _period;
5396 }
5397 /**
5398 * Return the element associated with the operator, or {@code null} if the AST structure has not
5399 * been resolved or if the operator could not be resolved. One example of the latter case is an
5400 * operator that is not defined for the type of the left-hand operand.
5401 * @return the element associated with this operator
5402 */
5403 MethodElement get element => _element;
5404 Token get endToken => _rightBracket;
5405 /**
5406 * Return the expression used to compute the index.
5407 * @return the expression used to compute the index
5408 */
5409 Expression get index => _index;
5410 /**
5411 * Return the left square bracket.
5412 * @return the left square bracket
5413 */
5414 Token get leftBracket => _leftBracket;
5415 /**
5416 * Return the period ("..") before a cascaded index expression, or {@code null } if this index
5417 * expression is not part of a cascade expression.
5418 * @return the period ("..") before a cascaded index expression
5419 */
5420 Token get period => _period;
5421 /**
5422 * Return the expression used to compute the object being indexed. If this ind ex expression is not
5423 * part of a cascade expression, then this is the same as {@link #getArray()}. If this index
5424 * expression is part of a cascade expression, then the target expression stor ed with the cascade
5425 * expression is returned.
5426 * @return the expression used to compute the object being indexed
5427 * @see #getArray()
5428 */
5429 Expression get realTarget {
5430 if (isCascaded()) {
5431 ASTNode ancestor = parent;
5432 while (ancestor is! CascadeExpression) {
5433 if (ancestor == null) {
5434 return _target;
5435 }
5436 ancestor = ancestor.parent;
5437 }
5438 return (ancestor as CascadeExpression).target;
5439 }
5440 return _target;
5441 }
5442 /**
5443 * Return the right square bracket.
5444 * @return the right square bracket
5445 */
5446 Token get rightBracket => _rightBracket;
5447 /**
5448 * Return {@code true} if this expression is computing a right-hand value.
5449 * <p>
5450 * Note that {@link #inGetterContext()} and {@link #inSetterContext()} are not opposites, nor are
5451 * they mutually exclusive. In other words, it is possible for both methods to return {@code true}when invoked on the same node.
5452 * @return {@code true} if this expression is in a context where the operator '[]' will be invoked
5453 */
5454 bool inGetterContext() {
5455 ASTNode parent4 = parent;
5456 if (parent4 is AssignmentExpression) {
5457 AssignmentExpression assignment = parent4 as AssignmentExpression;
5458 if (assignment.leftHandSide == this && assignment.operator.type == TokenTy pe.EQ) {
5459 return false;
5460 }
5461 }
5462 return true;
5463 }
5464 /**
5465 * Return {@code true} if this expression is computing a left-hand value.
5466 * <p>
5467 * Note that {@link #inGetterContext()} and {@link #inSetterContext()} are not opposites, nor are
5468 * they mutually exclusive. In other words, it is possible for both methods to return {@code true}when invoked on the same node.
5469 * @return {@code true} if this expression is in a context where the operator '[]=' will be
5470 * invoked
5471 */
5472 bool inSetterContext() {
5473 ASTNode parent5 = parent;
5474 if (parent5 is PrefixExpression) {
5475 return (parent5 as PrefixExpression).operator.type.isIncrementOperator();
5476 } else if (parent5 is PostfixExpression) {
5477 return true;
5478 } else if (parent5 is AssignmentExpression) {
5479 return (parent5 as AssignmentExpression).leftHandSide == this;
5480 }
5481 return false;
5482 }
5483 bool isAssignable() => true;
5484 /**
5485 * Return {@code true} if this expression is cascaded. If it is, then the targ et of this
5486 * expression is not stored locally but is stored in the nearest ancestor that is a{@link CascadeExpression}.
5487 * @return {@code true} if this expression is cascaded
5488 */
5489 bool isCascaded() => _period != null;
5490 /**
5491 * Set the expression used to compute the object being indexed to the given ex pression.
5492 * @param expression the expression used to compute the object being indexed
5493 */
5494 void set array2(Expression expression) {
5495 _target = becomeParentOf(expression);
5496 }
5497 /**
5498 * Set the element associated with the operator to the given element.
5499 * @param element the element associated with this operator
5500 */
5501 void set element11(MethodElement element) {
5502 this._element = element;
5503 }
5504 /**
5505 * Set the expression used to compute the index to the given expression.
5506 * @param expression the expression used to compute the index
5507 */
5508 void set index2(Expression expression) {
5509 _index = becomeParentOf(expression);
5510 }
5511 /**
5512 * Set the left square bracket to the given token.
5513 * @param bracket the left square bracket
5514 */
5515 void set leftBracket4(Token bracket) {
5516 _leftBracket = bracket;
5517 }
5518 /**
5519 * Set the period ("..") before a cascaded index expression to the given token .
5520 * @param period the period ("..") before a cascaded index expression
5521 */
5522 void set period7(Token period) {
5523 this._period = period;
5524 }
5525 /**
5526 * Set the right square bracket to the given token.
5527 * @param bracket the right square bracket
5528 */
5529 void set rightBracket4(Token bracket) {
5530 _rightBracket = bracket;
5531 }
5532 void visitChildren(ASTVisitor<Object> visitor) {
5533 safelyVisitChild(_target, visitor);
5534 safelyVisitChild(_index, visitor);
5535 }
5536 }
5537 /**
5538 * Instances of the class {@code InstanceCreationExpression} represent an instan ce creation
5539 * expression.
5540 * <pre>
5541 * newExpression ::=
5542 * ('new' | 'const') {@link TypeName type} ('.' {@link SimpleIdentifier identifi er})? {@link ArgumentList argumentList}</pre>
5543 */
5544 class InstanceCreationExpression extends Expression {
5545 /**
5546 * The keyword used to indicate how an object should be created.
5547 */
5548 Token _keyword;
5549 /**
5550 * The name of the constructor to be invoked.
5551 */
5552 ConstructorName _constructorName;
5553 /**
5554 * The list of arguments to the constructor.
5555 */
5556 ArgumentList _argumentList;
5557 /**
5558 * The element associated with the constructor, or {@code null} if the AST str ucture has not been
5559 * resolved or if the constructor could not be resolved.
5560 */
5561 ConstructorElement _element;
5562 /**
5563 * Initialize a newly created instance creation expression.
5564 * @param keyword the keyword used to indicate how an object should be created
5565 * @param constructorName the name of the constructor to be invoked
5566 * @param argumentList the list of arguments to the constructor
5567 */
5568 InstanceCreationExpression(Token keyword, ConstructorName constructorName, Arg umentList argumentList) {
5569 this._keyword = keyword;
5570 this._constructorName = becomeParentOf(constructorName);
5571 this._argumentList = becomeParentOf(argumentList);
5572 }
5573 accept(ASTVisitor visitor) => visitor.visitInstanceCreationExpression(this);
5574 /**
5575 * Return the list of arguments to the constructor.
5576 * @return the list of arguments to the constructor
5577 */
5578 ArgumentList get argumentList => _argumentList;
5579 Token get beginToken => _keyword;
5580 /**
5581 * Return the name of the constructor to be invoked.
5582 * @return the name of the constructor to be invoked
5583 */
5584 ConstructorName get constructorName => _constructorName;
5585 /**
5586 * Return the element associated with the constructor, or {@code null} if the AST structure has
5587 * not been resolved or if the constructor could not be resolved.
5588 * @return the element associated with the constructor
5589 */
5590 ConstructorElement get element => _element;
5591 Token get endToken => _argumentList.endToken;
5592 /**
5593 * Return the keyword used to indicate how an object should be created.
5594 * @return the keyword used to indicate how an object should be created
5595 */
5596 Token get keyword => _keyword;
5597 /**
5598 * Set the list of arguments to the constructor to the given list.
5599 * @param argumentList the list of arguments to the constructor
5600 */
5601 void set argumentList6(ArgumentList argumentList) {
5602 this._argumentList = becomeParentOf(argumentList);
5603 }
5604 /**
5605 * Set the name of the constructor to be invoked to the given name.
5606 * @param constructorName the name of the constructor to be invoked
5607 */
5608 void set constructorName3(ConstructorName constructorName) {
5609 this._constructorName = constructorName;
5610 }
5611 /**
5612 * Set the element associated with the constructor to the given element.
5613 * @param element the element associated with the constructor
5614 */
5615 void set element12(ConstructorElement element) {
5616 this._element = element;
5617 }
5618 /**
5619 * Set the keyword used to indicate how an object should be created to the giv en keyword.
5620 * @param keyword the keyword used to indicate how an object should be created
5621 */
5622 void set keyword12(Token keyword) {
5623 this._keyword = keyword;
5624 }
5625 void visitChildren(ASTVisitor<Object> visitor) {
5626 safelyVisitChild(_constructorName, visitor);
5627 safelyVisitChild(_argumentList, visitor);
5628 }
5629 }
5630 /**
5631 * Instances of the class {@code IntegerLiteral} represent an integer literal ex pression.
5632 * <pre>
5633 * integerLiteral ::=
5634 * decimalIntegerLiteral
5635 * | hexidecimalIntegerLiteral
5636 * decimalIntegerLiteral ::=
5637 * decimalDigit+
5638 * hexidecimalIntegerLiteral ::=
5639 * '0x' hexidecimalDigit+
5640 * | '0X' hexidecimalDigit+
5641 * </pre>
5642 */
5643 class IntegerLiteral extends Literal {
5644 /**
5645 * The token representing the literal.
5646 */
5647 Token _literal;
5648 /**
5649 * The value of the literal.
5650 */
5651 int _value = 0;
5652 /**
5653 * Initialize a newly created integer literal.
5654 * @param literal the token representing the literal
5655 * @param value the value of the literal
5656 */
5657 IntegerLiteral.con1(Token literal, int value) {
5658 _jtd_constructor_58_impl(literal, value);
5659 }
5660 _jtd_constructor_58_impl(Token literal, int value) {
5661 this._literal = literal;
5662 this._value = value;
5663 }
5664 /**
5665 * Initialize a newly created integer literal.
5666 * @param token the token representing the literal
5667 * @param value the value of the literal
5668 */
5669 IntegerLiteral.con2(Token token, int value) {
5670 _jtd_constructor_59_impl(token, value);
5671 }
5672 _jtd_constructor_59_impl(Token token, int value) {
5673 _jtd_constructor_58_impl(token, value);
5674 }
5675 accept(ASTVisitor visitor) => visitor.visitIntegerLiteral(this);
5676 Token get beginToken => _literal;
5677 Token get endToken => _literal;
5678 /**
5679 * Return the token representing the literal.
5680 * @return the token representing the literal
5681 */
5682 Token get literal => _literal;
5683 /**
5684 * Return the value of the literal.
5685 * @return the value of the literal
5686 */
5687 int get value => _value;
5688 /**
5689 * Set the token representing the literal to the given token.
5690 * @param literal the token representing the literal
5691 */
5692 void set literal4(Token literal) {
5693 this._literal = literal;
5694 }
5695 /**
5696 * Set the value of the literal to the given value.
5697 * @param value the value of the literal
5698 */
5699 void set value6(int value) {
5700 this._value = value;
5701 }
5702 void visitChildren(ASTVisitor<Object> visitor) {
5703 }
5704 }
5705 /**
5706 * The abstract class {@code InterpolationElement} defines the behavior common t o elements within a{@link StringInterpolation string interpolation}.
5707 * <pre>
5708 * interpolationElement ::={@link InterpolationExpression interpolationExpressio n}| {@link InterpolationString interpolationString}</pre>
5709 */
5710 abstract class InterpolationElement extends ASTNode {
5711 }
5712 /**
5713 * Instances of the class {@code InterpolationExpression} represent an expressio n embedded in a
5714 * string interpolation.
5715 * <pre>
5716 * interpolationExpression ::=
5717 * '$' {@link SimpleIdentifier identifier}| '$' '{' {@link Expression expression } '}'
5718 * </pre>
5719 */
5720 class InterpolationExpression extends InterpolationElement {
5721 /**
5722 * The token used to introduce the interpolation expression; either '$' if the expression is a
5723 * simple identifier or '${' if the expression is a full expression.
5724 */
5725 Token _leftBracket;
5726 /**
5727 * The expression to be evaluated for the value to be converted into a string.
5728 */
5729 Expression _expression;
5730 /**
5731 * The right curly bracket, or {@code null} if the expression is an identifier without brackets.
5732 */
5733 Token _rightBracket;
5734 /**
5735 * Initialize a newly created interpolation expression.
5736 * @param leftBracket the left curly bracket
5737 * @param expression the expression to be evaluated for the value to be conver ted into a string
5738 * @param rightBracket the right curly bracket
5739 */
5740 InterpolationExpression(Token leftBracket, Expression expression, Token rightB racket) {
5741 this._leftBracket = leftBracket;
5742 this._expression = becomeParentOf(expression);
5743 this._rightBracket = rightBracket;
5744 }
5745 accept(ASTVisitor visitor) => visitor.visitInterpolationExpression(this);
5746 Token get beginToken => _leftBracket;
5747 Token get endToken {
5748 if (_rightBracket != null) {
5749 return _rightBracket;
5750 }
5751 return _expression.endToken;
5752 }
5753 /**
5754 * Return the expression to be evaluated for the value to be converted into a string.
5755 * @return the expression to be evaluated for the value to be converted into a string
5756 */
5757 Expression get expression => _expression;
5758 /**
5759 * Return the left curly bracket.
5760 * @return the left curly bracket
5761 */
5762 Token get leftBracket => _leftBracket;
5763 /**
5764 * Return the right curly bracket.
5765 * @return the right curly bracket
5766 */
5767 Token get rightBracket => _rightBracket;
5768 /**
5769 * Set the expression to be evaluated for the value to be converted into a str ing to the given
5770 * expression.
5771 * @param expression the expression to be evaluated for the value to be conver ted into a string
5772 */
5773 void set expression6(Expression expression) {
5774 this._expression = becomeParentOf(expression);
5775 }
5776 /**
5777 * Set the left curly bracket to the given token.
5778 * @param leftBracket the left curly bracket
5779 */
5780 void set leftBracket5(Token leftBracket) {
5781 this._leftBracket = leftBracket;
5782 }
5783 /**
5784 * Set the right curly bracket to the given token.
5785 * @param rightBracket the right curly bracket
5786 */
5787 void set rightBracket5(Token rightBracket) {
5788 this._rightBracket = rightBracket;
5789 }
5790 void visitChildren(ASTVisitor<Object> visitor) {
5791 safelyVisitChild(_expression, visitor);
5792 }
5793 }
5794 /**
5795 * Instances of the class {@code InterpolationString} represent a non-empty subs tring of an
5796 * interpolated string.
5797 * <pre>
5798 * interpolationString ::=
5799 * characters
5800 * </pre>
5801 */
5802 class InterpolationString extends InterpolationElement {
5803 /**
5804 * The characters that will be added to the string.
5805 */
5806 Token _contents;
5807 /**
5808 * The value of the literal.
5809 */
5810 String _value;
5811 /**
5812 * Initialize a newly created string of characters that are part of a string i nterpolation.
5813 * @param the characters that will be added to the string
5814 * @param value the value of the literal
5815 */
5816 InterpolationString(Token contents, String value) {
5817 this._contents = contents;
5818 this._value = value;
5819 }
5820 accept(ASTVisitor visitor) => visitor.visitInterpolationString(this);
5821 Token get beginToken => _contents;
5822 /**
5823 * Return the characters that will be added to the string.
5824 * @return the characters that will be added to the string
5825 */
5826 Token get contents => _contents;
5827 Token get endToken => _contents;
5828 /**
5829 * Return the value of the literal.
5830 * @return the value of the literal
5831 */
5832 String get value => _value;
5833 /**
5834 * Set the characters that will be added to the string to those in the given s tring.
5835 * @param string the characters that will be added to the string
5836 */
5837 void set contents2(Token string) {
5838 _contents = string;
5839 }
5840 /**
5841 * Set the value of the literal to the given string.
5842 * @param string the value of the literal
5843 */
5844 void set value7(String string) {
5845 _value = string;
5846 }
5847 void visitChildren(ASTVisitor<Object> visitor) {
5848 }
5849 }
5850 /**
5851 * Instances of the class {@code IsExpression} represent an is expression.
5852 * <pre>
5853 * isExpression ::={@link Expression expression} 'is' '!'? {@link TypeName type} </pre>
5854 */
5855 class IsExpression extends Expression {
5856 /**
5857 * The expression used to compute the value whose type is being tested.
5858 */
5859 Expression _expression;
5860 /**
5861 * The is operator.
5862 */
5863 Token _isOperator;
5864 /**
5865 * The not operator, or {@code null} if the sense of the test is not negated.
5866 */
5867 Token _notOperator;
5868 /**
5869 * The name of the type being tested for.
5870 */
5871 TypeName _type;
5872 /**
5873 * Initialize a newly created is expression.
5874 * @param expression the expression used to compute the value whose type is be ing tested
5875 * @param isOperator the is operator
5876 * @param notOperator the not operator, or {@code null} if the sense of the te st is not negated
5877 * @param type the name of the type being tested for
5878 */
5879 IsExpression(Expression expression, Token isOperator, Token notOperator, TypeN ame type) {
5880 this._expression = becomeParentOf(expression);
5881 this._isOperator = isOperator;
5882 this._notOperator = notOperator;
5883 this._type = becomeParentOf(type);
5884 }
5885 accept(ASTVisitor visitor) => visitor.visitIsExpression(this);
5886 Token get beginToken => _expression.beginToken;
5887 Token get endToken => _type.endToken;
5888 /**
5889 * Return the expression used to compute the value whose type is being tested.
5890 * @return the expression used to compute the value whose type is being tested
5891 */
5892 Expression get expression => _expression;
5893 /**
5894 * Return the is operator being applied.
5895 * @return the is operator being applied
5896 */
5897 Token get isOperator => _isOperator;
5898 /**
5899 * Return the not operator being applied.
5900 * @return the not operator being applied
5901 */
5902 Token get notOperator => _notOperator;
5903 /**
5904 * Return the name of the type being tested for.
5905 * @return the name of the type being tested for
5906 */
5907 TypeName get type => _type;
5908 /**
5909 * Set the expression used to compute the value whose type is being tested to the given
5910 * expression.
5911 * @param expression the expression used to compute the value whose type is be ing tested
5912 */
5913 void set expression7(Expression expression) {
5914 this._expression = becomeParentOf(expression);
5915 }
5916 /**
5917 * Set the is operator being applied to the given operator.
5918 * @param isOperator the is operator being applied
5919 */
5920 void set isOperator2(Token isOperator) {
5921 this._isOperator = isOperator;
5922 }
5923 /**
5924 * Set the not operator being applied to the given operator.
5925 * @param notOperator the is operator being applied
5926 */
5927 void set notOperator2(Token notOperator) {
5928 this._notOperator = notOperator;
5929 }
5930 /**
5931 * Set the name of the type being tested for to the given name.
5932 * @param name the name of the type being tested for
5933 */
5934 void set type5(TypeName name) {
5935 this._type = becomeParentOf(name);
5936 }
5937 void visitChildren(ASTVisitor<Object> visitor) {
5938 safelyVisitChild(_expression, visitor);
5939 safelyVisitChild(_type, visitor);
5940 }
5941 }
5942 /**
5943 * Instances of the class {@code Label} represent a label.
5944 * <pre>
5945 * label ::={@link SimpleIdentifier label} ':'
5946 * </pre>
5947 */
5948 class Label extends ASTNode {
5949 /**
5950 * The label being associated with the statement.
5951 */
5952 SimpleIdentifier _label;
5953 /**
5954 * The colon that separates the label from the statement.
5955 */
5956 Token _colon;
5957 /**
5958 * Initialize a newly created label.
5959 * @param label the label being applied
5960 * @param colon the colon that separates the label from whatever follows
5961 */
5962 Label(SimpleIdentifier label, Token colon) {
5963 this._label = becomeParentOf(label);
5964 this._colon = colon;
5965 }
5966 accept(ASTVisitor visitor) => visitor.visitLabel(this);
5967 Token get beginToken => _label.beginToken;
5968 /**
5969 * Return the colon that separates the label from the statement.
5970 * @return the colon that separates the label from the statement
5971 */
5972 Token get colon => _colon;
5973 Token get endToken => _colon;
5974 /**
5975 * Return the label being associated with the statement.
5976 * @return the label being associated with the statement
5977 */
5978 SimpleIdentifier get label => _label;
5979 /**
5980 * Set the colon that separates the label from the statement to the given toke n.
5981 * @param colon the colon that separates the label from the statement
5982 */
5983 void set colon3(Token colon) {
5984 this._colon = colon;
5985 }
5986 /**
5987 * Set the label being associated with the statement to the given label.
5988 * @param label the label being associated with the statement
5989 */
5990 void set label4(SimpleIdentifier label) {
5991 this._label = becomeParentOf(label);
5992 }
5993 void visitChildren(ASTVisitor<Object> visitor) {
5994 safelyVisitChild(_label, visitor);
5995 }
5996 }
5997 /**
5998 * Instances of the class {@code LabeledStatement} represent a statement that ha s a label associated
5999 * with them.
6000 * <pre>
6001 * labeledStatement ::={@link Label label}+ {@link Statement statement}</pre>
6002 */
6003 class LabeledStatement extends Statement {
6004 /**
6005 * The labels being associated with the statement.
6006 */
6007 NodeList<Label> _labels;
6008 /**
6009 * The statement with which the labels are being associated.
6010 */
6011 Statement _statement;
6012 /**
6013 * Initialize a newly created labeled statement.
6014 * @param labels the labels being associated with the statement
6015 * @param statement the statement with which the labels are being associated
6016 */
6017 LabeledStatement(List<Label> labels, Statement statement) {
6018 this._labels = new NodeList<Label>(this);
6019 this._labels.addAll(labels);
6020 this._statement = becomeParentOf(statement);
6021 }
6022 accept(ASTVisitor visitor) => visitor.visitLabeledStatement(this);
6023 Token get beginToken {
6024 if (!_labels.isEmpty) {
6025 return _labels.beginToken;
6026 }
6027 return _statement.beginToken;
6028 }
6029 Token get endToken => _statement.endToken;
6030 /**
6031 * Return the labels being associated with the statement.
6032 * @return the labels being associated with the statement
6033 */
6034 NodeList<Label> get labels => _labels;
6035 /**
6036 * Return the statement with which the labels are being associated.
6037 * @return the statement with which the labels are being associated
6038 */
6039 Statement get statement => _statement;
6040 /**
6041 * Set the statement with which the labels are being associated to the given s tatement.
6042 * @param statement the statement with which the labels are being associated
6043 */
6044 void set statement2(Statement statement) {
6045 this._statement = becomeParentOf(statement);
6046 }
6047 void visitChildren(ASTVisitor<Object> visitor) {
6048 _labels.accept(visitor);
6049 safelyVisitChild(_statement, visitor);
6050 }
6051 }
6052 /**
6053 * Instances of the class {@code LibraryDirective} represent a library directive .
6054 * <pre>
6055 * libraryDirective ::={@link Annotation metadata} 'library' {@link Identifier n ame} ';'
6056 * </pre>
6057 */
6058 class LibraryDirective extends Directive {
6059 /**
6060 * The token representing the 'library' token.
6061 */
6062 Token _libraryToken;
6063 /**
6064 * The name of the library being defined.
6065 */
6066 LibraryIdentifier _name;
6067 /**
6068 * The semicolon terminating the directive.
6069 */
6070 Token _semicolon;
6071 /**
6072 * Initialize a newly created library directive.
6073 * @param comment the documentation comment associated with this directive
6074 * @param metadata the annotations associated with the directive
6075 * @param libraryToken the token representing the 'library' token
6076 * @param name the name of the library being defined
6077 * @param semicolon the semicolon terminating the directive
6078 */
6079 LibraryDirective(Comment comment, List<Annotation> metadata, Token libraryToke n, LibraryIdentifier name, Token semicolon) : super(comment, metadata) {
6080 this._libraryToken = libraryToken;
6081 this._name = becomeParentOf(name);
6082 this._semicolon = semicolon;
6083 }
6084 accept(ASTVisitor visitor) => visitor.visitLibraryDirective(this);
6085 Token get endToken => _semicolon;
6086 Token get keyword => _libraryToken;
6087 /**
6088 * Return the token representing the 'library' token.
6089 * @return the token representing the 'library' token
6090 */
6091 Token get libraryToken => _libraryToken;
6092 /**
6093 * Return the name of the library being defined.
6094 * @return the name of the library being defined
6095 */
6096 LibraryIdentifier get name => _name;
6097 /**
6098 * Return the semicolon terminating the directive.
6099 * @return the semicolon terminating the directive
6100 */
6101 Token get semicolon => _semicolon;
6102 /**
6103 * Set the token representing the 'library' token to the given token.
6104 * @param libraryToken the token representing the 'library' token
6105 */
6106 void set libraryToken2(Token libraryToken) {
6107 this._libraryToken = libraryToken;
6108 }
6109 /**
6110 * Set the name of the library being defined to the given name.
6111 * @param name the name of the library being defined
6112 */
6113 void set name9(LibraryIdentifier name) {
6114 this._name = becomeParentOf(name);
6115 }
6116 /**
6117 * Set the semicolon terminating the directive to the given token.
6118 * @param semicolon the semicolon terminating the directive
6119 */
6120 void set semicolon11(Token semicolon) {
6121 this._semicolon = semicolon;
6122 }
6123 void visitChildren(ASTVisitor<Object> visitor) {
6124 super.visitChildren(visitor);
6125 safelyVisitChild(_name, visitor);
6126 }
6127 Token get firstTokenAfterCommentAndMetadata => _libraryToken;
6128 }
6129 /**
6130 * Instances of the class {@code LibraryIdentifier} represent the identifier for a library.
6131 * <pre>
6132 * libraryIdentifier ::={@link SimpleIdentifier component} ('.' {@link SimpleIde ntifier component})
6133 * </pre>
6134 */
6135 class LibraryIdentifier extends Identifier {
6136 /**
6137 * The components of the identifier.
6138 */
6139 NodeList<SimpleIdentifier> _components;
6140 /**
6141 * Initialize a newly created prefixed identifier.
6142 * @param components the components of the identifier
6143 */
6144 LibraryIdentifier(List<SimpleIdentifier> components) {
6145 this._components = new NodeList<SimpleIdentifier>(this);
6146 this._components.addAll(components);
6147 }
6148 accept(ASTVisitor visitor) => visitor.visitLibraryIdentifier(this);
6149 Token get beginToken => _components.beginToken;
6150 /**
6151 * Return the components of the identifier.
6152 * @return the components of the identifier
6153 */
6154 NodeList<SimpleIdentifier> get components => _components;
6155 Token get endToken => _components.endToken;
6156 String get name {
6157 StringBuffer builder = new StringBuffer();
6158 bool needsPeriod = false;
6159 for (SimpleIdentifier identifier in _components) {
6160 if (needsPeriod) {
6161 builder.add(".");
6162 } else {
6163 needsPeriod = true;
6164 }
6165 builder.add(identifier.name);
6166 }
6167 return builder.toString();
6168 }
6169 void visitChildren(ASTVisitor<Object> visitor) {
6170 _components.accept(visitor);
6171 }
6172 }
6173 /**
6174 * Instances of the class {@code ListLiteral} represent a list literal.
6175 * <pre>
6176 * listLiteral ::=
6177 * 'const'? ('<' {@link TypeName type} '>')? '[' ({@link Expression expressionLi st} ','?)? ']'
6178 * </pre>
6179 */
6180 class ListLiteral extends TypedLiteral {
6181 /**
6182 * The left square bracket.
6183 */
6184 Token _leftBracket;
6185 /**
6186 * The expressions used to compute the elements of the list.
6187 */
6188 NodeList<Expression> _elements;
6189 /**
6190 * The right square bracket.
6191 */
6192 Token _rightBracket;
6193 /**
6194 * Initialize a newly created list literal.
6195 * @param modifier the const modifier associated with this literal
6196 * @param typeArguments the type argument associated with this literal, or {@c ode null} if no type
6197 * arguments were declared
6198 * @param leftBracket the left square bracket
6199 * @param elements the expressions used to compute the elements of the list
6200 * @param rightBracket the right square bracket
6201 */
6202 ListLiteral(Token modifier, TypeArgumentList typeArguments, Token leftBracket, List<Expression> elements, Token rightBracket) : super(modifier, typeArguments) {
6203 this._elements = new NodeList<Expression>(this);
6204 this._leftBracket = leftBracket;
6205 this._elements.addAll(elements);
6206 this._rightBracket = rightBracket;
6207 }
6208 accept(ASTVisitor visitor) => visitor.visitListLiteral(this);
6209 Token get beginToken {
6210 Token token = modifier;
6211 if (token != null) {
6212 return token;
6213 }
6214 TypeArgumentList typeArguments6 = typeArguments;
6215 if (typeArguments6 != null) {
6216 return typeArguments6.beginToken;
6217 }
6218 return _leftBracket;
6219 }
6220 /**
6221 * Return the expressions used to compute the elements of the list.
6222 * @return the expressions used to compute the elements of the list
6223 */
6224 NodeList<Expression> get elements => _elements;
6225 Token get endToken => _rightBracket;
6226 /**
6227 * Return the left square bracket.
6228 * @return the left square bracket
6229 */
6230 Token get leftBracket => _leftBracket;
6231 /**
6232 * Return the right square bracket.
6233 * @return the right square bracket
6234 */
6235 Token get rightBracket => _rightBracket;
6236 /**
6237 * Set the left square bracket to the given token.
6238 * @param bracket the left square bracket
6239 */
6240 void set leftBracket6(Token bracket) {
6241 _leftBracket = bracket;
6242 }
6243 /**
6244 * Set the right square bracket to the given token.
6245 * @param bracket the right square bracket
6246 */
6247 void set rightBracket6(Token bracket) {
6248 _rightBracket = bracket;
6249 }
6250 void visitChildren(ASTVisitor<Object> visitor) {
6251 super.visitChildren(visitor);
6252 _elements.accept(visitor);
6253 }
6254 }
6255 /**
6256 * The abstract class {@code Literal} defines the behavior common to nodes that represent a literal
6257 * expression.
6258 * <pre>
6259 * 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>
6260 */
6261 abstract class Literal extends Expression {
6262 }
6263 /**
6264 * Instances of the class {@code MapLiteral} represent a literal map.
6265 * <pre>
6266 * mapLiteral ::=
6267 * 'const'? ('<' {@link TypeName type} '>')? '{' ({@link MapLiteralEntry entry} (',' {@link MapLiteralEntry entry})* ','?)? '}'
6268 * </pre>
6269 */
6270 class MapLiteral extends TypedLiteral {
6271 /**
6272 * The left curly bracket.
6273 */
6274 Token _leftBracket;
6275 /**
6276 * The entries in the map.
6277 */
6278 NodeList<MapLiteralEntry> _entries;
6279 /**
6280 * The right curly bracket.
6281 */
6282 Token _rightBracket;
6283 /**
6284 * Initialize a newly created map literal.
6285 * @param modifier the const modifier associated with this literal
6286 * @param typeArguments the type argument associated with this literal, or {@c ode null} if no type
6287 * arguments were declared
6288 * @param leftBracket the left curly bracket
6289 * @param entries the entries in the map
6290 * @param rightBracket the right curly bracket
6291 */
6292 MapLiteral(Token modifier, TypeArgumentList typeArguments, Token leftBracket, List<MapLiteralEntry> entries, Token rightBracket) : super(modifier, typeArgumen ts) {
6293 this._entries = new NodeList<MapLiteralEntry>(this);
6294 this._leftBracket = leftBracket;
6295 this._entries.addAll(entries);
6296 this._rightBracket = rightBracket;
6297 }
6298 accept(ASTVisitor visitor) => visitor.visitMapLiteral(this);
6299 Token get beginToken {
6300 Token token = modifier;
6301 if (token != null) {
6302 return token;
6303 }
6304 TypeArgumentList typeArguments7 = typeArguments;
6305 if (typeArguments7 != null) {
6306 return typeArguments7.beginToken;
6307 }
6308 return _leftBracket;
6309 }
6310 Token get endToken => _rightBracket;
6311 /**
6312 * Return the entries in the map.
6313 * @return the entries in the map
6314 */
6315 NodeList<MapLiteralEntry> get entries => _entries;
6316 /**
6317 * Return the left curly bracket.
6318 * @return the left curly bracket
6319 */
6320 Token get leftBracket => _leftBracket;
6321 /**
6322 * Return the right curly bracket.
6323 * @return the right curly bracket
6324 */
6325 Token get rightBracket => _rightBracket;
6326 /**
6327 * Set the left curly bracket to the given token.
6328 * @param bracket the left curly bracket
6329 */
6330 void set leftBracket7(Token bracket) {
6331 _leftBracket = bracket;
6332 }
6333 /**
6334 * Set the right curly bracket to the given token.
6335 * @param bracket the right curly bracket
6336 */
6337 void set rightBracket7(Token bracket) {
6338 _rightBracket = bracket;
6339 }
6340 void visitChildren(ASTVisitor<Object> visitor) {
6341 super.visitChildren(visitor);
6342 _entries.accept(visitor);
6343 }
6344 }
6345 /**
6346 * Instances of the class {@code MapLiteralEntry} represent a single key/value p air in a map
6347 * literal.
6348 * <pre>
6349 * mapLiteralEntry ::={@link StringLiteral key} ':' {@link Expression value}</pr e>
6350 */
6351 class MapLiteralEntry extends ASTNode {
6352 /**
6353 * The key with which the value will be associated.
6354 */
6355 StringLiteral _key;
6356 /**
6357 * The colon that separates the key from the value.
6358 */
6359 Token _separator;
6360 /**
6361 * The expression computing the value that will be associated with the key.
6362 */
6363 Expression _value;
6364 /**
6365 * Initialize a newly created map literal entry.
6366 * @param key the key with which the value will be associated
6367 * @param separator the colon that separates the key from the value
6368 * @param value the expression computing the value that will be associated wit h the key
6369 */
6370 MapLiteralEntry(StringLiteral key, Token separator, Expression value) {
6371 this._key = becomeParentOf(key);
6372 this._separator = separator;
6373 this._value = becomeParentOf(value);
6374 }
6375 accept(ASTVisitor visitor) => visitor.visitMapLiteralEntry(this);
6376 Token get beginToken => _key.beginToken;
6377 Token get endToken => _value.endToken;
6378 /**
6379 * Return the key with which the value will be associated.
6380 * @return the key with which the value will be associated
6381 */
6382 StringLiteral get key => _key;
6383 /**
6384 * Return the colon that separates the key from the value.
6385 * @return the colon that separates the key from the value
6386 */
6387 Token get separator => _separator;
6388 /**
6389 * Return the expression computing the value that will be associated with the key.
6390 * @return the expression computing the value that will be associated with the key
6391 */
6392 Expression get value => _value;
6393 /**
6394 * Set the key with which the value will be associated to the given string.
6395 * @param string the key with which the value will be associated
6396 */
6397 void set key2(StringLiteral string) {
6398 _key = becomeParentOf(string);
6399 }
6400 /**
6401 * Set the colon that separates the key from the value to the given token.
6402 * @param separator the colon that separates the key from the value
6403 */
6404 void set separator4(Token separator) {
6405 this._separator = separator;
6406 }
6407 /**
6408 * Set the expression computing the value that will be associated with the key to the given
6409 * expression.
6410 * @param expression the expression computing the value that will be associate d with the key
6411 */
6412 void set value8(Expression expression) {
6413 _value = becomeParentOf(expression);
6414 }
6415 void visitChildren(ASTVisitor<Object> visitor) {
6416 safelyVisitChild(_key, visitor);
6417 safelyVisitChild(_value, visitor);
6418 }
6419 }
6420 /**
6421 * Instances of the class {@code MethodDeclaration} represent a method declarati on.
6422 * <pre>
6423 * methodDeclaration ::=
6424 * methodSignature {@link FunctionBody body}methodSignature ::=
6425 * 'external'? ('abstract' | 'static')? {@link Type returnType}? ('get' | 'set') ? methodName{@link FormalParameterList formalParameterList}methodName ::={@link SimpleIdentifier name} ('.' {@link SimpleIdentifier name})?
6426 * | 'operator' {@link SimpleIdentifier operator}</pre>
6427 */
6428 class MethodDeclaration extends ClassMember {
6429 /**
6430 * The token for the 'external' keyword, or {@code null} if the constructor is not external.
6431 */
6432 Token _externalKeyword;
6433 /**
6434 * The token representing the 'abstract' or 'static' keyword, or {@code null} if neither modifier
6435 * was specified.
6436 */
6437 Token _modifierKeyword;
6438 /**
6439 * The return type of the method, or {@code null} if no return type was declar ed.
6440 */
6441 TypeName _returnType;
6442 /**
6443 * The token representing the 'get' or 'set' keyword, or {@code null} if this is a method
6444 * declaration rather than a property declaration.
6445 */
6446 Token _propertyKeyword;
6447 /**
6448 * The token representing the 'operator' keyword, or {@code null} if this meth od does not declare
6449 * an operator.
6450 */
6451 Token _operatorKeyword;
6452 /**
6453 * The name of the method.
6454 */
6455 Identifier _name;
6456 /**
6457 * The parameters associated with the method, or {@code null} if this method d eclares a getter.
6458 */
6459 FormalParameterList _parameters;
6460 /**
6461 * The body of the method.
6462 */
6463 FunctionBody _body;
6464 /**
6465 * Initialize a newly created method declaration.
6466 * @param externalKeyword the token for the 'external' keyword
6467 * @param comment the documentation comment associated with this method
6468 * @param metadata the annotations associated with this method
6469 * @param modifierKeyword the token representing the 'abstract' or 'static' ke yword
6470 * @param returnType the return type of the method
6471 * @param propertyKeyword the token representing the 'get' or 'set' keyword
6472 * @param operatorKeyword the token representing the 'operator' keyword
6473 * @param name the name of the method
6474 * @param parameters the parameters associated with the method, or {@code null } if this method
6475 * declares a getter
6476 * @param body the body of the method
6477 */
6478 MethodDeclaration(Comment comment, List<Annotation> metadata, Token externalKe yword, Token modifierKeyword, TypeName returnType, Token propertyKeyword, Token operatorKeyword, Identifier name, FormalParameterList parameters, FunctionBody b ody) : super(comment, metadata) {
6479 this._externalKeyword = externalKeyword;
6480 this._modifierKeyword = modifierKeyword;
6481 this._returnType = becomeParentOf(returnType);
6482 this._propertyKeyword = propertyKeyword;
6483 this._operatorKeyword = operatorKeyword;
6484 this._name = becomeParentOf(name);
6485 this._parameters = becomeParentOf(parameters);
6486 this._body = becomeParentOf(body);
6487 }
6488 accept(ASTVisitor visitor) => visitor.visitMethodDeclaration(this);
6489 /**
6490 * Return the body of the method.
6491 * @return the body of the method
6492 */
6493 FunctionBody get body => _body;
6494 /**
6495 * Return the element associated with this method, or {@code null} if the AST structure has not
6496 * been resolved. The element can either be a {@link MethodElement}, if this r epresents the
6497 * declaration of a normal method, or a {@link PropertyAccessorElement} if thi s represents the
6498 * declaration of either a getter or a setter.
6499 * @return the element associated with this method
6500 */
6501 ExecutableElement get element => _name != null ? _name.element as ExecutableEl ement : null;
6502 Token get endToken => _body.endToken;
6503 /**
6504 * Return the token for the 'external' keyword, or {@code null} if the constru ctor is not
6505 * external.
6506 * @return the token for the 'external' keyword
6507 */
6508 Token get externalKeyword => _externalKeyword;
6509 /**
6510 * Return the token representing the 'abstract' or 'static' keyword, or {@code null} if neither
6511 * modifier was specified.
6512 * @return the token representing the 'abstract' or 'static' keyword
6513 */
6514 Token get modifierKeyword => _modifierKeyword;
6515 /**
6516 * Return the name of the method.
6517 * @return the name of the method
6518 */
6519 Identifier get name => _name;
6520 /**
6521 * Return the token representing the 'operator' keyword, or {@code null} if th is method does not
6522 * declare an operator.
6523 * @return the token representing the 'operator' keyword
6524 */
6525 Token get operatorKeyword => _operatorKeyword;
6526 /**
6527 * Return the parameters associated with the method, or {@code null} if this m ethod declares a
6528 * getter.
6529 * @return the parameters associated with the method
6530 */
6531 FormalParameterList get parameters => _parameters;
6532 /**
6533 * Return the token representing the 'get' or 'set' keyword, or {@code null} i f this is a method
6534 * declaration rather than a property declaration.
6535 * @return the token representing the 'get' or 'set' keyword
6536 */
6537 Token get propertyKeyword => _propertyKeyword;
6538 /**
6539 * Return the return type of the method, or {@code null} if no return type was declared.
6540 * @return the return type of the method
6541 */
6542 TypeName get returnType => _returnType;
6543 /**
6544 * Return {@code true} if this method declares a getter.
6545 * @return {@code true} if this method declares a getter
6546 */
6547 bool isGetter() => _propertyKeyword != null && (_propertyKeyword as KeywordTok en).keyword == Keyword.GET;
6548 /**
6549 * Return {@code true} if this method declares an operator.
6550 * @return {@code true} if this method declares an operator
6551 */
6552 bool isOperator() => _operatorKeyword != null;
6553 /**
6554 * Return {@code true} if this method declares a setter.
6555 * @return {@code true} if this method declares a setter
6556 */
6557 bool isSetter() => _propertyKeyword != null && (_propertyKeyword as KeywordTok en).keyword == Keyword.SET;
6558 /**
6559 * Set the body of the method to the given function body.
6560 * @param functionBody the body of the method
6561 */
6562 void set body8(FunctionBody functionBody) {
6563 _body = becomeParentOf(functionBody);
6564 }
6565 /**
6566 * Set the token for the 'external' keyword to the given token.
6567 * @param externalKeyword the token for the 'external' keyword
6568 */
6569 void set externalKeyword4(Token externalKeyword) {
6570 this._externalKeyword = externalKeyword;
6571 }
6572 /**
6573 * Set the token representing the 'abstract' or 'static' keyword to the given token.
6574 * @param modifierKeyword the token representing the 'abstract' or 'static' ke yword
6575 */
6576 void set modifierKeyword2(Token modifierKeyword) {
6577 this._modifierKeyword = modifierKeyword;
6578 }
6579 /**
6580 * Set the name of the method to the given identifier.
6581 * @param identifier the name of the method
6582 */
6583 void set name10(Identifier identifier) {
6584 _name = becomeParentOf(identifier);
6585 }
6586 /**
6587 * Set the token representing the 'operator' keyword to the given token.
6588 * @param operatorKeyword the token representing the 'operator' keyword
6589 */
6590 void set operatorKeyword2(Token operatorKeyword) {
6591 this._operatorKeyword = operatorKeyword;
6592 }
6593 /**
6594 * Set the parameters associated with the method to the given list of paramete rs.
6595 * @param parameters the parameters associated with the method
6596 */
6597 void set parameters6(FormalParameterList parameters) {
6598 this._parameters = becomeParentOf(parameters);
6599 }
6600 /**
6601 * Set the token representing the 'get' or 'set' keyword to the given token.
6602 * @param propertyKeyword the token representing the 'get' or 'set' keyword
6603 */
6604 void set propertyKeyword3(Token propertyKeyword) {
6605 this._propertyKeyword = propertyKeyword;
6606 }
6607 /**
6608 * Set the return type of the method to the given type name.
6609 * @param typeName the return type of the method
6610 */
6611 void set returnType6(TypeName typeName) {
6612 _returnType = becomeParentOf(typeName);
6613 }
6614 void visitChildren(ASTVisitor<Object> visitor) {
6615 super.visitChildren(visitor);
6616 safelyVisitChild(_returnType, visitor);
6617 safelyVisitChild(_name, visitor);
6618 safelyVisitChild(_parameters, visitor);
6619 safelyVisitChild(_body, visitor);
6620 }
6621 Token get firstTokenAfterCommentAndMetadata {
6622 if (_modifierKeyword != null) {
6623 return _modifierKeyword;
6624 } else if (_returnType != null) {
6625 return _returnType.beginToken;
6626 } else if (_propertyKeyword != null) {
6627 return _propertyKeyword;
6628 } else if (_operatorKeyword != null) {
6629 return _operatorKeyword;
6630 }
6631 return _name.beginToken;
6632 }
6633 }
6634 /**
6635 * Instances of the class {@code MethodInvocation} represent the invocation of e ither a function or
6636 * a method. Invocations of functions resulting from evaluating an expression ar e represented by{@link FunctionExpressionInvocation function expression invocati on} nodes. Invocations of getters
6637 * and setters are represented by either {@link PrefixedIdentifier prefixed iden tifier} or{@link PropertyAccess property access} nodes.
6638 * <pre>
6639 * methodInvoction ::=
6640 * ({@link Expression target} '.')? {@link SimpleIdentifier methodName} {@link A rgumentList argumentList}</pre>
6641 */
6642 class MethodInvocation extends Expression {
6643 /**
6644 * The expression producing the object on which the method is defined, or {@co de null} if there is
6645 * no target (that is, the target is implicitly {@code this}).
6646 */
6647 Expression _target;
6648 /**
6649 * The period that separates the target from the method name, or {@code null} if there is no
6650 * target.
6651 */
6652 Token _period;
6653 /**
6654 * The name of the method being invoked.
6655 */
6656 SimpleIdentifier _methodName;
6657 /**
6658 * The list of arguments to the method.
6659 */
6660 ArgumentList _argumentList;
6661 /**
6662 * Initialize a newly created method invocation.
6663 * @param target the expression producing the object on which the method is de fined
6664 * @param period the period that separates the target from the method name
6665 * @param methodName the name of the method being invoked
6666 * @param argumentList the list of arguments to the method
6667 */
6668 MethodInvocation(Expression target, Token period, SimpleIdentifier methodName, ArgumentList argumentList) {
6669 this._target = becomeParentOf(target);
6670 this._period = period;
6671 this._methodName = becomeParentOf(methodName);
6672 this._argumentList = becomeParentOf(argumentList);
6673 }
6674 accept(ASTVisitor visitor) => visitor.visitMethodInvocation(this);
6675 /**
6676 * Return the list of arguments to the method.
6677 * @return the list of arguments to the method
6678 */
6679 ArgumentList get argumentList => _argumentList;
6680 Token get beginToken {
6681 if (_target != null) {
6682 return _target.beginToken;
6683 }
6684 return _methodName.beginToken;
6685 }
6686 Token get endToken => _argumentList.endToken;
6687 /**
6688 * Return the name of the method being invoked.
6689 * @return the name of the method being invoked
6690 */
6691 SimpleIdentifier get methodName => _methodName;
6692 /**
6693 * Return the period that separates the target from the method name, or {@code null} if there is
6694 * no target.
6695 * @return the period that separates the target from the method name
6696 */
6697 Token get period => _period;
6698 /**
6699 * Return the expression used to compute the receiver of the invocation. If th is invocation is not
6700 * part of a cascade expression, then this is the same as {@link #getTarget()} . If this invocation
6701 * is part of a cascade expression, then the target stored with the cascade ex pression is
6702 * returned.
6703 * @return the expression used to compute the receiver of the invocation
6704 * @see #getTarget()
6705 */
6706 Expression get realTarget {
6707 if (isCascaded()) {
6708 ASTNode ancestor = parent;
6709 while (ancestor is! CascadeExpression) {
6710 if (ancestor == null) {
6711 return _target;
6712 }
6713 ancestor = ancestor.parent;
6714 }
6715 return (ancestor as CascadeExpression).target;
6716 }
6717 return _target;
6718 }
6719 /**
6720 * Return the expression producing the object on which the method is defined, or {@code null} if
6721 * there is no target (that is, the target is implicitly {@code this}) or if t his method
6722 * invocation is part of a cascade expression.
6723 * @return the expression producing the object on which the method is defined
6724 * @see #getRealTarget()
6725 */
6726 Expression get target => _target;
6727 /**
6728 * Return {@code true} if this expression is cascaded. If it is, then the targ et of this
6729 * expression is not stored locally but is stored in the nearest ancestor that is a{@link CascadeExpression}.
6730 * @return {@code true} if this expression is cascaded
6731 */
6732 bool isCascaded() => _period != null && _period.type == TokenType.PERIOD_PERIO D;
6733 /**
6734 * Set the list of arguments to the method to the given list.
6735 * @param argumentList the list of arguments to the method
6736 */
6737 void set argumentList7(ArgumentList argumentList) {
6738 this._argumentList = becomeParentOf(argumentList);
6739 }
6740 /**
6741 * Set the name of the method being invoked to the given identifier.
6742 * @param identifier the name of the method being invoked
6743 */
6744 void set methodName2(SimpleIdentifier identifier) {
6745 _methodName = becomeParentOf(identifier);
6746 }
6747 /**
6748 * Set the period that separates the target from the method name to the given token.
6749 * @param period the period that separates the target from the method name
6750 */
6751 void set period8(Token period) {
6752 this._period = period;
6753 }
6754 /**
6755 * Set the expression producing the object on which the method is defined to t he given expression.
6756 * @param expression the expression producing the object on which the method i s defined
6757 */
6758 void set target3(Expression expression) {
6759 _target = becomeParentOf(expression);
6760 }
6761 void visitChildren(ASTVisitor<Object> visitor) {
6762 safelyVisitChild(_target, visitor);
6763 safelyVisitChild(_methodName, visitor);
6764 safelyVisitChild(_argumentList, visitor);
6765 }
6766 }
6767 /**
6768 * Instances of the class {@code NamedExpression} represent an expression that h as a name associated
6769 * with it. They are used in method invocations when there are named parameters.
6770 * <pre>
6771 * namedExpression ::={@link Label name} {@link Expression expression}</pre>
6772 */
6773 class NamedExpression extends Expression {
6774 /**
6775 * The name associated with the expression.
6776 */
6777 Label _name;
6778 /**
6779 * The expression with which the name is associated.
6780 */
6781 Expression _expression;
6782 /**
6783 * Initialize a newly created named expression.
6784 * @param name the name associated with the expression
6785 * @param expression the expression with which the name is associated
6786 */
6787 NamedExpression(Label name, Expression expression) {
6788 this._name = becomeParentOf(name);
6789 this._expression = becomeParentOf(expression);
6790 }
6791 accept(ASTVisitor visitor) => visitor.visitNamedExpression(this);
6792 Token get beginToken => _name.beginToken;
6793 Token get endToken => _expression.endToken;
6794 /**
6795 * Return the expression with which the name is associated.
6796 * @return the expression with which the name is associated
6797 */
6798 Expression get expression => _expression;
6799 /**
6800 * Return the name associated with the expression.
6801 * @return the name associated with the expression
6802 */
6803 Label get name => _name;
6804 /**
6805 * Set the expression with which the name is associated to the given expressio n.
6806 * @param expression the expression with which the name is associated
6807 */
6808 void set expression8(Expression expression) {
6809 this._expression = becomeParentOf(expression);
6810 }
6811 /**
6812 * Set the name associated with the expression to the given identifier.
6813 * @param identifier the name associated with the expression
6814 */
6815 void set name11(Label identifier) {
6816 _name = becomeParentOf(identifier);
6817 }
6818 void visitChildren(ASTVisitor<Object> visitor) {
6819 safelyVisitChild(_name, visitor);
6820 safelyVisitChild(_expression, visitor);
6821 }
6822 }
6823 /**
6824 * The abstract class {@code NamespaceDirective} defines the behavior common to nodes that represent
6825 * a directive that impacts the namespace of a library.
6826 * <pre>
6827 * directive ::={@link ExportDirective exportDirective}| {@link ImportDirective importDirective}</pre>
6828 */
6829 abstract class NamespaceDirective extends Directive {
6830 /**
6831 * The token representing the 'import' or 'export' keyword.
6832 */
6833 Token _keyword;
6834 /**
6835 * The URI of the library being imported or exported.
6836 */
6837 StringLiteral _libraryUri;
6838 /**
6839 * The combinators used to control which names are imported or exported.
6840 */
6841 NodeList<Combinator> _combinators;
6842 /**
6843 * The semicolon terminating the directive.
6844 */
6845 Token _semicolon;
6846 /**
6847 * Initialize a newly created namespace directive.
6848 * @param comment the documentation comment associated with this directive
6849 * @param metadata the annotations associated with the directive
6850 * @param keyword the token representing the 'import' or 'export' keyword
6851 * @param libraryUri the URI of the library being imported or exported
6852 * @param combinators the combinators used to control which names are imported or exported
6853 * @param semicolon the semicolon terminating the directive
6854 */
6855 NamespaceDirective(Comment comment, List<Annotation> metadata, Token keyword, StringLiteral libraryUri, List<Combinator> combinators, Token semicolon) : super (comment, metadata) {
6856 this._combinators = new NodeList<Combinator>(this);
6857 this._keyword = keyword;
6858 this._libraryUri = becomeParentOf(libraryUri);
6859 this._combinators.addAll(combinators);
6860 this._semicolon = semicolon;
6861 }
6862 /**
6863 * Return the combinators used to control how names are imported or exported.
6864 * @return the combinators used to control how names are imported or exported
6865 */
6866 NodeList<Combinator> get combinators => _combinators;
6867 Token get endToken => _semicolon;
6868 Token get keyword => _keyword;
6869 /**
6870 * Return the URI of the library being imported or exported.
6871 * @return the URI of the library being imported or exported
6872 */
6873 StringLiteral get libraryUri => _libraryUri;
6874 /**
6875 * Return the semicolon terminating the directive.
6876 * @return the semicolon terminating the directive
6877 */
6878 Token get semicolon => _semicolon;
6879 /**
6880 * Set the token representing the 'import' or 'export' keyword to the given to ken.
6881 * @param exportToken the token representing the 'import' or 'export' keyword
6882 */
6883 void set keyword13(Token exportToken) {
6884 this._keyword = exportToken;
6885 }
6886 /**
6887 * Set the URI of the library being imported or exported to the given literal.
6888 * @param literal the URI of the library being imported or exported
6889 */
6890 void set libraryUri2(StringLiteral literal) {
6891 _libraryUri = becomeParentOf(literal);
6892 }
6893 /**
6894 * Set the semicolon terminating the directive to the given token.
6895 * @param semicolon the semicolon terminating the directive
6896 */
6897 void set semicolon12(Token semicolon) {
6898 this._semicolon = semicolon;
6899 }
6900 Token get firstTokenAfterCommentAndMetadata => _keyword;
6901 }
6902 /**
6903 * The abstract class {@code NormalFormalParameter} defines the behavior common to formal parameters
6904 * that are required (are not optional).
6905 * <pre>
6906 * normalFormalParameter ::={@link FunctionTypedFormalParameter functionSignatur e}| {@link FieldFormalParameter fieldFormalParameter}| {@link SimpleFormalParame ter simpleFormalParameter}</pre>
6907 */
6908 abstract class NormalFormalParameter extends FormalParameter {
6909 /**
6910 * The documentation comment associated with this parameter, or {@code null} i f this parameter
6911 * does not have a documentation comment associated with it.
6912 */
6913 Comment _comment;
6914 /**
6915 * The annotations associated with this parameter.
6916 */
6917 NodeList<Annotation> _metadata;
6918 /**
6919 * The name of the parameter being declared.
6920 */
6921 SimpleIdentifier _identifier;
6922 /**
6923 * Initialize a newly created formal parameter.
6924 * @param comment the documentation comment associated with this parameter
6925 * @param metadata the annotations associated with this parameter
6926 * @param identifier the name of the parameter being declared
6927 */
6928 NormalFormalParameter(Comment comment, List<Annotation> metadata, SimpleIdenti fier identifier) {
6929 this._metadata = new NodeList<Annotation>(this);
6930 this._comment = becomeParentOf(comment);
6931 this._metadata.addAll(metadata);
6932 this._identifier = becomeParentOf(identifier);
6933 }
6934 /**
6935 * Return the documentation comment associated with this parameter, or {@code null} if this
6936 * parameter does not have a documentation comment associated with it.
6937 * @return the documentation comment associated with this parameter
6938 */
6939 Comment get documentationComment => _comment;
6940 SimpleIdentifier get identifier => _identifier;
6941 ParameterKind get kind {
6942 ASTNode parent6 = parent;
6943 if (parent6 is DefaultFormalParameter) {
6944 return (parent6 as DefaultFormalParameter).kind;
6945 }
6946 return ParameterKind.REQUIRED;
6947 }
6948 /**
6949 * Return the annotations associated with this parameter.
6950 * @return the annotations associated with this parameter
6951 */
6952 NodeList<Annotation> get metadata => _metadata;
6953 /**
6954 * Return {@code true} if this parameter is a const parameter.
6955 * @return {@code true} if this parameter is a const parameter
6956 */
6957 bool isConst();
6958 /**
6959 * Return {@code true} if this parameter is a final parameter.
6960 * @return {@code true} if this parameter is a final parameter
6961 */
6962 bool isFinal();
6963 /**
6964 * Set the documentation comment associated with this parameter to the given c omment
6965 * @param comment the documentation comment to be associated with this paramet er
6966 */
6967 void set documentationComment(Comment comment) {
6968 this._comment = becomeParentOf(comment);
6969 }
6970 /**
6971 * Set the name of the parameter being declared to the given identifier.
6972 * @param identifier the name of the parameter being declared
6973 */
6974 void set identifier4(SimpleIdentifier identifier) {
6975 this._identifier = becomeParentOf(identifier);
6976 }
6977 void visitChildren(ASTVisitor<Object> visitor) {
6978 if (commentIsBeforeAnnotations()) {
6979 safelyVisitChild(_comment, visitor);
6980 _metadata.accept(visitor);
6981 } else {
6982 for (ASTNode child in sortedCommentAndAnnotations) {
6983 child.accept(visitor);
6984 }
6985 }
6986 }
6987 /**
6988 * Return {@code true} if the comment is lexically before any annotations.
6989 * @return {@code true} if the comment is lexically before any annotations
6990 */
6991 bool commentIsBeforeAnnotations() {
6992 if (_comment == null || _metadata.isEmpty) {
6993 return true;
6994 }
6995 Annotation firstAnnotation = _metadata[0];
6996 return _comment.offset < firstAnnotation.offset;
6997 }
6998 /**
6999 * Return an array containing the comment and annotations associated with this parameter, sorted
7000 * in lexical order.
7001 * @return the comment and annotations associated with this parameter in the o rder in which they
7002 * appeared in the original source
7003 */
7004 List<ASTNode> get sortedCommentAndAnnotations {
7005 List<ASTNode> childList = new List<ASTNode>();
7006 childList.add(_comment);
7007 childList.addAll(_metadata);
7008 List<ASTNode> children = new List.from(childList);
7009 children.sort();
7010 return children;
7011 }
7012 }
7013 /**
7014 * Instances of the class {@code NullLiteral} represent a null literal expressio n.
7015 * <pre>
7016 * nullLiteral ::=
7017 * 'null'
7018 * </pre>
7019 */
7020 class NullLiteral extends Literal {
7021 /**
7022 * The token representing the literal.
7023 */
7024 Token _literal;
7025 /**
7026 * Initialize a newly created null literal.
7027 * @param token the token representing the literal
7028 */
7029 NullLiteral(Token token) {
7030 this._literal = token;
7031 }
7032 accept(ASTVisitor visitor) => visitor.visitNullLiteral(this);
7033 Token get beginToken => _literal;
7034 Token get endToken => _literal;
7035 /**
7036 * Return the token representing the literal.
7037 * @return the token representing the literal
7038 */
7039 Token get literal => _literal;
7040 /**
7041 * Set the token representing the literal to the given token.
7042 * @param literal the token representing the literal
7043 */
7044 void set literal5(Token literal) {
7045 this._literal = literal;
7046 }
7047 void visitChildren(ASTVisitor<Object> visitor) {
7048 }
7049 }
7050 /**
7051 * Instances of the class {@code ParenthesizedExpression} represent a parenthesi zed expression.
7052 * <pre>
7053 * parenthesizedExpression ::=
7054 * '(' {@link Expression expression} ')'
7055 * </pre>
7056 */
7057 class ParenthesizedExpression extends Expression {
7058 /**
7059 * The left parenthesis.
7060 */
7061 Token _leftParenthesis;
7062 /**
7063 * The expression within the parentheses.
7064 */
7065 Expression _expression;
7066 /**
7067 * The right parenthesis.
7068 */
7069 Token _rightParenthesis;
7070 /**
7071 * Initialize a newly created parenthesized expression.
7072 * @param leftParenthesis the left parenthesis
7073 * @param expression the expression within the parentheses
7074 * @param rightParenthesis the right parenthesis
7075 */
7076 ParenthesizedExpression(Token leftParenthesis, Expression expression, Token ri ghtParenthesis) {
7077 this._leftParenthesis = leftParenthesis;
7078 this._expression = becomeParentOf(expression);
7079 this._rightParenthesis = rightParenthesis;
7080 }
7081 accept(ASTVisitor visitor) => visitor.visitParenthesizedExpression(this);
7082 Token get beginToken => _leftParenthesis;
7083 Token get endToken => _rightParenthesis;
7084 /**
7085 * Return the expression within the parentheses.
7086 * @return the expression within the parentheses
7087 */
7088 Expression get expression => _expression;
7089 /**
7090 * Return the left parenthesis.
7091 * @return the left parenthesis
7092 */
7093 Token get leftParenthesis => _leftParenthesis;
7094 /**
7095 * Return the right parenthesis.
7096 * @return the right parenthesis
7097 */
7098 Token get rightParenthesis => _rightParenthesis;
7099 /**
7100 * Set the expression within the parentheses to the given expression.
7101 * @param expression the expression within the parentheses
7102 */
7103 void set expression9(Expression expression) {
7104 this._expression = becomeParentOf(expression);
7105 }
7106 /**
7107 * Set the left parenthesis to the given token.
7108 * @param parenthesis the left parenthesis
7109 */
7110 void set leftParenthesis10(Token parenthesis) {
7111 _leftParenthesis = parenthesis;
7112 }
7113 /**
7114 * Set the right parenthesis to the given token.
7115 * @param parenthesis the right parenthesis
7116 */
7117 void set rightParenthesis10(Token parenthesis) {
7118 _rightParenthesis = parenthesis;
7119 }
7120 void visitChildren(ASTVisitor<Object> visitor) {
7121 safelyVisitChild(_expression, visitor);
7122 }
7123 }
7124 /**
7125 * Instances of the class {@code PartDirective} represent a part directive.
7126 * <pre>
7127 * partDirective ::={@link Annotation metadata} 'part' {@link StringLiteral part Uri} ';'
7128 * </pre>
7129 */
7130 class PartDirective extends Directive {
7131 /**
7132 * The token representing the 'part' token.
7133 */
7134 Token _partToken;
7135 /**
7136 * The URI of the part being included.
7137 */
7138 StringLiteral _partUri;
7139 /**
7140 * The semicolon terminating the directive.
7141 */
7142 Token _semicolon;
7143 /**
7144 * Initialize a newly created part directive.
7145 * @param comment the documentation comment associated with this directive
7146 * @param metadata the annotations associated with the directive
7147 * @param partToken the token representing the 'part' token
7148 * @param partUri the URI of the part being included
7149 * @param semicolon the semicolon terminating the directive
7150 */
7151 PartDirective(Comment comment, List<Annotation> metadata, Token partToken, Str ingLiteral partUri, Token semicolon) : super(comment, metadata) {
7152 this._partToken = partToken;
7153 this._partUri = becomeParentOf(partUri);
7154 this._semicolon = semicolon;
7155 }
7156 accept(ASTVisitor visitor) => visitor.visitPartDirective(this);
7157 Token get endToken => _semicolon;
7158 Token get keyword => _partToken;
7159 /**
7160 * Return the token representing the 'part' token.
7161 * @return the token representing the 'part' token
7162 */
7163 Token get partToken => _partToken;
7164 /**
7165 * Return the URI of the part being included.
7166 * @return the URI of the part being included
7167 */
7168 StringLiteral get partUri => _partUri;
7169 /**
7170 * Return the semicolon terminating the directive.
7171 * @return the semicolon terminating the directive
7172 */
7173 Token get semicolon => _semicolon;
7174 /**
7175 * Set the token representing the 'part' token to the given token.
7176 * @param partToken the token representing the 'part' token
7177 */
7178 void set partToken2(Token partToken) {
7179 this._partToken = partToken;
7180 }
7181 /**
7182 * Set the URI of the part being included to the given string.
7183 * @param partUri the URI of the part being included
7184 */
7185 void set partUri2(StringLiteral partUri) {
7186 this._partUri = becomeParentOf(partUri);
7187 }
7188 /**
7189 * Set the semicolon terminating the directive to the given token.
7190 * @param semicolon the semicolon terminating the directive
7191 */
7192 void set semicolon13(Token semicolon) {
7193 this._semicolon = semicolon;
7194 }
7195 void visitChildren(ASTVisitor<Object> visitor) {
7196 super.visitChildren(visitor);
7197 safelyVisitChild(_partUri, visitor);
7198 }
7199 Token get firstTokenAfterCommentAndMetadata => _partToken;
7200 }
7201 /**
7202 * Instances of the class {@code PartOfDirective} represent a part-of directive.
7203 * <pre>
7204 * partOfDirective ::={@link Annotation metadata} 'part' 'of' {@link Identifier libraryName} ';'
7205 * </pre>
7206 */
7207 class PartOfDirective extends Directive {
7208 /**
7209 * The token representing the 'part' token.
7210 */
7211 Token _partToken;
7212 /**
7213 * The token representing the 'of' token.
7214 */
7215 Token _ofToken;
7216 /**
7217 * The name of the library that the containing compilation unit is part of.
7218 */
7219 LibraryIdentifier _libraryName;
7220 /**
7221 * The semicolon terminating the directive.
7222 */
7223 Token _semicolon;
7224 /**
7225 * Initialize a newly created part-of directive.
7226 * @param comment the documentation comment associated with this directive
7227 * @param metadata the annotations associated with the directive
7228 * @param partToken the token representing the 'part' token
7229 * @param ofToken the token representing the 'of' token
7230 * @param libraryName the name of the library that the containing compilation unit is part of
7231 * @param semicolon the semicolon terminating the directive
7232 */
7233 PartOfDirective(Comment comment, List<Annotation> metadata, Token partToken, T oken ofToken, LibraryIdentifier libraryName, Token semicolon) : super(comment, m etadata) {
7234 this._partToken = partToken;
7235 this._ofToken = ofToken;
7236 this._libraryName = becomeParentOf(libraryName);
7237 this._semicolon = semicolon;
7238 }
7239 accept(ASTVisitor visitor) => visitor.visitPartOfDirective(this);
7240 Token get endToken => _semicolon;
7241 Token get keyword => _partToken;
7242 /**
7243 * Return the name of the library that the containing compilation unit is part of.
7244 * @return the name of the library that the containing compilation unit is par t of
7245 */
7246 LibraryIdentifier get libraryName => _libraryName;
7247 /**
7248 * Return the token representing the 'of' token.
7249 * @return the token representing the 'of' token
7250 */
7251 Token get ofToken => _ofToken;
7252 /**
7253 * Return the token representing the 'part' token.
7254 * @return the token representing the 'part' token
7255 */
7256 Token get partToken => _partToken;
7257 /**
7258 * Return the semicolon terminating the directive.
7259 * @return the semicolon terminating the directive
7260 */
7261 Token get semicolon => _semicolon;
7262 /**
7263 * Set the name of the library that the containing compilation unit is part of to the given name.
7264 * @param libraryName the name of the library that the containing compilation unit is part of
7265 */
7266 void set libraryName2(LibraryIdentifier libraryName) {
7267 this._libraryName = becomeParentOf(libraryName);
7268 }
7269 /**
7270 * Set the token representing the 'of' token to the given token.
7271 * @param ofToken the token representing the 'of' token
7272 */
7273 void set ofToken2(Token ofToken) {
7274 this._ofToken = ofToken;
7275 }
7276 /**
7277 * Set the token representing the 'part' token to the given token.
7278 * @param partToken the token representing the 'part' token
7279 */
7280 void set partToken3(Token partToken) {
7281 this._partToken = partToken;
7282 }
7283 /**
7284 * Set the semicolon terminating the directive to the given token.
7285 * @param semicolon the semicolon terminating the directive
7286 */
7287 void set semicolon14(Token semicolon) {
7288 this._semicolon = semicolon;
7289 }
7290 void visitChildren(ASTVisitor<Object> visitor) {
7291 super.visitChildren(visitor);
7292 safelyVisitChild(_libraryName, visitor);
7293 }
7294 Token get firstTokenAfterCommentAndMetadata => _partToken;
7295 }
7296 /**
7297 * Instances of the class {@code PostfixExpression} represent a postfix unary ex pression.
7298 * <pre>
7299 * postfixExpression ::={@link Expression operand} {@link Token operator}</pre>
7300 */
7301 class PostfixExpression extends Expression {
7302 /**
7303 * The expression computing the operand for the operator.
7304 */
7305 Expression _operand;
7306 /**
7307 * The postfix operator being applied to the operand.
7308 */
7309 Token _operator;
7310 /**
7311 * The element associated with this the operator, or {@code null} if the AST s tructure has not
7312 * been resolved, if the operator is not user definable, or if the operator co uld not be resolved.
7313 */
7314 MethodElement _element;
7315 /**
7316 * Initialize a newly created postfix expression.
7317 * @param operand the expression computing the operand for the operator
7318 * @param operator the postfix operator being applied to the operand
7319 */
7320 PostfixExpression(Expression operand, Token operator) {
7321 this._operand = becomeParentOf(operand);
7322 this._operator = operator;
7323 }
7324 accept(ASTVisitor visitor) => visitor.visitPostfixExpression(this);
7325 Token get beginToken => _operand.beginToken;
7326 /**
7327 * Return the element associated with the operator, or {@code null} if the AST structure has not
7328 * been resolved, if the operator is not user definable, or if the operator co uld not be resolved.
7329 * One example of the latter case is an operator that is not defined for the t ype of the operand.
7330 * @return the element associated with the operator
7331 */
7332 MethodElement get element => _element;
7333 Token get endToken => _operator;
7334 /**
7335 * Return the expression computing the operand for the operator.
7336 * @return the expression computing the operand for the operator
7337 */
7338 Expression get operand => _operand;
7339 /**
7340 * Return the postfix operator being applied to the operand.
7341 * @return the postfix operator being applied to the operand
7342 */
7343 Token get operator => _operator;
7344 /**
7345 * Set the element associated with the operator to the given element.
7346 * @param element the element associated with the operator
7347 */
7348 void set element13(MethodElement element) {
7349 this._element = element;
7350 }
7351 /**
7352 * Set the expression computing the operand for the operator to the given expr ession.
7353 * @param expression the expression computing the operand for the operator
7354 */
7355 void set operand2(Expression expression) {
7356 _operand = becomeParentOf(expression);
7357 }
7358 /**
7359 * Set the postfix operator being applied to the operand to the given operator .
7360 * @param operator the postfix operator being applied to the operand
7361 */
7362 void set operator4(Token operator) {
7363 this._operator = operator;
7364 }
7365 void visitChildren(ASTVisitor<Object> visitor) {
7366 safelyVisitChild(_operand, visitor);
7367 }
7368 }
7369 /**
7370 * Instances of the class {@code PrefixExpression} represent a prefix unary expr ession.
7371 * <pre>
7372 * prefixExpression ::={@link Token operator} {@link Expression operand}</pre>
7373 */
7374 class PrefixExpression extends Expression {
7375 /**
7376 * The prefix operator being applied to the operand.
7377 */
7378 Token _operator;
7379 /**
7380 * The expression computing the operand for the operator.
7381 */
7382 Expression _operand;
7383 /**
7384 * The element associated with the operator, or {@code null} if the AST struct ure has not been
7385 * resolved, if the operator is not user definable, or if the operator could n ot be resolved.
7386 */
7387 MethodElement _element;
7388 /**
7389 * Initialize a newly created prefix expression.
7390 * @param operator the prefix operator being applied to the operand
7391 * @param operand the expression computing the operand for the operator
7392 */
7393 PrefixExpression(Token operator, Expression operand) {
7394 this._operator = operator;
7395 this._operand = becomeParentOf(operand);
7396 }
7397 accept(ASTVisitor visitor) => visitor.visitPrefixExpression(this);
7398 Token get beginToken => _operator;
7399 /**
7400 * Return the element associated with the operator, or {@code null} if the AST structure has not
7401 * been resolved, if the operator is not user definable, or if the operator co uld not be resolved.
7402 * One example of the latter case is an operator that is not defined for the t ype of the operand.
7403 * @return the element associated with the operator
7404 */
7405 MethodElement get element => _element;
7406 Token get endToken => _operand.endToken;
7407 /**
7408 * Return the expression computing the operand for the operator.
7409 * @return the expression computing the operand for the operator
7410 */
7411 Expression get operand => _operand;
7412 /**
7413 * Return the prefix operator being applied to the operand.
7414 * @return the prefix operator being applied to the operand
7415 */
7416 Token get operator => _operator;
7417 /**
7418 * Set the element associated with the operator to the given element.
7419 * @param element the element associated with the operator
7420 */
7421 void set element14(MethodElement element) {
7422 this._element = element;
7423 }
7424 /**
7425 * Set the expression computing the operand for the operator to the given expr ession.
7426 * @param expression the expression computing the operand for the operator
7427 */
7428 void set operand3(Expression expression) {
7429 _operand = becomeParentOf(expression);
7430 }
7431 /**
7432 * Set the prefix operator being applied to the operand to the given operator.
7433 * @param operator the prefix operator being applied to the operand
7434 */
7435 void set operator5(Token operator) {
7436 this._operator = operator;
7437 }
7438 void visitChildren(ASTVisitor<Object> visitor) {
7439 safelyVisitChild(_operand, visitor);
7440 }
7441 }
7442 /**
7443 * Instances of the class {@code PrefixedIdentifier} represent either an identif ier that is prefixed
7444 * or an access to an object property where the target of the property access is a simple
7445 * identifier.
7446 * <pre>
7447 * prefixedIdentifier ::={@link SimpleIdentifier prefix} '.' {@link SimpleIdenti fier identifier}</pre>
7448 */
7449 class PrefixedIdentifier extends Identifier {
7450 /**
7451 * The prefix associated with the library in which the identifier is defined.
7452 */
7453 SimpleIdentifier _prefix;
7454 /**
7455 * The period used to separate the prefix from the identifier.
7456 */
7457 Token _period;
7458 /**
7459 * The identifier being prefixed.
7460 */
7461 SimpleIdentifier _identifier;
7462 /**
7463 * Initialize a newly created prefixed identifier.
7464 * @param prefix the identifier being prefixed
7465 * @param period the period used to separate the prefix from the identifier
7466 * @param identifier the prefix associated with the library in which the ident ifier is defined
7467 */
7468 PrefixedIdentifier(SimpleIdentifier prefix, Token period, SimpleIdentifier ide ntifier) {
7469 this._prefix = becomeParentOf(prefix);
7470 this._period = period;
7471 this._identifier = becomeParentOf(identifier);
7472 }
7473 accept(ASTVisitor visitor) => visitor.visitPrefixedIdentifier(this);
7474 Token get beginToken => _prefix.beginToken;
7475 Token get endToken => _identifier.endToken;
7476 /**
7477 * Return the identifier being prefixed.
7478 * @return the identifier being prefixed
7479 */
7480 SimpleIdentifier get identifier => _identifier;
7481 String get name => "${_prefix.name}.${_identifier.name}";
7482 /**
7483 * Return the period used to separate the prefix from the identifier.
7484 * @return the period used to separate the prefix from the identifier
7485 */
7486 Token get period => _period;
7487 /**
7488 * Return the prefix associated with the library in which the identifier is de fined.
7489 * @return the prefix associated with the library in which the identifier is d efined
7490 */
7491 SimpleIdentifier get prefix => _prefix;
7492 /**
7493 * Set the identifier being prefixed to the given identifier.
7494 * @param identifier the identifier being prefixed
7495 */
7496 void set identifier5(SimpleIdentifier identifier) {
7497 this._identifier = becomeParentOf(identifier);
7498 }
7499 /**
7500 * Set the period used to separate the prefix from the identifier to the given token.
7501 * @param period the period used to separate the prefix from the identifier
7502 */
7503 void set period9(Token period) {
7504 this._period = period;
7505 }
7506 /**
7507 * Set the prefix associated with the library in which the identifier is defin ed to the given
7508 * identifier.
7509 * @param identifier the prefix associated with the library in which the ident ifier is defined
7510 */
7511 void set prefix3(SimpleIdentifier identifier) {
7512 _prefix = becomeParentOf(identifier);
7513 }
7514 void visitChildren(ASTVisitor<Object> visitor) {
7515 safelyVisitChild(_prefix, visitor);
7516 safelyVisitChild(_identifier, visitor);
7517 }
7518 }
7519 /**
7520 * Instances of the class {@code PropertyAccess} represent the access of a prope rty of an object.
7521 * <p>
7522 * 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
7523 * identifier.
7524 * <pre>
7525 * propertyAccess ::={@link Expression target} '.' {@link SimpleIdentifier prope rtyName}</pre>
7526 */
7527 class PropertyAccess extends Expression {
7528 /**
7529 * The expression computing the object defining the property being accessed.
7530 */
7531 Expression _target;
7532 /**
7533 * The property access operator.
7534 */
7535 Token _operator;
7536 /**
7537 * The name of the property being accessed.
7538 */
7539 SimpleIdentifier _propertyName;
7540 /**
7541 * Initialize a newly created property access expression.
7542 * @param target the expression computing the object defining the property bei ng accessed
7543 * @param operator the property access operator
7544 * @param propertyName the name of the property being accessed
7545 */
7546 PropertyAccess(Expression target, Token operator, SimpleIdentifier propertyNam e) {
7547 this._target = becomeParentOf(target);
7548 this._operator = operator;
7549 this._propertyName = becomeParentOf(propertyName);
7550 }
7551 accept(ASTVisitor visitor) => visitor.visitPropertyAccess(this);
7552 Token get beginToken {
7553 if (_target != null) {
7554 return _target.beginToken;
7555 }
7556 return _operator;
7557 }
7558 Token get endToken => _propertyName.endToken;
7559 /**
7560 * Return the property access operator.
7561 * @return the property access operator
7562 */
7563 Token get operator => _operator;
7564 /**
7565 * Return the name of the property being accessed.
7566 * @return the name of the property being accessed
7567 */
7568 SimpleIdentifier get propertyName => _propertyName;
7569 /**
7570 * Return the expression used to compute the receiver of the invocation. If th is invocation is not
7571 * part of a cascade expression, then this is the same as {@link #getTarget()} . If this invocation
7572 * is part of a cascade expression, then the target stored with the cascade ex pression is
7573 * returned.
7574 * @return the expression used to compute the receiver of the invocation
7575 * @see #getTarget()
7576 */
7577 Expression get realTarget {
7578 if (isCascaded()) {
7579 ASTNode ancestor = parent;
7580 while (ancestor is! CascadeExpression) {
7581 if (ancestor == null) {
7582 return _target;
7583 }
7584 ancestor = ancestor.parent;
7585 }
7586 return (ancestor as CascadeExpression).target;
7587 }
7588 return _target;
7589 }
7590 /**
7591 * 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.
7592 * @return the expression computing the object defining the property being acc essed
7593 * @see #getRealTarget()
7594 */
7595 Expression get target => _target;
7596 bool isAssignable() => true;
7597 /**
7598 * Return {@code true} if this expression is cascaded. If it is, then the targ et of this
7599 * expression is not stored locally but is stored in the nearest ancestor that is a{@link CascadeExpression}.
7600 * @return {@code true} if this expression is cascaded
7601 */
7602 bool isCascaded() => _operator != null && _operator.type == TokenType.PERIOD_P ERIOD;
7603 /**
7604 * Set the property access operator to the given token.
7605 * @param operator the property access operator
7606 */
7607 void set operator6(Token operator) {
7608 this._operator = operator;
7609 }
7610 /**
7611 * Set the name of the property being accessed to the given identifier.
7612 * @param identifier the name of the property being accessed
7613 */
7614 void set propertyName2(SimpleIdentifier identifier) {
7615 _propertyName = becomeParentOf(identifier);
7616 }
7617 /**
7618 * Set the expression computing the object defining the property being accesse d to the given
7619 * expression.
7620 * @param expression the expression computing the object defining the property being accessed
7621 */
7622 void set target4(Expression expression) {
7623 _target = becomeParentOf(expression);
7624 }
7625 void visitChildren(ASTVisitor<Object> visitor) {
7626 safelyVisitChild(_target, visitor);
7627 safelyVisitChild(_propertyName, visitor);
7628 }
7629 }
7630 /**
7631 * Instances of the class {@code RedirectingConstructorInvocation} represent the invocation of a
7632 * another constructor in the same class from within a constructor's initializat ion list.
7633 * <pre>
7634 * redirectingConstructorInvocation ::=
7635 * 'this' ('.' identifier)? arguments
7636 * </pre>
7637 */
7638 class RedirectingConstructorInvocation extends ConstructorInitializer {
7639 /**
7640 * The token for the 'this' keyword.
7641 */
7642 Token _keyword;
7643 /**
7644 * 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.
7645 */
7646 Token _period;
7647 /**
7648 * The name of the constructor that is being invoked, or {@code null} if the u nnamed constructor
7649 * is being invoked.
7650 */
7651 SimpleIdentifier _constructorName;
7652 /**
7653 * The list of arguments to the constructor.
7654 */
7655 ArgumentList _argumentList;
7656 /**
7657 * Initialize a newly created redirecting invocation to invoke the constructor with the given name
7658 * with the given arguments.
7659 * @param keyword the token for the 'this' keyword
7660 * @param period the token for the period before the name of the constructor t hat is being invoked
7661 * @param constructorName the name of the constructor that is being invoked
7662 * @param argumentList the list of arguments to the constructor
7663 */
7664 RedirectingConstructorInvocation(Token keyword, Token period, SimpleIdentifier constructorName, ArgumentList argumentList) {
7665 this._keyword = keyword;
7666 this._period = period;
7667 this._constructorName = becomeParentOf(constructorName);
7668 this._argumentList = becomeParentOf(argumentList);
7669 }
7670 accept(ASTVisitor visitor) => visitor.visitRedirectingConstructorInvocation(th is);
7671 /**
7672 * Return the list of arguments to the constructor.
7673 * @return the list of arguments to the constructor
7674 */
7675 ArgumentList get argumentList => _argumentList;
7676 Token get beginToken => _keyword;
7677 /**
7678 * Return the name of the constructor that is being invoked, or {@code null} i f the unnamed
7679 * constructor is being invoked.
7680 * @return the name of the constructor that is being invoked
7681 */
7682 SimpleIdentifier get constructorName => _constructorName;
7683 Token get endToken => _argumentList.endToken;
7684 /**
7685 * Return the token for the 'this' keyword.
7686 * @return the token for the 'this' keyword
7687 */
7688 Token get keyword => _keyword;
7689 /**
7690 * 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.
7691 * @return the token for the period before the name of the constructor that is being invoked
7692 */
7693 Token get period => _period;
7694 /**
7695 * Set the list of arguments to the constructor to the given list.
7696 * @param argumentList the list of arguments to the constructor
7697 */
7698 void set argumentList8(ArgumentList argumentList) {
7699 this._argumentList = becomeParentOf(argumentList);
7700 }
7701 /**
7702 * Set the name of the constructor that is being invoked to the given identifi er.
7703 * @param identifier the name of the constructor that is being invoked
7704 */
7705 void set constructorName4(SimpleIdentifier identifier) {
7706 _constructorName = becomeParentOf(identifier);
7707 }
7708 /**
7709 * Set the token for the 'this' keyword to the given token.
7710 * @param keyword the token for the 'this' keyword
7711 */
7712 void set keyword14(Token keyword) {
7713 this._keyword = keyword;
7714 }
7715 /**
7716 * Set the token for the period before the name of the constructor that is bei ng invoked to the
7717 * given token.
7718 * @param period the token for the period before the name of the constructor t hat is being invoked
7719 */
7720 void set period10(Token period) {
7721 this._period = period;
7722 }
7723 void visitChildren(ASTVisitor<Object> visitor) {
7724 safelyVisitChild(_constructorName, visitor);
7725 safelyVisitChild(_argumentList, visitor);
7726 }
7727 }
7728 /**
7729 * Instances of the class {@code ReturnStatement} represent a return statement.
7730 * <pre>
7731 * returnStatement ::=
7732 * 'return' {@link Expression expression}? ';'
7733 * </pre>
7734 */
7735 class ReturnStatement extends Statement {
7736 /**
7737 * The token representing the 'return' keyword.
7738 */
7739 Token _keyword;
7740 /**
7741 * The expression computing the value to be returned, or {@code null} if no ex plicit value was
7742 * provided.
7743 */
7744 Expression _expression;
7745 /**
7746 * The semicolon terminating the statement.
7747 */
7748 Token _semicolon;
7749 /**
7750 * Initialize a newly created return statement.
7751 * @param keyword the token representing the 'return' keyword
7752 * @param expression the expression computing the value to be returned
7753 * @param semicolon the semicolon terminating the statement
7754 */
7755 ReturnStatement(Token keyword, Expression expression, Token semicolon) {
7756 this._keyword = keyword;
7757 this._expression = becomeParentOf(expression);
7758 this._semicolon = semicolon;
7759 }
7760 accept(ASTVisitor visitor) => visitor.visitReturnStatement(this);
7761 Token get beginToken => _keyword;
7762 Token get endToken => _semicolon;
7763 /**
7764 * Return the expression computing the value to be returned, or {@code null} i f no explicit value
7765 * was provided.
7766 * @return the expression computing the value to be returned
7767 */
7768 Expression get expression => _expression;
7769 /**
7770 * Return the token representing the 'return' keyword.
7771 * @return the token representing the 'return' keyword
7772 */
7773 Token get keyword => _keyword;
7774 /**
7775 * Return the semicolon terminating the statement.
7776 * @return the semicolon terminating the statement
7777 */
7778 Token get semicolon => _semicolon;
7779 /**
7780 * Set the expression computing the value to be returned to the given expressi on.
7781 * @param expression the expression computing the value to be returned
7782 */
7783 void set expression10(Expression expression) {
7784 this._expression = becomeParentOf(expression);
7785 }
7786 /**
7787 * Set the token representing the 'return' keyword to the given token.
7788 * @param keyword the token representing the 'return' keyword
7789 */
7790 void set keyword15(Token keyword) {
7791 this._keyword = keyword;
7792 }
7793 /**
7794 * Set the semicolon terminating the statement to the given token.
7795 * @param semicolon the semicolon terminating the statement
7796 */
7797 void set semicolon15(Token semicolon) {
7798 this._semicolon = semicolon;
7799 }
7800 void visitChildren(ASTVisitor<Object> visitor) {
7801 safelyVisitChild(_expression, visitor);
7802 }
7803 }
7804 /**
7805 * Instances of the class {@code ScriptTag} represent the script tag that can op tionally occur at
7806 * the beginning of a compilation unit.
7807 * <pre>
7808 * scriptTag ::=
7809 * '#!' (~NEWLINE)* NEWLINE
7810 * </pre>
7811 */
7812 class ScriptTag extends ASTNode {
7813 /**
7814 * The token representing this script tag.
7815 */
7816 Token _scriptTag;
7817 /**
7818 * Initialize a newly created script tag.
7819 * @param scriptTag the token representing this script tag
7820 */
7821 ScriptTag(Token scriptTag) {
7822 this._scriptTag = scriptTag;
7823 }
7824 accept(ASTVisitor visitor) => visitor.visitScriptTag(this);
7825 Token get beginToken => _scriptTag;
7826 Token get endToken => _scriptTag;
7827 /**
7828 * Return the token representing this script tag.
7829 * @return the token representing this script tag
7830 */
7831 Token get scriptTag => _scriptTag;
7832 /**
7833 * Set the token representing this script tag to the given script tag.
7834 * @param scriptTag the token representing this script tag
7835 */
7836 void set scriptTag3(Token scriptTag) {
7837 this._scriptTag = scriptTag;
7838 }
7839 void visitChildren(ASTVisitor<Object> visitor) {
7840 }
7841 }
7842 /**
7843 * Instances of the class {@code ShowCombinator} represent a combinator that res tricts the names
7844 * being imported to those in a given list.
7845 * <pre>
7846 * showCombinator ::=
7847 * 'show' {@link SimpleIdentifier identifier} (',' {@link SimpleIdentifier ident ifier})
7848 * </pre>
7849 */
7850 class ShowCombinator extends Combinator {
7851 /**
7852 * The list of names from the library that are made visible by this combinator .
7853 */
7854 NodeList<SimpleIdentifier> _shownNames;
7855 /**
7856 * Initialize a newly created import show combinator.
7857 * @param keyword the comma introducing the combinator
7858 * @param shownNames the list of names from the library that are made visible by this combinator
7859 */
7860 ShowCombinator(Token keyword, List<SimpleIdentifier> shownNames) : super(keywo rd) {
7861 this._shownNames = new NodeList<SimpleIdentifier>(this);
7862 this._shownNames.addAll(shownNames);
7863 }
7864 accept(ASTVisitor visitor) => visitor.visitShowCombinator(this);
7865 Token get endToken => _shownNames.endToken;
7866 /**
7867 * Return the list of names from the library that are made visible by this com binator.
7868 * @return the list of names from the library that are made visible by this co mbinator
7869 */
7870 NodeList<SimpleIdentifier> get shownNames => _shownNames;
7871 void visitChildren(ASTVisitor<Object> visitor) {
7872 _shownNames.accept(visitor);
7873 }
7874 }
7875 /**
7876 * Instances of the class {@code SimpleFormalParameter} represent a simple forma l parameter.
7877 * <pre>
7878 * simpleFormalParameter ::=
7879 * ('final' {@link TypeName type} | 'var' | {@link TypeName type})? {@link Simpl eIdentifier identifier}</pre>
7880 */
7881 class SimpleFormalParameter extends NormalFormalParameter {
7882 /**
7883 * The token representing either the 'final', 'const' or 'var' keyword, or {@c ode null} if no
7884 * keyword was used.
7885 */
7886 Token _keyword;
7887 /**
7888 * The name of the declared type of the parameter, or {@code null} if the para meter does not have
7889 * a declared type.
7890 */
7891 TypeName _type;
7892 /**
7893 * Initialize a newly created formal parameter.
7894 * @param comment the documentation comment associated with this parameter
7895 * @param metadata the annotations associated with this parameter
7896 * @param keyword the token representing either the 'final', 'const' or 'var' keyword
7897 * @param type the name of the declared type of the parameter
7898 * @param identifier the name of the parameter being declared
7899 */
7900 SimpleFormalParameter(Comment comment, List<Annotation> metadata, Token keywor d, TypeName type, SimpleIdentifier identifier) : super(comment, metadata, identi fier) {
7901 this._keyword = keyword;
7902 this._type = becomeParentOf(type);
7903 }
7904 accept(ASTVisitor visitor) => visitor.visitSimpleFormalParameter(this);
7905 Token get beginToken {
7906 if (_keyword != null) {
7907 return _keyword;
7908 } else if (_type != null) {
7909 return _type.beginToken;
7910 }
7911 return identifier.beginToken;
7912 }
7913 Token get endToken => identifier.endToken;
7914 /**
7915 * Return the token representing either the 'final', 'const' or 'var' keyword.
7916 * @return the token representing either the 'final', 'const' or 'var' keyword
7917 */
7918 Token get keyword => _keyword;
7919 /**
7920 * Return the name of the declared type of the parameter, or {@code null} if t he parameter does
7921 * not have a declared type.
7922 * @return the name of the declared type of the parameter
7923 */
7924 TypeName get type => _type;
7925 bool isConst() => (_keyword is KeywordToken) && (_keyword as KeywordToken).key word == Keyword.CONST;
7926 bool isFinal() => (_keyword is KeywordToken) && (_keyword as KeywordToken).key word == Keyword.FINAL;
7927 /**
7928 * Set the token representing either the 'final', 'const' or 'var' keyword to the given token.
7929 * @param keyword the token representing either the 'final', 'const' or 'var' keyword
7930 */
7931 void set keyword16(Token keyword) {
7932 this._keyword = keyword;
7933 }
7934 /**
7935 * Set the name of the declared type of the parameter to the given type name.
7936 * @param typeName the name of the declared type of the parameter
7937 */
7938 void set type6(TypeName typeName) {
7939 _type = becomeParentOf(typeName);
7940 }
7941 void visitChildren(ASTVisitor<Object> visitor) {
7942 super.visitChildren(visitor);
7943 safelyVisitChild(_type, visitor);
7944 safelyVisitChild(identifier, visitor);
7945 }
7946 }
7947 /**
7948 * Instances of the class {@code SimpleIdentifier} represent a simple identifier .
7949 * <pre>
7950 * simpleIdentifier ::=
7951 * initialCharacter internalCharacter
7952 * initialCharacter ::= '_' | '$' | letter
7953 * internalCharacter ::= '_' | '$' | letter | digit
7954 * </pre>
7955 */
7956 class SimpleIdentifier extends Identifier {
7957 /**
7958 * The token representing the identifier.
7959 */
7960 Token _token;
7961 /**
7962 * Initialize a newly created identifier.
7963 * @param token the token representing the identifier
7964 */
7965 SimpleIdentifier(Token token) {
7966 this._token = token;
7967 }
7968 accept(ASTVisitor visitor) => visitor.visitSimpleIdentifier(this);
7969 Token get beginToken => _token;
7970 Token get endToken => _token;
7971 String get name => _token.lexeme;
7972 /**
7973 * Return the token representing the identifier.
7974 * @return the token representing the identifier
7975 */
7976 Token get token => _token;
7977 /**
7978 * Return {@code true} if this expression is computing a right-hand value.
7979 * <p>
7980 * Note that {@link #inGetterContext()} and {@link #inSetterContext()} are not opposites, nor are
7981 * they mutually exclusive. In other words, it is possible for both methods to return {@code true}when invoked on the same node.
7982 * @return {@code true} if this expression is in a context where a getter will be invoked
7983 */
7984 bool inGetterContext() {
7985 ASTNode parent7 = parent;
7986 ASTNode target = this;
7987 if (parent7 is PrefixedIdentifier) {
7988 PrefixedIdentifier prefixed = parent7 as PrefixedIdentifier;
7989 if (prefixed.identifier != this) {
7990 return false;
7991 }
7992 parent7 = prefixed.parent;
7993 target = prefixed;
7994 }
7995 if (parent7 is AssignmentExpression) {
7996 AssignmentExpression expr = parent7 as AssignmentExpression;
7997 if (expr.leftHandSide == target && expr.operator.type == TokenType.EQ) {
7998 return false;
7999 }
8000 }
8001 return true;
8002 }
8003 /**
8004 * Return {@code true} if this expression is computing a left-hand value.
8005 * <p>
8006 * Note that {@link #inGetterContext()} and {@link #inSetterContext()} are not opposites, nor are
8007 * they mutually exclusive. In other words, it is possible for both methods to return {@code true}when invoked on the same node.
8008 * @return {@code true} if this expression is in a context where a setter will be invoked
8009 */
8010 bool inSetterContext() {
8011 ASTNode parent8 = parent;
8012 ASTNode target = this;
8013 if (parent8 is PrefixedIdentifier) {
8014 PrefixedIdentifier prefixed = parent8 as PrefixedIdentifier;
8015 if (prefixed.identifier != this) {
8016 return false;
8017 }
8018 parent8 = prefixed.parent;
8019 target = prefixed;
8020 }
8021 if (parent8 is PrefixExpression) {
8022 return (parent8 as PrefixExpression).operator.type.isIncrementOperator();
8023 } else if (parent8 is PostfixExpression) {
8024 return true;
8025 } else if (parent8 is AssignmentExpression) {
8026 return (parent8 as AssignmentExpression).leftHandSide == target;
8027 }
8028 return false;
8029 }
8030 bool isSynthetic() => _token.isSynthetic();
8031 /**
8032 * Set the token representing the identifier to the given token.
8033 * @param token the token representing the literal
8034 */
8035 void set token12(Token token) {
8036 this._token = token;
8037 }
8038 void visitChildren(ASTVisitor<Object> visitor) {
8039 }
8040 }
8041 /**
8042 * Instances of the class {@code SimpleStringLiteral} represent a string literal expression that
8043 * does not contain any interpolations.
8044 * <pre>
8045 * simpleStringLiteral ::=
8046 * rawStringLiteral
8047 * | basicStringLiteral
8048 * rawStringLiteral ::=
8049 * '@' basicStringLiteral
8050 * simpleStringLiteral ::=
8051 * multiLineStringLiteral
8052 * | singleLineStringLiteral
8053 * multiLineStringLiteral ::=
8054 * "'''" characters "'''"
8055 * | '"""' characters '"""'
8056 * singleLineStringLiteral ::=
8057 * "'" characters "'"
8058 * '"' characters '"'
8059 * </pre>
8060 */
8061 class SimpleStringLiteral extends StringLiteral {
8062 /**
8063 * The token representing the literal.
8064 */
8065 Token _literal;
8066 /**
8067 * The value of the literal.
8068 */
8069 String _value;
8070 /**
8071 * Initialize a newly created simple string literal.
8072 * @param literal the token representing the literal
8073 * @param value the value of the literal
8074 */
8075 SimpleStringLiteral(Token literal, String value) {
8076 this._literal = literal;
8077 this._value = value;
8078 }
8079 accept(ASTVisitor visitor) => visitor.visitSimpleStringLiteral(this);
8080 Token get beginToken => _literal;
8081 Token get endToken => _literal;
8082 /**
8083 * Return the token representing the literal.
8084 * @return the token representing the literal
8085 */
8086 Token get literal => _literal;
8087 /**
8088 * Return the value of the literal.
8089 * @return the value of the literal
8090 */
8091 String get value => _value;
8092 /**
8093 * Return {@code true} if this string literal is a multi-line string.
8094 * @return {@code true} if this string literal is a multi-line string
8095 */
8096 bool isMultiline() {
8097 if (_value.length < 6) {
8098 return false;
8099 }
8100 return _value.endsWith("\"\"\"") || _value.endsWith("'''");
8101 }
8102 /**
8103 * Return {@code true} if this string literal is a raw string.
8104 * @return {@code true} if this string literal is a raw string
8105 */
8106 bool isRaw() => _value.charCodeAt(0) == 0x40;
8107 bool isSynthetic() => _literal.isSynthetic();
8108 /**
8109 * Set the token representing the literal to the given token.
8110 * @param literal the token representing the literal
8111 */
8112 void set literal6(Token literal) {
8113 this._literal = literal;
8114 }
8115 /**
8116 * Set the value of the literal to the given string.
8117 * @param string the value of the literal
8118 */
8119 void set value9(String string) {
8120 _value = string;
8121 }
8122 void visitChildren(ASTVisitor<Object> visitor) {
8123 }
8124 }
8125 /**
8126 * Instances of the class {@code Statement} defines the behavior common to nodes that represent a
8127 * statement.
8128 * <pre>
8129 * 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>
8130 */
8131 abstract class Statement extends ASTNode {
8132 }
8133 /**
8134 * Instances of the class {@code StringInterpolation} represent a string interpo lation literal.
8135 * <pre>
8136 * stringInterpolation ::=
8137 * ''' {@link InterpolationElement interpolationElement}* '''
8138 * | '"' {@link InterpolationElement interpolationElement}* '"'
8139 * </pre>
8140 */
8141 class StringInterpolation extends StringLiteral {
8142 /**
8143 * The elements that will be composed to produce the resulting string.
8144 */
8145 NodeList<InterpolationElement> _elements;
8146 /**
8147 * Initialize a newly created string interpolation expression.
8148 * @param elements the elements that will be composed to produce the resulting string
8149 */
8150 StringInterpolation(List<InterpolationElement> elements) {
8151 this._elements = new NodeList<InterpolationElement>(this);
8152 this._elements.addAll(elements);
8153 }
8154 accept(ASTVisitor visitor) => visitor.visitStringInterpolation(this);
8155 Token get beginToken => _elements.beginToken;
8156 /**
8157 * Return the elements that will be composed to produce the resulting string.
8158 * @return the elements that will be composed to produce the resulting string
8159 */
8160 NodeList<InterpolationElement> get elements => _elements;
8161 Token get endToken => _elements.endToken;
8162 void visitChildren(ASTVisitor<Object> visitor) {
8163 _elements.accept(visitor);
8164 }
8165 }
8166 /**
8167 * Instances of the class {@code StringLiteral} represent a string literal expre ssion.
8168 * <pre>
8169 * stringLiteral ::={@link SimpleStringLiteral simpleStringLiteral}| {@link Adja centStrings adjacentStrings}| {@link StringInterpolation stringInterpolation}</p re>
8170 */
8171 abstract class StringLiteral extends Literal {
8172 }
8173 /**
8174 * Instances of the class {@code SuperConstructorInvocation} represent the invoc ation of a
8175 * superclass' constructor from within a constructor's initialization list.
8176 * <pre>
8177 * superInvocation ::=
8178 * 'super' ('.' {@link SimpleIdentifier name})? {@link ArgumentList argumentList }</pre>
8179 */
8180 class SuperConstructorInvocation extends ConstructorInitializer {
8181 /**
8182 * The token for the 'super' keyword.
8183 */
8184 Token _keyword;
8185 /**
8186 * 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.
8187 */
8188 Token _period;
8189 /**
8190 * The name of the constructor that is being invoked, or {@code null} if the u nnamed constructor
8191 * is being invoked.
8192 */
8193 SimpleIdentifier _constructorName;
8194 /**
8195 * The list of arguments to the constructor.
8196 */
8197 ArgumentList _argumentList;
8198 /**
8199 * Initialize a newly created super invocation to invoke the inherited constru ctor with the given
8200 * name with the given arguments.
8201 * @param keyword the token for the 'super' keyword
8202 * @param period the token for the period before the name of the constructor t hat is being invoked
8203 * @param constructorName the name of the constructor that is being invoked
8204 * @param argumentList the list of arguments to the constructor
8205 */
8206 SuperConstructorInvocation(Token keyword, Token period, SimpleIdentifier const ructorName, ArgumentList argumentList) {
8207 this._keyword = keyword;
8208 this._period = period;
8209 this._constructorName = becomeParentOf(constructorName);
8210 this._argumentList = becomeParentOf(argumentList);
8211 }
8212 accept(ASTVisitor visitor) => visitor.visitSuperConstructorInvocation(this);
8213 /**
8214 * Return the list of arguments to the constructor.
8215 * @return the list of arguments to the constructor
8216 */
8217 ArgumentList get argumentList => _argumentList;
8218 Token get beginToken => _keyword;
8219 /**
8220 * Return the name of the constructor that is being invoked, or {@code null} i f the unnamed
8221 * constructor is being invoked.
8222 * @return the name of the constructor that is being invoked
8223 */
8224 SimpleIdentifier get constructorName => _constructorName;
8225 Token get endToken => _argumentList.endToken;
8226 /**
8227 * Return the token for the 'super' keyword.
8228 * @return the token for the 'super' keyword
8229 */
8230 Token get keyword => _keyword;
8231 /**
8232 * 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.
8233 * @return the token for the period before the name of the constructor that is being invoked
8234 */
8235 Token get period => _period;
8236 /**
8237 * Set the list of arguments to the constructor to the given list.
8238 * @param argumentList the list of arguments to the constructor
8239 */
8240 void set argumentList9(ArgumentList argumentList) {
8241 this._argumentList = becomeParentOf(argumentList);
8242 }
8243 /**
8244 * Set the name of the constructor that is being invoked to the given identifi er.
8245 * @param identifier the name of the constructor that is being invoked
8246 */
8247 void set constructorName5(SimpleIdentifier identifier) {
8248 _constructorName = becomeParentOf(identifier);
8249 }
8250 /**
8251 * Set the token for the 'super' keyword to the given token.
8252 * @param keyword the token for the 'super' keyword
8253 */
8254 void set keyword17(Token keyword) {
8255 this._keyword = keyword;
8256 }
8257 /**
8258 * Set the token for the period before the name of the constructor that is bei ng invoked to the
8259 * given token.
8260 * @param period the token for the period before the name of the constructor t hat is being invoked
8261 */
8262 void set period11(Token period) {
8263 this._period = period;
8264 }
8265 void visitChildren(ASTVisitor<Object> visitor) {
8266 safelyVisitChild(_constructorName, visitor);
8267 safelyVisitChild(_argumentList, visitor);
8268 }
8269 }
8270 /**
8271 * Instances of the class {@code SuperExpression} represent a super expression.
8272 * <pre>
8273 * superExpression ::=
8274 * 'super'
8275 * </pre>
8276 */
8277 class SuperExpression extends Expression {
8278 /**
8279 * The token representing the keyword.
8280 */
8281 Token _keyword;
8282 /**
8283 * Initialize a newly created super expression.
8284 * @param keyword the token representing the keyword
8285 */
8286 SuperExpression(Token keyword) {
8287 this._keyword = keyword;
8288 }
8289 accept(ASTVisitor visitor) => visitor.visitSuperExpression(this);
8290 Token get beginToken => _keyword;
8291 Token get endToken => _keyword;
8292 /**
8293 * Return the token representing the keyword.
8294 * @return the token representing the keyword
8295 */
8296 Token get keyword => _keyword;
8297 /**
8298 * Set the token representing the keyword to the given token.
8299 * @param keyword the token representing the keyword
8300 */
8301 void set keyword18(Token keyword) {
8302 this._keyword = keyword;
8303 }
8304 void visitChildren(ASTVisitor<Object> visitor) {
8305 }
8306 }
8307 /**
8308 * Instances of the class {@code SwitchCase} represent the case in a switch stat ement.
8309 * <pre>
8310 * switchCase ::={@link SimpleIdentifier label}* 'case' {@link Expression expres sion} ':' {@link Statement statement}</pre>
8311 */
8312 class SwitchCase extends SwitchMember {
8313 /**
8314 * The expression controlling whether the statements will be executed.
8315 */
8316 Expression _expression;
8317 /**
8318 * Initialize a newly created switch case.
8319 * @param labels the labels associated with the switch member
8320 * @param keyword the token representing the 'case' or 'default' keyword
8321 * @param expression the expression controlling whether the statements will be executed
8322 * @param colon the colon separating the keyword or the expression from the st atements
8323 * @param statements the statements that will be executed if this switch membe r is selected
8324 */
8325 SwitchCase(List<Label> labels, Token keyword, Expression expression, Token col on, List<Statement> statements) : super(labels, keyword, colon, statements) {
8326 this._expression = becomeParentOf(expression);
8327 }
8328 accept(ASTVisitor visitor) => visitor.visitSwitchCase(this);
8329 /**
8330 * Return the expression controlling whether the statements will be executed.
8331 * @return the expression controlling whether the statements will be executed
8332 */
8333 Expression get expression => _expression;
8334 /**
8335 * Set the expression controlling whether the statements will be executed to t he given expression.
8336 * @param expression the expression controlling whether the statements will be executed
8337 */
8338 void set expression11(Expression expression) {
8339 this._expression = becomeParentOf(expression);
8340 }
8341 void visitChildren(ASTVisitor<Object> visitor) {
8342 labels.accept(visitor);
8343 safelyVisitChild(_expression, visitor);
8344 statements.accept(visitor);
8345 }
8346 }
8347 /**
8348 * Instances of the class {@code SwitchDefault} represent the default case in a switch statement.
8349 * <pre>
8350 * switchDefault ::={@link SimpleIdentifier label}* 'default' ':' {@link Stateme nt statement}</pre>
8351 */
8352 class SwitchDefault extends SwitchMember {
8353 /**
8354 * Initialize a newly created switch default.
8355 * @param labels the labels associated with the switch member
8356 * @param keyword the token representing the 'case' or 'default' keyword
8357 * @param colon the colon separating the keyword or the expression from the st atements
8358 * @param statements the statements that will be executed if this switch membe r is selected
8359 */
8360 SwitchDefault(List<Label> labels, Token keyword, Token colon, List<Statement> statements) : super(labels, keyword, colon, statements) {
8361 }
8362 accept(ASTVisitor visitor) => visitor.visitSwitchDefault(this);
8363 void visitChildren(ASTVisitor<Object> visitor) {
8364 labels.accept(visitor);
8365 statements.accept(visitor);
8366 }
8367 }
8368 /**
8369 * The abstract class {@code SwitchMember} defines the behavior common to object s representing
8370 * elements within a switch statement.
8371 * <pre>
8372 * switchMember ::=
8373 * switchCase
8374 * | switchDefault
8375 * </pre>
8376 */
8377 abstract class SwitchMember extends ASTNode {
8378 /**
8379 * The labels associated with the switch member.
8380 */
8381 NodeList<Label> _labels;
8382 /**
8383 * The token representing the 'case' or 'default' keyword.
8384 */
8385 Token _keyword;
8386 /**
8387 * The colon separating the keyword or the expression from the statements.
8388 */
8389 Token _colon;
8390 /**
8391 * The statements that will be executed if this switch member is selected.
8392 */
8393 NodeList<Statement> _statements;
8394 /**
8395 * Initialize a newly created switch member.
8396 * @param labels the labels associated with the switch member
8397 * @param keyword the token representing the 'case' or 'default' keyword
8398 * @param colon the colon separating the keyword or the expression from the st atements
8399 * @param statements the statements that will be executed if this switch membe r is selected
8400 */
8401 SwitchMember(List<Label> labels, Token keyword, Token colon, List<Statement> s tatements) {
8402 this._labels = new NodeList<Label>(this);
8403 this._statements = new NodeList<Statement>(this);
8404 this._labels.addAll(labels);
8405 this._keyword = keyword;
8406 this._colon = colon;
8407 this._statements.addAll(statements);
8408 }
8409 Token get beginToken {
8410 if (!_labels.isEmpty) {
8411 return _labels.beginToken;
8412 }
8413 return _keyword;
8414 }
8415 /**
8416 * Return the colon separating the keyword or the expression from the statemen ts.
8417 * @return the colon separating the keyword or the expression from the stateme nts
8418 */
8419 Token get colon => _colon;
8420 Token get endToken {
8421 if (!_statements.isEmpty) {
8422 return _statements.endToken;
8423 }
8424 return _colon;
8425 }
8426 /**
8427 * Return the token representing the 'case' or 'default' keyword.
8428 * @return the token representing the 'case' or 'default' keyword
8429 */
8430 Token get keyword => _keyword;
8431 /**
8432 * Return the labels associated with the switch member.
8433 * @return the labels associated with the switch member
8434 */
8435 NodeList<Label> get labels => _labels;
8436 /**
8437 * Return the statements that will be executed if this switch member is select ed.
8438 * @return the statements that will be executed if this switch member is selec ted
8439 */
8440 NodeList<Statement> get statements => _statements;
8441 /**
8442 * Set the colon separating the keyword or the expression from the statements to the given token.
8443 * @param colon the colon separating the keyword or the expression from the st atements
8444 */
8445 void set colon4(Token colon) {
8446 this._colon = colon;
8447 }
8448 /**
8449 * Set the token representing the 'case' or 'default' keyword to the given tok en.
8450 * @param keyword the token representing the 'case' or 'default' keyword
8451 */
8452 void set keyword19(Token keyword) {
8453 this._keyword = keyword;
8454 }
8455 }
8456 /**
8457 * Instances of the class {@code SwitchStatement} represent a switch statement.
8458 * <pre>
8459 * switchStatement ::=
8460 * 'switch' '(' {@link Expression expression} ')' '{' {@link SwitchCase switchCa se}* {@link SwitchDefault defaultCase}? '}'
8461 * </pre>
8462 */
8463 class SwitchStatement extends Statement {
8464 /**
8465 * The token representing the 'switch' keyword.
8466 */
8467 Token _keyword;
8468 /**
8469 * The left parenthesis.
8470 */
8471 Token _leftParenthesis;
8472 /**
8473 * The expression used to determine which of the switch members will be select ed.
8474 */
8475 Expression _expression;
8476 /**
8477 * The right parenthesis.
8478 */
8479 Token _rightParenthesis;
8480 /**
8481 * The left curly bracket.
8482 */
8483 Token _leftBracket;
8484 /**
8485 * The switch members that can be selected by the expression.
8486 */
8487 NodeList<SwitchMember> _members;
8488 /**
8489 * The right curly bracket.
8490 */
8491 Token _rightBracket;
8492 /**
8493 * Initialize a newly created switch statement.
8494 * @param keyword the token representing the 'switch' keyword
8495 * @param leftParenthesis the left parenthesis
8496 * @param expression the expression used to determine which of the switch memb ers will be selected
8497 * @param rightParenthesis the right parenthesis
8498 * @param leftBracket the left curly bracket
8499 * @param members the switch members that can be selected by the expression
8500 * @param rightBracket the right curly bracket
8501 */
8502 SwitchStatement(Token keyword, Token leftParenthesis, Expression expression, T oken rightParenthesis, Token leftBracket, List<SwitchMember> members, Token righ tBracket) {
8503 this._members = new NodeList<SwitchMember>(this);
8504 this._keyword = keyword;
8505 this._leftParenthesis = leftParenthesis;
8506 this._expression = becomeParentOf(expression);
8507 this._rightParenthesis = rightParenthesis;
8508 this._leftBracket = leftBracket;
8509 this._members.addAll(members);
8510 this._rightBracket = rightBracket;
8511 }
8512 accept(ASTVisitor visitor) => visitor.visitSwitchStatement(this);
8513 Token get beginToken => _keyword;
8514 Token get endToken => _rightBracket;
8515 /**
8516 * Return the expression used to determine which of the switch members will be selected.
8517 * @return the expression used to determine which of the switch members will b e selected
8518 */
8519 Expression get expression => _expression;
8520 /**
8521 * Return the token representing the 'switch' keyword.
8522 * @return the token representing the 'switch' keyword
8523 */
8524 Token get keyword => _keyword;
8525 /**
8526 * Return the left curly bracket.
8527 * @return the left curly bracket
8528 */
8529 Token get leftBracket => _leftBracket;
8530 /**
8531 * Return the left parenthesis.
8532 * @return the left parenthesis
8533 */
8534 Token get leftParenthesis => _leftParenthesis;
8535 /**
8536 * Return the switch members that can be selected by the expression.
8537 * @return the switch members that can be selected by the expression
8538 */
8539 NodeList<SwitchMember> get members => _members;
8540 /**
8541 * Return the right curly bracket.
8542 * @return the right curly bracket
8543 */
8544 Token get rightBracket => _rightBracket;
8545 /**
8546 * Return the right parenthesis.
8547 * @return the right parenthesis
8548 */
8549 Token get rightParenthesis => _rightParenthesis;
8550 /**
8551 * Set the expression used to determine which of the switch members will be se lected to the given
8552 * expression.
8553 * @param expression the expression used to determine which of the switch memb ers will be selected
8554 */
8555 void set expression12(Expression expression) {
8556 this._expression = becomeParentOf(expression);
8557 }
8558 /**
8559 * Set the token representing the 'switch' keyword to the given token.
8560 * @param keyword the token representing the 'switch' keyword
8561 */
8562 void set keyword20(Token keyword) {
8563 this._keyword = keyword;
8564 }
8565 /**
8566 * Set the left curly bracket to the given token.
8567 * @param leftBracket the left curly bracket
8568 */
8569 void set leftBracket8(Token leftBracket) {
8570 this._leftBracket = leftBracket;
8571 }
8572 /**
8573 * Set the left parenthesis to the given token.
8574 * @param leftParenthesis the left parenthesis
8575 */
8576 void set leftParenthesis11(Token leftParenthesis) {
8577 this._leftParenthesis = leftParenthesis;
8578 }
8579 /**
8580 * Set the right curly bracket to the given token.
8581 * @param rightBracket the right curly bracket
8582 */
8583 void set rightBracket8(Token rightBracket) {
8584 this._rightBracket = rightBracket;
8585 }
8586 /**
8587 * Set the right parenthesis to the given token.
8588 * @param rightParenthesis the right parenthesis
8589 */
8590 void set rightParenthesis11(Token rightParenthesis) {
8591 this._rightParenthesis = rightParenthesis;
8592 }
8593 void visitChildren(ASTVisitor<Object> visitor) {
8594 safelyVisitChild(_expression, visitor);
8595 _members.accept(visitor);
8596 }
8597 }
8598 /**
8599 * Instances of the class {@code ThisExpression} represent a this expression.
8600 * <pre>
8601 * thisExpression ::=
8602 * 'this'
8603 * </pre>
8604 */
8605 class ThisExpression extends Expression {
8606 /**
8607 * The token representing the keyword.
8608 */
8609 Token _keyword;
8610 /**
8611 * Initialize a newly created this expression.
8612 * @param keyword the token representing the keyword
8613 */
8614 ThisExpression(Token keyword) {
8615 this._keyword = keyword;
8616 }
8617 accept(ASTVisitor visitor) => visitor.visitThisExpression(this);
8618 Token get beginToken => _keyword;
8619 Token get endToken => _keyword;
8620 /**
8621 * Return the token representing the keyword.
8622 * @return the token representing the keyword
8623 */
8624 Token get keyword => _keyword;
8625 /**
8626 * Set the token representing the keyword to the given token.
8627 * @param keyword the token representing the keyword
8628 */
8629 void set keyword21(Token keyword) {
8630 this._keyword = keyword;
8631 }
8632 void visitChildren(ASTVisitor<Object> visitor) {
8633 }
8634 }
8635 /**
8636 * Instances of the class {@code ThrowExpression} represent a throw expression.
8637 * <pre>
8638 * throwExpression ::=
8639 * 'throw' {@link Expression expression}? ';'
8640 * </pre>
8641 */
8642 class ThrowExpression extends Expression {
8643 /**
8644 * The token representing the 'throw' keyword.
8645 */
8646 Token _keyword;
8647 /**
8648 * The expression computing the exception to be thrown, or {@code null} if the current exception
8649 * is to be re-thrown. (The latter case can only occur if the throw statement is inside a catch
8650 * clause.)
8651 */
8652 Expression _expression;
8653 /**
8654 * Initialize a newly created throw expression.
8655 * @param keyword the token representing the 'throw' keyword
8656 * @param expression the expression computing the exception to be thrown
8657 */
8658 ThrowExpression(Token keyword, Expression expression) {
8659 this._keyword = keyword;
8660 this._expression = becomeParentOf(expression);
8661 }
8662 accept(ASTVisitor visitor) => visitor.visitThrowExpression(this);
8663 Token get beginToken => _keyword;
8664 Token get endToken {
8665 if (_expression != null) {
8666 return _expression.endToken;
8667 }
8668 return _keyword;
8669 }
8670 /**
8671 * Return the expression computing the exception to be thrown, or {@code null} if the current
8672 * exception is to be re-thrown. (The latter case can only occur if the throw statement is inside
8673 * a catch clause.)
8674 * @return the expression computing the exception to be thrown
8675 */
8676 Expression get expression => _expression;
8677 /**
8678 * Return the token representing the 'throw' keyword.
8679 * @return the token representing the 'throw' keyword
8680 */
8681 Token get keyword => _keyword;
8682 /**
8683 * Set the expression computing the exception to be thrown to the given expres sion.
8684 * @param expression the expression computing the exception to be thrown
8685 */
8686 void set expression13(Expression expression) {
8687 this._expression = becomeParentOf(expression);
8688 }
8689 /**
8690 * Set the token representing the 'throw' keyword to the given token.
8691 * @param keyword the token representing the 'throw' keyword
8692 */
8693 void set keyword22(Token keyword) {
8694 this._keyword = keyword;
8695 }
8696 void visitChildren(ASTVisitor<Object> visitor) {
8697 safelyVisitChild(_expression, visitor);
8698 }
8699 }
8700 /**
8701 * Instances of the class {@code TopLevelVariableDeclaration} represent the decl aration of one or
8702 * more top-level variables of the same type.
8703 * <pre>
8704 * topLevelVariableDeclaration ::=
8705 * ('final' | 'const') type? staticFinalDeclarationList ';'
8706 * | variableDeclaration ';'
8707 * </pre>
8708 */
8709 class TopLevelVariableDeclaration extends CompilationUnitMember {
8710 /**
8711 * The top-level variables being declared.
8712 */
8713 VariableDeclarationList _variableList;
8714 /**
8715 * The semicolon terminating the declaration.
8716 */
8717 Token _semicolon;
8718 /**
8719 * Initialize a newly created top-level variable declaration.
8720 * @param comment the documentation comment associated with this variable
8721 * @param metadata the annotations associated with this variable
8722 * @param variableList the top-level variables being declared
8723 * @param semicolon the semicolon terminating the declaration
8724 */
8725 TopLevelVariableDeclaration(Comment comment, List<Annotation> metadata, Variab leDeclarationList variableList, Token semicolon) : super(comment, metadata) {
8726 this._variableList = becomeParentOf(variableList);
8727 this._semicolon = semicolon;
8728 }
8729 accept(ASTVisitor visitor) => visitor.visitTopLevelVariableDeclaration(this);
8730 Token get endToken => _semicolon;
8731 /**
8732 * Return the semicolon terminating the declaration.
8733 * @return the semicolon terminating the declaration
8734 */
8735 Token get semicolon => _semicolon;
8736 /**
8737 * Return the top-level variables being declared.
8738 * @return the top-level variables being declared
8739 */
8740 VariableDeclarationList get variables => _variableList;
8741 /**
8742 * Set the semicolon terminating the declaration to the given token.
8743 * @param semicolon the semicolon terminating the declaration
8744 */
8745 void set semicolon16(Token semicolon) {
8746 this._semicolon = semicolon;
8747 }
8748 /**
8749 * Set the top-level variables being declared to the given list of variables.
8750 * @param variableList the top-level variables being declared
8751 */
8752 void set variables3(VariableDeclarationList variableList) {
8753 variableList = becomeParentOf(variableList);
8754 }
8755 void visitChildren(ASTVisitor<Object> visitor) {
8756 super.visitChildren(visitor);
8757 safelyVisitChild(_variableList, visitor);
8758 }
8759 Token get firstTokenAfterCommentAndMetadata => _variableList.beginToken;
8760 }
8761 /**
8762 * Instances of the class {@code TryStatement} represent a try statement.
8763 * <pre>
8764 * tryStatement ::=
8765 * 'try' {@link Block block} ({@link CatchClause catchClause}+ finallyClause? | finallyClause)
8766 * finallyClause ::=
8767 * 'finally' {@link Block block}</pre>
8768 */
8769 class TryStatement extends Statement {
8770 /**
8771 * The token representing the 'try' keyword.
8772 */
8773 Token _tryKeyword;
8774 /**
8775 * The body of the statement.
8776 */
8777 Block _body;
8778 /**
8779 * The catch clauses contained in the try statement.
8780 */
8781 NodeList<CatchClause> _catchClauses;
8782 /**
8783 * The token representing the 'finally' keyword, or {@code null} if the statem ent does not contain
8784 * a finally clause.
8785 */
8786 Token _finallyKeyword;
8787 /**
8788 * The finally clause contained in the try statement, or {@code null} if the s tatement does not
8789 * contain a finally clause.
8790 */
8791 Block _finallyClause;
8792 /**
8793 * Initialize a newly created try statement.
8794 * @param tryKeyword the token representing the 'try' keyword
8795 * @param body the body of the statement
8796 * @param catchClauses the catch clauses contained in the try statement
8797 * @param finallyKeyword the token representing the 'finally' keyword
8798 * @param finallyClause the finally clause contained in the try statement
8799 */
8800 TryStatement(Token tryKeyword, Block body, List<CatchClause> catchClauses, Tok en finallyKeyword, Block finallyClause) {
8801 this._catchClauses = new NodeList<CatchClause>(this);
8802 this._tryKeyword = tryKeyword;
8803 this._body = becomeParentOf(body);
8804 this._catchClauses.addAll(catchClauses);
8805 this._finallyKeyword = finallyKeyword;
8806 this._finallyClause = becomeParentOf(finallyClause);
8807 }
8808 accept(ASTVisitor visitor) => visitor.visitTryStatement(this);
8809 Token get beginToken => _tryKeyword;
8810 /**
8811 * Return the body of the statement.
8812 * @return the body of the statement
8813 */
8814 Block get body => _body;
8815 /**
8816 * Return the catch clauses contained in the try statement.
8817 * @return the catch clauses contained in the try statement
8818 */
8819 NodeList<CatchClause> get catchClauses => _catchClauses;
8820 Token get endToken {
8821 if (_finallyClause != null) {
8822 return _finallyClause.endToken;
8823 } else if (_finallyKeyword != null) {
8824 return _finallyKeyword;
8825 } else if (!_catchClauses.isEmpty) {
8826 return _catchClauses.endToken;
8827 }
8828 return _body.endToken;
8829 }
8830 /**
8831 * Return the finally clause contained in the try statement, or {@code null} i f the statement does
8832 * not contain a finally clause.
8833 * @return the finally clause contained in the try statement
8834 */
8835 Block get finallyClause => _finallyClause;
8836 /**
8837 * Return the token representing the 'finally' keyword, or {@code null} if the statement does not
8838 * contain a finally clause.
8839 * @return the token representing the 'finally' keyword
8840 */
8841 Token get finallyKeyword => _finallyKeyword;
8842 /**
8843 * Return the token representing the 'try' keyword.
8844 * @return the token representing the 'try' keyword
8845 */
8846 Token get tryKeyword => _tryKeyword;
8847 /**
8848 * Set the body of the statement to the given block.
8849 * @param block the body of the statement
8850 */
8851 void set body9(Block block) {
8852 _body = becomeParentOf(block);
8853 }
8854 /**
8855 * Set the finally clause contained in the try statement to the given block.
8856 * @param block the finally clause contained in the try statement
8857 */
8858 void set finallyClause2(Block block) {
8859 _finallyClause = becomeParentOf(block);
8860 }
8861 /**
8862 * Set the token representing the 'finally' keyword to the given token.
8863 * @param finallyKeyword the token representing the 'finally' keyword
8864 */
8865 void set finallyKeyword2(Token finallyKeyword) {
8866 this._finallyKeyword = finallyKeyword;
8867 }
8868 /**
8869 * Set the token representing the 'try' keyword to the given token.
8870 * @param tryKeyword the token representing the 'try' keyword
8871 */
8872 void set tryKeyword2(Token tryKeyword) {
8873 this._tryKeyword = tryKeyword;
8874 }
8875 void visitChildren(ASTVisitor<Object> visitor) {
8876 safelyVisitChild(_body, visitor);
8877 _catchClauses.accept(visitor);
8878 safelyVisitChild(_finallyClause, visitor);
8879 }
8880 }
8881 /**
8882 * The abstract class {@code TypeAlias} defines the behavior common to declarati ons of type aliases.
8883 * <pre>
8884 * typeAlias ::=
8885 * 'typedef' typeAliasBody
8886 * typeAliasBody ::=
8887 * classTypeAlias
8888 * | functionTypeAlias
8889 * </pre>
8890 */
8891 abstract class TypeAlias extends CompilationUnitMember {
8892 /**
8893 * The token representing the 'typedef' keyword.
8894 */
8895 Token _keyword;
8896 /**
8897 * The semicolon terminating the declaration.
8898 */
8899 Token _semicolon;
8900 /**
8901 * Initialize a newly created type alias.
8902 * @param comment the documentation comment associated with this type alias
8903 * @param metadata the annotations associated with this type alias
8904 * @param keyword the token representing the 'typedef' keyword
8905 * @param semicolon the semicolon terminating the declaration
8906 */
8907 TypeAlias(Comment comment, List<Annotation> metadata, Token keyword, Token sem icolon) : super(comment, metadata) {
8908 this._keyword = keyword;
8909 this._semicolon = semicolon;
8910 }
8911 Token get endToken => _semicolon;
8912 /**
8913 * Return the token representing the 'typedef' keyword.
8914 * @return the token representing the 'typedef' keyword
8915 */
8916 Token get keyword => _keyword;
8917 /**
8918 * Return the semicolon terminating the declaration.
8919 * @return the semicolon terminating the declaration
8920 */
8921 Token get semicolon => _semicolon;
8922 /**
8923 * Set the token representing the 'typedef' keyword to the given token.
8924 * @param keyword the token representing the 'typedef' keyword
8925 */
8926 void set keyword23(Token keyword) {
8927 this._keyword = keyword;
8928 }
8929 /**
8930 * Set the semicolon terminating the declaration to the given token.
8931 * @param semicolon the semicolon terminating the declaration
8932 */
8933 void set semicolon17(Token semicolon) {
8934 this._semicolon = semicolon;
8935 }
8936 Token get firstTokenAfterCommentAndMetadata => _keyword;
8937 }
8938 /**
8939 * Instances of the class {@code TypeArgumentList} represent a list of type argu ments.
8940 * <pre>
8941 * typeArguments ::=
8942 * '<' typeName (',' typeName)* '>'
8943 * </pre>
8944 */
8945 class TypeArgumentList extends ASTNode {
8946 /**
8947 * The left bracket.
8948 */
8949 Token _leftBracket;
8950 /**
8951 * The type arguments associated with the type.
8952 */
8953 NodeList<TypeName> _arguments;
8954 /**
8955 * The right bracket.
8956 */
8957 Token _rightBracket;
8958 /**
8959 * Initialize a newly created list of type arguments.
8960 * @param leftBracket the left bracket
8961 * @param arguments the type arguments associated with the type
8962 * @param rightBracket the right bracket
8963 */
8964 TypeArgumentList(Token leftBracket, List<TypeName> arguments, Token rightBrack et) {
8965 this._arguments = new NodeList<TypeName>(this);
8966 this._leftBracket = leftBracket;
8967 this._arguments.addAll(arguments);
8968 this._rightBracket = rightBracket;
8969 }
8970 accept(ASTVisitor visitor) => visitor.visitTypeArgumentList(this);
8971 /**
8972 * Return the type arguments associated with the type.
8973 * @return the type arguments associated with the type
8974 */
8975 NodeList<TypeName> get arguments => _arguments;
8976 Token get beginToken => _leftBracket;
8977 Token get endToken => _rightBracket;
8978 /**
8979 * Return the left bracket.
8980 * @return the left bracket
8981 */
8982 Token get leftBracket => _leftBracket;
8983 /**
8984 * Return the right bracket.
8985 * @return the right bracket
8986 */
8987 Token get rightBracket => _rightBracket;
8988 /**
8989 * Set the left bracket to the given token.
8990 * @param leftBracket the left bracket
8991 */
8992 void set leftBracket9(Token leftBracket) {
8993 this._leftBracket = leftBracket;
8994 }
8995 /**
8996 * Set the right bracket to the given token.
8997 * @param rightBracket the right bracket
8998 */
8999 void set rightBracket9(Token rightBracket) {
9000 this._rightBracket = rightBracket;
9001 }
9002 void visitChildren(ASTVisitor<Object> visitor) {
9003 _arguments.accept(visitor);
9004 }
9005 }
9006 /**
9007 * Instances of the class {@code TypeName} represent the name of a type, which c an optionally
9008 * include type arguments.
9009 * <pre>
9010 * typeName ::={@link Identifier identifier} typeArguments?
9011 * </pre>
9012 */
9013 class TypeName extends ASTNode {
9014 /**
9015 * The name of the type.
9016 */
9017 Identifier _name;
9018 /**
9019 * The type arguments associated with the type, or {@code null} if there are n o type arguments.
9020 */
9021 TypeArgumentList _typeArguments;
9022 /**
9023 * The type being named, or {@code null} if the AST structure has not been res olved.
9024 */
9025 Type2 _type;
9026 /**
9027 * Initialize a newly created type name.
9028 * @param name the name of the type
9029 * @param typeArguments the type arguments associated with the type, or {@code null} if there are
9030 * no type arguments
9031 */
9032 TypeName(Identifier name, TypeArgumentList typeArguments) {
9033 this._name = becomeParentOf(name);
9034 this._typeArguments = becomeParentOf(typeArguments);
9035 }
9036 accept(ASTVisitor visitor) => visitor.visitTypeName(this);
9037 Token get beginToken => _name.beginToken;
9038 Token get endToken {
9039 if (_typeArguments != null) {
9040 return _typeArguments.endToken;
9041 }
9042 return _name.endToken;
9043 }
9044 /**
9045 * Return the name of the type.
9046 * @return the name of the type
9047 */
9048 Identifier get name => _name;
9049 /**
9050 * Return the type being named, or {@code null} if the AST structure has not b een resolved.
9051 * @return the type being named
9052 */
9053 Type2 get type => _type;
9054 /**
9055 * Return the type arguments associated with the type, or {@code null} if ther e are no type
9056 * arguments.
9057 * @return the type arguments associated with the type
9058 */
9059 TypeArgumentList get typeArguments => _typeArguments;
9060 bool isSynthetic() => _name.isSynthetic() && _typeArguments == null;
9061 /**
9062 * Set the name of the type to the given identifier.
9063 * @param identifier the name of the type
9064 */
9065 void set name12(Identifier identifier) {
9066 _name = becomeParentOf(identifier);
9067 }
9068 /**
9069 * Set the type being named to the given type.
9070 * @param type the type being named
9071 */
9072 void set type7(Type2 type) {
9073 this._type = type;
9074 }
9075 /**
9076 * Set the type arguments associated with the type to the given type arguments .
9077 * @param typeArguments the type arguments associated with the type
9078 */
9079 void set typeArguments2(TypeArgumentList typeArguments) {
9080 this._typeArguments = becomeParentOf(typeArguments);
9081 }
9082 void visitChildren(ASTVisitor<Object> visitor) {
9083 safelyVisitChild(_name, visitor);
9084 safelyVisitChild(_typeArguments, visitor);
9085 }
9086 }
9087 /**
9088 * Instances of the class {@code TypeParameter} represent a type parameter.
9089 * <pre>
9090 * typeParameter ::={@link SimpleIdentifier name} ('extends' {@link TypeName bou nd})?
9091 * </pre>
9092 */
9093 class TypeParameter extends Declaration {
9094 /**
9095 * The name of the type parameter.
9096 */
9097 SimpleIdentifier _name;
9098 /**
9099 * The token representing the 'extends' keyword, or {@code null} if there was no explicit upper
9100 * bound.
9101 */
9102 Token _keyword;
9103 /**
9104 * The name of the upper bound for legal arguments, or {@code null} if there w as no explicit upper
9105 * bound.
9106 */
9107 TypeName _bound;
9108 /**
9109 * Initialize a newly created type parameter.
9110 * @param comment the documentation comment associated with the type parameter
9111 * @param metadata the annotations associated with the type parameter
9112 * @param name the name of the type parameter
9113 * @param keyword the token representing the 'extends' keyword
9114 * @param bound the name of the upper bound for legal arguments
9115 */
9116 TypeParameter(Comment comment, List<Annotation> metadata, SimpleIdentifier nam e, Token keyword, TypeName bound) : super(comment, metadata) {
9117 this._name = becomeParentOf(name);
9118 this._keyword = keyword;
9119 this._bound = becomeParentOf(bound);
9120 }
9121 accept(ASTVisitor visitor) => visitor.visitTypeParameter(this);
9122 /**
9123 * Return the name of the upper bound for legal arguments, or {@code null} if there was no
9124 * explicit upper bound.
9125 * @return the name of the upper bound for legal arguments
9126 */
9127 TypeName get bound => _bound;
9128 Token get endToken {
9129 if (_bound == null) {
9130 return _name.endToken;
9131 }
9132 return _bound.endToken;
9133 }
9134 /**
9135 * Return the token representing the 'assert' keyword.
9136 * @return the token representing the 'assert' keyword
9137 */
9138 Token get keyword => _keyword;
9139 /**
9140 * Return the name of the type parameter.
9141 * @return the name of the type parameter
9142 */
9143 SimpleIdentifier get name => _name;
9144 /**
9145 * Set the name of the upper bound for legal arguments to the given type name.
9146 * @param typeName the name of the upper bound for legal arguments
9147 */
9148 void set bound2(TypeName typeName) {
9149 _bound = becomeParentOf(typeName);
9150 }
9151 /**
9152 * Set the token representing the 'assert' keyword to the given token.
9153 * @param keyword the token representing the 'assert' keyword
9154 */
9155 void set keyword24(Token keyword) {
9156 this._keyword = keyword;
9157 }
9158 /**
9159 * Set the name of the type parameter to the given identifier.
9160 * @param identifier the name of the type parameter
9161 */
9162 void set name13(SimpleIdentifier identifier) {
9163 _name = becomeParentOf(identifier);
9164 }
9165 void visitChildren(ASTVisitor<Object> visitor) {
9166 super.visitChildren(visitor);
9167 safelyVisitChild(_name, visitor);
9168 safelyVisitChild(_bound, visitor);
9169 }
9170 Token get firstTokenAfterCommentAndMetadata => _name.beginToken;
9171 }
9172 /**
9173 * Instances of the class {@code TypeParameterList} represent type parameters wi thin a declaration.
9174 * <pre>
9175 * typeParameterList ::=
9176 * '<' {@link TypeParameter typeParameter} (',' {@link TypeParameter typeParamet er})* '>'
9177 * </pre>
9178 */
9179 class TypeParameterList extends ASTNode {
9180 /**
9181 * The left angle bracket.
9182 */
9183 Token _leftBracket;
9184 /**
9185 * The type parameters in the list.
9186 */
9187 NodeList<TypeParameter> _typeParameters;
9188 /**
9189 * The right angle bracket.
9190 */
9191 Token _rightBracket;
9192 /**
9193 * Initialize a newly created list of type parameters.
9194 * @param leftBracket the left angle bracket
9195 * @param typeParameters the type parameters in the list
9196 * @param rightBracket the right angle bracket
9197 */
9198 TypeParameterList(Token leftBracket, List<TypeParameter> typeParameters, Token rightBracket) {
9199 this._typeParameters = new NodeList<TypeParameter>(this);
9200 this._leftBracket = leftBracket;
9201 this._typeParameters.addAll(typeParameters);
9202 this._rightBracket = rightBracket;
9203 }
9204 accept(ASTVisitor visitor) => visitor.visitTypeParameterList(this);
9205 Token get beginToken => _leftBracket;
9206 Token get endToken => _rightBracket;
9207 /**
9208 * Return the left angle bracket.
9209 * @return the left angle bracket
9210 */
9211 Token get leftBracket => _leftBracket;
9212 /**
9213 * Return the right angle bracket.
9214 * @return the right angle bracket
9215 */
9216 Token get rightBracket => _rightBracket;
9217 /**
9218 * Return the type parameters for the type.
9219 * @return the type parameters for the type
9220 */
9221 NodeList<TypeParameter> get typeParameters => _typeParameters;
9222 void visitChildren(ASTVisitor<Object> visitor) {
9223 _typeParameters.accept(visitor);
9224 }
9225 }
9226 /**
9227 * The abstract class {@code TypedLiteral} defines the behavior common to litera ls that have a type
9228 * associated with them.
9229 * <pre>
9230 * listLiteral ::={@link ListLiteral listLiteral}| {@link MapLiteral mapLiteral} </pre>
9231 */
9232 abstract class TypedLiteral extends Literal {
9233 /**
9234 * The const modifier associated with this literal, or {@code null} if the lit eral is not a
9235 * constant.
9236 */
9237 Token _modifier;
9238 /**
9239 * The type argument associated with this literal, or {@code null} if no type arguments were
9240 * declared.
9241 */
9242 TypeArgumentList _typeArguments;
9243 /**
9244 * Initialize a newly created typed literal.
9245 * @param modifier the const modifier associated with this literal
9246 * @param typeArguments the type argument associated with this literal, or {@c ode null} if no type
9247 * arguments were declared
9248 */
9249 TypedLiteral(Token modifier, TypeArgumentList typeArguments) {
9250 this._modifier = modifier;
9251 this._typeArguments = becomeParentOf(typeArguments);
9252 }
9253 /**
9254 * Return the const modifier associated with this literal.
9255 * @return the const modifier associated with this literal
9256 */
9257 Token get modifier => _modifier;
9258 /**
9259 * Return the type argument associated with this literal, or {@code null} if n o type arguments
9260 * were declared.
9261 * @return the type argument associated with this literal
9262 */
9263 TypeArgumentList get typeArguments => _typeArguments;
9264 /**
9265 * Set the modifiers associated with this literal to the given modifiers.
9266 * @param modifiers the modifiers associated with this literal
9267 */
9268 void set modifier2(Token modifier) {
9269 this._modifier = modifier;
9270 }
9271 /**
9272 * Set the type argument associated with this literal to the given arguments.
9273 * @param typeArguments the type argument associated with this literal
9274 */
9275 void set typeArguments3(TypeArgumentList typeArguments) {
9276 this._typeArguments = typeArguments;
9277 }
9278 void visitChildren(ASTVisitor<Object> visitor) {
9279 safelyVisitChild(_typeArguments, visitor);
9280 }
9281 }
9282 /**
9283 * Instances of the class {@code VariableDeclaration} represent an identifier th at has an initial
9284 * value associated with it. Instances of this class are always children of the class{@link VariableDeclarationList}.
9285 * <pre>
9286 * variableDeclaration ::={@link SimpleIdentifier identifier} ('=' {@link Expres sion initialValue})?
9287 * </pre>
9288 */
9289 class VariableDeclaration extends Declaration {
9290 /**
9291 * The name of the variable being declared.
9292 */
9293 SimpleIdentifier _name;
9294 /**
9295 * The equal sign separating the variable name from the initial value, or {@co de null} if the
9296 * initial value was not specified.
9297 */
9298 Token _equals;
9299 /**
9300 * The expression used to compute the initial value for the variable, or {@cod e null} if the
9301 * initial value was not specified.
9302 */
9303 Expression _initializer;
9304 /**
9305 * Initialize a newly created variable declaration.
9306 * @param comment the documentation comment associated with this declaration
9307 * @param metadata the annotations associated with this member
9308 * @param name the name of the variable being declared
9309 * @param equals the equal sign separating the variable name from the initial value
9310 * @param initializer the expression used to compute the initial value for the variable
9311 */
9312 VariableDeclaration(Comment comment, List<Annotation> metadata, SimpleIdentifi er name, Token equals, Expression initializer) : super(comment, metadata) {
9313 this._name = becomeParentOf(name);
9314 this._equals = equals;
9315 this._initializer = becomeParentOf(initializer);
9316 }
9317 accept(ASTVisitor visitor) => visitor.visitVariableDeclaration(this);
9318 /**
9319 * Return the {@link VariableElement} associated with this variable, or {@code null} if the AST
9320 * structure has not been resolved.
9321 * @return the {@link VariableElement} associated with this variable
9322 */
9323 VariableElement get element => _name != null ? _name.element as VariableElemen t : null;
9324 Token get endToken {
9325 if (_initializer != null) {
9326 return _initializer.endToken;
9327 }
9328 return _name.endToken;
9329 }
9330 /**
9331 * Return the equal sign separating the variable name from the initial value, or {@code null} if
9332 * the initial value was not specified.
9333 * @return the equal sign separating the variable name from the initial value
9334 */
9335 Token get equals => _equals;
9336 /**
9337 * Return the expression used to compute the initial value for the variable, o r {@code null} if
9338 * the initial value was not specified.
9339 * @return the expression used to compute the initial value for the variable
9340 */
9341 Expression get initializer => _initializer;
9342 /**
9343 * Return the name of the variable being declared.
9344 * @return the name of the variable being declared
9345 */
9346 SimpleIdentifier get name => _name;
9347 /**
9348 * Set the equal sign separating the variable name from the initial value to t he given token.
9349 * @param equals the equal sign separating the variable name from the initial value
9350 */
9351 void set equals6(Token equals) {
9352 this._equals = equals;
9353 }
9354 /**
9355 * Set the expression used to compute the initial value for the variable to th e given expression.
9356 * @param initializer the expression used to compute the initial value for the variable
9357 */
9358 void set initializer2(Expression initializer) {
9359 this._initializer = becomeParentOf(initializer);
9360 }
9361 /**
9362 * Set the name of the variable being declared to the given identifier.
9363 * @param name the name of the variable being declared
9364 */
9365 void set name14(SimpleIdentifier name) {
9366 this._name = becomeParentOf(name);
9367 }
9368 void visitChildren(ASTVisitor<Object> visitor) {
9369 super.visitChildren(visitor);
9370 safelyVisitChild(_name, visitor);
9371 safelyVisitChild(_initializer, visitor);
9372 }
9373 Token get firstTokenAfterCommentAndMetadata => _name.beginToken;
9374 }
9375 /**
9376 * Instances of the class {@code VariableDeclarationList} represent the declarat ion of one or more
9377 * variables of the same type.
9378 * <pre>
9379 * variableDeclarationList ::=
9380 * finalConstVarOrType {@link VariableDeclaration variableDeclaration} (',' {@li nk VariableDeclaration variableDeclaration})
9381 * finalConstVarOrType ::=
9382 * | 'final' {@link TypeName type}?
9383 * | 'const' {@link TypeName type}?
9384 * | 'var'
9385 * | {@link TypeName type}</pre>
9386 */
9387 class VariableDeclarationList extends ASTNode {
9388 /**
9389 * The token representing the 'final', 'const' or 'var' keyword, or {@code nul l} if no keyword was
9390 * included.
9391 */
9392 Token _keyword;
9393 /**
9394 * The type of the variables being declared, or {@code null} if no type was pr ovided.
9395 */
9396 TypeName _type;
9397 /**
9398 * A list containing the individual variables being declared.
9399 */
9400 NodeList<VariableDeclaration> _variables;
9401 /**
9402 * Initialize a newly created variable declaration list.
9403 * @param keyword the token representing the 'final', 'const' or 'var' keyword
9404 * @param type the type of the variables being declared
9405 * @param variables a list containing the individual variables being declared
9406 */
9407 VariableDeclarationList(Token keyword, TypeName type, List<VariableDeclaration > variables) {
9408 this._variables = new NodeList<VariableDeclaration>(this);
9409 this._keyword = keyword;
9410 this._type = becomeParentOf(type);
9411 this._variables.addAll(variables);
9412 }
9413 accept(ASTVisitor visitor) => visitor.visitVariableDeclarationList(this);
9414 Token get beginToken {
9415 if (_keyword != null) {
9416 return _keyword;
9417 } else if (_type != null) {
9418 return _type.beginToken;
9419 }
9420 return _variables.beginToken;
9421 }
9422 Token get endToken => _variables.endToken;
9423 /**
9424 * Return the token representing the 'final', 'const' or 'var' keyword, or {@c ode null} if no
9425 * keyword was included.
9426 * @return the token representing the 'final', 'const' or 'var' keyword
9427 */
9428 Token get keyword => _keyword;
9429 /**
9430 * Return the type of the variables being declared, or {@code null} if no type was provided.
9431 * @return the type of the variables being declared
9432 */
9433 TypeName get type => _type;
9434 /**
9435 * Return a list containing the individual variables being declared.
9436 * @return a list containing the individual variables being declared
9437 */
9438 NodeList<VariableDeclaration> get variables => _variables;
9439 /**
9440 * Set the token representing the 'final', 'const' or 'var' keyword to the giv en token.
9441 * @param keyword the token representing the 'final', 'const' or 'var' keyword
9442 */
9443 void set keyword25(Token keyword) {
9444 this._keyword = keyword;
9445 }
9446 /**
9447 * Set the type of the variables being declared to the given type name.
9448 * @param typeName the type of the variables being declared
9449 */
9450 void set type8(TypeName typeName) {
9451 _type = becomeParentOf(typeName);
9452 }
9453 void visitChildren(ASTVisitor<Object> visitor) {
9454 safelyVisitChild(_type, visitor);
9455 _variables.accept(visitor);
9456 }
9457 }
9458 /**
9459 * Instances of the class {@code VariableDeclarationStatement} represent a list of variables that
9460 * are being declared in a context where a statement is required.
9461 * <pre>
9462 * variableDeclarationStatement ::={@link VariableDeclarationList variableList} ';'
9463 * </pre>
9464 */
9465 class VariableDeclarationStatement extends Statement {
9466 /**
9467 * The variables being declared.
9468 */
9469 VariableDeclarationList _variableList;
9470 /**
9471 * The semicolon terminating the statement.
9472 */
9473 Token _semicolon;
9474 /**
9475 * Initialize a newly created variable declaration statement.
9476 * @param variableList the fields being declared
9477 * @param semicolon the semicolon terminating the statement
9478 */
9479 VariableDeclarationStatement(VariableDeclarationList variableList, Token semic olon) {
9480 this._variableList = becomeParentOf(variableList);
9481 this._semicolon = semicolon;
9482 }
9483 accept(ASTVisitor visitor) => visitor.visitVariableDeclarationStatement(this);
9484 Token get beginToken => _variableList.beginToken;
9485 Token get endToken => _semicolon;
9486 /**
9487 * Return the semicolon terminating the statement.
9488 * @return the semicolon terminating the statement
9489 */
9490 Token get semicolon => _semicolon;
9491 /**
9492 * Return the variables being declared.
9493 * @return the variables being declared
9494 */
9495 VariableDeclarationList get variables => _variableList;
9496 /**
9497 * Set the semicolon terminating the statement to the given token.
9498 * @param semicolon the semicolon terminating the statement
9499 */
9500 void set semicolon18(Token semicolon) {
9501 this._semicolon = semicolon;
9502 }
9503 /**
9504 * Set the variables being declared to the given list of variables.
9505 * @param variableList the variables being declared
9506 */
9507 void set variables4(VariableDeclarationList variableList) {
9508 this._variableList = becomeParentOf(variableList);
9509 }
9510 void visitChildren(ASTVisitor<Object> visitor) {
9511 safelyVisitChild(_variableList, visitor);
9512 }
9513 }
9514 /**
9515 * Instances of the class {@code WhileStatement} represent a while statement.
9516 * <pre>
9517 * whileStatement ::=
9518 * 'while' '(' {@link Expression condition} ')' {@link Statement body}</pre>
9519 */
9520 class WhileStatement extends Statement {
9521 /**
9522 * The token representing the 'while' keyword.
9523 */
9524 Token _keyword;
9525 /**
9526 * The left parenthesis.
9527 */
9528 Token _leftParenthesis;
9529 /**
9530 * The expression used to determine whether to execute the body of the loop.
9531 */
9532 Expression _condition;
9533 /**
9534 * The right parenthesis.
9535 */
9536 Token _rightParenthesis;
9537 /**
9538 * The body of the loop.
9539 */
9540 Statement _body;
9541 /**
9542 * Initialize a newly created while statement.
9543 * @param keyword the token representing the 'while' keyword
9544 * @param leftParenthesis the left parenthesis
9545 * @param condition the expression used to determine whether to execute the bo dy of the loop
9546 * @param rightParenthesis the right parenthesis
9547 * @param body the body of the loop
9548 */
9549 WhileStatement(Token keyword, Token leftParenthesis, Expression condition, Tok en rightParenthesis, Statement body) {
9550 this._keyword = keyword;
9551 this._leftParenthesis = leftParenthesis;
9552 this._condition = becomeParentOf(condition);
9553 this._rightParenthesis = rightParenthesis;
9554 this._body = becomeParentOf(body);
9555 }
9556 accept(ASTVisitor visitor) => visitor.visitWhileStatement(this);
9557 Token get beginToken => _keyword;
9558 /**
9559 * Return the body of the loop.
9560 * @return the body of the loop
9561 */
9562 Statement get body => _body;
9563 /**
9564 * Return the expression used to determine whether to execute the body of the loop.
9565 * @return the expression used to determine whether to execute the body of the loop
9566 */
9567 Expression get condition => _condition;
9568 Token get endToken => _body.endToken;
9569 /**
9570 * Return the token representing the 'while' keyword.
9571 * @return the token representing the 'while' keyword
9572 */
9573 Token get keyword => _keyword;
9574 /**
9575 * Return the left parenthesis.
9576 * @return the left parenthesis
9577 */
9578 Token get leftParenthesis => _leftParenthesis;
9579 /**
9580 * Return the right parenthesis.
9581 * @return the right parenthesis
9582 */
9583 Token get rightParenthesis => _rightParenthesis;
9584 /**
9585 * Set the body of the loop to the given statement.
9586 * @param statement the body of the loop
9587 */
9588 void set body10(Statement statement) {
9589 _body = becomeParentOf(statement);
9590 }
9591 /**
9592 * Set the expression used to determine whether to execute the body of the loo p to the given
9593 * expression.
9594 * @param expression the expression used to determine whether to execute the b ody of the loop
9595 */
9596 void set condition7(Expression expression) {
9597 _condition = becomeParentOf(expression);
9598 }
9599 /**
9600 * Set the token representing the 'while' keyword to the given token.
9601 * @param keyword the token representing the 'while' keyword
9602 */
9603 void set keyword26(Token keyword) {
9604 this._keyword = keyword;
9605 }
9606 /**
9607 * Set the left parenthesis to the given token.
9608 * @param leftParenthesis the left parenthesis
9609 */
9610 void set leftParenthesis12(Token leftParenthesis) {
9611 this._leftParenthesis = leftParenthesis;
9612 }
9613 /**
9614 * Set the right parenthesis to the given token.
9615 * @param rightParenthesis the right parenthesis
9616 */
9617 void set rightParenthesis12(Token rightParenthesis) {
9618 this._rightParenthesis = rightParenthesis;
9619 }
9620 void visitChildren(ASTVisitor<Object> visitor) {
9621 safelyVisitChild(_condition, visitor);
9622 safelyVisitChild(_body, visitor);
9623 }
9624 }
9625 /**
9626 * Instances of the class {@code WithClause} represent the with clause in a clas s declaration.
9627 * <pre>
9628 * withClause ::=
9629 * 'with' {@link TypeName mixin} (',' {@link TypeName mixin})
9630 * </pre>
9631 */
9632 class WithClause extends ASTNode {
9633 /**
9634 * The token representing the 'with' keyword.
9635 */
9636 Token _withKeyword;
9637 /**
9638 * The names of the mixins that were specified.
9639 */
9640 NodeList<TypeName> _mixinTypes;
9641 /**
9642 * Initialize a newly created with clause.
9643 * @param withKeyword the token representing the 'with' keyword
9644 * @param mixinTypes the names of the mixins that were specified
9645 */
9646 WithClause(Token withKeyword, List<TypeName> mixinTypes) {
9647 this._mixinTypes = new NodeList<TypeName>(this);
9648 this._withKeyword = withKeyword;
9649 this._mixinTypes.addAll(mixinTypes);
9650 }
9651 accept(ASTVisitor visitor) => visitor.visitWithClause(this);
9652 Token get beginToken => _withKeyword;
9653 Token get endToken => _mixinTypes.endToken;
9654 /**
9655 * Return the names of the mixins that were specified.
9656 * @return the names of the mixins that were specified
9657 */
9658 NodeList<TypeName> get mixinTypes => _mixinTypes;
9659 /**
9660 * Return the token representing the 'with' keyword.
9661 * @return the token representing the 'with' keyword
9662 */
9663 Token get withKeyword => _withKeyword;
9664 /**
9665 * Set the token representing the 'with' keyword to the given token.
9666 * @param withKeyword the token representing the 'with' keyword
9667 */
9668 void set mixinKeyword(Token withKeyword) {
9669 this._withKeyword = withKeyword;
9670 }
9671 void visitChildren(ASTVisitor<Object> visitor) {
9672 _mixinTypes.accept(visitor);
9673 }
9674 }
9675 /**
9676 * Instances of the class {@code ConstantEvaluator} evaluate constant expression s to produce their
9677 * compile-time value. According to the Dart Language Specification: <blockquote > A constant
9678 * expression is one of the following:
9679 * <ul>
9680 * <li>A literal number.</li>
9681 * <li>A literal boolean.</li>
9682 * <li>A literal string where any interpolated expression is a compile-time cons tant that evaluates
9683 * to a numeric, string or boolean value or to {@code null}.</li>
9684 * <li>{@code null}.</li>
9685 * <li>A reference to a static constant variable.</li>
9686 * <li>An identifier expression that denotes a constant variable, a class or a t ype variable.</li>
9687 * <li>A constant constructor invocation.</li>
9688 * <li>A constant list literal.</li>
9689 * <li>A constant map literal.</li>
9690 * <li>A simple or qualified identifier denoting a top-level function or a stati c method.</li>
9691 * <li>A parenthesized expression {@code (e)} where {@code e} is a constant expr ession.</li>
9692 * <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
9693 * numeric, string or boolean value or to {@code null}.</li>
9694 * <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
9695 * to {@code null}.</li>
9696 * <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>
9697 * <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>
9698 * </ul>
9699 * </blockquote> The values returned by instances of this class are therefore {@ code null} and
9700 * instances of the classes {@code Boolean}, {@code BigInteger}, {@code Double}, {@code String}, and{@code DartObject}.
9701 * <p>
9702 * In addition, this class defines several values that can be returned to indica te various
9703 * conditions encountered during evaluation. These are documented with the stati c field that define
9704 * those values.
9705 */
9706 class ConstantEvaluator extends GeneralizingASTVisitor<Object> {
9707 /**
9708 * The value returned for expressions (or non-expression nodes) that are not c ompile-time constant
9709 * expressions.
9710 */
9711 static Object NOT_A_CONSTANT = new Object();
9712 Object visitAdjacentStrings(AdjacentStrings node) {
9713 StringBuffer builder = new StringBuffer();
9714 for (StringLiteral string in node.strings) {
9715 Object value = string.accept(this);
9716 if (value == ConstantEvaluator.NOT_A_CONSTANT) {
9717 return value;
9718 }
9719 builder.add(value);
9720 }
9721 return builder.toString();
9722 }
9723 Object visitBinaryExpression(BinaryExpression node) {
9724 Object leftOperand3 = node.leftOperand.accept(this);
9725 if (leftOperand3 == ConstantEvaluator.NOT_A_CONSTANT) {
9726 return leftOperand3;
9727 }
9728 Object rightOperand3 = node.rightOperand.accept(this);
9729 if (rightOperand3 == ConstantEvaluator.NOT_A_CONSTANT) {
9730 return rightOperand3;
9731 }
9732 if (node.operator.type == TokenType.AMPERSAND) {
9733 if (leftOperand3 is int && rightOperand3 is int) {
9734 return (leftOperand3 as int) & rightOperand3 as int;
9735 }
9736 } else if (node.operator.type == TokenType.AMPERSAND_AMPERSAND) {
9737 if (leftOperand3 is bool && rightOperand3 is bool) {
9738 return (leftOperand3 as bool) && (rightOperand3 as bool);
9739 }
9740 } else if (node.operator.type == TokenType.BANG_EQ) {
9741 if (leftOperand3 is bool && rightOperand3 is bool) {
9742 return (leftOperand3 as bool) != (rightOperand3 as bool);
9743 } else if (leftOperand3 is int && rightOperand3 is int) {
9744 return (leftOperand3 as int) != rightOperand3;
9745 } else if (leftOperand3 is double && rightOperand3 is double) {
9746 return (leftOperand3 as double) != rightOperand3;
9747 } else if (leftOperand3 is String && rightOperand3 is String) {
9748 return (leftOperand3 as String) != rightOperand3;
9749 }
9750 } else if (node.operator.type == TokenType.BAR) {
9751 if (leftOperand3 is int && rightOperand3 is int) {
9752 return (leftOperand3 as int) | rightOperand3 as int;
9753 }
9754 } else if (node.operator.type == TokenType.BAR_BAR) {
9755 if (leftOperand3 is bool && rightOperand3 is bool) {
9756 return (leftOperand3 as bool) || (rightOperand3 as bool);
9757 }
9758 } else if (node.operator.type == TokenType.CARET) {
9759 if (leftOperand3 is int && rightOperand3 is int) {
9760 return (leftOperand3 as int) ^ rightOperand3 as int;
9761 }
9762 } else if (node.operator.type == TokenType.EQ_EQ) {
9763 if (leftOperand3 is bool && rightOperand3 is bool) {
9764 return (leftOperand3 as bool) == (rightOperand3 as bool);
9765 } else if (leftOperand3 is int && rightOperand3 is int) {
9766 return (leftOperand3 as int) == rightOperand3;
9767 } else if (leftOperand3 is double && rightOperand3 is double) {
9768 return (leftOperand3 as double) == rightOperand3;
9769 } else if (leftOperand3 is String && rightOperand3 is String) {
9770 return (leftOperand3 as String) == rightOperand3;
9771 }
9772 } else if (node.operator.type == TokenType.GT) {
9773 if (leftOperand3 is int && rightOperand3 is int) {
9774 return (leftOperand3 as int).compareTo(rightOperand3 as int) > 0;
9775 } else if (leftOperand3 is double && rightOperand3 is double) {
9776 return (leftOperand3 as double).compareTo(rightOperand3 as double) > 0;
9777 }
9778 } else if (node.operator.type == TokenType.GT_EQ) {
9779 if (leftOperand3 is int && rightOperand3 is int) {
9780 return (leftOperand3 as int).compareTo(rightOperand3 as int) >= 0;
9781 } else if (leftOperand3 is double && rightOperand3 is double) {
9782 return (leftOperand3 as double).compareTo(rightOperand3 as double) >= 0;
9783 }
9784 } else if (node.operator.type == TokenType.GT_GT) {
9785 if (leftOperand3 is int && rightOperand3 is int) {
9786 return (leftOperand3 as int) >> (rightOperand3 as int);
9787 }
9788 } else if (node.operator.type == TokenType.LT) {
9789 if (leftOperand3 is int && rightOperand3 is int) {
9790 return (leftOperand3 as int).compareTo(rightOperand3 as int) < 0;
9791 } else if (leftOperand3 is double && rightOperand3 is double) {
9792 return (leftOperand3 as double).compareTo(rightOperand3 as double) < 0;
9793 }
9794 } else if (node.operator.type == TokenType.LT_EQ) {
9795 if (leftOperand3 is int && rightOperand3 is int) {
9796 return (leftOperand3 as int).compareTo(rightOperand3 as int) <= 0;
9797 } else if (leftOperand3 is double && rightOperand3 is double) {
9798 return (leftOperand3 as double).compareTo(rightOperand3 as double) <= 0;
9799 }
9800 } else if (node.operator.type == TokenType.LT_LT) {
9801 if (leftOperand3 is int && rightOperand3 is int) {
9802 return (leftOperand3 as int) << (rightOperand3 as int);
9803 }
9804 } else if (node.operator.type == TokenType.MINUS) {
9805 if (leftOperand3 is int && rightOperand3 is int) {
9806 return (leftOperand3 as int) - rightOperand3 as int;
9807 } else if (leftOperand3 is double && rightOperand3 is double) {
9808 return (leftOperand3 as double) - (rightOperand3 as double);
9809 }
9810 } else if (node.operator.type == TokenType.PERCENT) {
9811 if (leftOperand3 is int && rightOperand3 is int) {
9812 return (leftOperand3 as int).remainder(rightOperand3 as int);
9813 } else if (leftOperand3 is double && rightOperand3 is double) {
9814 return (leftOperand3 as double) % (rightOperand3 as double);
9815 }
9816 } else if (node.operator.type == TokenType.PLUS) {
9817 if (leftOperand3 is int && rightOperand3 is int) {
9818 return (leftOperand3 as int) + rightOperand3 as int;
9819 } else if (leftOperand3 is double && rightOperand3 is double) {
9820 return (leftOperand3 as double) + (rightOperand3 as double);
9821 }
9822 } else if (node.operator.type == TokenType.STAR) {
9823 if (leftOperand3 is int && rightOperand3 is int) {
9824 return (leftOperand3 as int) * rightOperand3 as int;
9825 } else if (leftOperand3 is double && rightOperand3 is double) {
9826 return (leftOperand3 as double) * (rightOperand3 as double);
9827 }
9828 } else if (node.operator.type == TokenType.SLASH) {
9829 if (leftOperand3 is int && rightOperand3 is int) {
9830 return (leftOperand3 as int) / rightOperand3 as int;
9831 } else if (leftOperand3 is double && rightOperand3 is double) {
9832 return (leftOperand3 as double) / (rightOperand3 as double);
9833 }
9834 } else if (node.operator.type == TokenType.TILDE_SLASH) {
9835 if (leftOperand3 is int && rightOperand3 is int) {
9836 return (leftOperand3 as int) / rightOperand3 as int;
9837 } else if (leftOperand3 is double && rightOperand3 is double) {
9838 return (leftOperand3 as double) ~/ (rightOperand3 as double);
9839 }
9840 }
9841 return visitExpression(node);
9842 }
9843 Object visitBooleanLiteral(BooleanLiteral node) => node.value ? true : false;
9844 Object visitDoubleLiteral(DoubleLiteral node) => node.value;
9845 Object visitIntegerLiteral(IntegerLiteral node) => node.value;
9846 Object visitInterpolationExpression(InterpolationExpression node) {
9847 Object value = node.expression.accept(this);
9848 if (value == null || value is bool || value is String || value is int || val ue is double) {
9849 return value;
9850 }
9851 return NOT_A_CONSTANT;
9852 }
9853 Object visitInterpolationString(InterpolationString node) => node.value;
9854 Object visitListLiteral(ListLiteral node) {
9855 List<Object> list = new List<Object>();
9856 for (Expression element in node.elements) {
9857 Object value = element.accept(this);
9858 if (value == ConstantEvaluator.NOT_A_CONSTANT) {
9859 return value;
9860 }
9861 list.add(value);
9862 }
9863 return list;
9864 }
9865 Object visitMapLiteral(MapLiteral node) {
9866 Map<String, Object> map = new Map<String, Object>();
9867 for (MapLiteralEntry entry in node.entries) {
9868 Object key3 = entry.key.accept(this);
9869 Object value10 = entry.value.accept(this);
9870 if (key3 is! String || value10 == ConstantEvaluator.NOT_A_CONSTANT) {
9871 return NOT_A_CONSTANT;
9872 }
9873 map[key3 as String] = value10;
9874 }
9875 return map;
9876 }
9877 Object visitMethodInvocation(MethodInvocation node) => visitNode(node);
9878 Object visitNode(ASTNode node) => NOT_A_CONSTANT;
9879 Object visitNullLiteral(NullLiteral node) => null;
9880 Object visitParenthesizedExpression(ParenthesizedExpression node) => node.expr ession.accept(this);
9881 Object visitPrefixedIdentifier(PrefixedIdentifier node) => getConstantValue(nu ll);
9882 Object visitPrefixExpression(PrefixExpression node) {
9883 Object operand4 = node.operand.accept(this);
9884 if (operand4 == ConstantEvaluator.NOT_A_CONSTANT) {
9885 return operand4;
9886 }
9887 if (node.operator.type == TokenType.BANG) {
9888 if (operand4 == true) {
9889 return false;
9890 } else if (operand4 == false) {
9891 return true;
9892 }
9893 } else if (node.operator.type == TokenType.TILDE) {
9894 if (operand4 is int) {
9895 return ~(operand4 as int);
9896 }
9897 } else if (node.operator.type == TokenType.MINUS) {
9898 if (operand4 == null) {
9899 return null;
9900 } else if (operand4 is int) {
9901 return -(operand4 as int);
9902 } else if (operand4 is double) {
9903 return -(operand4 as double);
9904 }
9905 }
9906 return NOT_A_CONSTANT;
9907 }
9908 Object visitPropertyAccess(PropertyAccess node) => getConstantValue(null);
9909 Object visitSimpleIdentifier(SimpleIdentifier node) => getConstantValue(null);
9910 Object visitSimpleStringLiteral(SimpleStringLiteral node) => node.value;
9911 Object visitStringInterpolation(StringInterpolation node) {
9912 StringBuffer builder = new StringBuffer();
9913 for (InterpolationElement element in node.elements) {
9914 Object value = element.accept(this);
9915 if (value == ConstantEvaluator.NOT_A_CONSTANT) {
9916 return value;
9917 }
9918 builder.add(value);
9919 }
9920 return builder.toString();
9921 }
9922 /**
9923 * Return the constant value of the static constant represented by the given e lement.
9924 * @param element the element whose value is to be returned
9925 * @return the constant value of the static constant
9926 */
9927 Object getConstantValue(Element element) {
9928 if (element is FieldElement) {
9929 FieldElement field = element as FieldElement;
9930 if (field.isStatic() && field.isConst()) {
9931 }
9932 }
9933 return NOT_A_CONSTANT;
9934 }
9935 }
9936 /**
9937 * Instances of the class {@code GeneralizingASTVisitor} implement an AST visito r that will
9938 * 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
9939 * will the visit method for that specific type of node be invoked, but addition al methods for the
9940 * superclasses of that node will also be invoked. For example, using an instanc e of this class to
9941 * visit a {@link Block} will cause the method {@link #visitBlock(Block)} to be invoked but will
9942 * also cause the methods {@link #visitStatement(Statement)} and {@link #visitNo de(ASTNode)} to be
9943 * subsequently invoked. This allows visitors to be written that visit all state ments without
9944 * needing to override the visit method for each of the specific subclasses of { @link Statement}.
9945 * <p>
9946 * Subclasses that override a visit method must either invoke the overridden vis it method or
9947 * explicitly invoke the more general visit method. Failure to do so will cause the visit methods
9948 * for superclasses of the node to not be invoked and will cause the children of the visited node to
9949 * not be visited.
9950 */
9951 class GeneralizingASTVisitor<R> implements ASTVisitor<R> {
9952 R visitAdjacentStrings(AdjacentStrings node) => visitStringLiteral(node);
9953 R visitAnnotatedNode(AnnotatedNode node) => visitNode(node);
9954 R visitAnnotation(Annotation node) => visitNode(node);
9955 R visitArgumentDefinitionTest(ArgumentDefinitionTest node) => visitExpression( node);
9956 R visitArgumentList(ArgumentList node) => visitNode(node);
9957 R visitAsExpression(AsExpression node) => visitExpression(node);
9958 R visitAssertStatement(AssertStatement node) => visitStatement(node);
9959 R visitAssignmentExpression(AssignmentExpression node) => visitExpression(node );
9960 R visitBinaryExpression(BinaryExpression node) => visitExpression(node);
9961 R visitBlock(Block node) => visitStatement(node);
9962 R visitBlockFunctionBody(BlockFunctionBody node) => visitFunctionBody(node);
9963 R visitBooleanLiteral(BooleanLiteral node) => visitLiteral(node);
9964 R visitBreakStatement(BreakStatement node) => visitStatement(node);
9965 R visitCascadeExpression(CascadeExpression node) => visitExpression(node);
9966 R visitCatchClause(CatchClause node) => visitNode(node);
9967 R visitClassDeclaration(ClassDeclaration node) => visitCompilationUnitMember(n ode);
9968 R visitClassMember(ClassMember node) => visitDeclaration(node);
9969 R visitClassTypeAlias(ClassTypeAlias node) => visitTypeAlias(node);
9970 R visitCombinator(Combinator node) => visitNode(node);
9971 R visitComment(Comment node) => visitNode(node);
9972 R visitCommentReference(CommentReference node) => visitNode(node);
9973 R visitCompilationUnit(CompilationUnit node) => visitNode(node);
9974 R visitCompilationUnitMember(CompilationUnitMember node) => visitDeclaration(n ode);
9975 R visitConditionalExpression(ConditionalExpression node) => visitExpression(no de);
9976 R visitConstructorDeclaration(ConstructorDeclaration node) => visitClassMember (node);
9977 R visitConstructorFieldInitializer(ConstructorFieldInitializer node) => visitC onstructorInitializer(node);
9978 R visitConstructorInitializer(ConstructorInitializer node) => visitNode(node);
9979 R visitConstructorName(ConstructorName node) => visitNode(node);
9980 R visitContinueStatement(ContinueStatement node) => visitStatement(node);
9981 R visitDeclaration(Declaration node) => visitAnnotatedNode(node);
9982 R visitDefaultFormalParameter(DefaultFormalParameter node) => visitFormalParam eter(node);
9983 R visitDirective(Directive node) => visitAnnotatedNode(node);
9984 R visitDoStatement(DoStatement node) => visitStatement(node);
9985 R visitDoubleLiteral(DoubleLiteral node) => visitLiteral(node);
9986 R visitEmptyFunctionBody(EmptyFunctionBody node) => visitFunctionBody(node);
9987 R visitEmptyStatement(EmptyStatement node) => visitStatement(node);
9988 R visitExportDirective(ExportDirective node) => visitNamespaceDirective(node);
9989 R visitExpression(Expression node) => visitNode(node);
9990 R visitExpressionFunctionBody(ExpressionFunctionBody node) => visitFunctionBod y(node);
9991 R visitExpressionStatement(ExpressionStatement node) => visitStatement(node);
9992 R visitExtendsClause(ExtendsClause node) => visitNode(node);
9993 R visitFieldDeclaration(FieldDeclaration node) => visitClassMember(node);
9994 R visitFieldFormalParameter(FieldFormalParameter node) => visitNormalFormalPar ameter(node);
9995 R visitForEachStatement(ForEachStatement node) => visitStatement(node);
9996 R visitFormalParameter(FormalParameter node) => visitNode(node);
9997 R visitFormalParameterList(FormalParameterList node) => visitNode(node);
9998 R visitForStatement(ForStatement node) => visitStatement(node);
9999 R visitFunctionBody(FunctionBody node) => visitNode(node);
10000 R visitFunctionDeclaration(FunctionDeclaration node) => visitNode(node);
10001 R visitFunctionDeclarationStatement(FunctionDeclarationStatement node) => visi tStatement(node);
10002 R visitFunctionExpression(FunctionExpression node) => visitExpression(node);
10003 R visitFunctionExpressionInvocation(FunctionExpressionInvocation node) => visi tExpression(node);
10004 R visitFunctionTypeAlias(FunctionTypeAlias node) => visitTypeAlias(node);
10005 R visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) => visi tNormalFormalParameter(node);
10006 R visitHideCombinator(HideCombinator node) => visitCombinator(node);
10007 R visitIdentifier(Identifier node) => visitExpression(node);
10008 R visitIfStatement(IfStatement node) => visitStatement(node);
10009 R visitImplementsClause(ImplementsClause node) => visitNode(node);
10010 R visitImportDirective(ImportDirective node) => visitNamespaceDirective(node);
10011 R visitIndexExpression(IndexExpression node) => visitExpression(node);
10012 R visitInstanceCreationExpression(InstanceCreationExpression node) => visitExp ression(node);
10013 R visitIntegerLiteral(IntegerLiteral node) => visitLiteral(node);
10014 R visitInterpolationElement(InterpolationElement node) => visitNode(node);
10015 R visitInterpolationExpression(InterpolationExpression node) => visitInterpola tionElement(node);
10016 R visitInterpolationString(InterpolationString node) => visitInterpolationElem ent(node);
10017 R visitIsExpression(IsExpression node) => visitExpression(node);
10018 R visitLabel(Label node) => visitNode(node);
10019 R visitLabeledStatement(LabeledStatement node) => visitStatement(node);
10020 R visitLibraryDirective(LibraryDirective node) => visitDirective(node);
10021 R visitLibraryIdentifier(LibraryIdentifier node) => visitIdentifier(node);
10022 R visitListLiteral(ListLiteral node) => visitTypedLiteral(node);
10023 R visitLiteral(Literal node) => visitExpression(node);
10024 R visitMapLiteral(MapLiteral node) => visitTypedLiteral(node);
10025 R visitMapLiteralEntry(MapLiteralEntry node) => visitNode(node);
10026 R visitMethodDeclaration(MethodDeclaration node) => visitClassMember(node);
10027 R visitMethodInvocation(MethodInvocation node) => visitNode(node);
10028 R visitNamedExpression(NamedExpression node) => visitExpression(node);
10029 R visitNamespaceDirective(NamespaceDirective node) => visitDirective(node);
10030 R visitNode(ASTNode node) {
10031 node.visitChildren(this);
10032 return null;
10033 }
10034 R visitNormalFormalParameter(NormalFormalParameter node) => visitFormalParamet er(node);
10035 R visitNullLiteral(NullLiteral node) => visitLiteral(node);
10036 R visitParenthesizedExpression(ParenthesizedExpression node) => visitExpressio n(node);
10037 R visitPartDirective(PartDirective node) => visitDirective(node);
10038 R visitPartOfDirective(PartOfDirective node) => visitDirective(node);
10039 R visitPostfixExpression(PostfixExpression node) => visitExpression(node);
10040 R visitPrefixedIdentifier(PrefixedIdentifier node) => visitIdentifier(node);
10041 R visitPrefixExpression(PrefixExpression node) => visitExpression(node);
10042 R visitPropertyAccess(PropertyAccess node) => visitExpression(node);
10043 R visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) => visitConstructorInitializer(node);
10044 R visitReturnStatement(ReturnStatement node) => visitStatement(node);
10045 R visitScriptTag(ScriptTag scriptTag) => visitNode(scriptTag);
10046 R visitShowCombinator(ShowCombinator node) => visitCombinator(node);
10047 R visitSimpleFormalParameter(SimpleFormalParameter node) => visitNormalFormalP arameter(node);
10048 R visitSimpleIdentifier(SimpleIdentifier node) => visitIdentifier(node);
10049 R visitSimpleStringLiteral(SimpleStringLiteral node) => visitStringLiteral(nod e);
10050 R visitStatement(Statement node) => visitNode(node);
10051 R visitStringInterpolation(StringInterpolation node) => visitStringLiteral(nod e);
10052 R visitStringLiteral(StringLiteral node) => visitLiteral(node);
10053 R visitSuperConstructorInvocation(SuperConstructorInvocation node) => visitCon structorInitializer(node);
10054 R visitSuperExpression(SuperExpression node) => visitExpression(node);
10055 R visitSwitchCase(SwitchCase node) => visitSwitchMember(node);
10056 R visitSwitchDefault(SwitchDefault node) => visitSwitchMember(node);
10057 R visitSwitchMember(SwitchMember node) => visitNode(node);
10058 R visitSwitchStatement(SwitchStatement node) => visitStatement(node);
10059 R visitThisExpression(ThisExpression node) => visitExpression(node);
10060 R visitThrowExpression(ThrowExpression node) => visitExpression(node);
10061 R visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) => visitC ompilationUnitMember(node);
10062 R visitTryStatement(TryStatement node) => visitStatement(node);
10063 R visitTypeAlias(TypeAlias node) => visitCompilationUnitMember(node);
10064 R visitTypeArgumentList(TypeArgumentList node) => visitNode(node);
10065 R visitTypedLiteral(TypedLiteral node) => visitLiteral(node);
10066 R visitTypeName(TypeName node) => visitNode(node);
10067 R visitTypeParameter(TypeParameter node) => visitNode(node);
10068 R visitTypeParameterList(TypeParameterList node) => visitNode(node);
10069 R visitVariableDeclaration(VariableDeclaration node) => visitDeclaration(node) ;
10070 R visitVariableDeclarationList(VariableDeclarationList node) => visitNode(node );
10071 R visitVariableDeclarationStatement(VariableDeclarationStatement node) => visi tStatement(node);
10072 R visitWhileStatement(WhileStatement node) => visitStatement(node);
10073 R visitWithClause(WithClause node) => visitNode(node);
10074 }
10075 /**
10076 * Instances of the class {@code NodeFoundException} are used to cancel visiting after a node has
10077 * been found.
10078 */
10079 class NodeLocator_NodeFoundException extends RuntimeException {
10080 static int _serialVersionUID = 1;
10081 }
10082 /**
10083 * Instances of the class {@code RecursiveASTVisitor} implement an AST visitor t hat will recursively
10084 * visit all of the nodes in an AST structure. For example, using an instance of this class to visit
10085 * a {@link Block} will also cause all of the statements in the block to be visi ted.
10086 * <p>
10087 * Subclasses that override a visit method must either invoke the overridden vis it method or must
10088 * explicitly ask the visited node to visit its children. Failure to do so will cause the children
10089 * of the visited node to not be visited.
10090 */
10091 class RecursiveASTVisitor<R> implements ASTVisitor<R> {
10092 R visitAdjacentStrings(AdjacentStrings node) {
10093 node.visitChildren(this);
10094 return null;
10095 }
10096 R visitAnnotation(Annotation node) {
10097 node.visitChildren(this);
10098 return null;
10099 }
10100 R visitArgumentDefinitionTest(ArgumentDefinitionTest node) {
10101 node.visitChildren(this);
10102 return null;
10103 }
10104 R visitArgumentList(ArgumentList node) {
10105 node.visitChildren(this);
10106 return null;
10107 }
10108 R visitAsExpression(AsExpression node) {
10109 node.visitChildren(this);
10110 return null;
10111 }
10112 R visitAssertStatement(AssertStatement node) {
10113 node.visitChildren(this);
10114 return null;
10115 }
10116 R visitAssignmentExpression(AssignmentExpression node) {
10117 node.visitChildren(this);
10118 return null;
10119 }
10120 R visitBinaryExpression(BinaryExpression node) {
10121 node.visitChildren(this);
10122 return null;
10123 }
10124 R visitBlock(Block node) {
10125 node.visitChildren(this);
10126 return null;
10127 }
10128 R visitBlockFunctionBody(BlockFunctionBody node) {
10129 node.visitChildren(this);
10130 return null;
10131 }
10132 R visitBooleanLiteral(BooleanLiteral node) {
10133 node.visitChildren(this);
10134 return null;
10135 }
10136 R visitBreakStatement(BreakStatement node) {
10137 node.visitChildren(this);
10138 return null;
10139 }
10140 R visitCascadeExpression(CascadeExpression node) {
10141 node.visitChildren(this);
10142 return null;
10143 }
10144 R visitCatchClause(CatchClause node) {
10145 node.visitChildren(this);
10146 return null;
10147 }
10148 R visitClassDeclaration(ClassDeclaration node) {
10149 node.visitChildren(this);
10150 return null;
10151 }
10152 R visitClassTypeAlias(ClassTypeAlias node) {
10153 node.visitChildren(this);
10154 return null;
10155 }
10156 R visitComment(Comment node) {
10157 node.visitChildren(this);
10158 return null;
10159 }
10160 R visitCommentReference(CommentReference node) {
10161 node.visitChildren(this);
10162 return null;
10163 }
10164 R visitCompilationUnit(CompilationUnit node) {
10165 node.visitChildren(this);
10166 return null;
10167 }
10168 R visitConditionalExpression(ConditionalExpression node) {
10169 node.visitChildren(this);
10170 return null;
10171 }
10172 R visitConstructorDeclaration(ConstructorDeclaration node) {
10173 node.visitChildren(this);
10174 return null;
10175 }
10176 R visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
10177 node.visitChildren(this);
10178 return null;
10179 }
10180 R visitConstructorName(ConstructorName node) {
10181 node.visitChildren(this);
10182 return null;
10183 }
10184 R visitContinueStatement(ContinueStatement node) {
10185 node.visitChildren(this);
10186 return null;
10187 }
10188 R visitDefaultFormalParameter(DefaultFormalParameter node) {
10189 node.visitChildren(this);
10190 return null;
10191 }
10192 R visitDoStatement(DoStatement node) {
10193 node.visitChildren(this);
10194 return null;
10195 }
10196 R visitDoubleLiteral(DoubleLiteral node) {
10197 node.visitChildren(this);
10198 return null;
10199 }
10200 R visitEmptyFunctionBody(EmptyFunctionBody node) {
10201 node.visitChildren(this);
10202 return null;
10203 }
10204 R visitEmptyStatement(EmptyStatement node) {
10205 node.visitChildren(this);
10206 return null;
10207 }
10208 R visitExportDirective(ExportDirective node) {
10209 node.visitChildren(this);
10210 return null;
10211 }
10212 R visitExpressionFunctionBody(ExpressionFunctionBody node) {
10213 node.visitChildren(this);
10214 return null;
10215 }
10216 R visitExpressionStatement(ExpressionStatement node) {
10217 node.visitChildren(this);
10218 return null;
10219 }
10220 R visitExtendsClause(ExtendsClause node) {
10221 node.visitChildren(this);
10222 return null;
10223 }
10224 R visitFieldDeclaration(FieldDeclaration node) {
10225 node.visitChildren(this);
10226 return null;
10227 }
10228 R visitFieldFormalParameter(FieldFormalParameter node) {
10229 node.visitChildren(this);
10230 return null;
10231 }
10232 R visitForEachStatement(ForEachStatement node) {
10233 node.visitChildren(this);
10234 return null;
10235 }
10236 R visitFormalParameterList(FormalParameterList node) {
10237 node.visitChildren(this);
10238 return null;
10239 }
10240 R visitForStatement(ForStatement node) {
10241 node.visitChildren(this);
10242 return null;
10243 }
10244 R visitFunctionDeclaration(FunctionDeclaration node) {
10245 node.visitChildren(this);
10246 return null;
10247 }
10248 R visitFunctionDeclarationStatement(FunctionDeclarationStatement node) {
10249 node.visitChildren(this);
10250 return null;
10251 }
10252 R visitFunctionExpression(FunctionExpression node) {
10253 node.visitChildren(this);
10254 return null;
10255 }
10256 R visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
10257 node.visitChildren(this);
10258 return null;
10259 }
10260 R visitFunctionTypeAlias(FunctionTypeAlias node) {
10261 node.visitChildren(this);
10262 return null;
10263 }
10264 R visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
10265 node.visitChildren(this);
10266 return null;
10267 }
10268 R visitHideCombinator(HideCombinator node) {
10269 node.visitChildren(this);
10270 return null;
10271 }
10272 R visitIfStatement(IfStatement node) {
10273 node.visitChildren(this);
10274 return null;
10275 }
10276 R visitImplementsClause(ImplementsClause node) {
10277 node.visitChildren(this);
10278 return null;
10279 }
10280 R visitImportDirective(ImportDirective node) {
10281 node.visitChildren(this);
10282 return null;
10283 }
10284 R visitIndexExpression(IndexExpression node) {
10285 node.visitChildren(this);
10286 return null;
10287 }
10288 R visitInstanceCreationExpression(InstanceCreationExpression node) {
10289 node.visitChildren(this);
10290 return null;
10291 }
10292 R visitIntegerLiteral(IntegerLiteral node) {
10293 node.visitChildren(this);
10294 return null;
10295 }
10296 R visitInterpolationExpression(InterpolationExpression node) {
10297 node.visitChildren(this);
10298 return null;
10299 }
10300 R visitInterpolationString(InterpolationString node) {
10301 node.visitChildren(this);
10302 return null;
10303 }
10304 R visitIsExpression(IsExpression node) {
10305 node.visitChildren(this);
10306 return null;
10307 }
10308 R visitLabel(Label node) {
10309 node.visitChildren(this);
10310 return null;
10311 }
10312 R visitLabeledStatement(LabeledStatement node) {
10313 node.visitChildren(this);
10314 return null;
10315 }
10316 R visitLibraryDirective(LibraryDirective node) {
10317 node.visitChildren(this);
10318 return null;
10319 }
10320 R visitLibraryIdentifier(LibraryIdentifier node) {
10321 node.visitChildren(this);
10322 return null;
10323 }
10324 R visitListLiteral(ListLiteral node) {
10325 node.visitChildren(this);
10326 return null;
10327 }
10328 R visitMapLiteral(MapLiteral node) {
10329 node.visitChildren(this);
10330 return null;
10331 }
10332 R visitMapLiteralEntry(MapLiteralEntry node) {
10333 node.visitChildren(this);
10334 return null;
10335 }
10336 R visitMethodDeclaration(MethodDeclaration node) {
10337 node.visitChildren(this);
10338 return null;
10339 }
10340 R visitMethodInvocation(MethodInvocation node) {
10341 node.visitChildren(this);
10342 return null;
10343 }
10344 R visitNamedExpression(NamedExpression node) {
10345 node.visitChildren(this);
10346 return null;
10347 }
10348 R visitNullLiteral(NullLiteral node) {
10349 node.visitChildren(this);
10350 return null;
10351 }
10352 R visitParenthesizedExpression(ParenthesizedExpression node) {
10353 node.visitChildren(this);
10354 return null;
10355 }
10356 R visitPartDirective(PartDirective node) {
10357 node.visitChildren(this);
10358 return null;
10359 }
10360 R visitPartOfDirective(PartOfDirective node) {
10361 node.visitChildren(this);
10362 return null;
10363 }
10364 R visitPostfixExpression(PostfixExpression node) {
10365 node.visitChildren(this);
10366 return null;
10367 }
10368 R visitPrefixedIdentifier(PrefixedIdentifier node) {
10369 node.visitChildren(this);
10370 return null;
10371 }
10372 R visitPrefixExpression(PrefixExpression node) {
10373 node.visitChildren(this);
10374 return null;
10375 }
10376 R visitPropertyAccess(PropertyAccess node) {
10377 node.visitChildren(this);
10378 return null;
10379 }
10380 R visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) {
10381 node.visitChildren(this);
10382 return null;
10383 }
10384 R visitReturnStatement(ReturnStatement node) {
10385 node.visitChildren(this);
10386 return null;
10387 }
10388 R visitScriptTag(ScriptTag node) {
10389 node.visitChildren(this);
10390 return null;
10391 }
10392 R visitShowCombinator(ShowCombinator node) {
10393 node.visitChildren(this);
10394 return null;
10395 }
10396 R visitSimpleFormalParameter(SimpleFormalParameter node) {
10397 node.visitChildren(this);
10398 return null;
10399 }
10400 R visitSimpleIdentifier(SimpleIdentifier node) {
10401 node.visitChildren(this);
10402 return null;
10403 }
10404 R visitSimpleStringLiteral(SimpleStringLiteral node) {
10405 node.visitChildren(this);
10406 return null;
10407 }
10408 R visitStringInterpolation(StringInterpolation node) {
10409 node.visitChildren(this);
10410 return null;
10411 }
10412 R visitSuperConstructorInvocation(SuperConstructorInvocation node) {
10413 node.visitChildren(this);
10414 return null;
10415 }
10416 R visitSuperExpression(SuperExpression node) {
10417 node.visitChildren(this);
10418 return null;
10419 }
10420 R visitSwitchCase(SwitchCase node) {
10421 node.visitChildren(this);
10422 return null;
10423 }
10424 R visitSwitchDefault(SwitchDefault node) {
10425 node.visitChildren(this);
10426 return null;
10427 }
10428 R visitSwitchStatement(SwitchStatement node) {
10429 node.visitChildren(this);
10430 return null;
10431 }
10432 R visitThisExpression(ThisExpression node) {
10433 node.visitChildren(this);
10434 return null;
10435 }
10436 R visitThrowExpression(ThrowExpression node) {
10437 node.visitChildren(this);
10438 return null;
10439 }
10440 R visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
10441 node.visitChildren(this);
10442 return null;
10443 }
10444 R visitTryStatement(TryStatement node) {
10445 node.visitChildren(this);
10446 return null;
10447 }
10448 R visitTypeArgumentList(TypeArgumentList node) {
10449 node.visitChildren(this);
10450 return null;
10451 }
10452 R visitTypeName(TypeName node) {
10453 node.visitChildren(this);
10454 return null;
10455 }
10456 R visitTypeParameter(TypeParameter node) {
10457 node.visitChildren(this);
10458 return null;
10459 }
10460 R visitTypeParameterList(TypeParameterList node) {
10461 node.visitChildren(this);
10462 return null;
10463 }
10464 R visitVariableDeclaration(VariableDeclaration node) {
10465 node.visitChildren(this);
10466 return null;
10467 }
10468 R visitVariableDeclarationList(VariableDeclarationList node) {
10469 node.visitChildren(this);
10470 return null;
10471 }
10472 R visitVariableDeclarationStatement(VariableDeclarationStatement node) {
10473 node.visitChildren(this);
10474 return null;
10475 }
10476 R visitWhileStatement(WhileStatement node) {
10477 node.visitChildren(this);
10478 return null;
10479 }
10480 R visitWithClause(WithClause node) {
10481 node.visitChildren(this);
10482 return null;
10483 }
10484 }
10485 /**
10486 * Instances of the class {@code SimpleASTVisitor} implement an AST visitor that will do nothing
10487 * when visiting an AST node. It is intended to be a superclass for classes that use the visitor
10488 * pattern primarily as a dispatch mechanism (and hence don't need to recursivel y visit a whole
10489 * structure) and that only need to visit a small number of node types.
10490 */
10491 class SimpleASTVisitor<R> implements ASTVisitor<R> {
10492 R visitAdjacentStrings(AdjacentStrings node) => null;
10493 R visitAnnotation(Annotation node) => null;
10494 R visitArgumentDefinitionTest(ArgumentDefinitionTest node) => null;
10495 R visitArgumentList(ArgumentList node) => null;
10496 R visitAsExpression(AsExpression node) => null;
10497 R visitAssertStatement(AssertStatement node) => null;
10498 R visitAssignmentExpression(AssignmentExpression node) => null;
10499 R visitBinaryExpression(BinaryExpression node) => null;
10500 R visitBlock(Block node) => null;
10501 R visitBlockFunctionBody(BlockFunctionBody node) => null;
10502 R visitBooleanLiteral(BooleanLiteral node) => null;
10503 R visitBreakStatement(BreakStatement node) => null;
10504 R visitCascadeExpression(CascadeExpression node) => null;
10505 R visitCatchClause(CatchClause node) => null;
10506 R visitClassDeclaration(ClassDeclaration node) => null;
10507 R visitClassTypeAlias(ClassTypeAlias node) => null;
10508 R visitComment(Comment node) => null;
10509 R visitCommentReference(CommentReference node) => null;
10510 R visitCompilationUnit(CompilationUnit node) => null;
10511 R visitConditionalExpression(ConditionalExpression node) => null;
10512 R visitConstructorDeclaration(ConstructorDeclaration node) => null;
10513 R visitConstructorFieldInitializer(ConstructorFieldInitializer node) => null;
10514 R visitConstructorName(ConstructorName node) => null;
10515 R visitContinueStatement(ContinueStatement node) => null;
10516 R visitDefaultFormalParameter(DefaultFormalParameter node) => null;
10517 R visitDoStatement(DoStatement node) => null;
10518 R visitDoubleLiteral(DoubleLiteral node) => null;
10519 R visitEmptyFunctionBody(EmptyFunctionBody node) => null;
10520 R visitEmptyStatement(EmptyStatement node) => null;
10521 R visitExportDirective(ExportDirective node) => null;
10522 R visitExpressionFunctionBody(ExpressionFunctionBody node) => null;
10523 R visitExpressionStatement(ExpressionStatement node) => null;
10524 R visitExtendsClause(ExtendsClause node) => null;
10525 R visitFieldDeclaration(FieldDeclaration node) => null;
10526 R visitFieldFormalParameter(FieldFormalParameter node) => null;
10527 R visitForEachStatement(ForEachStatement node) => null;
10528 R visitFormalParameterList(FormalParameterList node) => null;
10529 R visitForStatement(ForStatement node) => null;
10530 R visitFunctionDeclaration(FunctionDeclaration node) => null;
10531 R visitFunctionDeclarationStatement(FunctionDeclarationStatement node) => null ;
10532 R visitFunctionExpression(FunctionExpression node) => null;
10533 R visitFunctionExpressionInvocation(FunctionExpressionInvocation node) => null ;
10534 R visitFunctionTypeAlias(FunctionTypeAlias node) => null;
10535 R visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) => null ;
10536 R visitHideCombinator(HideCombinator node) => null;
10537 R visitIfStatement(IfStatement node) => null;
10538 R visitImplementsClause(ImplementsClause node) => null;
10539 R visitImportDirective(ImportDirective node) => null;
10540 R visitIndexExpression(IndexExpression node) => null;
10541 R visitInstanceCreationExpression(InstanceCreationExpression node) => null;
10542 R visitIntegerLiteral(IntegerLiteral node) => null;
10543 R visitInterpolationExpression(InterpolationExpression node) => null;
10544 R visitInterpolationString(InterpolationString node) => null;
10545 R visitIsExpression(IsExpression node) => null;
10546 R visitLabel(Label node) => null;
10547 R visitLabeledStatement(LabeledStatement node) => null;
10548 R visitLibraryDirective(LibraryDirective node) => null;
10549 R visitLibraryIdentifier(LibraryIdentifier node) => null;
10550 R visitListLiteral(ListLiteral node) => null;
10551 R visitMapLiteral(MapLiteral node) => null;
10552 R visitMapLiteralEntry(MapLiteralEntry node) => null;
10553 R visitMethodDeclaration(MethodDeclaration node) => null;
10554 R visitMethodInvocation(MethodInvocation node) => null;
10555 R visitNamedExpression(NamedExpression node) => null;
10556 R visitNullLiteral(NullLiteral node) => null;
10557 R visitParenthesizedExpression(ParenthesizedExpression node) => null;
10558 R visitPartDirective(PartDirective node) => null;
10559 R visitPartOfDirective(PartOfDirective node) => null;
10560 R visitPostfixExpression(PostfixExpression node) => null;
10561 R visitPrefixedIdentifier(PrefixedIdentifier node) => null;
10562 R visitPrefixExpression(PrefixExpression node) => null;
10563 R visitPropertyAccess(PropertyAccess node) => null;
10564 R visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) => null;
10565 R visitReturnStatement(ReturnStatement node) => null;
10566 R visitScriptTag(ScriptTag node) => null;
10567 R visitShowCombinator(ShowCombinator node) => null;
10568 R visitSimpleFormalParameter(SimpleFormalParameter node) => null;
10569 R visitSimpleIdentifier(SimpleIdentifier node) => null;
10570 R visitSimpleStringLiteral(SimpleStringLiteral node) => null;
10571 R visitStringInterpolation(StringInterpolation node) => null;
10572 R visitSuperConstructorInvocation(SuperConstructorInvocation node) => null;
10573 R visitSuperExpression(SuperExpression node) => null;
10574 R visitSwitchCase(SwitchCase node) => null;
10575 R visitSwitchDefault(SwitchDefault node) => null;
10576 R visitSwitchStatement(SwitchStatement node) => null;
10577 R visitThisExpression(ThisExpression node) => null;
10578 R visitThrowExpression(ThrowExpression node) => null;
10579 R visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) => null;
10580 R visitTryStatement(TryStatement node) => null;
10581 R visitTypeArgumentList(TypeArgumentList node) => null;
10582 R visitTypeName(TypeName node) => null;
10583 R visitTypeParameter(TypeParameter node) => null;
10584 R visitTypeParameterList(TypeParameterList node) => null;
10585 R visitVariableDeclaration(VariableDeclaration node) => null;
10586 R visitVariableDeclarationList(VariableDeclarationList node) => null;
10587 R visitVariableDeclarationStatement(VariableDeclarationStatement node) => null ;
10588 R visitWhileStatement(WhileStatement node) => null;
10589 R visitWithClause(WithClause node) => null;
10590 }
10591 /**
10592 * Instances of the class {@code ToSourceVisitor} write a source representation of a visited AST
10593 * node (and all of it's children) to a writer.
10594 */
10595 class ToSourceVisitor implements ASTVisitor<Object> {
10596 /**
10597 * The writer to which the source is to be written.
10598 */
10599 PrintWriter _writer;
10600 /**
10601 * Initialize a newly created visitor to write source code representing the vi sited nodes to the
10602 * given writer.
10603 * @param writer the writer to which the source is to be written
10604 */
10605 ToSourceVisitor(PrintWriter writer) {
10606 this._writer = writer;
10607 }
10608 Object visitAdjacentStrings(AdjacentStrings node) {
10609 visitList2(node.strings, " ");
10610 return null;
10611 }
10612 Object visitAnnotation(Annotation node) {
10613 _writer.print('@');
10614 visit(node.name);
10615 visit3(".", node.constructorName);
10616 visit(node.arguments);
10617 return null;
10618 }
10619 Object visitArgumentDefinitionTest(ArgumentDefinitionTest node) {
10620 _writer.print('?');
10621 visit(node.identifier);
10622 return null;
10623 }
10624 Object visitArgumentList(ArgumentList node) {
10625 _writer.print('(');
10626 visitList2(node.arguments, ", ");
10627 _writer.print(')');
10628 return null;
10629 }
10630 Object visitAsExpression(AsExpression node) {
10631 visit(node.expression);
10632 _writer.print(" as ");
10633 visit(node.type);
10634 return null;
10635 }
10636 Object visitAssertStatement(AssertStatement node) {
10637 _writer.print("assert (");
10638 visit(node.condition);
10639 _writer.print(");");
10640 return null;
10641 }
10642 Object visitAssignmentExpression(AssignmentExpression node) {
10643 visit(node.leftHandSide);
10644 _writer.print(' ');
10645 _writer.print(node.operator.lexeme);
10646 _writer.print(' ');
10647 visit(node.rightHandSide);
10648 return null;
10649 }
10650 Object visitBinaryExpression(BinaryExpression node) {
10651 visit(node.leftOperand);
10652 _writer.print(' ');
10653 _writer.print(node.operator.lexeme);
10654 _writer.print(' ');
10655 visit(node.rightOperand);
10656 return null;
10657 }
10658 Object visitBlock(Block node) {
10659 _writer.print('{');
10660 visitList2(node.statements, " ");
10661 _writer.print('}');
10662 return null;
10663 }
10664 Object visitBlockFunctionBody(BlockFunctionBody node) {
10665 visit(node.block);
10666 return null;
10667 }
10668 Object visitBooleanLiteral(BooleanLiteral node) {
10669 _writer.print(node.literal.lexeme);
10670 return null;
10671 }
10672 Object visitBreakStatement(BreakStatement node) {
10673 _writer.print("break");
10674 visit3(" ", node.label);
10675 _writer.print(";");
10676 return null;
10677 }
10678 Object visitCascadeExpression(CascadeExpression node) {
10679 visit(node.target);
10680 visitList(node.cascadeSections);
10681 return null;
10682 }
10683 Object visitCatchClause(CatchClause node) {
10684 visit3("on ", node.exceptionType);
10685 if (node.catchKeyword != null) {
10686 if (node.exceptionType != null) {
10687 _writer.print(' ');
10688 }
10689 _writer.print("catch (");
10690 visit(node.exceptionParameter);
10691 visit3(", ", node.stackTraceParameter);
10692 _writer.print(") ");
10693 } else {
10694 _writer.print(" ");
10695 }
10696 visit(node.body);
10697 return null;
10698 }
10699 Object visitClassDeclaration(ClassDeclaration node) {
10700 visit5(node.abstractKeyword, " ");
10701 _writer.print("class ");
10702 visit(node.name);
10703 visit(node.typeParameters);
10704 visit3(" ", node.extendsClause);
10705 visit3(" ", node.withClause);
10706 visit3(" ", node.implementsClause);
10707 _writer.print(" {");
10708 visitList2(node.members, " ");
10709 _writer.print("}");
10710 return null;
10711 }
10712 Object visitClassTypeAlias(ClassTypeAlias node) {
10713 _writer.print("typedef ");
10714 visit(node.name);
10715 visit(node.typeParameters);
10716 _writer.print(" = ");
10717 if (node.abstractKeyword != null) {
10718 _writer.print("abstract ");
10719 }
10720 visit(node.superclass);
10721 visit3(" ", node.withClause);
10722 visit3(" ", node.implementsClause);
10723 _writer.print(";");
10724 return null;
10725 }
10726 Object visitComment(Comment node) => null;
10727 Object visitCommentReference(CommentReference node) => null;
10728 Object visitCompilationUnit(CompilationUnit node) {
10729 ScriptTag scriptTag4 = node.scriptTag;
10730 NodeList<Directive> directives2 = node.directives;
10731 visit(scriptTag4);
10732 String prefix = scriptTag4 == null ? "" : " ";
10733 visitList4(prefix, directives2, " ");
10734 prefix = scriptTag4 == null && directives2.isEmpty ? "" : " ";
10735 visitList4(prefix, node.declarations, " ");
10736 return null;
10737 }
10738 Object visitConditionalExpression(ConditionalExpression node) {
10739 visit(node.condition);
10740 _writer.print(" ? ");
10741 visit(node.thenExpression);
10742 _writer.print(" : ");
10743 visit(node.elseExpression);
10744 return null;
10745 }
10746 Object visitConstructorDeclaration(ConstructorDeclaration node) {
10747 visit5(node.externalKeyword, " ");
10748 visit5(node.constKeyword, " ");
10749 visit5(node.factoryKeyword, " ");
10750 visit(node.returnType);
10751 visit3(".", node.name);
10752 visit(node.parameters);
10753 visitList4(" : ", node.initializers, ", ");
10754 visit3(" = ", node.redirectedConstructor);
10755 visit4(" ", node.body);
10756 return null;
10757 }
10758 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
10759 visit5(node.keyword, ".");
10760 visit(node.fieldName);
10761 _writer.print(" = ");
10762 visit(node.expression);
10763 return null;
10764 }
10765 Object visitConstructorName(ConstructorName node) {
10766 visit(node.type);
10767 visit3(".", node.name);
10768 return null;
10769 }
10770 Object visitContinueStatement(ContinueStatement node) {
10771 _writer.print("continue");
10772 visit3(" ", node.label);
10773 _writer.print(";");
10774 return null;
10775 }
10776 Object visitDefaultFormalParameter(DefaultFormalParameter node) {
10777 visit(node.parameter);
10778 if (node.separator != null) {
10779 _writer.print(" ");
10780 _writer.print(node.separator.lexeme);
10781 visit3(" ", node.defaultValue);
10782 }
10783 return null;
10784 }
10785 Object visitDoStatement(DoStatement node) {
10786 _writer.print("do ");
10787 visit(node.body);
10788 _writer.print(" while (");
10789 visit(node.condition);
10790 _writer.print(");");
10791 return null;
10792 }
10793 Object visitDoubleLiteral(DoubleLiteral node) {
10794 _writer.print(node.literal.lexeme);
10795 return null;
10796 }
10797 Object visitEmptyFunctionBody(EmptyFunctionBody node) {
10798 _writer.print(';');
10799 return null;
10800 }
10801 Object visitEmptyStatement(EmptyStatement node) {
10802 _writer.print(';');
10803 return null;
10804 }
10805 Object visitExportDirective(ExportDirective node) {
10806 _writer.print("export ");
10807 visit(node.libraryUri);
10808 visitList4(" ", node.combinators, " ");
10809 _writer.print(';');
10810 return null;
10811 }
10812 Object visitExpressionFunctionBody(ExpressionFunctionBody node) {
10813 _writer.print("=> ");
10814 visit(node.expression);
10815 if (node.semicolon != null) {
10816 _writer.print(';');
10817 }
10818 return null;
10819 }
10820 Object visitExpressionStatement(ExpressionStatement node) {
10821 visit(node.expression);
10822 _writer.print(';');
10823 return null;
10824 }
10825 Object visitExtendsClause(ExtendsClause node) {
10826 _writer.print("extends ");
10827 visit(node.superclass);
10828 return null;
10829 }
10830 Object visitFieldDeclaration(FieldDeclaration node) {
10831 visit5(node.keyword, " ");
10832 visit(node.fields);
10833 _writer.print(";");
10834 return null;
10835 }
10836 Object visitFieldFormalParameter(FieldFormalParameter node) {
10837 visit5(node.keyword, " ");
10838 visit2(node.type, " ");
10839 _writer.print("this.");
10840 visit(node.identifier);
10841 return null;
10842 }
10843 Object visitForEachStatement(ForEachStatement node) {
10844 _writer.print("for (");
10845 visit(node.loopParameter);
10846 _writer.print(" in ");
10847 visit(node.iterator);
10848 _writer.print(") ");
10849 visit(node.body);
10850 return null;
10851 }
10852 Object visitFormalParameterList(FormalParameterList node) {
10853 String groupEnd = null;
10854 _writer.print('(');
10855 NodeList<FormalParameter> parameters9 = node.parameters;
10856 int size2 = parameters9.length;
10857 for (int i = 0; i < size2; i++) {
10858 FormalParameter parameter = parameters9[i];
10859 if (i > 0) {
10860 _writer.print(", ");
10861 }
10862 if (groupEnd == null && parameter is DefaultFormalParameter) {
10863 if (parameter.kind == ParameterKind.NAMED) {
10864 groupEnd = "}";
10865 _writer.print('{');
10866 } else {
10867 groupEnd = "]";
10868 _writer.print('[');
10869 }
10870 }
10871 parameter.accept(this);
10872 }
10873 if (groupEnd != null) {
10874 _writer.print(groupEnd);
10875 }
10876 _writer.print(')');
10877 return null;
10878 }
10879 Object visitForStatement(ForStatement node) {
10880 Expression initialization3 = node.initialization;
10881 _writer.print("for (");
10882 if (initialization3 != null) {
10883 visit(initialization3);
10884 } else {
10885 visit(node.variables);
10886 }
10887 _writer.print(";");
10888 visit3(" ", node.condition);
10889 _writer.print(";");
10890 visitList4(" ", node.updaters, ", ");
10891 _writer.print(") ");
10892 visit(node.body);
10893 return null;
10894 }
10895 Object visitFunctionDeclaration(FunctionDeclaration node) {
10896 visit2(node.returnType, " ");
10897 visit5(node.propertyKeyword, " ");
10898 visit(node.name);
10899 visit(node.functionExpression);
10900 return null;
10901 }
10902 Object visitFunctionDeclarationStatement(FunctionDeclarationStatement node) {
10903 visit(node.functionDeclaration);
10904 _writer.print(';');
10905 return null;
10906 }
10907 Object visitFunctionExpression(FunctionExpression node) {
10908 visit(node.parameters);
10909 _writer.print(' ');
10910 visit(node.body);
10911 return null;
10912 }
10913 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
10914 visit(node.function);
10915 visit(node.argumentList);
10916 return null;
10917 }
10918 Object visitFunctionTypeAlias(FunctionTypeAlias node) {
10919 _writer.print("typedef ");
10920 visit2(node.returnType, " ");
10921 visit(node.name);
10922 visit(node.typeParameters);
10923 visit(node.parameters);
10924 _writer.print(";");
10925 return null;
10926 }
10927 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
10928 visit2(node.returnType, " ");
10929 visit(node.identifier);
10930 visit(node.parameters);
10931 return null;
10932 }
10933 Object visitHideCombinator(HideCombinator node) {
10934 _writer.print("hide ");
10935 visitList2(node.hiddenNames, ", ");
10936 return null;
10937 }
10938 Object visitIfStatement(IfStatement node) {
10939 _writer.print("if (");
10940 visit(node.condition);
10941 _writer.print(") ");
10942 visit(node.thenStatement);
10943 visit3(" else ", node.elseStatement);
10944 return null;
10945 }
10946 Object visitImplementsClause(ImplementsClause node) {
10947 _writer.print("implements ");
10948 visitList2(node.interfaces, ", ");
10949 return null;
10950 }
10951 Object visitImportDirective(ImportDirective node) {
10952 _writer.print("import ");
10953 visit(node.libraryUri);
10954 visit3(" as ", node.prefix);
10955 visitList4(" ", node.combinators, " ");
10956 _writer.print(';');
10957 return null;
10958 }
10959 Object visitIndexExpression(IndexExpression node) {
10960 if (node.isCascaded()) {
10961 _writer.print("..");
10962 } else {
10963 visit(node.array);
10964 }
10965 _writer.print('[');
10966 visit(node.index);
10967 _writer.print(']');
10968 return null;
10969 }
10970 Object visitInstanceCreationExpression(InstanceCreationExpression node) {
10971 visit5(node.keyword, " ");
10972 visit(node.constructorName);
10973 visit(node.argumentList);
10974 return null;
10975 }
10976 Object visitIntegerLiteral(IntegerLiteral node) {
10977 _writer.print(node.literal.lexeme);
10978 return null;
10979 }
10980 Object visitInterpolationExpression(InterpolationExpression node) {
10981 if (node.rightBracket != null) {
10982 _writer.print("\${");
10983 visit(node.expression);
10984 _writer.print("}");
10985 } else {
10986 _writer.print("\$");
10987 visit(node.expression);
10988 }
10989 return null;
10990 }
10991 Object visitInterpolationString(InterpolationString node) {
10992 _writer.print(node.contents.lexeme);
10993 return null;
10994 }
10995 Object visitIsExpression(IsExpression node) {
10996 visit(node.expression);
10997 if (node.notOperator == null) {
10998 _writer.print(" is ");
10999 } else {
11000 _writer.print(" is! ");
11001 }
11002 visit(node.type);
11003 return null;
11004 }
11005 Object visitLabel(Label node) {
11006 visit(node.label);
11007 _writer.print(":");
11008 return null;
11009 }
11010 Object visitLabeledStatement(LabeledStatement node) {
11011 visitList3(node.labels, " ", " ");
11012 visit(node.statement);
11013 return null;
11014 }
11015 Object visitLibraryDirective(LibraryDirective node) {
11016 _writer.print("library ");
11017 visit(node.name);
11018 _writer.print(';');
11019 return null;
11020 }
11021 Object visitLibraryIdentifier(LibraryIdentifier node) {
11022 _writer.print(node.name);
11023 return null;
11024 }
11025 Object visitListLiteral(ListLiteral node) {
11026 if (node.modifier != null) {
11027 _writer.print(node.modifier.lexeme);
11028 _writer.print(' ');
11029 }
11030 visit2(node.typeArguments, " ");
11031 _writer.print("[");
11032 visitList2(node.elements, ", ");
11033 _writer.print("]");
11034 return null;
11035 }
11036 Object visitMapLiteral(MapLiteral node) {
11037 if (node.modifier != null) {
11038 _writer.print(node.modifier.lexeme);
11039 _writer.print(' ');
11040 }
11041 visit2(node.typeArguments, " ");
11042 _writer.print("{");
11043 visitList2(node.entries, ", ");
11044 _writer.print("}");
11045 return null;
11046 }
11047 Object visitMapLiteralEntry(MapLiteralEntry node) {
11048 visit(node.key);
11049 _writer.print(" : ");
11050 visit(node.value);
11051 return null;
11052 }
11053 Object visitMethodDeclaration(MethodDeclaration node) {
11054 visit5(node.externalKeyword, " ");
11055 visit5(node.modifierKeyword, " ");
11056 visit2(node.returnType, " ");
11057 visit5(node.propertyKeyword, " ");
11058 visit5(node.operatorKeyword, " ");
11059 visit(node.name);
11060 if (!node.isGetter()) {
11061 visit(node.parameters);
11062 }
11063 visit4(" ", node.body);
11064 return null;
11065 }
11066 Object visitMethodInvocation(MethodInvocation node) {
11067 if (node.isCascaded()) {
11068 _writer.print("..");
11069 } else {
11070 visit2(node.target, ".");
11071 }
11072 visit(node.methodName);
11073 visit(node.argumentList);
11074 return null;
11075 }
11076 Object visitNamedExpression(NamedExpression node) {
11077 visit(node.name);
11078 visit3(" ", node.expression);
11079 return null;
11080 }
11081 Object visitNullLiteral(NullLiteral node) {
11082 _writer.print("null");
11083 return null;
11084 }
11085 Object visitParenthesizedExpression(ParenthesizedExpression node) {
11086 _writer.print('(');
11087 visit(node.expression);
11088 _writer.print(')');
11089 return null;
11090 }
11091 Object visitPartDirective(PartDirective node) {
11092 _writer.print("part ");
11093 visit(node.partUri);
11094 _writer.print(';');
11095 return null;
11096 }
11097 Object visitPartOfDirective(PartOfDirective node) {
11098 _writer.print("part of ");
11099 visit(node.libraryName);
11100 _writer.print(';');
11101 return null;
11102 }
11103 Object visitPostfixExpression(PostfixExpression node) {
11104 visit(node.operand);
11105 _writer.print(node.operator.lexeme);
11106 return null;
11107 }
11108 Object visitPrefixedIdentifier(PrefixedIdentifier node) {
11109 visit(node.prefix);
11110 _writer.print('.');
11111 visit(node.identifier);
11112 return null;
11113 }
11114 Object visitPrefixExpression(PrefixExpression node) {
11115 _writer.print(node.operator.lexeme);
11116 visit(node.operand);
11117 return null;
11118 }
11119 Object visitPropertyAccess(PropertyAccess node) {
11120 if (node.isCascaded()) {
11121 _writer.print("..");
11122 } else {
11123 visit(node.target);
11124 _writer.print('.');
11125 }
11126 visit(node.propertyName);
11127 return null;
11128 }
11129 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) {
11130 _writer.print("this");
11131 visit3(".", node.constructorName);
11132 visit(node.argumentList);
11133 return null;
11134 }
11135 Object visitReturnStatement(ReturnStatement node) {
11136 Expression expression14 = node.expression;
11137 if (expression14 == null) {
11138 _writer.print("return;");
11139 } else {
11140 _writer.print("return ");
11141 expression14.accept(this);
11142 _writer.print(";");
11143 }
11144 return null;
11145 }
11146 Object visitScriptTag(ScriptTag node) {
11147 _writer.print(node.scriptTag.lexeme);
11148 return null;
11149 }
11150 Object visitShowCombinator(ShowCombinator node) {
11151 _writer.print("show ");
11152 visitList2(node.shownNames, ", ");
11153 return null;
11154 }
11155 Object visitSimpleFormalParameter(SimpleFormalParameter node) {
11156 visit5(node.keyword, " ");
11157 visit2(node.type, " ");
11158 visit(node.identifier);
11159 return null;
11160 }
11161 Object visitSimpleIdentifier(SimpleIdentifier node) {
11162 _writer.print(node.token.lexeme);
11163 return null;
11164 }
11165 Object visitSimpleStringLiteral(SimpleStringLiteral node) {
11166 _writer.print(node.literal.lexeme);
11167 return null;
11168 }
11169 Object visitStringInterpolation(StringInterpolation node) {
11170 visitList(node.elements);
11171 return null;
11172 }
11173 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) {
11174 _writer.print("super");
11175 visit3(".", node.constructorName);
11176 visit(node.argumentList);
11177 return null;
11178 }
11179 Object visitSuperExpression(SuperExpression node) {
11180 _writer.print("super");
11181 return null;
11182 }
11183 Object visitSwitchCase(SwitchCase node) {
11184 visitList3(node.labels, " ", " ");
11185 _writer.print("case ");
11186 visit(node.expression);
11187 _writer.print(": ");
11188 visitList2(node.statements, " ");
11189 return null;
11190 }
11191 Object visitSwitchDefault(SwitchDefault node) {
11192 visitList3(node.labels, " ", " ");
11193 _writer.print("default: ");
11194 visitList2(node.statements, " ");
11195 return null;
11196 }
11197 Object visitSwitchStatement(SwitchStatement node) {
11198 _writer.print("switch (");
11199 visit(node.expression);
11200 _writer.print(") {");
11201 visitList2(node.members, " ");
11202 _writer.print("}");
11203 return null;
11204 }
11205 Object visitThisExpression(ThisExpression node) {
11206 _writer.print("this");
11207 return null;
11208 }
11209 Object visitThrowExpression(ThrowExpression node) {
11210 _writer.print("throw ");
11211 visit(node.expression);
11212 return null;
11213 }
11214 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
11215 visit2(node.variables, ";");
11216 return null;
11217 }
11218 Object visitTryStatement(TryStatement node) {
11219 _writer.print("try ");
11220 visit(node.body);
11221 visitList4(" ", node.catchClauses, " ");
11222 visit3(" finally ", node.finallyClause);
11223 return null;
11224 }
11225 Object visitTypeArgumentList(TypeArgumentList node) {
11226 _writer.print('<');
11227 visitList2(node.arguments, ", ");
11228 _writer.print('>');
11229 return null;
11230 }
11231 Object visitTypeName(TypeName node) {
11232 visit(node.name);
11233 visit(node.typeArguments);
11234 return null;
11235 }
11236 Object visitTypeParameter(TypeParameter node) {
11237 visit(node.name);
11238 visit3(" extends ", node.bound);
11239 return null;
11240 }
11241 Object visitTypeParameterList(TypeParameterList node) {
11242 _writer.print('<');
11243 visitList2(node.typeParameters, ", ");
11244 _writer.print('>');
11245 return null;
11246 }
11247 Object visitVariableDeclaration(VariableDeclaration node) {
11248 visit(node.name);
11249 visit3(" = ", node.initializer);
11250 return null;
11251 }
11252 Object visitVariableDeclarationList(VariableDeclarationList node) {
11253 visit5(node.keyword, " ");
11254 visit2(node.type, " ");
11255 visitList2(node.variables, ", ");
11256 return null;
11257 }
11258 Object visitVariableDeclarationStatement(VariableDeclarationStatement node) {
11259 visit(node.variables);
11260 _writer.print(";");
11261 return null;
11262 }
11263 Object visitWhileStatement(WhileStatement node) {
11264 _writer.print("while (");
11265 visit(node.condition);
11266 _writer.print(") ");
11267 visit(node.body);
11268 return null;
11269 }
11270 Object visitWithClause(WithClause node) {
11271 _writer.print("with ");
11272 visitList2(node.mixinTypes, ", ");
11273 return null;
11274 }
11275 /**
11276 * Safely visit the given node.
11277 * @param node the node to be visited
11278 */
11279 void visit(ASTNode node) {
11280 if (node != null) {
11281 node.accept(this);
11282 }
11283 }
11284 /**
11285 * Safely visit the given node, printing the suffix after the node if it is no n-{@code null}.
11286 * @param suffix the suffix to be printed if there is a node to visit
11287 * @param node the node to be visited
11288 */
11289 void visit2(ASTNode node, String suffix) {
11290 if (node != null) {
11291 node.accept(this);
11292 _writer.print(suffix);
11293 }
11294 }
11295 /**
11296 * Safely visit the given node, printing the prefix before the node if it is n on-{@code null}.
11297 * @param prefix the prefix to be printed if there is a node to visit
11298 * @param node the node to be visited
11299 */
11300 void visit3(String prefix, ASTNode node) {
11301 if (node != null) {
11302 _writer.print(prefix);
11303 node.accept(this);
11304 }
11305 }
11306 /**
11307 * Visit the given function body, printing the prefix before if given body is not empty.
11308 * @param prefix the prefix to be printed if there is a node to visit
11309 * @param body the function body to be visited
11310 */
11311 void visit4(String prefix, FunctionBody body) {
11312 if (body is! EmptyFunctionBody) {
11313 _writer.print(prefix);
11314 }
11315 visit(body);
11316 }
11317 /**
11318 * Safely visit the given node, printing the suffix after the node if it is no n-{@code null}.
11319 * @param suffix the suffix to be printed if there is a node to visit
11320 * @param node the node to be visited
11321 */
11322 void visit5(Token token, String suffix) {
11323 if (token != null) {
11324 _writer.print(token.lexeme);
11325 _writer.print(suffix);
11326 }
11327 }
11328 /**
11329 * Print a list of nodes without any separation.
11330 * @param nodes the nodes to be printed
11331 * @param separator the separator to be printed between adjacent nodes
11332 */
11333 void visitList(NodeList<ASTNode> nodes) {
11334 visitList2(nodes, "");
11335 }
11336 /**
11337 * Print a list of nodes, separated by the given separator.
11338 * @param nodes the nodes to be printed
11339 * @param separator the separator to be printed between adjacent nodes
11340 */
11341 void visitList2(NodeList<ASTNode> nodes, String separator) {
11342 if (nodes != null) {
11343 int size3 = nodes.length;
11344 for (int i = 0; i < size3; i++) {
11345 if (i > 0) {
11346 _writer.print(separator);
11347 }
11348 nodes[i].accept(this);
11349 }
11350 }
11351 }
11352 /**
11353 * Print a list of nodes, separated by the given separator.
11354 * @param nodes the nodes to be printed
11355 * @param separator the separator to be printed between adjacent nodes
11356 * @param suffix the suffix to be printed if the list is not empty
11357 */
11358 void visitList3(NodeList<ASTNode> nodes, String separator, String suffix) {
11359 if (nodes != null) {
11360 int size4 = nodes.length;
11361 if (size4 > 0) {
11362 for (int i = 0; i < size4; i++) {
11363 if (i > 0) {
11364 _writer.print(separator);
11365 }
11366 nodes[i].accept(this);
11367 }
11368 _writer.print(suffix);
11369 }
11370 }
11371 }
11372 /**
11373 * Print a list of nodes, separated by the given separator.
11374 * @param prefix the prefix to be printed if the list is not empty
11375 * @param nodes the nodes to be printed
11376 * @param separator the separator to be printed between adjacent nodes
11377 */
11378 void visitList4(String prefix, NodeList<ASTNode> nodes, String separator) {
11379 if (nodes != null) {
11380 int size5 = nodes.length;
11381 if (size5 > 0) {
11382 _writer.print(prefix);
11383 for (int i = 0; i < size5; i++) {
11384 if (i > 0) {
11385 _writer.print(separator);
11386 }
11387 nodes[i].accept(this);
11388 }
11389 }
11390 }
11391 }
11392 }
11393 /**
11394 * Instances of the class {@code NodeList} represent a list of AST nodes that ha ve a common parent.
11395 */
11396 class NodeList<E extends ASTNode> extends ListWrapper<E> {
11397 /**
11398 * The node that is the parent of each of the elements in the list.
11399 */
11400 ASTNode owner;
11401 /**
11402 * The elements of the list.
11403 */
11404 List<E> elements = new List<E>();
11405 /**
11406 * Initialize a newly created list of nodes to be empty.
11407 * @param owner the node that is the parent of each of the elements in the lis t
11408 */
11409 NodeList(ASTNode this.owner);
11410 /**
11411 * Use the given visitor to visit each of the nodes in this list.
11412 * @param visitor the visitor to be used to visit the elements of this list
11413 */
11414 accept(ASTVisitor visitor) {
11415 for (E element in elements) {
11416 element.accept(visitor);
11417 }
11418 }
11419 void add(E node) {
11420 owner.becomeParentOf(node);
11421 elements.add(node);
11422 }
11423 bool addAll(Collection<E> nodes) {
11424 if (nodes != null) {
11425 super.addAll(nodes);
11426 return true;
11427 }
11428 return false;
11429 }
11430 /**
11431 * Return the first token included in this node's source range.
11432 * @return the first token included in this node's source range
11433 */
11434 Token get beginToken {
11435 if (elements.isEmpty) {
11436 return null;
11437 }
11438 return elements[0].beginToken;
11439 }
11440 /**
11441 * Return the last token included in this node list's source range.
11442 * @return the last token included in this node list's source range
11443 */
11444 Token get endToken {
11445 if (elements.isEmpty) {
11446 return null;
11447 }
11448 return elements[elements.length - 1].endToken;
11449 }
11450 /**
11451 * Return the node that is the parent of each of the elements in the list.
11452 * @return the node that is the parent of each of the elements in the list
11453 */
11454 ASTNode getOwner() {
11455 return owner;
11456 }
11457 }
OLDNEW
« no previous file with comments | « pkg/analyzer-experimental/example/scanner_driver.dart ('k') | pkg/analyzer-experimental/lib/src/generated/element.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698