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

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

Issue 955683003: Improved doc comments (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Additional clean-up Created 5 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.ast; 8 library engine.ast;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
11 11
12 import 'constant.dart'; 12 import 'constant.dart';
13 import 'element.dart'; 13 import 'element.dart';
14 import 'engine.dart' show AnalysisEngine; 14 import 'engine.dart' show AnalysisEngine;
15 import 'java_core.dart'; 15 import 'java_core.dart';
16 import 'java_engine.dart'; 16 import 'java_engine.dart';
17 import 'parser.dart'; 17 import 'parser.dart';
18 import 'scanner.dart'; 18 import 'scanner.dart';
19 import 'source.dart' show LineInfo, Source; 19 import 'source.dart' show LineInfo, Source;
20 import 'utilities_collection.dart' show TokenMap; 20 import 'utilities_collection.dart' show TokenMap;
21 import 'utilities_dart.dart'; 21 import 'utilities_dart.dart';
22 22
23 /** 23 /**
24 * Instances of the class `AdjacentStrings` represents two or more string litera ls that are 24 * Two or more string literals that are implicitly concatenated because of being
25 * implicitly concatenated because of being adjacent (separated only by whitespa ce). 25 * adjacent (separated only by whitespace).
26 * 26 *
27 * While the grammar only allows adjacent strings when all of the strings are of the same kind 27 * While the grammar only allows adjacent strings when all of the strings are of
28 * (single line or multi-line), this class doesn't enforce that restriction. 28 * the same kind (single line or multi-line), this class doesn't enforce that
29 * restriction.
29 * 30 *
30 * <pre> 31 * > adjacentStrings ::=
31 * adjacentStrings ::= 32 * > [StringLiteral] [StringLiteral]+
32 * [StringLiteral] [StringLiteral]+
33 * </pre>
34 */ 33 */
35 class AdjacentStrings extends StringLiteral { 34 class AdjacentStrings extends StringLiteral {
36 /** 35 /**
37 * The strings that are implicitly concatenated. 36 * The strings that are implicitly concatenated.
38 */ 37 */
39 NodeList<StringLiteral> _strings; 38 NodeList<StringLiteral> _strings;
40 39
41 /** 40 /**
42 * Initialize a newly created list of adjacent strings. 41 * Initialize a newly created list of adjacent strings. To be syntactically
43 * 42 * valid, the list of [strings] must contain at least two elements.
44 * @param strings the strings that are implicitly concatenated
45 */ 43 */
46 AdjacentStrings(List<StringLiteral> strings) { 44 AdjacentStrings(List<StringLiteral> strings) {
47 _strings = new NodeList<StringLiteral>(this, strings); 45 _strings = new NodeList<StringLiteral>(this, strings);
48 } 46 }
49 47
50 @override 48 @override
51 Token get beginToken => _strings.beginToken; 49 Token get beginToken => _strings.beginToken;
52 50
53 @override 51 @override
54 Iterable get childEntities => new ChildEntities()..addAll(_strings); 52 Iterable get childEntities => new ChildEntities()..addAll(_strings);
55 53
56 @override 54 @override
57 Token get endToken => _strings.endToken; 55 Token get endToken => _strings.endToken;
58 56
59 /** 57 /**
60 * Return the strings that are implicitly concatenated. 58 * Return the strings that are implicitly concatenated.
61 *
62 * @return the strings that are implicitly concatenated
63 */ 59 */
64 NodeList<StringLiteral> get strings => _strings; 60 NodeList<StringLiteral> get strings => _strings;
65 61
66 @override 62 @override
67 accept(AstVisitor visitor) => visitor.visitAdjacentStrings(this); 63 accept(AstVisitor visitor) => visitor.visitAdjacentStrings(this);
68 64
69 @override 65 @override
70 void appendStringValue(StringBuffer buffer) { 66 void appendStringValue(StringBuffer buffer) {
71 for (StringLiteral stringLiteral in strings) { 67 for (StringLiteral stringLiteral in strings) {
72 stringLiteral.appendStringValue(buffer); 68 stringLiteral.appendStringValue(buffer);
73 } 69 }
74 } 70 }
75 71
76 @override 72 @override
77 void visitChildren(AstVisitor visitor) { 73 void visitChildren(AstVisitor visitor) {
78 _strings.accept(visitor); 74 _strings.accept(visitor);
79 } 75 }
80 } 76 }
81 77
82 /** 78 /**
83 * The abstract class `AnnotatedNode` defines the behavior of nodes that can be annotated with 79 * An AST node that can be annotated with both a documentation comment and a
84 * both a comment and metadata. 80 * list of annotations.
85 */ 81 */
86 abstract class AnnotatedNode extends AstNode { 82 abstract class AnnotatedNode extends AstNode {
87 /** 83 /**
88 * The documentation comment associated with this node, or `null` if this node does not have 84 * The documentation comment associated with this node, or `null` if this node
89 * a documentation comment associated with it. 85 * does not have a documentation comment associated with it.
90 */ 86 */
91 Comment _comment; 87 Comment _comment;
92 88
93 /** 89 /**
94 * The annotations associated with this node. 90 * The annotations associated with this node.
95 */ 91 */
96 NodeList<Annotation> _metadata; 92 NodeList<Annotation> _metadata;
97 93
98 /** 94 /**
99 * Initialize a newly created node. 95 * Initialize a newly created annotated node. Either or both of the [comment]
100 * 96 * and [metadata] can be `null` if the node does not have the corresponding
101 * @param comment the documentation comment associated with this node 97 * attribute.
102 * @param metadata the annotations associated with this node
103 */ 98 */
104 AnnotatedNode(Comment comment, List<Annotation> metadata) { 99 AnnotatedNode(Comment comment, List<Annotation> metadata) {
105 _comment = becomeParentOf(comment); 100 _comment = becomeParentOf(comment);
106 _metadata = new NodeList<Annotation>(this, metadata); 101 _metadata = new NodeList<Annotation>(this, metadata);
107 } 102 }
108 103
109 @override 104 @override
110 Token get beginToken { 105 Token get beginToken {
111 if (_comment == null) { 106 if (_comment == null) {
112 if (_metadata.isEmpty) { 107 if (_metadata.isEmpty) {
113 return firstTokenAfterCommentAndMetadata; 108 return firstTokenAfterCommentAndMetadata;
114 } 109 }
115 return _metadata.beginToken; 110 return _metadata.beginToken;
116 } else if (_metadata.isEmpty) { 111 } else if (_metadata.isEmpty) {
117 return _comment.beginToken; 112 return _comment.beginToken;
118 } 113 }
119 Token commentToken = _comment.beginToken; 114 Token commentToken = _comment.beginToken;
120 Token metadataToken = _metadata.beginToken; 115 Token metadataToken = _metadata.beginToken;
121 if (commentToken.offset < metadataToken.offset) { 116 if (commentToken.offset < metadataToken.offset) {
122 return commentToken; 117 return commentToken;
123 } 118 }
124 return metadataToken; 119 return metadataToken;
125 } 120 }
126 121
127 /** 122 /**
128 * Return the documentation comment associated with this node, or `null` if th is node does 123 * Return the documentation comment associated with this node, or `null` if
129 * not have a documentation comment associated with it. 124 * this node does not have a documentation comment associated with it.
130 *
131 * @return the documentation comment associated with this node
132 */ 125 */
133 Comment get documentationComment => _comment; 126 Comment get documentationComment => _comment;
134 127
135 /** 128 /**
136 * Set the documentation comment associated with this node to the given commen t. 129 * Set the documentation comment associated with this node to the given
137 * 130 * [comment].
138 * @param comment the documentation comment to be associated with this node
139 */ 131 */
140 void set documentationComment(Comment comment) { 132 void set documentationComment(Comment comment) {
141 _comment = becomeParentOf(comment); 133 _comment = becomeParentOf(comment);
142 } 134 }
143 135
144 /** 136 /**
145 * Return the first token following the comment and metadata. 137 * Return the first token following the comment and metadata.
146 *
147 * @return the first token following the comment and metadata
148 */ 138 */
149 Token get firstTokenAfterCommentAndMetadata; 139 Token get firstTokenAfterCommentAndMetadata;
150 140
151 /** 141 /**
152 * Return the annotations associated with this node. 142 * Return the annotations associated with this node.
153 *
154 * @return the annotations associated with this node
155 */ 143 */
156 NodeList<Annotation> get metadata => _metadata; 144 NodeList<Annotation> get metadata => _metadata;
157 145
158 /** 146 /**
159 * Set the metadata associated with this node to the given metadata. 147 * Set the metadata associated with this node to the given [metadata].
160 *
161 * @param metadata the metadata to be associated with this node
162 */ 148 */
163 void set metadata(List<Annotation> metadata) { 149 void set metadata(List<Annotation> metadata) {
164 _metadata.clear(); 150 _metadata.clear();
165 _metadata.addAll(metadata); 151 _metadata.addAll(metadata);
166 } 152 }
167 153
168 /** 154 /**
169 * Return an array containing the comment and annotations associated with this node, sorted in 155 * Return a list containing the comment and annotations associated with this
170 * lexical order. 156 * node, sorted in lexical order.
171 *
172 * @return the comment and annotations associated with this node in the order in which they
173 * appeared in the original source
174 */ 157 */
175 List<AstNode> get sortedCommentAndAnnotations { 158 List<AstNode> get sortedCommentAndAnnotations {
176 return <AstNode>[] 159 return <AstNode>[]
177 ..add(_comment) 160 ..add(_comment)
178 ..addAll(_metadata) 161 ..addAll(_metadata)
179 ..sort(AstNode.LEXICAL_ORDER); 162 ..sort(AstNode.LEXICAL_ORDER);
180 } 163 }
181 164
182 ChildEntities get _childEntities { 165 ChildEntities get _childEntities {
183 ChildEntities result = new ChildEntities(); 166 ChildEntities result = new ChildEntities();
184 if (_commentIsBeforeAnnotations()) { 167 if (_commentIsBeforeAnnotations()) {
185 result 168 result
186 ..add(_comment) 169 ..add(_comment)
187 ..addAll(_metadata); 170 ..addAll(_metadata);
188 } else { 171 } else {
189 result.addAll(sortedCommentAndAnnotations); 172 result.addAll(sortedCommentAndAnnotations);
190 } 173 }
191 return result; 174 return result;
192 } 175 }
193 176
194 @override 177 @override
195 void visitChildren(AstVisitor visitor) { 178 void visitChildren(AstVisitor visitor) {
196 if (_commentIsBeforeAnnotations()) { 179 if (_commentIsBeforeAnnotations()) {
197 safelyVisitChild(_comment, visitor); 180 _safelyVisitChild(_comment, visitor);
198 _metadata.accept(visitor); 181 _metadata.accept(visitor);
199 } else { 182 } else {
200 for (AstNode child in sortedCommentAndAnnotations) { 183 for (AstNode child in sortedCommentAndAnnotations) {
201 child.accept(visitor); 184 child.accept(visitor);
202 } 185 }
203 } 186 }
204 } 187 }
205 188
206 /** 189 /**
207 * Return `true` if the comment is lexically before any annotations. 190 * Return `true` if the comment is lexically before any annotations.
208 *
209 * @return `true` if the comment is lexically before any annotations
210 */ 191 */
211 bool _commentIsBeforeAnnotations() { 192 bool _commentIsBeforeAnnotations() {
212 if (_comment == null || _metadata.isEmpty) { 193 if (_comment == null || _metadata.isEmpty) {
213 return true; 194 return true;
214 } 195 }
215 Annotation firstAnnotation = _metadata[0]; 196 Annotation firstAnnotation = _metadata[0];
216 return _comment.offset < firstAnnotation.offset; 197 return _comment.offset < firstAnnotation.offset;
217 } 198 }
218 } 199 }
219 200
220 /** 201 /**
221 * Instances of the class `Annotation` represent an annotation that can be assoc iated with an 202 * An annotation that can be associated with an AST node.
222 * AST node.
223 * 203 *
224 * <pre> 204 * > metadata ::=
225 * metadata ::= 205 * > annotation*
226 * annotation* 206 * >
227 * 207 * > annotation ::=
228 * annotation ::= 208 * > '@' [Identifier] ('.' [SimpleIdentifier])? [ArgumentList]?
229 * '@' [Identifier] ('.' [SimpleIdentifier])? [ArgumentList]?
230 * </pre>
231 */ 209 */
232 class Annotation extends AstNode { 210 class Annotation extends AstNode {
233 /** 211 /**
234 * The at sign that introduced the annotation. 212 * The at sign that introduced the annotation.
235 */ 213 */
236 Token atSign; 214 Token atSign;
237 215
238 /** 216 /**
239 * The name of the class defining the constructor that is being invoked or the name of the field 217 * The name of the class defining the constructor that is being invoked or the
240 * that is being referenced. 218 * name of the field that is being referenced.
241 */ 219 */
242 Identifier _name; 220 Identifier _name;
243 221
244 /** 222 /**
245 * The period before the constructor name, or `null` if this annotation is not the 223 * The period before the constructor name, or `null` if this annotation is not
246 * invocation of a named constructor. 224 * the invocation of a named constructor.
247 */ 225 */
248 Token period; 226 Token period;
249 227
250 /** 228 /**
251 * The name of the constructor being invoked, or `null` if this annotation is not the 229 * The name of the constructor being invoked, or `null` if this annotation is
252 * invocation of a named constructor. 230 * not the invocation of a named constructor.
253 */ 231 */
254 SimpleIdentifier _constructorName; 232 SimpleIdentifier _constructorName;
255 233
256 /** 234 /**
257 * The arguments to the constructor being invoked, or `null` if this annotatio n is not the 235 * The arguments to the constructor being invoked, or `null` if this
258 * invocation of a constructor. 236 * annotation is not the invocation of a constructor.
259 */ 237 */
260 ArgumentList _arguments; 238 ArgumentList _arguments;
261 239
262 /** 240 /**
263 * The element associated with this annotation, or `null` if the AST structure has not been 241 * The element associated with this annotation, or `null` if the AST structure
264 * resolved or if this annotation could not be resolved. 242 * has not been resolved or if this annotation could not be resolved.
265 */ 243 */
266 Element _element; 244 Element _element;
267 245
268 /** 246 /**
269 * The element annotation representing this annotation in the element model. 247 * The element annotation representing this annotation in the element model.
270 */ 248 */
271 ElementAnnotation elementAnnotation; 249 ElementAnnotation elementAnnotation;
272 250
273 /** 251 /**
274 * Initialize a newly created annotation. 252 * Initialize a newly created annotation. Both the [period] and the
275 * 253 * [constructorName] can be `null` if the annotation is not referencing a
276 * @param atSign the at sign that introduced the annotation 254 * named constructor. The [arguments] can be `null` if the annotation is not
277 * @param name the name of the class defining the constructor that is being in voked or the name of 255 * referencing a constructor.
278 * the field that is being referenced
279 * @param period the period before the constructor name, or `null` if this ann otation is not
280 * the invocation of a named constructor
281 * @param constructorName the name of the constructor being invoked, or `null` if this
282 * annotation is not the invocation of a named constructor
283 * @param arguments the arguments to the constructor being invoked, or `null` if this
284 * annotation is not the invocation of a constructor
285 */ 256 */
286 Annotation(this.atSign, Identifier name, this.period, 257 Annotation(this.atSign, Identifier name, this.period,
287 SimpleIdentifier constructorName, ArgumentList arguments) { 258 SimpleIdentifier constructorName, ArgumentList arguments) {
288 _name = becomeParentOf(name); 259 _name = becomeParentOf(name);
289 _constructorName = becomeParentOf(constructorName); 260 _constructorName = becomeParentOf(constructorName);
290 _arguments = becomeParentOf(arguments); 261 _arguments = becomeParentOf(arguments);
291 } 262 }
292 263
293 /** 264 /**
294 * Return the arguments to the constructor being invoked, or `null` if this an notation is 265 * Return the arguments to the constructor being invoked, or `null` if this
295 * not the invocation of a constructor. 266 * annotation is not the invocation of a constructor.
296 *
297 * @return the arguments to the constructor being invoked
298 */ 267 */
299 ArgumentList get arguments => _arguments; 268 ArgumentList get arguments => _arguments;
300 269
301 /** 270 /**
302 * Set the arguments to the constructor being invoked to the given arguments. 271 * Set the arguments to the constructor being invoked to the given arguments.
303 *
304 * @param arguments the arguments to the constructor being invoked
305 */ 272 */
306 void set arguments(ArgumentList arguments) { 273 void set arguments(ArgumentList arguments) {
307 _arguments = becomeParentOf(arguments); 274 _arguments = becomeParentOf(arguments);
308 } 275 }
309 276
310 @override 277 @override
311 Token get beginToken => atSign; 278 Token get beginToken => atSign;
312 279
313 @override 280 @override
314 Iterable get childEntities => new ChildEntities() 281 Iterable get childEntities => new ChildEntities()
315 ..add(atSign) 282 ..add(atSign)
316 ..add(_name) 283 ..add(_name)
317 ..add(period) 284 ..add(period)
318 ..add(_constructorName) 285 ..add(_constructorName)
319 ..add(_arguments); 286 ..add(_arguments);
320 287
321 /** 288 /**
322 * Return the name of the constructor being invoked, or `null` if this annotat ion is not the 289 * Return the name of the constructor being invoked, or `null` if this
323 * invocation of a named constructor. 290 * annotation is not the invocation of a named constructor.
324 *
325 * @return the name of the constructor being invoked
326 */ 291 */
327 SimpleIdentifier get constructorName => _constructorName; 292 SimpleIdentifier get constructorName => _constructorName;
328 293
329 /** 294 /**
330 * Set the name of the constructor being invoked to the given name. 295 * Set the name of the constructor being invoked to the given [name].
331 *
332 * @param constructorName the name of the constructor being invoked
333 */ 296 */
334 void set constructorName(SimpleIdentifier constructorName) { 297 void set constructorName(SimpleIdentifier name) {
335 _constructorName = becomeParentOf(constructorName); 298 _constructorName = becomeParentOf(name);
336 } 299 }
337 300
338 /** 301 /**
339 * Return the element associated with this annotation, or `null` if the AST st ructure has 302 * Return the element associated with this annotation, or `null` if the AST
340 * not been resolved or if this annotation could not be resolved. 303 * structure has not been resolved or if this annotation could not be
341 * 304 * resolved.
342 * @return the element associated with this annotation
343 */ 305 */
344 Element get element { 306 Element get element {
345 if (_element != null) { 307 if (_element != null) {
346 return _element; 308 return _element;
347 } else if (_name != null) { 309 } else if (_name != null) {
348 return _name.staticElement; 310 return _name.staticElement;
349 } 311 }
350 return null; 312 return null;
351 } 313 }
352 314
353 /** 315 /**
354 * Set the element associated with this annotation based. 316 * Set the element associated with this annotation to the given [element].
355 *
356 * @param element the element to be associated with this identifier
357 */ 317 */
358 void set element(Element element) { 318 void set element(Element element) {
359 _element = element; 319 _element = element;
360 } 320 }
361 321
362 @override 322 @override
363 Token get endToken { 323 Token get endToken {
364 if (_arguments != null) { 324 if (_arguments != null) {
365 return _arguments.endToken; 325 return _arguments.endToken;
366 } else if (_constructorName != null) { 326 } else if (_constructorName != null) {
367 return _constructorName.endToken; 327 return _constructorName.endToken;
368 } 328 }
369 return _name.endToken; 329 return _name.endToken;
370 } 330 }
371 331
372 /** 332 /**
373 * Return the name of the class defining the constructor that is being invoked or the name of the 333 * Return the name of the class defining the constructor that is being invoked
374 * field that is being referenced. 334 * or the name of the field that is being referenced.
375 *
376 * @return the name of the constructor being invoked or the name of the field being referenced
377 */ 335 */
378 Identifier get name => _name; 336 Identifier get name => _name;
379 337
380 /** 338 /**
381 * Set the name of the class defining the constructor that is being invoked or the name of the 339 * Set the name of the class defining the constructor that is being invoked or
382 * field that is being referenced to the given name. 340 * the name of the field that is being referenced to the given [name].
383 *
384 * @param name the name of the constructor being invoked or the name of the fi eld being referenced
385 */ 341 */
386 void set name(Identifier name) { 342 void set name(Identifier name) {
387 _name = becomeParentOf(name); 343 _name = becomeParentOf(name);
388 } 344 }
389 345
390 @override 346 @override
391 accept(AstVisitor visitor) => visitor.visitAnnotation(this); 347 accept(AstVisitor visitor) => visitor.visitAnnotation(this);
392 348
393 @override 349 @override
394 void visitChildren(AstVisitor visitor) { 350 void visitChildren(AstVisitor visitor) {
395 safelyVisitChild(_name, visitor); 351 _safelyVisitChild(_name, visitor);
396 safelyVisitChild(_constructorName, visitor); 352 _safelyVisitChild(_constructorName, visitor);
397 safelyVisitChild(_arguments, visitor); 353 _safelyVisitChild(_arguments, visitor);
398 } 354 }
399 } 355 }
400 356
401 /** 357 /**
402 * Instances of the class `ArgumentList` represent a list of arguments in the in vocation of a 358 * A list of arguments in the invocation of an executable element: a function,
403 * executable element: a function, method, or constructor. 359 * method, or constructor.
404 * 360 *
405 * <pre> 361 * > argumentList ::=
406 * argumentList ::= 362 * > '(' arguments? ')'
407 * '(' arguments? ')' 363 * >
408 * 364 * > arguments ::=
409 * arguments ::= 365 * > [NamedExpression] (',' [NamedExpression])*
410 * [NamedExpression] (',' [NamedExpression])* 366 * > | [Expression] (',' [Expression])* (',' [NamedExpression])*
411 * | [Expression] (',' [NamedExpression])*
412 * </pre>
413 */ 367 */
414 class ArgumentList extends AstNode { 368 class ArgumentList extends AstNode {
415 /** 369 /**
416 * The left parenthesis. 370 * The left parenthesis.
417 */ 371 */
418 Token leftParenthesis; 372 Token leftParenthesis;
419 373
420 /** 374 /**
421 * The expressions producing the values of the arguments. 375 * The expressions producing the values of the arguments.
422 */ 376 */
423 NodeList<Expression> _arguments; 377 NodeList<Expression> _arguments;
424 378
425 /** 379 /**
426 * The right parenthesis. 380 * The right parenthesis.
427 */ 381 */
428 Token rightParenthesis; 382 Token rightParenthesis;
429 383
430 /** 384 /**
431 * An array containing the elements representing the parameters corresponding to each of the 385 * A list containing the elements representing the parameters corresponding to
432 * arguments in this list, or `null` if the AST has not been resolved or if th e function or 386 * each of the arguments in this list, or `null` if the AST has not been
433 * method being invoked could not be determined based on static type informati on. The array must 387 * resolved or if the function or method being invoked could not be determined
434 * be the same length as the number of arguments, but can contain `null` entri es if a given 388 * based on static type information. The list must be the same length as the
435 * argument does not correspond to a formal parameter. 389 * number of arguments, but can contain `null` entries if a given argument
390 * does not correspond to a formal parameter.
436 */ 391 */
437 List<ParameterElement> _correspondingStaticParameters; 392 List<ParameterElement> _correspondingStaticParameters;
438 393
439 /** 394 /**
440 * An array containing the elements representing the parameters corresponding to each of the 395 * A list containing the elements representing the parameters corresponding to
441 * arguments in this list, or `null` if the AST has not been resolved or if th e function or 396 * each of the arguments in this list, or `null` if the AST has not been
442 * method being invoked could not be determined based on propagated type infor mation. The array 397 * resolved or if the function or method being invoked could not be determined
443 * must be the same length as the number of arguments, but can contain `null` entries if a 398 * based on propagated type information. The list must be the same length as
444 * given argument does not correspond to a formal parameter. 399 * the number of arguments, but can contain `null` entries if a given argument
400 * does not correspond to a formal parameter.
445 */ 401 */
446 List<ParameterElement> _correspondingPropagatedParameters; 402 List<ParameterElement> _correspondingPropagatedParameters;
447 403
448 /** 404 /**
449 * Initialize a newly created list of arguments. 405 * Initialize a newly created list of arguments. The list of [arguments] can
450 * 406 * be `null` if there are no arguments.
451 * @param leftParenthesis the left parenthesis
452 * @param arguments the expressions producing the values of the arguments
453 * @param rightParenthesis the right parenthesis
454 */ 407 */
455 ArgumentList(this.leftParenthesis, List<Expression> arguments, 408 ArgumentList(this.leftParenthesis, List<Expression> arguments,
456 this.rightParenthesis) { 409 this.rightParenthesis) {
457 _arguments = new NodeList<Expression>(this, arguments); 410 _arguments = new NodeList<Expression>(this, arguments);
458 } 411 }
459 412
460 /** 413 /**
461 * Return the expressions producing the values of the arguments. Although the language requires 414 * Return the expressions producing the values of the arguments. Although the
462 * that positional arguments appear before named arguments, this class allows them to be 415 * language requires that positional arguments appear before named arguments,
463 * intermixed. 416 * this class allows them to be intermixed.
464 *
465 * @return the expressions producing the values of the arguments
466 */ 417 */
467 NodeList<Expression> get arguments => _arguments; 418 NodeList<Expression> get arguments => _arguments;
468 419
469 @override 420 @override
470 Token get beginToken => leftParenthesis; 421 Token get beginToken => leftParenthesis;
471 422
472 /** 423 /**
473 * TODO(paulberry): Add commas. 424 * TODO(paulberry): Add commas.
474 */ 425 */
475 @override 426 @override
476 Iterable get childEntities => new ChildEntities() 427 Iterable get childEntities => new ChildEntities()
477 ..add(leftParenthesis) 428 ..add(leftParenthesis)
478 ..addAll(_arguments) 429 ..addAll(_arguments)
479 ..add(rightParenthesis); 430 ..add(rightParenthesis);
480 431
481 /** 432 /**
482 * Set the parameter elements corresponding to each of the arguments in this l ist to the given 433 * Set the parameter elements corresponding to each of the arguments in this
483 * array of parameters. The array of parameters must be the same length as the number of 434 * list to the given list of [parameters]. The list of parameters must be the
484 * arguments, but can contain `null` entries if a given argument does not corr espond to a 435 * same length as the number of arguments, but can contain `null` entries if a
485 * formal parameter. 436 * given argument does not correspond to a formal parameter.
486 *
487 * @param parameters the parameter elements corresponding to the arguments
488 */ 437 */
489 void set 438 void set
490 correspondingPropagatedParameters(List<ParameterElement> parameters) { 439 correspondingPropagatedParameters(List<ParameterElement> parameters) {
491 if (parameters.length != _arguments.length) { 440 if (parameters.length != _arguments.length) {
492 throw new IllegalArgumentException( 441 throw new IllegalArgumentException(
493 "Expected ${_arguments.length} parameters, not ${parameters.length}"); 442 "Expected ${_arguments.length} parameters, not ${parameters.length}");
494 } 443 }
495 _correspondingPropagatedParameters = parameters; 444 _correspondingPropagatedParameters = parameters;
496 } 445 }
497 446
498 /** 447 /**
499 * Set the parameter elements corresponding to each of the arguments in this l ist to the given 448 * Set the parameter elements corresponding to each of the arguments in this
500 * array of parameters. The array of parameters must be the same length as the number of 449 * list to the given list of parameters. The list of parameters must be the
501 * arguments, but can contain `null` entries if a given argument does not corr espond to a 450 * same length as the number of arguments, but can contain `null` entries if a
502 * formal parameter. 451 * given argument does not correspond to a formal parameter.
503 *
504 * @param parameters the parameter elements corresponding to the arguments
505 */ 452 */
506 void set correspondingStaticParameters(List<ParameterElement> parameters) { 453 void set correspondingStaticParameters(List<ParameterElement> parameters) {
507 if (parameters.length != _arguments.length) { 454 if (parameters.length != _arguments.length) {
508 throw new IllegalArgumentException( 455 throw new IllegalArgumentException(
509 "Expected ${_arguments.length} parameters, not ${parameters.length}"); 456 "Expected ${_arguments.length} parameters, not ${parameters.length}");
510 } 457 }
511 _correspondingStaticParameters = parameters; 458 _correspondingStaticParameters = parameters;
512 } 459 }
513 460
514 @override 461 @override
515 Token get endToken => rightParenthesis; 462 Token get endToken => rightParenthesis;
516 463
517 @override 464 @override
518 accept(AstVisitor visitor) => visitor.visitArgumentList(this); 465 accept(AstVisitor visitor) => visitor.visitArgumentList(this);
519 466
520 /** 467 /**
521 * If the given expression is a child of this list, and the AST structure has been resolved, and 468 * If
522 * the function being invoked is known based on propagated type information, a nd the expression 469 * * the given [expression] is a child of this list,
523 * corresponds to one of the parameters of the function being invoked, then re turn the parameter 470 * * the AST structure has been resolved,
524 * element representing the parameter to which the value of the given expressi on will be bound. 471 * * the function being invoked is known based on propagated type information,
525 * Otherwise, return `null`. 472 * and
473 * * the expression corresponds to one of the parameters of the function being
474 * invoked,
475 * then return the parameter element representing the parameter to which the
476 * value of the given expression will be bound. Otherwise, return `null`.
526 * 477 *
527 * This method is only intended to be used by [Expression.propagatedParameterE lement]. 478 * This method is only intended to be used by
528 * 479 * [Expression.propagatedParameterElement].
529 * @param expression the expression corresponding to the parameter to be retur ned
530 * @return the parameter element representing the parameter to which the value of the expression
531 * will be bound
532 */ 480 */
533 ParameterElement getPropagatedParameterElementFor(Expression expression) { 481 ParameterElement getPropagatedParameterElementFor(Expression expression) {
534 if (_correspondingPropagatedParameters == null) { 482 if (_correspondingPropagatedParameters == null) {
535 // Either the AST structure has not been resolved or the invocation 483 // Either the AST structure has not been resolved or the invocation
536 // of which this list is a part could not be resolved. 484 // of which this list is a part could not be resolved.
537 return null; 485 return null;
538 } 486 }
539 int index = _arguments.indexOf(expression); 487 int index = _arguments.indexOf(expression);
540 if (index < 0) { 488 if (index < 0) {
541 // The expression isn't a child of this node. 489 // The expression isn't a child of this node.
542 return null; 490 return null;
543 } 491 }
544 return _correspondingPropagatedParameters[index]; 492 return _correspondingPropagatedParameters[index];
545 } 493 }
546 494
547 /** 495 /**
548 * If the given expression is a child of this list, and the AST structure has been resolved, and 496 * If
549 * the function being invoked is known based on static type information, and t he expression 497 * * the given [expression] is a child of this list,
550 * corresponds to one of the parameters of the function being invoked, then re turn the parameter 498 * * the AST structure has been resolved,
551 * element representing the parameter to which the value of the given expressi on will be bound. 499 * * the function being invoked is known based on static type information, and
552 * Otherwise, return `null`. 500 * * the expression corresponds to one of the parameters of the function being
501 * invoked,
502 * then return the parameter element representing the parameter to which the
503 * value of the given expression will be bound. Otherwise, return `null`.
553 * 504 *
554 * This method is only intended to be used by [Expression.staticParameterEleme nt]. 505 * This method is only intended to be used by
555 * 506 * [Expression.staticParameterElement].
556 * @param expression the expression corresponding to the parameter to be retur ned
557 * @return the parameter element representing the parameter to which the value of the expression
558 * will be bound
559 */ 507 */
560 ParameterElement getStaticParameterElementFor(Expression expression) { 508 ParameterElement getStaticParameterElementFor(Expression expression) {
561 if (_correspondingStaticParameters == null) { 509 if (_correspondingStaticParameters == null) {
562 // Either the AST structure has not been resolved or the invocation 510 // Either the AST structure has not been resolved or the invocation
563 // of which this list is a part could not be resolved. 511 // of which this list is a part could not be resolved.
564 return null; 512 return null;
565 } 513 }
566 int index = _arguments.indexOf(expression); 514 int index = _arguments.indexOf(expression);
567 if (index < 0) { 515 if (index < 0) {
568 // The expression isn't a child of this node. 516 // The expression isn't a child of this node.
569 return null; 517 return null;
570 } 518 }
571 return _correspondingStaticParameters[index]; 519 return _correspondingStaticParameters[index];
572 } 520 }
573 521
574 @override 522 @override
575 void visitChildren(AstVisitor visitor) { 523 void visitChildren(AstVisitor visitor) {
576 _arguments.accept(visitor); 524 _arguments.accept(visitor);
577 } 525 }
578 } 526 }
579 527
580 /** 528 /**
581 * Instances of the class `AsExpression` represent an 'as' expression. 529 * An as expression.
582 * 530 *
583 * <pre> 531 * > asExpression ::=
584 * asExpression ::= 532 * > [Expression] 'as' [TypeName]
585 * [Expression] 'as' [TypeName]
586 * </pre>
587 */ 533 */
588 class AsExpression extends Expression { 534 class AsExpression extends Expression {
589 /** 535 /**
590 * The expression used to compute the value being cast. 536 * The expression used to compute the value being cast.
591 */ 537 */
592 Expression _expression; 538 Expression _expression;
593 539
594 /** 540 /**
595 * The as operator. 541 * The as operator.
596 */ 542 */
597 Token asOperator; 543 Token asOperator;
598 544
599 /** 545 /**
600 * The name of the type being cast to. 546 * The name of the type being cast to.
601 */ 547 */
602 TypeName _type; 548 TypeName _type;
603 549
604 /** 550 /**
605 * Initialize a newly created as expression. 551 * Initialize a newly created as expression.
606 *
607 * @param expression the expression used to compute the value being cast
608 * @param asOperator the as operator
609 * @param type the name of the type being cast to
610 */ 552 */
611 AsExpression(Expression expression, this.asOperator, TypeName type) { 553 AsExpression(Expression expression, this.asOperator, TypeName type) {
612 _expression = becomeParentOf(expression); 554 _expression = becomeParentOf(expression);
613 _type = becomeParentOf(type); 555 _type = becomeParentOf(type);
614 } 556 }
615 557
616 @override 558 @override
617 Token get beginToken => _expression.beginToken; 559 Token get beginToken => _expression.beginToken;
618 560
619 @override 561 @override
620 Iterable get childEntities => new ChildEntities() 562 Iterable get childEntities => new ChildEntities()
621 ..add(_expression) 563 ..add(_expression)
622 ..add(asOperator) 564 ..add(asOperator)
623 ..add(_type); 565 ..add(_type);
624 566
625 @override 567 @override
626 Token get endToken => _type.endToken; 568 Token get endToken => _type.endToken;
627 569
628 /** 570 /**
629 * Return the expression used to compute the value being cast. 571 * Return the expression used to compute the value being cast.
630 *
631 * @return the expression used to compute the value being cast
632 */ 572 */
633 Expression get expression => _expression; 573 Expression get expression => _expression;
634 574
635 /** 575 /**
636 * Set the expression used to compute the value being cast to the given expres sion. 576 * Set the expression used to compute the value being cast to the given
637 * 577 * [expression].
638 * @param expression the expression used to compute the value being cast
639 */ 578 */
640 void set expression(Expression expression) { 579 void set expression(Expression expression) {
641 _expression = becomeParentOf(expression); 580 _expression = becomeParentOf(expression);
642 } 581 }
643 582
644 @override 583 @override
645 int get precedence => 7; 584 int get precedence => 7;
646 585
647 /** 586 /**
648 * Return the name of the type being cast to. 587 * Return the name of the type being cast to.
649 *
650 * @return the name of the type being cast to
651 */ 588 */
652 TypeName get type => _type; 589 TypeName get type => _type;
653 590
654 /** 591 /**
655 * Set the name of the type being cast to to the given name. 592 * Set the name of the type being cast to to the given [name].
656 *
657 * @param name the name of the type being cast to
658 */ 593 */
659 void set type(TypeName name) { 594 void set type(TypeName name) {
660 _type = becomeParentOf(name); 595 _type = becomeParentOf(name);
661 } 596 }
662 597
663 @override 598 @override
664 accept(AstVisitor visitor) => visitor.visitAsExpression(this); 599 accept(AstVisitor visitor) => visitor.visitAsExpression(this);
665 600
666 @override 601 @override
667 void visitChildren(AstVisitor visitor) { 602 void visitChildren(AstVisitor visitor) {
668 safelyVisitChild(_expression, visitor); 603 _safelyVisitChild(_expression, visitor);
669 safelyVisitChild(_type, visitor); 604 _safelyVisitChild(_type, visitor);
670 } 605 }
671 } 606 }
672 607
673 /** 608 /**
674 * Instances of the class `AssertStatement` represent an assert statement. 609 * An assert statement.
675 * 610 *
676 * <pre> 611 * > assertStatement ::=
677 * assertStatement ::= 612 * > 'assert' '(' [Expression] ')' ';'
678 * 'assert' '(' [Expression] ')' ';'
679 * </pre>
680 */ 613 */
681 class AssertStatement extends Statement { 614 class AssertStatement extends Statement {
682 /** 615 /**
683 * The token representing the 'assert' keyword. 616 * The token representing the 'assert' keyword.
684 */ 617 */
685 Token keyword; 618 Token keyword;
686 619
687 /** 620 /**
688 * The left parenthesis. 621 * The left parenthesis.
689 */ 622 */
690 Token leftParenthesis; 623 Token leftParenthesis;
691 624
692 /** 625 /**
693 * The condition that is being asserted to be `true`. 626 * The condition that is being asserted to be `true`.
694 */ 627 */
695 Expression _condition; 628 Expression _condition;
696 629
697 /** 630 /**
698 * The right parenthesis. 631 * The right parenthesis.
699 */ 632 */
700 Token rightParenthesis; 633 Token rightParenthesis;
701 634
702 /** 635 /**
703 * The semicolon terminating the statement. 636 * The semicolon terminating the statement.
704 */ 637 */
705 Token semicolon; 638 Token semicolon;
706 639
707 /** 640 /**
708 * Initialize a newly created assert statement. 641 * Initialize a newly created assert statement.
709 *
710 * @param keyword the token representing the 'assert' keyword
711 * @param leftParenthesis the left parenthesis
712 * @param condition the condition that is being asserted to be `true`
713 * @param rightParenthesis the right parenthesis
714 * @param semicolon the semicolon terminating the statement
715 */ 642 */
716 AssertStatement(this.keyword, this.leftParenthesis, Expression condition, 643 AssertStatement(this.keyword, this.leftParenthesis, Expression condition,
717 this.rightParenthesis, this.semicolon) { 644 this.rightParenthesis, this.semicolon) {
718 _condition = becomeParentOf(condition); 645 _condition = becomeParentOf(condition);
719 } 646 }
720 647
721 @override 648 @override
722 Token get beginToken => keyword; 649 Token get beginToken => keyword;
723 650
724 /** 651 /**
725 * TODO(paulberry): untested. 652 * TODO(paulberry): untested.
726 */ 653 */
727 @override 654 @override
728 Iterable get childEntities => new ChildEntities() 655 Iterable get childEntities => new ChildEntities()
729 ..add(keyword) 656 ..add(keyword)
730 ..add(leftParenthesis) 657 ..add(leftParenthesis)
731 ..add(_condition) 658 ..add(_condition)
732 ..add(rightParenthesis) 659 ..add(rightParenthesis)
733 ..add(semicolon); 660 ..add(semicolon);
734 661
735 /** 662 /**
736 * Return the condition that is being asserted to be `true`. 663 * Return the condition that is being asserted to be `true`.
737 *
738 * @return the condition that is being asserted to be `true`
739 */ 664 */
740 Expression get condition => _condition; 665 Expression get condition => _condition;
741 666
742 /** 667 /**
743 * Set the condition that is being asserted to be `true` to the given expressi on. 668 * Set the condition that is being asserted to be `true` to the given
744 * 669 * [expression].
745 * @param the condition that is being asserted to be `true`
746 */ 670 */
747 void set condition(Expression condition) { 671 void set condition(Expression condition) {
748 _condition = becomeParentOf(condition); 672 _condition = becomeParentOf(condition);
749 } 673 }
750 674
751 @override 675 @override
752 Token get endToken => semicolon; 676 Token get endToken => semicolon;
753 677
754 @override 678 @override
755 accept(AstVisitor visitor) => visitor.visitAssertStatement(this); 679 accept(AstVisitor visitor) => visitor.visitAssertStatement(this);
756 680
757 @override 681 @override
758 void visitChildren(AstVisitor visitor) { 682 void visitChildren(AstVisitor visitor) {
759 safelyVisitChild(_condition, visitor); 683 _safelyVisitChild(_condition, visitor);
760 } 684 }
761 } 685 }
762 686
763 /** 687 /**
764 * Instances of the class `AssignmentExpression` represent an assignment express ion. 688 * An assignment expression.
765 * 689 *
766 * <pre> 690 * > assignmentExpression ::=
767 * assignmentExpression ::= 691 * > [Expression] operator [Expression]
768 * [Expression] [Token] [Expression]
769 * </pre>
770 */ 692 */
771 class AssignmentExpression extends Expression { 693 class AssignmentExpression extends Expression {
772 /** 694 /**
773 * The expression used to compute the left hand side. 695 * The expression used to compute the left hand side.
774 */ 696 */
775 Expression _leftHandSide; 697 Expression _leftHandSide;
776 698
777 /** 699 /**
778 * The assignment operator being applied. 700 * The assignment operator being applied.
779 */ 701 */
780 Token operator; 702 Token operator;
781 703
782 /** 704 /**
783 * The expression used to compute the right hand side. 705 * The expression used to compute the right hand side.
784 */ 706 */
785 Expression _rightHandSide; 707 Expression _rightHandSide;
786 708
787 /** 709 /**
788 * The element associated with the operator based on the static type of the le ft-hand-side, or 710 * The element associated with the operator based on the static type of the
789 * `null` if the AST structure has not been resolved, if the operator is not a compound 711 * left-hand-side, or `null` if the AST structure has not been resolved, if
790 * operator, or if the operator could not be resolved. 712 * the operator is not a compound operator, or if the operator could not be
713 * resolved.
791 */ 714 */
792 MethodElement staticElement; 715 MethodElement staticElement;
793 716
794 /** 717 /**
795 * The element associated with the operator based on the propagated type of th e left-hand-side, or 718 * The element associated with the operator based on the propagated type of
796 * `null` if the AST structure has not been resolved, if the operator is not a compound 719 * the left-hand-side, or `null` if the AST structure has not been resolved,
797 * operator, or if the operator could not be resolved. 720 * if the operator is not a compound operator, or if the operator could not be
721 * resolved.
798 */ 722 */
799 MethodElement propagatedElement; 723 MethodElement propagatedElement;
800 724
801 /** 725 /**
802 * Initialize a newly created assignment expression. 726 * Initialize a newly created assignment expression.
803 *
804 * @param leftHandSide the expression used to compute the left hand side
805 * @param operator the assignment operator being applied
806 * @param rightHandSide the expression used to compute the right hand side
807 */ 727 */
808 AssignmentExpression(Expression leftHandSide, this.operator, 728 AssignmentExpression(Expression leftHandSide, this.operator,
809 Expression rightHandSide) { 729 Expression rightHandSide) {
810 if (leftHandSide == null || rightHandSide == null) { 730 if (leftHandSide == null || rightHandSide == null) {
811 String message; 731 String message;
812 if (leftHandSide == null) { 732 if (leftHandSide == null) {
813 if (rightHandSide == null) { 733 if (rightHandSide == null) {
814 message = "Both the left-hand and right-hand sides are null"; 734 message = "Both the left-hand and right-hand sides are null";
815 } else { 735 } else {
816 message = "The left-hand size is null"; 736 message = "The left-hand size is null";
817 } 737 }
818 } else { 738 } else {
819 message = "The right-hand size is null"; 739 message = "The right-hand size is null";
820 } 740 }
821 AnalysisEngine.instance.logger.logError( 741 AnalysisEngine.instance.logger.logError(
822 message, 742 message,
823 new CaughtException(new AnalysisException(message), null)); 743 new CaughtException(new AnalysisException(message), null));
824 } 744 }
825 _leftHandSide = becomeParentOf(leftHandSide); 745 _leftHandSide = becomeParentOf(leftHandSide);
826 _rightHandSide = becomeParentOf(rightHandSide); 746 _rightHandSide = becomeParentOf(rightHandSide);
827 } 747 }
828 748
829 @override 749 @override
830 Token get beginToken => _leftHandSide.beginToken; 750 Token get beginToken => _leftHandSide.beginToken;
831 751
832 /** 752 /**
833 * Return the best element available for this operator. If resolution was able to find a better 753 * Return the best element available for this operator. If resolution was able
834 * element based on type propagation, that element will be returned. Otherwise , the element found 754 * to find a better element based on type propagation, that element will be
835 * using the result of static analysis will be returned. If resolution has not been performed, 755 * returned. Otherwise, the element found using the result of static analysis
836 * then `null` will be returned. 756 * will be returned. If resolution has not been performed, then `null` will be
837 * 757 * returned.
838 * @return the best element available for this operator
839 */ 758 */
840 MethodElement get bestElement { 759 MethodElement get bestElement {
841 MethodElement element = propagatedElement; 760 MethodElement element = propagatedElement;
842 if (element == null) { 761 if (element == null) {
843 element = staticElement; 762 element = staticElement;
844 } 763 }
845 return element; 764 return element;
846 } 765 }
847 766
848 @override 767 @override
849 Iterable get childEntities => new ChildEntities() 768 Iterable get childEntities => new ChildEntities()
850 ..add(_leftHandSide) 769 ..add(_leftHandSide)
851 ..add(operator) 770 ..add(operator)
852 ..add(_rightHandSide); 771 ..add(_rightHandSide);
853 772
854 @override 773 @override
855 Token get endToken => _rightHandSide.endToken; 774 Token get endToken => _rightHandSide.endToken;
856 775
857 /** 776 /**
858 * Set the expression used to compute the left hand side to the given expressi on. 777 * Set the expression used to compute the left hand side to the given
859 * 778 * [expression].
860 * @return the expression used to compute the left hand side
861 */ 779 */
862 Expression get leftHandSide => _leftHandSide; 780 Expression get leftHandSide => _leftHandSide;
863 781
864 /** 782 /**
865 * Return the expression used to compute the left hand side. 783 * Return the expression used to compute the left hand side.
866 *
867 * @param expression the expression used to compute the left hand side
868 */ 784 */
869 void set leftHandSide(Expression expression) { 785 void set leftHandSide(Expression expression) {
870 _leftHandSide = becomeParentOf(expression); 786 _leftHandSide = becomeParentOf(expression);
871 } 787 }
872 788
873 @override 789 @override
874 int get precedence => 1; 790 int get precedence => 1;
875 791
876 /** 792 /**
877 * If the AST structure has been resolved, and the function being invoked is k nown based on 793 * If the AST structure has been resolved, and the function being invoked is
878 * propagated type information, then return the parameter element representing the parameter to 794 * known based on propagated type information, then return the parameter
879 * which the value of the right operand will be bound. Otherwise, return `null `. 795 * element representing the parameter to which the value of the right operand
796 * will be bound. Otherwise, return `null`.
880 * 797 *
881 * This method is only intended to be used by [Expression.propagatedParameterE lement]. 798 * This method is only intended to be used by
882 * 799 * [Expression.propagatedParameterElement].
883 * @return the parameter element representing the parameter to which the value of the right
884 * operand will be bound
885 */ 800 */
886 ParameterElement get propagatedParameterElementForRightHandSide { 801 ParameterElement get propagatedParameterElementForRightHandSide {
887 ExecutableElement executableElement = null; 802 ExecutableElement executableElement = null;
888 if (propagatedElement != null) { 803 if (propagatedElement != null) {
889 executableElement = propagatedElement; 804 executableElement = propagatedElement;
890 } else { 805 } else {
891 if (_leftHandSide is Identifier) { 806 if (_leftHandSide is Identifier) {
892 Identifier identifier = _leftHandSide as Identifier; 807 Identifier identifier = _leftHandSide as Identifier;
893 Element leftElement = identifier.propagatedElement; 808 Element leftElement = identifier.propagatedElement;
894 if (leftElement is ExecutableElement) { 809 if (leftElement is ExecutableElement) {
(...skipping 14 matching lines...) Expand all
909 } 824 }
910 List<ParameterElement> parameters = executableElement.parameters; 825 List<ParameterElement> parameters = executableElement.parameters;
911 if (parameters.length < 1) { 826 if (parameters.length < 1) {
912 return null; 827 return null;
913 } 828 }
914 return parameters[0]; 829 return parameters[0];
915 } 830 }
916 831
917 /** 832 /**
918 * Return the expression used to compute the right hand side. 833 * Return the expression used to compute the right hand side.
919 *
920 * @return the expression used to compute the right hand side
921 */ 834 */
922 Expression get rightHandSide => _rightHandSide; 835 Expression get rightHandSide => _rightHandSide;
923 836
924 /** 837 /**
925 * Set the expression used to compute the left hand side to the given expressi on. 838 * Set the expression used to compute the left hand side to the given
926 * 839 * [expression].
927 * @param expression the expression used to compute the left hand side
928 */ 840 */
929 void set rightHandSide(Expression expression) { 841 void set rightHandSide(Expression expression) {
930 _rightHandSide = becomeParentOf(expression); 842 _rightHandSide = becomeParentOf(expression);
931 } 843 }
932 844
933 /** 845 /**
934 * If the AST structure has been resolved, and the function being invoked is k nown based on static 846 * If the AST structure has been resolved, and the function being invoked is
935 * type information, then return the parameter element representing the parame ter to which the 847 * known based on static type information, then return the parameter element
936 * value of the right operand will be bound. Otherwise, return `null`. 848 * representing the parameter to which the value of the right operand will be
849 * bound. Otherwise, return `null`.
937 * 850 *
938 * This method is only intended to be used by [Expression.staticParameterEleme nt]. 851 * This method is only intended to be used by
939 * 852 * [Expression.staticParameterElement].
940 * @return the parameter element representing the parameter to which the value of the right
941 * operand will be bound
942 */ 853 */
943 ParameterElement get staticParameterElementForRightHandSide { 854 ParameterElement get staticParameterElementForRightHandSide {
944 ExecutableElement executableElement = null; 855 ExecutableElement executableElement = null;
945 if (staticElement != null) { 856 if (staticElement != null) {
946 executableElement = staticElement; 857 executableElement = staticElement;
947 } else { 858 } else {
948 if (_leftHandSide is Identifier) { 859 if (_leftHandSide is Identifier) {
949 Element leftElement = (_leftHandSide as Identifier).staticElement; 860 Element leftElement = (_leftHandSide as Identifier).staticElement;
950 if (leftElement is ExecutableElement) { 861 if (leftElement is ExecutableElement) {
951 executableElement = leftElement; 862 executableElement = leftElement;
(...skipping 15 matching lines...) Expand all
967 return null; 878 return null;
968 } 879 }
969 return parameters[0]; 880 return parameters[0];
970 } 881 }
971 882
972 @override 883 @override
973 accept(AstVisitor visitor) => visitor.visitAssignmentExpression(this); 884 accept(AstVisitor visitor) => visitor.visitAssignmentExpression(this);
974 885
975 @override 886 @override
976 void visitChildren(AstVisitor visitor) { 887 void visitChildren(AstVisitor visitor) {
977 safelyVisitChild(_leftHandSide, visitor); 888 _safelyVisitChild(_leftHandSide, visitor);
978 safelyVisitChild(_rightHandSide, visitor); 889 _safelyVisitChild(_rightHandSide, visitor);
979 } 890 }
980 } 891 }
981 892
982 /** 893 /**
983 * An `AstCloner` is an AST visitor that will clone any AST structure that it 894 * An AST visitor that will clone any AST structure that it visits. The cloner
984 * visits. The cloner will only clone the structure, it will not preserve any 895 * will only clone the structure, it will not preserve any resolution results or
985 * resolution results or properties associated with the nodes. 896 * properties associated with the nodes.
986 */ 897 */
987 class AstCloner implements AstVisitor<AstNode> { 898 class AstCloner implements AstVisitor<AstNode> {
988 /** 899 /**
989 * A flag indicating whether tokens should be cloned while cloning an AST 900 * A flag indicating whether tokens should be cloned while cloning an AST
990 * structure. 901 * structure.
991 */ 902 */
992 final bool cloneTokens; 903 final bool cloneTokens;
993 904
994 /** 905 /**
995 * Initialize a newly created AST cloner to optionally clone tokens while 906 * Initialize a newly created AST cloner to optionally clone tokens while
996 * cloning AST nodes if [cloneTokens] is `true`. 907 * cloning AST nodes if [cloneTokens] is `true`.
997 */ 908 */
909 // TODO(brianwilkerson) Change this to be a named parameter.
998 AstCloner([this.cloneTokens = false]); 910 AstCloner([this.cloneTokens = false]);
999 911
1000 /** 912 /**
1001 * Return a clone of the given [node]. 913 * Return a clone of the given [node].
1002 */ 914 */
1003 AstNode cloneNode(AstNode node) { 915 AstNode cloneNode(AstNode node) {
1004 if (node == null) { 916 if (node == null) {
1005 return null; 917 return null;
1006 } 918 }
1007 return node.accept(this) as AstNode; 919 return node.accept(this) as AstNode;
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 @override 1789 @override
1878 YieldStatement visitYieldStatement(YieldStatement node) => 1790 YieldStatement visitYieldStatement(YieldStatement node) =>
1879 new YieldStatement( 1791 new YieldStatement(
1880 cloneToken(node.yieldKeyword), 1792 cloneToken(node.yieldKeyword),
1881 cloneToken(node.star), 1793 cloneToken(node.star),
1882 cloneNode(node.expression), 1794 cloneNode(node.expression),
1883 cloneToken(node.semicolon)); 1795 cloneToken(node.semicolon));
1884 } 1796 }
1885 1797
1886 /** 1798 /**
1887 * An `AstComparator` compares the structure of two AstNodes to see whether 1799 * An AstVisitor that compares the structure of two AstNodes to see whether they
1888 * they are equal. 1800 * are equal.
1889 */ 1801 */
1890 class AstComparator implements AstVisitor<bool> { 1802 class AstComparator implements AstVisitor<bool> {
1891 /** 1803 /**
1892 * The AST node with which the node being visited is to be compared. This is o nly valid at the 1804 * The AST node with which the node being visited is to be compared. This is
1893 * beginning of each visit method (until [isEqualNodes] is invoked). 1805 * only valid at the beginning of each visit method (until [isEqualNodes] is
1806 * invoked).
1894 */ 1807 */
1895 AstNode _other; 1808 AstNode _other;
1896 1809
1897 /** 1810 /**
1898 * Return `true` if the [first] node and the [second] node have the same 1811 * Return `true` if the [first] node and the [second] node have the same
1899 * structure. 1812 * structure.
1900 * 1813 *
1901 * *Note:* This method is only visible for testing purposes and should not be 1814 * *Note:* This method is only visible for testing purposes and should not be
1902 * used by clients. 1815 * used by clients.
1903 */ 1816 */
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
2906 2819
2907 @override 2820 @override
2908 bool visitYieldStatement(YieldStatement node) { 2821 bool visitYieldStatement(YieldStatement node) {
2909 YieldStatement other = _other as YieldStatement; 2822 YieldStatement other = _other as YieldStatement;
2910 return isEqualTokens(node.yieldKeyword, other.yieldKeyword) && 2823 return isEqualTokens(node.yieldKeyword, other.yieldKeyword) &&
2911 isEqualNodes(node.expression, other.expression) && 2824 isEqualNodes(node.expression, other.expression) &&
2912 isEqualTokens(node.semicolon, other.semicolon); 2825 isEqualTokens(node.semicolon, other.semicolon);
2913 } 2826 }
2914 2827
2915 /** 2828 /**
2916 * Return `true` if the given lists of AST nodes have the same size and corres ponding 2829 * Return `true` if the [first] and [second] lists of AST nodes have the same
2917 * elements are equal. 2830 * size and corresponding elements are equal.
2918 *
2919 * @param first the first node being compared
2920 * @param second the second node being compared
2921 * @return `true` if the given AST nodes have the same size and corresponding elements are
2922 * equal
2923 */ 2831 */
2924 bool _isEqualNodeLists(NodeList first, NodeList second) { 2832 bool _isEqualNodeLists(NodeList first, NodeList second) {
2925 if (first == null) { 2833 if (first == null) {
2926 return second == null; 2834 return second == null;
2927 } else if (second == null) { 2835 } else if (second == null) {
2928 return false; 2836 return false;
2929 } 2837 }
2930 int size = first.length; 2838 int size = first.length;
2931 if (second.length != size) { 2839 if (second.length != size) {
2932 return false; 2840 return false;
2933 } 2841 }
2934 for (int i = 0; i < size; i++) { 2842 for (int i = 0; i < size; i++) {
2935 if (!isEqualNodes(first[i], second[i])) { 2843 if (!isEqualNodes(first[i], second[i])) {
2936 return false; 2844 return false;
2937 } 2845 }
2938 } 2846 }
2939 return true; 2847 return true;
2940 } 2848 }
2941 2849
2942 /** 2850 /**
2943 * Return `true` if the given arrays of tokens have the same length and corres ponding 2851 * Return `true` if the [first] and [second] lists of tokens have the same
2944 * elements are equal. 2852 * length and corresponding elements are equal.
2945 *
2946 * @param first the first node being compared
2947 * @param second the second node being compared
2948 * @return `true` if the given arrays of tokens have the same length and corre sponding
2949 * elements are equal
2950 */ 2853 */
2951 bool _isEqualTokenLists(List<Token> first, List<Token> second) { 2854 bool _isEqualTokenLists(List<Token> first, List<Token> second) {
2952 int length = first.length; 2855 int length = first.length;
2953 if (second.length != length) { 2856 if (second.length != length) {
2954 return false; 2857 return false;
2955 } 2858 }
2956 for (int i = 0; i < length; i++) { 2859 for (int i = 0; i < length; i++) {
2957 if (!isEqualTokens(first[i], second[i])) { 2860 if (!isEqualTokens(first[i], second[i])) {
2958 return false; 2861 return false;
2959 } 2862 }
2960 } 2863 }
2961 return true; 2864 return true;
2962 } 2865 }
2963 2866
2964 /** 2867 /**
2965 * Return `true` if the [first] node and the [second] node are equal. 2868 * Return `true` if the [first] and [second] nodes are equal.
2966 */ 2869 */
2967 static bool equalNodes(AstNode first, AstNode second) { 2870 static bool equalNodes(AstNode first, AstNode second) {
2968 AstComparator comparator = new AstComparator(); 2871 AstComparator comparator = new AstComparator();
2969 return comparator.isEqualNodes(first, second); 2872 return comparator.isEqualNodes(first, second);
2970 } 2873 }
2971 } 2874 }
2972 2875
2973 /** 2876 /**
2974 * The abstract class `AstNode` defines the behavior common to all nodes in the AST structure 2877 * A node in the AST structure for a Dart program.
2975 * for a Dart program.
2976 */ 2878 */
2977 abstract class AstNode { 2879 abstract class AstNode {
2978 /** 2880 /**
2979 * An empty array of ast nodes. 2881 * An empty list of ast nodes.
2980 */ 2882 */
2981 static const List<AstNode> EMPTY_ARRAY = const <AstNode>[]; 2883 static const List<AstNode> EMPTY_ARRAY = const <AstNode>[];
2982 2884
2983 /** 2885 /**
2984 * A comparator that can be used to sort AST nodes in lexical order. In other words, 2886 * A comparator that can be used to sort AST nodes in lexical order. In other
2985 * `compare` will return a negative value if the offset of the first node is l ess than the 2887 * words, `compare` will return a negative value if the offset of the first
2986 * offset of the second node, zero (0) if the nodes have the same offset, and a positive value if 2888 * node is less than the offset of the second node, zero (0) if the nodes have
2987 * if the offset of the first node is greater than the offset of the second no de. 2889 * the same offset, and a positive value if if the offset of the first node is
2890 * greater than the offset of the second node.
2988 */ 2891 */
2989 static Comparator<AstNode> LEXICAL_ORDER = 2892 static Comparator<AstNode> LEXICAL_ORDER =
2990 (AstNode first, AstNode second) => second.offset - first.offset; 2893 (AstNode first, AstNode second) => second.offset - first.offset;
2991 2894
2992 /** 2895 /**
2993 * The parent of the node, or `null` if the node is the root of an AST structu re. 2896 * The parent of the node, or `null` if the node is the root of an AST
2897 * structure.
2994 */ 2898 */
2995 AstNode _parent; 2899 AstNode _parent;
2996 2900
2997 /** 2901 /**
2998 * A table mapping the names of properties to their values, or `null` if this node does not 2902 * A table mapping the names of properties to their values, or `null` if this
2999 * have any properties associated with it. 2903 * node does not have any properties associated with it.
3000 */ 2904 */
3001 Map<String, Object> _propertyMap; 2905 Map<String, Object> _propertyMap;
3002 2906
3003 /** 2907 /**
3004 * Return the first token included in this node's source range. 2908 * Return the first token included in this node's source range.
3005 *
3006 * @return the first token included in this node's source range
3007 */ 2909 */
3008 Token get beginToken; 2910 Token get beginToken;
3009 2911
3010 /** 2912 /**
3011 * Iterate through all the entities (either AST nodes or tokens) which make 2913 * Iterate through all the entities (either AST nodes or tokens) which make
3012 * up the contents of this node, including doc comments but excluding other 2914 * up the contents of this node, including doc comments but excluding other
3013 * comments. 2915 * comments.
3014 */ 2916 */
3015 Iterable get childEntities; 2917 Iterable /*<AstNode | Token>*/ get childEntities;
3016 2918
3017 /** 2919 /**
3018 * Return the offset of the character immediately following the last character of this node's 2920 * Return the offset of the character immediately following the last character
3019 * source range. This is equivalent to `node.getOffset() + node.getLength()`. For a 2921 * of this node's source range. This is equivalent to
3020 * compilation unit this will be equal to the length of the unit's source. For synthetic nodes 2922 * `node.getOffset() + node.getLength()`. For a compilation unit this will be
3021 * this will be equivalent to the node's offset (because the length is zero (0 ) by definition). 2923 * equal to the length of the unit's source. For synthetic nodes this will be
3022 * 2924 * equivalent to the node's offset (because the length is zero (0) by
3023 * @return the offset of the character just past the node's source range 2925 * definition).
3024 */ 2926 */
3025 int get end => offset + length; 2927 int get end => offset + length;
3026 2928
3027 /** 2929 /**
3028 * Return the last token included in this node's source range. 2930 * Return the last token included in this node's source range.
3029 *
3030 * @return the last token included in this node's source range
3031 */ 2931 */
3032 Token get endToken; 2932 Token get endToken;
3033 2933
3034 /** 2934 /**
3035 * Return `true` if this node is a synthetic node. A synthetic node is a node that was 2935 * Return `true` if this node is a synthetic node. A synthetic node is a node
3036 * introduced by the parser in order to recover from an error in the code. Syn thetic nodes always 2936 * that was introduced by the parser in order to recover from an error in the
3037 * have a length of zero (`0`). 2937 * code. Synthetic nodes always have a length of zero (`0`).
3038 *
3039 * @return `true` if this node is a synthetic node
3040 */ 2938 */
3041 bool get isSynthetic => false; 2939 bool get isSynthetic => false;
3042 2940
3043 /** 2941 /**
3044 * Return the number of characters in the node's source range. 2942 * Return the number of characters in the node's source range.
3045 *
3046 * @return the number of characters in the node's source range
3047 */ 2943 */
3048 int get length { 2944 int get length {
3049 Token beginToken = this.beginToken; 2945 Token beginToken = this.beginToken;
3050 Token endToken = this.endToken; 2946 Token endToken = this.endToken;
3051 if (beginToken == null || endToken == null) { 2947 if (beginToken == null || endToken == null) {
3052 return -1; 2948 return -1;
3053 } 2949 }
3054 return endToken.offset + endToken.length - beginToken.offset; 2950 return endToken.offset + endToken.length - beginToken.offset;
3055 } 2951 }
3056 2952
3057 /** 2953 /**
3058 * Return the offset from the beginning of the file to the first character in the node's source 2954 * Return the offset from the beginning of the file to the first character in
3059 * range. 2955 * the node's source range.
3060 *
3061 * @return the offset from the beginning of the file to the first character in the node's source
3062 * range
3063 */ 2956 */
3064 int get offset { 2957 int get offset {
3065 Token beginToken = this.beginToken; 2958 Token beginToken = this.beginToken;
3066 if (beginToken == null) { 2959 if (beginToken == null) {
3067 return -1; 2960 return -1;
3068 } 2961 }
3069 return beginToken.offset; 2962 return beginToken.offset;
3070 } 2963 }
3071 2964
3072 /** 2965 /**
3073 * Return this node's parent node, or `null` if this node is the root of an AS T structure. 2966 * Return this node's parent node, or `null` if this node is the root of an
2967 * AST structure.
3074 * 2968 *
3075 * Note that the relationship between an AST node and its parent node may chan ge over the lifetime 2969 * Note that the relationship between an AST node and its parent node may
3076 * of a node. 2970 * change over the lifetime of a node.
3077 *
3078 * @return the parent of this node, or `null` if none
3079 */ 2971 */
3080 AstNode get parent => _parent; 2972 AstNode get parent => _parent;
3081 2973
3082 /** 2974 /**
3083 * Set the parent of this node to the given node. 2975 * Set the parent of this node to the [newParent].
3084 *
3085 * @param newParent the node that is to be made the parent of this node
3086 */ 2976 */
3087 @deprecated 2977 @deprecated
3088 void set parent(AstNode newParent) { 2978 void set parent(AstNode newParent) {
3089 _parent = newParent; 2979 _parent = newParent;
3090 } 2980 }
3091 2981
3092 /** 2982 /**
3093 * Return the node at the root of this node's AST structure. Note that this me thod's performance 2983 * Return the node at the root of this node's AST structure. Note that this
3094 * is linear with respect to the depth of the node in the AST structure (O(dep th)). 2984 * method's performance is linear with respect to the depth of the node in the
3095 * 2985 * AST structure (O(depth)).
3096 * @return the node at the root of this node's AST structure
3097 */ 2986 */
3098 AstNode get root { 2987 AstNode get root {
3099 AstNode root = this; 2988 AstNode root = this;
3100 AstNode parent = this.parent; 2989 AstNode parent = this.parent;
3101 while (parent != null) { 2990 while (parent != null) {
3102 root = parent; 2991 root = parent;
3103 parent = root.parent; 2992 parent = root.parent;
3104 } 2993 }
3105 return root; 2994 return root;
3106 } 2995 }
3107 2996
3108 /** 2997 /**
3109 * Use the given visitor to visit this node. 2998 * Use the given [visitor] to visit this node. Return the value returned by
3110 * 2999 * the visitor as a result of visiting this node.
3111 * @param visitor the visitor that will visit this node
3112 * @return the value returned by the visitor as a result of visiting this node
3113 */ 3000 */
3114 accept(AstVisitor visitor); 3001 /* <E> E */ accept(AstVisitor /*<E>*/ visitor);
3115 3002
3116 /** 3003 /**
3117 * Make this node the parent of the given child node. 3004 * Make this node the parent of the given [child] node. Return the child node.
3118 *
3119 * @param child the node that will become a child of this node
3120 * @return the node that was made a child of this node
3121 */ 3005 */
3122 AstNode becomeParentOf(AstNode child) { 3006 AstNode becomeParentOf(AstNode child) {
3123 if (child != null) { 3007 if (child != null) {
3124 child._parent = this; 3008 child._parent = this;
3125 } 3009 }
3126 return child; 3010 return child;
3127 } 3011 }
3128 3012
3129 /** 3013 /**
3130 * Return the node of the given class that most immediately encloses this node , or `null` if 3014 * Return the most immediate ancestor of this node for which the [predicate]
3131 * there is no enclosing node of the given class. 3015 * returns `true`, or `null` if there is no such ancestor. Note that this node
3132 * 3016 * will never be returned.
3133 * @param nodeClass the class of the node to be returned
3134 * @return the node of the given type that encloses this node
3135 */ 3017 */
3136 AstNode getAncestor(Predicate<AstNode> predicate) { 3018 AstNode getAncestor(Predicate<AstNode> predicate) {
3019 // TODO(brianwilkerson) It is a bug that this method can return `this`.
3137 AstNode node = this; 3020 AstNode node = this;
3138 while (node != null && !predicate(node)) { 3021 while (node != null && !predicate(node)) {
3139 node = node.parent; 3022 node = node.parent;
3140 } 3023 }
3141 return node; 3024 return node;
3142 } 3025 }
3143 3026
3144 /** 3027 /**
3145 * Return the value of the property with the given name, or `null` if this nod e does not 3028 * Return the value of the property with the given [name], or `null` if this
3146 * have a property with the given name. 3029 * node does not have a property with the given name.
3147 *
3148 * @return the value of the property with the given name
3149 */ 3030 */
3150 Object getProperty(String propertyName) { 3031 Object getProperty(String name) {
3151 if (_propertyMap == null) { 3032 if (_propertyMap == null) {
3152 return null; 3033 return null;
3153 } 3034 }
3154 return _propertyMap[propertyName]; 3035 return _propertyMap[name];
3155 } 3036 }
3156 3037
3157 /** 3038 /**
3158 * If the given child is not `null`, use the given visitor to visit it. 3039 * If the given [child] is not `null`, use the given [visitor] to visit it.
3159 *
3160 * @param child the child to be visited
3161 * @param visitor the visitor that will be used to visit the child
3162 */ 3040 */
3041 @deprecated
3163 void safelyVisitChild(AstNode child, AstVisitor visitor) { 3042 void safelyVisitChild(AstNode child, AstVisitor visitor) {
3164 if (child != null) { 3043 if (child != null) {
3165 child.accept(visitor); 3044 child.accept(visitor);
3166 } 3045 }
3167 } 3046 }
3168 3047
3169 /** 3048 /**
3170 * Set the value of the property with the given name to the given value. If th e value is 3049 * Set the value of the property with the given [name] to the given [value].
3171 * `null`, the property will effectively be removed. 3050 * If the value is `null`, the property will effectively be removed.
3172 *
3173 * @param propertyName the name of the property whose value is to be set
3174 * @param propertyValue the new value of the property
3175 */ 3051 */
3176 void setProperty(String propertyName, Object propertyValue) { 3052 void setProperty(String name, Object value) {
3177 if (propertyValue == null) { 3053 if (value == null) {
3178 if (_propertyMap != null) { 3054 if (_propertyMap != null) {
3179 _propertyMap.remove(propertyName); 3055 _propertyMap.remove(name);
3180 if (_propertyMap.isEmpty) { 3056 if (_propertyMap.isEmpty) {
3181 _propertyMap = null; 3057 _propertyMap = null;
3182 } 3058 }
3183 } 3059 }
3184 } else { 3060 } else {
3185 if (_propertyMap == null) { 3061 if (_propertyMap == null) {
3186 _propertyMap = new HashMap<String, Object>(); 3062 _propertyMap = new HashMap<String, Object>();
3187 } 3063 }
3188 _propertyMap[propertyName] = propertyValue; 3064 _propertyMap[name] = value;
3189 } 3065 }
3190 } 3066 }
3191 3067
3192 /** 3068 /**
3193 * Return a textual description of this node in a form approximating valid sou rce. The returned 3069 * Return a textual description of this node in a form approximating valid
3194 * string will not be valid source primarily in the case where the node itself is not well-formed. 3070 * source. The returned string will not be valid source primarily in the case
3195 * 3071 * where the node itself is not well-formed.
3196 * @return the source code equivalent of this node
3197 */ 3072 */
3198 String toSource() { 3073 String toSource() {
3199 PrintStringWriter writer = new PrintStringWriter(); 3074 PrintStringWriter writer = new PrintStringWriter();
3200 accept(new ToSourceVisitor(writer)); 3075 accept(new ToSourceVisitor(writer));
3201 return writer.toString(); 3076 return writer.toString();
3202 } 3077 }
3203 3078
3204 @override 3079 @override
3205 String toString() => toSource(); 3080 String toString() => toSource();
3206 3081
3207 /** 3082 /**
3208 * Use the given visitor to visit all of the children of this node. The childr en will be visited 3083 * Use the given [visitor] to visit all of the children of this node. The
3209 * in source order. 3084 * children will be visited in lexical order.
3210 *
3211 * @param visitor the visitor that will be used to visit the children of this node
3212 */ 3085 */
3213 void visitChildren(AstVisitor visitor); 3086 void visitChildren(AstVisitor visitor);
3087
3088 /**
3089 * If the given [child] is not `null`, use the given [visitor] to visit it.
3090 */
3091 void _safelyVisitChild(AstNode child, AstVisitor visitor) {
3092 if (child != null) {
3093 child.accept(visitor);
3094 }
3095 }
3214 } 3096 }
3215 3097
3216 /** 3098 /**
3217 * The interface `AstVisitor` defines the behavior of objects that can be used t o visit an AST 3099 * An object that can be used to visit an AST structure.
3218 * structure.
3219 */ 3100 */
3220 abstract class AstVisitor<R> { 3101 abstract class AstVisitor<R> {
3221 R visitAdjacentStrings(AdjacentStrings node); 3102 R visitAdjacentStrings(AdjacentStrings node);
3222 3103
3223 R visitAnnotation(Annotation node); 3104 R visitAnnotation(Annotation node);
3224 3105
3225 R visitArgumentList(ArgumentList node); 3106 R visitArgumentList(ArgumentList node);
3226 3107
3227 R visitAsExpression(AsExpression node); 3108 R visitAsExpression(AsExpression node);
3228 3109
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
3426 R visitVariableDeclarationStatement(VariableDeclarationStatement node); 3307 R visitVariableDeclarationStatement(VariableDeclarationStatement node);
3427 3308
3428 R visitWhileStatement(WhileStatement node); 3309 R visitWhileStatement(WhileStatement node);
3429 3310
3430 R visitWithClause(WithClause node); 3311 R visitWithClause(WithClause node);
3431 3312
3432 R visitYieldStatement(YieldStatement node); 3313 R visitYieldStatement(YieldStatement node);
3433 } 3314 }
3434 3315
3435 /** 3316 /**
3436 * Instances of the class `AwaitExpression` implement an await expression. 3317 * An await expression.
3318 *
3319 * > awaitExpression ::=
3320 * > 'await' [Expression]
3437 */ 3321 */
3438 class AwaitExpression extends Expression { 3322 class AwaitExpression extends Expression {
3439 /** 3323 /**
3440 * The 'await' keyword. 3324 * The 'await' keyword.
3441 */ 3325 */
3442 Token awaitKeyword; 3326 Token awaitKeyword;
3443 3327
3444 /** 3328 /**
3445 * The expression whose value is being waited on. 3329 * The expression whose value is being waited on.
3446 */ 3330 */
3447 Expression _expression; 3331 Expression _expression;
3448 3332
3449 /** 3333 /**
3450 * Initialize a newly created await expression. 3334 * Initialize a newly created await expression.
3451 *
3452 * @param awaitKeyword the 'await' keyword
3453 * @param expression the expression whose value is being waited on
3454 */ 3335 */
3455 AwaitExpression(this.awaitKeyword, Expression expression) { 3336 AwaitExpression(this.awaitKeyword, Expression expression) {
3456 _expression = becomeParentOf(expression); 3337 _expression = becomeParentOf(expression);
3457 } 3338 }
3458 3339
3459 @override 3340 @override
3460 Token get beginToken { 3341 Token get beginToken {
3461 if (awaitKeyword != null) { 3342 if (awaitKeyword != null) {
3462 return awaitKeyword; 3343 return awaitKeyword;
3463 } 3344 }
3464 return _expression.beginToken; 3345 return _expression.beginToken;
3465 } 3346 }
3466 3347
3467 @override 3348 @override
3468 Iterable get childEntities => new ChildEntities() 3349 Iterable get childEntities => new ChildEntities()
3469 ..add(awaitKeyword) 3350 ..add(awaitKeyword)
3470 ..add(_expression); 3351 ..add(_expression);
3471 3352
3472 @override 3353 @override
3473 Token get endToken => _expression.endToken; 3354 Token get endToken => _expression.endToken;
3474 3355
3475 /** 3356 /**
3476 * Return the expression whose value is being waited on. 3357 * Return the expression whose value is being waited on.
3477 *
3478 * @return the expression whose value is being waited on
3479 */ 3358 */
3480 Expression get expression => _expression; 3359 Expression get expression => _expression;
3481 3360
3482 /** 3361 /**
3483 * Set the expression whose value is being waited on to the given expression. 3362 * Set the expression whose value is being waited on to the given [expression] .
3484 *
3485 * @param expression the expression whose value is being waited on
3486 */ 3363 */
3487 void set expression(Expression expression) { 3364 void set expression(Expression expression) {
3488 _expression = becomeParentOf(expression); 3365 _expression = becomeParentOf(expression);
3489 } 3366 }
3490 3367
3491 @override 3368 @override
3492 int get precedence => 0; 3369 int get precedence => 0;
3493 3370
3494 @override 3371 @override
3495 accept(AstVisitor visitor) => visitor.visitAwaitExpression(this); 3372 accept(AstVisitor visitor) => visitor.visitAwaitExpression(this);
3496 3373
3497 @override 3374 @override
3498 void visitChildren(AstVisitor visitor) { 3375 void visitChildren(AstVisitor visitor) {
3499 safelyVisitChild(_expression, visitor); 3376 _safelyVisitChild(_expression, visitor);
3500 } 3377 }
3501 } 3378 }
3502 3379
3503 /** 3380 /**
3504 * Instances of the class `BinaryExpression` represent a binary (infix) expressi on. 3381 * A binary (infix) expression.
3505 * 3382 *
3506 * <pre> 3383 * > binaryExpression ::=
3507 * binaryExpression ::= 3384 * > [Expression] [Token] [Expression]
3508 * [Expression] [Token] [Expression]
3509 * </pre>
3510 */ 3385 */
3511 class BinaryExpression extends Expression { 3386 class BinaryExpression extends Expression {
3512 /** 3387 /**
3513 * The expression used to compute the left operand. 3388 * The expression used to compute the left operand.
3514 */ 3389 */
3515 Expression _leftOperand; 3390 Expression _leftOperand;
3516 3391
3517 /** 3392 /**
3518 * The binary operator being applied. 3393 * The binary operator being applied.
3519 */ 3394 */
3520 Token operator; 3395 Token operator;
3521 3396
3522 /** 3397 /**
3523 * The expression used to compute the right operand. 3398 * The expression used to compute the right operand.
3524 */ 3399 */
3525 Expression _rightOperand; 3400 Expression _rightOperand;
3526 3401
3527 /** 3402 /**
3528 * The element associated with the operator based on the static type of the le ft operand, or 3403 * The element associated with the operator based on the static type of the
3529 * `null` if the AST structure has not been resolved, if the operator is not u ser definable, 3404 * left operand, or `null` if the AST structure has not been resolved, if the
3530 * or if the operator could not be resolved. 3405 * operator is not user definable, or if the operator could not be resolved.
3531 */ 3406 */
3532 MethodElement staticElement; 3407 MethodElement staticElement;
3533 3408
3534 /** 3409 /**
3535 * The element associated with the operator based on the propagated type of th e left operand, or 3410 * The element associated with the operator based on the propagated type of
3536 * `null` if the AST structure has not been resolved, if the operator is not u ser definable, 3411 * the left operand, or `null` if the AST structure has not been resolved, if
3537 * or if the operator could not be resolved. 3412 * the operator is not user definable, or if the operator could not be
3413 * resolved.
3538 */ 3414 */
3539 MethodElement propagatedElement; 3415 MethodElement propagatedElement;
3540 3416
3541 /** 3417 /**
3542 * Initialize a newly created binary expression. 3418 * Initialize a newly created binary expression.
3543 *
3544 * @param leftOperand the expression used to compute the left operand
3545 * @param operator the binary operator being applied
3546 * @param rightOperand the expression used to compute the right operand
3547 */ 3419 */
3548 BinaryExpression(Expression leftOperand, this.operator, 3420 BinaryExpression(Expression leftOperand, this.operator,
3549 Expression rightOperand) { 3421 Expression rightOperand) {
3550 _leftOperand = becomeParentOf(leftOperand); 3422 _leftOperand = becomeParentOf(leftOperand);
3551 _rightOperand = becomeParentOf(rightOperand); 3423 _rightOperand = becomeParentOf(rightOperand);
3552 } 3424 }
3553 3425
3554 @override 3426 @override
3555 Token get beginToken => _leftOperand.beginToken; 3427 Token get beginToken => _leftOperand.beginToken;
3556 3428
3557 /** 3429 /**
3558 * Return the best element available for this operator. If resolution was able to find a better 3430 * Return the best element available for this operator. If resolution was able
3559 * element based on type propagation, that element will be returned. Otherwise , the element found 3431 * to find a better element based on type propagation, that element will be
3560 * using the result of static analysis will be returned. If resolution has not been performed, 3432 * returned. Otherwise, the element found using the result of static analysis
3561 * then `null` will be returned. 3433 * will be returned. If resolution has not been performed, then `null` will be
3562 * 3434 * returned.
3563 * @return the best element available for this operator
3564 */ 3435 */
3565 MethodElement get bestElement { 3436 MethodElement get bestElement {
3566 MethodElement element = propagatedElement; 3437 MethodElement element = propagatedElement;
3567 if (element == null) { 3438 if (element == null) {
3568 element = staticElement; 3439 element = staticElement;
3569 } 3440 }
3570 return element; 3441 return element;
3571 } 3442 }
3572 3443
3573 @override 3444 @override
3574 Iterable get childEntities => new ChildEntities() 3445 Iterable get childEntities => new ChildEntities()
3575 ..add(_leftOperand) 3446 ..add(_leftOperand)
3576 ..add(operator) 3447 ..add(operator)
3577 ..add(_rightOperand); 3448 ..add(_rightOperand);
3578 3449
3579 @override 3450 @override
3580 Token get endToken => _rightOperand.endToken; 3451 Token get endToken => _rightOperand.endToken;
3581 3452
3582 /** 3453 /**
3583 * Return the expression used to compute the left operand. 3454 * Return the expression used to compute the left operand.
3584 *
3585 * @return the expression used to compute the left operand
3586 */ 3455 */
3587 Expression get leftOperand => _leftOperand; 3456 Expression get leftOperand => _leftOperand;
3588 3457
3589 /** 3458 /**
3590 * Set the expression used to compute the left operand to the given expression . 3459 * Set the expression used to compute the left operand to the given
3591 * 3460 * [expression].
3592 * @param expression the expression used to compute the left operand
3593 */ 3461 */
3594 void set leftOperand(Expression expression) { 3462 void set leftOperand(Expression expression) {
3595 _leftOperand = becomeParentOf(expression); 3463 _leftOperand = becomeParentOf(expression);
3596 } 3464 }
3597 3465
3598 @override 3466 @override
3599 int get precedence => operator.type.precedence; 3467 int get precedence => operator.type.precedence;
3600 3468
3601 /** 3469 /**
3602 * If the AST structure has been resolved, and the function being invoked is k nown based on 3470 * If the AST structure has been resolved, and the function being invoked is
3603 * propagated type information, then return the parameter element representing the parameter to 3471 * known based on propagated type information, then return the parameter
3604 * which the value of the right operand will be bound. Otherwise, return `null `. 3472 * element representing the parameter to which the value of the right operand
3473 * will be bound. Otherwise, return `null`.
3605 * 3474 *
3606 * This method is only intended to be used by [Expression.propagatedParameterE lement]. 3475 * This method is only intended to be used by
3607 * 3476 * [Expression.propagatedParameterElement].
3608 * @return the parameter element representing the parameter to which the value of the right
3609 * operand will be bound
3610 */ 3477 */
3611 ParameterElement get propagatedParameterElementForRightOperand { 3478 ParameterElement get propagatedParameterElementForRightOperand {
3612 if (propagatedElement == null) { 3479 if (propagatedElement == null) {
3613 return null; 3480 return null;
3614 } 3481 }
3615 List<ParameterElement> parameters = propagatedElement.parameters; 3482 List<ParameterElement> parameters = propagatedElement.parameters;
3616 if (parameters.length < 1) { 3483 if (parameters.length < 1) {
3617 return null; 3484 return null;
3618 } 3485 }
3619 return parameters[0]; 3486 return parameters[0];
3620 } 3487 }
3621 3488
3622 /** 3489 /**
3623 * Return the expression used to compute the right operand. 3490 * Return the expression used to compute the right operand.
3624 *
3625 * @return the expression used to compute the right operand
3626 */ 3491 */
3627 Expression get rightOperand => _rightOperand; 3492 Expression get rightOperand => _rightOperand;
3628 3493
3629 /** 3494 /**
3630 * Set the expression used to compute the right operand to the given expressio n. 3495 * Set the expression used to compute the right operand to the given
3631 * 3496 * [expression].
3632 * @param expression the expression used to compute the right operand
3633 */ 3497 */
3634 void set rightOperand(Expression expression) { 3498 void set rightOperand(Expression expression) {
3635 _rightOperand = becomeParentOf(expression); 3499 _rightOperand = becomeParentOf(expression);
3636 } 3500 }
3637 3501
3638 /** 3502 /**
3639 * If the AST structure has been resolved, and the function being invoked is k nown based on static 3503 * If the AST structure has been resolved, and the function being invoked is
3640 * type information, then return the parameter element representing the parame ter to which the 3504 * known based on static type information, then return the parameter element
3641 * value of the right operand will be bound. Otherwise, return `null`. 3505 * representing the parameter to which the value of the right operand will be
3506 * bound. Otherwise, return `null`.
3642 * 3507 *
3643 * This method is only intended to be used by [Expression.staticParameterEleme nt]. 3508 * This method is only intended to be used by
3644 * 3509 * [Expression.staticParameterElement].
3645 * @return the parameter element representing the parameter to which the value of the right
3646 * operand will be bound
3647 */ 3510 */
3648 ParameterElement get staticParameterElementForRightOperand { 3511 ParameterElement get staticParameterElementForRightOperand {
3649 if (staticElement == null) { 3512 if (staticElement == null) {
3650 return null; 3513 return null;
3651 } 3514 }
3652 List<ParameterElement> parameters = staticElement.parameters; 3515 List<ParameterElement> parameters = staticElement.parameters;
3653 if (parameters.length < 1) { 3516 if (parameters.length < 1) {
3654 return null; 3517 return null;
3655 } 3518 }
3656 return parameters[0]; 3519 return parameters[0];
3657 } 3520 }
3658 3521
3659 @override 3522 @override
3660 accept(AstVisitor visitor) => visitor.visitBinaryExpression(this); 3523 accept(AstVisitor visitor) => visitor.visitBinaryExpression(this);
3661 3524
3662 @override 3525 @override
3663 void visitChildren(AstVisitor visitor) { 3526 void visitChildren(AstVisitor visitor) {
3664 safelyVisitChild(_leftOperand, visitor); 3527 _safelyVisitChild(_leftOperand, visitor);
3665 safelyVisitChild(_rightOperand, visitor); 3528 _safelyVisitChild(_rightOperand, visitor);
3666 } 3529 }
3667 } 3530 }
3668 3531
3669 /** 3532 /**
3670 * Instances of the class `Block` represent a sequence of statements. 3533 * A sequence of statements.
3671 * 3534 *
3672 * <pre> 3535 * > block ::=
3673 * block ::= 3536 * > '{' statement* '}'
3674 * '{' statement* '}'
3675 * </pre>
3676 */ 3537 */
3677 class Block extends Statement { 3538 class Block extends Statement {
3678 /** 3539 /**
3679 * The left curly bracket. 3540 * The left curly bracket.
3680 */ 3541 */
3681 Token leftBracket; 3542 Token leftBracket;
3682 3543
3683 /** 3544 /**
3684 * The statements contained in the block. 3545 * The statements contained in the block.
3685 */ 3546 */
3686 NodeList<Statement> _statements; 3547 NodeList<Statement> _statements;
3687 3548
3688 /** 3549 /**
3689 * The right curly bracket. 3550 * The right curly bracket.
3690 */ 3551 */
3691 Token rightBracket; 3552 Token rightBracket;
3692 3553
3693 /** 3554 /**
3694 * Initialize a newly created block of code. 3555 * Initialize a newly created block of code.
3695 *
3696 * @param leftBracket the left curly bracket
3697 * @param statements the statements contained in the block
3698 * @param rightBracket the right curly bracket
3699 */ 3556 */
3700 Block(this.leftBracket, List<Statement> statements, this.rightBracket) { 3557 Block(this.leftBracket, List<Statement> statements, this.rightBracket) {
3701 _statements = new NodeList<Statement>(this, statements); 3558 _statements = new NodeList<Statement>(this, statements);
3702 } 3559 }
3703 3560
3704 @override 3561 @override
3705 Token get beginToken => leftBracket; 3562 Token get beginToken => leftBracket;
3706 3563
3707 @override 3564 @override
3708 Iterable get childEntities => new ChildEntities() 3565 Iterable get childEntities => new ChildEntities()
3709 ..add(leftBracket) 3566 ..add(leftBracket)
3710 ..addAll(_statements) 3567 ..addAll(_statements)
3711 ..add(rightBracket); 3568 ..add(rightBracket);
3712 3569
3713 @override 3570 @override
3714 Token get endToken => rightBracket; 3571 Token get endToken => rightBracket;
3715 3572
3716 /** 3573 /**
3717 * Return the statements contained in the block. 3574 * Return the statements contained in the block.
3718 *
3719 * @return the statements contained in the block
3720 */ 3575 */
3721 NodeList<Statement> get statements => _statements; 3576 NodeList<Statement> get statements => _statements;
3722 3577
3723 @override 3578 @override
3724 accept(AstVisitor visitor) => visitor.visitBlock(this); 3579 accept(AstVisitor visitor) => visitor.visitBlock(this);
3725 3580
3726 @override 3581 @override
3727 void visitChildren(AstVisitor visitor) { 3582 void visitChildren(AstVisitor visitor) {
3728 _statements.accept(visitor); 3583 _statements.accept(visitor);
3729 } 3584 }
3730 } 3585 }
3731 3586
3732 /** 3587 /**
3733 * Instances of the class `BlockFunctionBody` represent a function body that con sists of a 3588 * A function body that consists of a block of statements.
3734 * block of statements.
3735 * 3589 *
3736 * <pre> 3590 * > blockFunctionBody ::=
3737 * blockFunctionBody ::= 3591 * > ('async' | 'async' '*' | 'sync' '*')? [Block]
3738 * ('async' | 'async' '*' | 'sync' '*')? [Block]
3739 * </pre>
3740 */ 3592 */
3741 class BlockFunctionBody extends FunctionBody { 3593 class BlockFunctionBody extends FunctionBody {
3742 /** 3594 /**
3743 * The token representing the 'async' or 'sync' keyword, or `null` if there is no such 3595 * The token representing the 'async' or 'sync' keyword, or `null` if there is
3744 * keyword. 3596 * no such keyword.
3745 */ 3597 */
3746 Token keyword; 3598 Token keyword;
3747 3599
3748 /** 3600 /**
3749 * The star optionally following the 'async' or following the 'sync' keyword. 3601 * The star optionally following the 'async' or 'sync' keyword, or `null` if
3602 * there is wither no such keyword or no star.
3750 */ 3603 */
3751 Token star; 3604 Token star;
3752 3605
3753 /** 3606 /**
3754 * The block representing the body of the function. 3607 * The block representing the body of the function.
3755 */ 3608 */
3756 Block _block; 3609 Block _block;
3757 3610
3758 /** 3611 /**
3759 * Initialize a newly created function body consisting of a block of statement s. 3612 * Initialize a newly created function body consisting of a block of
3760 * 3613 * statements. The [keyword] can be `null` if there is no keyword specified
3761 * @param keyword the token representing the 'async' or 'sync' keyword 3614 * for the block. The [star] can be `null` if there is no star following the
3762 * @param star the star following the 'async' or 'sync' keyword 3615 * keyword (and must be `null` if there is no keyword).
3763 * @param block the block representing the body of the function
3764 */ 3616 */
3765 BlockFunctionBody(this.keyword, this.star, Block block) { 3617 BlockFunctionBody(this.keyword, this.star, Block block) {
3766 _block = becomeParentOf(block); 3618 _block = becomeParentOf(block);
3767 } 3619 }
3768 3620
3769 @override 3621 @override
3770 Token get beginToken => _block.beginToken; 3622 Token get beginToken => _block.beginToken;
3771 3623
3772 /** 3624 /**
3773 * Return the block representing the body of the function. 3625 * Return the block representing the body of the function.
3774 *
3775 * @return the block representing the body of the function
3776 */ 3626 */
3777 Block get block => _block; 3627 Block get block => _block;
3778 3628
3779 /** 3629 /**
3780 * Set the block representing the body of the function to the given block. 3630 * Set the block representing the body of the function to the given [block].
3781 *
3782 * @param block the block representing the body of the function
3783 */ 3631 */
3784 void set block(Block block) { 3632 void set block(Block block) {
3785 _block = becomeParentOf(block); 3633 _block = becomeParentOf(block);
3786 } 3634 }
3787 3635
3788 @override 3636 @override
3789 Iterable get childEntities => new ChildEntities() 3637 Iterable get childEntities => new ChildEntities()
3790 ..add(keyword) 3638 ..add(keyword)
3791 ..add(star) 3639 ..add(star)
3792 ..add(_block); 3640 ..add(_block);
(...skipping 14 matching lines...) Expand all
3807 bool get isGenerator => star != null; 3655 bool get isGenerator => star != null;
3808 3656
3809 @override 3657 @override
3810 bool get isSynchronous => keyword == null || keyword.lexeme != Parser.ASYNC; 3658 bool get isSynchronous => keyword == null || keyword.lexeme != Parser.ASYNC;
3811 3659
3812 @override 3660 @override
3813 accept(AstVisitor visitor) => visitor.visitBlockFunctionBody(this); 3661 accept(AstVisitor visitor) => visitor.visitBlockFunctionBody(this);
3814 3662
3815 @override 3663 @override
3816 void visitChildren(AstVisitor visitor) { 3664 void visitChildren(AstVisitor visitor) {
3817 safelyVisitChild(_block, visitor); 3665 _safelyVisitChild(_block, visitor);
3818 } 3666 }
3819 } 3667 }
3820 3668
3821 /** 3669 /**
3822 * Instances of the class `BooleanLiteral` represent a boolean literal expressio n. 3670 * A boolean literal expression.
3823 * 3671 *
3824 * <pre> 3672 * > booleanLiteral ::=
3825 * booleanLiteral ::= 3673 * > 'false' | 'true'
3826 * 'false' | 'true'
3827 * </pre>
3828 */ 3674 */
3829 class BooleanLiteral extends Literal { 3675 class BooleanLiteral extends Literal {
3830 /** 3676 /**
3831 * The token representing the literal. 3677 * The token representing the literal.
3832 */ 3678 */
3833 Token literal; 3679 Token literal;
3834 3680
3835 /** 3681 /**
3836 * The value of the literal. 3682 * The value of the literal.
3837 */ 3683 */
3838 bool value = false; 3684 bool value = false;
3839 3685
3840 /** 3686 /**
3841 * Initialize a newly created boolean literal. 3687 * Initialize a newly created boolean literal.
3842 *
3843 * @param literal the token representing the literal
3844 * @param value the value of the literal
3845 */ 3688 */
3846 BooleanLiteral(this.literal, this.value); 3689 BooleanLiteral(this.literal, this.value);
3847 3690
3848 @override 3691 @override
3849 Token get beginToken => literal; 3692 Token get beginToken => literal;
3850 3693
3851 /** 3694 /**
3852 * TODO(paulberry): untested. 3695 * TODO(paulberry): untested.
3853 */ 3696 */
3854 @override 3697 @override
3855 Iterable get childEntities => new ChildEntities()..add(literal); 3698 Iterable get childEntities => new ChildEntities()..add(literal);
3856 3699
3857 @override 3700 @override
3858 Token get endToken => literal; 3701 Token get endToken => literal;
3859 3702
3860 @override 3703 @override
3861 bool get isSynthetic => literal.isSynthetic; 3704 bool get isSynthetic => literal.isSynthetic;
3862 3705
3863 @override 3706 @override
3864 accept(AstVisitor visitor) => visitor.visitBooleanLiteral(this); 3707 accept(AstVisitor visitor) => visitor.visitBooleanLiteral(this);
3865 3708
3866 @override 3709 @override
3867 void visitChildren(AstVisitor visitor) { 3710 void visitChildren(AstVisitor visitor) {
3868 // There are no children to visit. 3711 // There are no children to visit.
3869 } 3712 }
3870 } 3713 }
3871 3714
3872 /** 3715 /**
3873 * Instances of the class `BreadthFirstVisitor` implement an AST visitor that wi ll recursively 3716 * An AST visitor that will recursively visit all of the nodes in an AST
3874 * visit all of the nodes in an AST structure, similar to [GeneralizingAstVisito r]. This 3717 * structure, similar to [GeneralizingAstVisitor]. This visitor uses a
3875 * visitor uses a breadth-first ordering rather than the depth-first ordering of 3718 * breadth-first ordering rather than the depth-first ordering of
3876 * [GeneralizingAstVisitor]. 3719 * [GeneralizingAstVisitor].
3877 * 3720 *
3878 * Subclasses that override a visit method must either invoke the overridden vis it method or 3721 * Subclasses that override a visit method must either invoke the overridden
3879 * explicitly invoke the more general visit method. Failure to do so will cause the visit methods 3722 * visit method or explicitly invoke the more general visit method. Failure to
3880 * for superclasses of the node to not be invoked and will cause the children of the visited node to 3723 * do so will cause the visit methods for superclasses of the node to not be
3881 * not be visited. 3724 * invoked and will cause the children of the visited node to not be visited.
3882 * 3725 *
3883 * In addition, subclasses should <b>not</b> explicitly visit the children of a node, but should 3726 * In addition, subclasses should <b>not</b> explicitly visit the children of a
3884 * ensure that the method [visitNode] is used to visit the children (either dire ctly 3727 * node, but should ensure that the method [visitNode] is used to visit the
3885 * or indirectly). Failure to do will break the order in which nodes are visited . 3728 * children (either directly or indirectly). Failure to do will break the order
3729 * in which nodes are visited.
3886 */ 3730 */
3887 class BreadthFirstVisitor<R> extends GeneralizingAstVisitor<R> { 3731 class BreadthFirstVisitor<R> extends GeneralizingAstVisitor<R> {
3888 /** 3732 /**
3889 * A queue holding the nodes that have not yet been visited in the order in wh ich they ought to be 3733 * A queue holding the nodes that have not yet been visited in the order in
3890 * visited. 3734 * which they ought to be visited.
3891 */ 3735 */
3892 Queue<AstNode> _queue = new Queue<AstNode>(); 3736 Queue<AstNode> _queue = new Queue<AstNode>();
3893 3737
3894 /** 3738 /**
3895 * A visitor, used to visit the children of the current node, that will add th e nodes it visits to 3739 * A visitor, used to visit the children of the current node, that will add
3896 * the [queue]. 3740 * the nodes it visits to the [_queue].
3897 */ 3741 */
3898 GeneralizingAstVisitor<Object> _childVisitor; 3742 GeneralizingAstVisitor<Object> _childVisitor;
3899 3743
3744 /**
3745 * Initialize a newly created visitor.
3746 */
3900 BreadthFirstVisitor() { 3747 BreadthFirstVisitor() {
3901 _childVisitor = new GeneralizingAstVisitor_BreadthFirstVisitor(this); 3748 _childVisitor = new GeneralizingAstVisitor_BreadthFirstVisitor(this);
3902 } 3749 }
3903 3750
3904 /** 3751 /**
3905 * Visit all nodes in the tree starting at the given `root` node, in breadth-f irst order. 3752 * Visit all nodes in the tree starting at the given [root] node, in
3906 * 3753 * breadth-first order.
3907 * @param root the root of the AST structure to be visited
3908 */ 3754 */
3909 void visitAllNodes(AstNode root) { 3755 void visitAllNodes(AstNode root) {
3910 _queue.add(root); 3756 _queue.add(root);
3911 while (!_queue.isEmpty) { 3757 while (!_queue.isEmpty) {
3912 AstNode next = _queue.removeFirst(); 3758 AstNode next = _queue.removeFirst();
3913 next.accept(this); 3759 next.accept(this);
3914 } 3760 }
3915 } 3761 }
3916 3762
3917 @override 3763 @override
3918 R visitNode(AstNode node) { 3764 R visitNode(AstNode node) {
3919 node.visitChildren(_childVisitor); 3765 node.visitChildren(_childVisitor);
3920 return null; 3766 return null;
3921 } 3767 }
3922 } 3768 }
3923 3769
3924 /** 3770 /**
3925 * Instances of the class `BreakStatement` represent a break statement. 3771 * A break statement.
3926 * 3772 *
3927 * <pre> 3773 * > breakStatement ::=
3928 * breakStatement ::= 3774 * > 'break' [SimpleIdentifier]? ';'
3929 * 'break' [SimpleIdentifier]? ';'
3930 * </pre>
3931 */ 3775 */
3932 class BreakStatement extends Statement { 3776 class BreakStatement extends Statement {
3933 /** 3777 /**
3934 * The token representing the 'break' keyword. 3778 * The token representing the 'break' keyword.
3935 */ 3779 */
3936 Token keyword; 3780 Token keyword;
3937 3781
3938 /** 3782 /**
3939 * The label associated with the statement, or `null` if there is no label. 3783 * The label associated with the statement, or `null` if there is no label.
3940 */ 3784 */
3941 SimpleIdentifier _label; 3785 SimpleIdentifier _label;
3942 3786
3943 /** 3787 /**
3944 * The semicolon terminating the statement. 3788 * The semicolon terminating the statement.
3945 */ 3789 */
3946 Token semicolon; 3790 Token semicolon;
3947 3791
3948 /** 3792 /**
3949 * The AstNode which this break statement is breaking from. This will be 3793 * The AstNode which this break statement is breaking from. This will be
3950 * either a Statement (in the case of breaking out of a loop) or a 3794 * either a [Statement] (in the case of breaking out of a loop), a
3951 * SwitchMember (in the case of a labeled break statement whose label matches 3795 * [SwitchMember] (in the case of a labeled break statement whose label
3952 * a label on a switch case in an enclosing switch statement). Null if the 3796 * matches a label on a switch case in an enclosing switch statement), or
3953 * AST has not yet been resolved or if the target could not be resolved. 3797 * `null` if the AST has not yet been resolved or if the target could not be
3954 * Note that if the source code has errors, the target may be invalid (e.g. 3798 * resolved. Note that if the source code has errors, the target might be
3955 * trying to break to a switch case). 3799 * invalid (e.g. trying to break to a switch case).
3956 */ 3800 */
3957 AstNode target; 3801 AstNode target;
3958 3802
3959 /** 3803 /**
3960 * Initialize a newly created break statement. 3804 * Initialize a newly created break statement. The [label] can be `null` if
3961 * 3805 * there is no label associated with the statement.
3962 * @param keyword the token representing the 'break' keyword
3963 * @param label the label associated with the statement
3964 * @param semicolon the semicolon terminating the statement
3965 */ 3806 */
3966 BreakStatement(this.keyword, SimpleIdentifier label, this.semicolon) { 3807 BreakStatement(this.keyword, SimpleIdentifier label, this.semicolon) {
3967 _label = becomeParentOf(label); 3808 _label = becomeParentOf(label);
3968 } 3809 }
3969 3810
3970 @override 3811 @override
3971 Token get beginToken => keyword; 3812 Token get beginToken => keyword;
3972 3813
3973 /** 3814 /**
3974 * TODO(paulberry): untested. 3815 * TODO(paulberry): untested.
3975 */ 3816 */
3976 @override 3817 @override
3977 Iterable get childEntities => new ChildEntities() 3818 Iterable get childEntities => new ChildEntities()
3978 ..add(keyword) 3819 ..add(keyword)
3979 ..add(_label) 3820 ..add(_label)
3980 ..add(semicolon); 3821 ..add(semicolon);
3981 3822
3982 @override 3823 @override
3983 Token get endToken => semicolon; 3824 Token get endToken => semicolon;
3984 3825
3985 /** 3826 /**
3986 * Return the label associated with the statement, or `null` if there is no la bel. 3827 * Return the label associated with the statement, or `null` if there is no
3987 * 3828 * label.
3988 * @return the label associated with the statement
3989 */ 3829 */
3990 SimpleIdentifier get label => _label; 3830 SimpleIdentifier get label => _label;
3991 3831
3992 /** 3832 /**
3993 * Set the label associated with the statement to the given identifier. 3833 * Set the label associated with the statement to the given [identifier].
3994 *
3995 * @param identifier the label associated with the statement
3996 */ 3834 */
3997 void set label(SimpleIdentifier identifier) { 3835 void set label(SimpleIdentifier identifier) {
3998 _label = becomeParentOf(identifier); 3836 _label = becomeParentOf(identifier);
3999 } 3837 }
4000 3838
4001 @override 3839 @override
4002 accept(AstVisitor visitor) => visitor.visitBreakStatement(this); 3840 accept(AstVisitor visitor) => visitor.visitBreakStatement(this);
4003 3841
4004 @override 3842 @override
4005 void visitChildren(AstVisitor visitor) { 3843 void visitChildren(AstVisitor visitor) {
4006 safelyVisitChild(_label, visitor); 3844 _safelyVisitChild(_label, visitor);
4007 } 3845 }
4008 } 3846 }
4009 3847
4010 /** 3848 /**
4011 * Instances of the class `CascadeExpression` represent a sequence of cascaded e xpressions: 3849 * A sequence of cascaded expressions: expressions that share a common target.
4012 * expressions that share a common target. There are three kinds of expressions that can be used in 3850 * There are three kinds of expressions that can be used in a cascade
4013 * a cascade expression: [IndexExpression], [MethodInvocation] and 3851 * expression: [IndexExpression], [MethodInvocation] and [PropertyAccess].
4014 * [PropertyAccess].
4015 * 3852 *
4016 * <pre> 3853 * > cascadeExpression ::=
4017 * cascadeExpression ::= 3854 * > [Expression] cascadeSection*
4018 * [Expression] cascadeSection* 3855 * >
4019 * 3856 * > cascadeSection ::=
4020 * cascadeSection ::= 3857 * > '..' (cascadeSelector arguments*) (assignableSelector arguments*)*
4021 * '..' (cascadeSelector arguments*) (assignableSelector arguments*)* (assi gnmentOperator expressionWithoutCascade)? 3858 * > (assignmentOperator expressionWithoutCascade)?
4022 * 3859 * >
4023 * cascadeSelector ::= 3860 * > cascadeSelector ::=
4024 * '[ ' expression '] ' 3861 * > '[ ' expression '] '
4025 * | identifier 3862 * > | identifier
4026 * </pre>
4027 */ 3863 */
4028 class CascadeExpression extends Expression { 3864 class CascadeExpression extends Expression {
4029 /** 3865 /**
4030 * The target of the cascade sections. 3866 * The target of the cascade sections.
4031 */ 3867 */
4032 Expression _target; 3868 Expression _target;
4033 3869
4034 /** 3870 /**
4035 * The cascade sections sharing the common target. 3871 * The cascade sections sharing the common target.
4036 */ 3872 */
4037 NodeList<Expression> _cascadeSections; 3873 NodeList<Expression> _cascadeSections;
4038 3874
4039 /** 3875 /**
4040 * Initialize a newly created cascade expression. 3876 * Initialize a newly created cascade expression. The list of
4041 * 3877 * [cascadeSections] must contain at least one element.
4042 * @param target the target of the cascade sections
4043 * @param cascadeSections the cascade sections sharing the common target
4044 */ 3878 */
4045 CascadeExpression(Expression target, List<Expression> cascadeSections) { 3879 CascadeExpression(Expression target, List<Expression> cascadeSections) {
4046 _target = becomeParentOf(target); 3880 _target = becomeParentOf(target);
4047 _cascadeSections = new NodeList<Expression>(this, cascadeSections); 3881 _cascadeSections = new NodeList<Expression>(this, cascadeSections);
4048 } 3882 }
4049 3883
4050 @override 3884 @override
4051 Token get beginToken => _target.beginToken; 3885 Token get beginToken => _target.beginToken;
4052 3886
4053 /** 3887 /**
4054 * Return the cascade sections sharing the common target. 3888 * Return the cascade sections sharing the common target.
4055 *
4056 * @return the cascade sections sharing the common target
4057 */ 3889 */
4058 NodeList<Expression> get cascadeSections => _cascadeSections; 3890 NodeList<Expression> get cascadeSections => _cascadeSections;
4059 3891
4060 @override 3892 @override
4061 Iterable get childEntities => new ChildEntities() 3893 Iterable get childEntities => new ChildEntities()
4062 ..add(_target) 3894 ..add(_target)
4063 ..addAll(_cascadeSections); 3895 ..addAll(_cascadeSections);
4064 3896
4065 @override 3897 @override
4066 Token get endToken => _cascadeSections.endToken; 3898 Token get endToken => _cascadeSections.endToken;
4067 3899
4068 @override 3900 @override
4069 int get precedence => 2; 3901 int get precedence => 2;
4070 3902
4071 /** 3903 /**
4072 * Return the target of the cascade sections. 3904 * Return the target of the cascade sections.
4073 *
4074 * @return the target of the cascade sections
4075 */ 3905 */
4076 Expression get target => _target; 3906 Expression get target => _target;
4077 3907
4078 /** 3908 /**
4079 * Set the target of the cascade sections to the given expression. 3909 * Set the target of the cascade sections to the given [expression].
4080 *
4081 * @param target the target of the cascade sections
4082 */ 3910 */
4083 void set target(Expression target) { 3911 void set target(Expression target) {
4084 _target = becomeParentOf(target); 3912 _target = becomeParentOf(target);
4085 } 3913 }
4086 3914
4087 @override 3915 @override
4088 accept(AstVisitor visitor) => visitor.visitCascadeExpression(this); 3916 accept(AstVisitor visitor) => visitor.visitCascadeExpression(this);
4089 3917
4090 @override 3918 @override
4091 void visitChildren(AstVisitor visitor) { 3919 void visitChildren(AstVisitor visitor) {
4092 safelyVisitChild(_target, visitor); 3920 _safelyVisitChild(_target, visitor);
4093 _cascadeSections.accept(visitor); 3921 _cascadeSections.accept(visitor);
4094 } 3922 }
4095 } 3923 }
4096 3924
4097 /** 3925 /**
4098 * Instances of the class `CatchClause` represent a catch clause within a try st atement. 3926 * A catch clause within a try statement.
4099 * 3927 *
4100 * <pre> 3928 * > onPart ::=
4101 * onPart ::= 3929 * > catchPart [Block]
4102 * catchPart [Block] 3930 * > | 'on' type catchPart? [Block]
4103 * | 'on' type catchPart? [Block] 3931 * >
4104 * 3932 * > catchPart ::=
4105 * catchPart ::= 3933 * > 'catch' '(' [SimpleIdentifier] (',' [SimpleIdentifier])? ')'
4106 * 'catch' '(' [SimpleIdentifier] (',' [SimpleIdentifier])? ')'
4107 * </pre>
4108 */ 3934 */
4109 class CatchClause extends AstNode { 3935 class CatchClause extends AstNode {
4110 /** 3936 /**
4111 * The token representing the 'on' keyword, or `null` if there is no 'on' keyw ord. 3937 * The token representing the 'on' keyword, or `null` if there is no 'on'
3938 * keyword.
4112 */ 3939 */
4113 Token onKeyword; 3940 Token onKeyword;
4114 3941
4115 /** 3942 /**
4116 * The type of exceptions caught by this catch clause, or `null` if this catch clause 3943 * The type of exceptions caught by this catch clause, or `null` if this catch
4117 * catches every type of exception. 3944 * clause catches every type of exception.
4118 */ 3945 */
4119 TypeName _exceptionType; 3946 TypeName _exceptionType;
4120 3947
4121 /** 3948 /**
4122 * The token representing the 'catch' keyword, or `null` if there is no 'catch ' keyword. 3949 * The token representing the 'catch' keyword, or `null` if there is no
3950 * 'catch' keyword.
4123 */ 3951 */
4124 Token catchKeyword; 3952 Token catchKeyword;
4125 3953
4126 /** 3954 /**
4127 * The left parenthesis. 3955 * The left parenthesis.
4128 */ 3956 */
4129 Token leftParenthesis; 3957 Token leftParenthesis;
4130 3958
4131 /** 3959 /**
4132 * The parameter whose value will be the exception that was thrown. 3960 * The parameter whose value will be the exception that was thrown.
4133 */ 3961 */
4134 SimpleIdentifier _exceptionParameter; 3962 SimpleIdentifier _exceptionParameter;
4135 3963
4136 /** 3964 /**
4137 * The comma separating the exception parameter from the stack trace parameter , or `null` if 3965 * The comma separating the exception parameter from the stack trace
4138 * there is no stack trace parameter. 3966 * parameter, or `null` if there is no stack trace parameter.
4139 */ 3967 */
4140 Token comma; 3968 Token comma;
4141 3969
4142 /** 3970 /**
4143 * The parameter whose value will be the stack trace associated with the excep tion, or 3971 * The parameter whose value will be the stack trace associated with the
4144 * `null` if there is no stack trace parameter. 3972 * exception, or `null` if there is no stack trace parameter.
4145 */ 3973 */
4146 SimpleIdentifier _stackTraceParameter; 3974 SimpleIdentifier _stackTraceParameter;
4147 3975
4148 /** 3976 /**
4149 * The right parenthesis. 3977 * The right parenthesis.
4150 */ 3978 */
4151 Token rightParenthesis; 3979 Token rightParenthesis;
4152 3980
4153 /** 3981 /**
4154 * The body of the catch block. 3982 * The body of the catch block.
4155 */ 3983 */
4156 Block _body; 3984 Block _body;
4157 3985
4158 /** 3986 /**
4159 * Initialize a newly created catch clause. 3987 * Initialize a newly created catch clause. The [onKeyword] and
4160 * 3988 * [exceptionType] can be `null` if the clause will catch all exceptions. The
4161 * @param onKeyword the token representing the 'on' keyword 3989 * [comma] and [stackTraceParameter] can be `null` if the stack trace is not
4162 * @param exceptionType the type of exceptions caught by this catch clause 3990 * referencable within the body.
4163 * @param leftParenthesis the left parenthesis
4164 * @param exceptionParameter the parameter whose value will be the exception t hat was thrown
4165 * @param comma the comma separating the exception parameter from the stack tr ace parameter
4166 * @param stackTraceParameter the parameter whose value will be the stack trac e associated with
4167 * the exception
4168 * @param rightParenthesis the right parenthesis
4169 * @param body the body of the catch block
4170 */ 3991 */
4171 CatchClause(this.onKeyword, TypeName exceptionType, this.catchKeyword, 3992 CatchClause(this.onKeyword, TypeName exceptionType, this.catchKeyword,
4172 this.leftParenthesis, SimpleIdentifier exceptionParameter, this.comma, 3993 this.leftParenthesis, SimpleIdentifier exceptionParameter, this.comma,
4173 SimpleIdentifier stackTraceParameter, this.rightParenthesis, Block body) { 3994 SimpleIdentifier stackTraceParameter, this.rightParenthesis, Block body) {
4174 _exceptionType = becomeParentOf(exceptionType); 3995 _exceptionType = becomeParentOf(exceptionType);
4175 _exceptionParameter = becomeParentOf(exceptionParameter); 3996 _exceptionParameter = becomeParentOf(exceptionParameter);
4176 _stackTraceParameter = becomeParentOf(stackTraceParameter); 3997 _stackTraceParameter = becomeParentOf(stackTraceParameter);
4177 _body = becomeParentOf(body); 3998 _body = becomeParentOf(body);
4178 } 3999 }
4179 4000
4180 @override 4001 @override
4181 Token get beginToken { 4002 Token get beginToken {
4182 if (onKeyword != null) { 4003 if (onKeyword != null) {
4183 return onKeyword; 4004 return onKeyword;
4184 } 4005 }
4185 return catchKeyword; 4006 return catchKeyword;
4186 } 4007 }
4187 4008
4188 /** 4009 /**
4189 * Return the body of the catch block. 4010 * Return the body of the catch block.
4190 *
4191 * @return the body of the catch block
4192 */ 4011 */
4193 Block get body => _body; 4012 Block get body => _body;
4194 4013
4195 /** 4014 /**
4196 * Set the body of the catch block to the given block. 4015 * Set the body of the catch block to the given [block].
4197 *
4198 * @param block the body of the catch block
4199 */ 4016 */
4200 void set body(Block block) { 4017 void set body(Block block) {
4201 _body = becomeParentOf(block); 4018 _body = becomeParentOf(block);
4202 } 4019 }
4203 4020
4204 @override 4021 @override
4205 Iterable get childEntities => new ChildEntities() 4022 Iterable get childEntities => new ChildEntities()
4206 ..add(onKeyword) 4023 ..add(onKeyword)
4207 ..add(_exceptionType) 4024 ..add(_exceptionType)
4208 ..add(catchKeyword) 4025 ..add(catchKeyword)
4209 ..add(leftParenthesis) 4026 ..add(leftParenthesis)
4210 ..add(_exceptionParameter) 4027 ..add(_exceptionParameter)
4211 ..add(comma) 4028 ..add(comma)
4212 ..add(_stackTraceParameter) 4029 ..add(_stackTraceParameter)
4213 ..add(rightParenthesis) 4030 ..add(rightParenthesis)
4214 ..add(_body); 4031 ..add(_body);
4215 4032
4216 @override 4033 @override
4217 Token get endToken => _body.endToken; 4034 Token get endToken => _body.endToken;
4218 4035
4219 /** 4036 /**
4220 * Return the parameter whose value will be the exception that was thrown. 4037 * Return the parameter whose value will be the exception that was thrown.
4221 *
4222 * @return the parameter whose value will be the exception that was thrown
4223 */ 4038 */
4224 SimpleIdentifier get exceptionParameter => _exceptionParameter; 4039 SimpleIdentifier get exceptionParameter => _exceptionParameter;
4225 4040
4226 /** 4041 /**
4227 * Set the parameter whose value will be the exception that was thrown to the given parameter. 4042 * Set the parameter whose value will be the exception that was thrown to the
4228 * 4043 * given [parameter].
4229 * @param parameter the parameter whose value will be the exception that was t hrown
4230 */ 4044 */
4231 void set exceptionParameter(SimpleIdentifier parameter) { 4045 void set exceptionParameter(SimpleIdentifier parameter) {
4232 _exceptionParameter = becomeParentOf(parameter); 4046 _exceptionParameter = becomeParentOf(parameter);
4233 } 4047 }
4234 4048
4235 /** 4049 /**
4236 * Return the type of exceptions caught by this catch clause, or `null` if thi s catch clause 4050 * Return the type of exceptions caught by this catch clause, or `null` if
4237 * catches every type of exception. 4051 * this catch clause catches every type of exception.
4238 *
4239 * @return the type of exceptions caught by this catch clause
4240 */ 4052 */
4241 TypeName get exceptionType => _exceptionType; 4053 TypeName get exceptionType => _exceptionType;
4242 4054
4243 /** 4055 /**
4244 * Set the type of exceptions caught by this catch clause to the given type. 4056 * Set the type of exceptions caught by this catch clause to the given
4245 * 4057 * [exceptionType].
4246 * @param exceptionType the type of exceptions caught by this catch clause
4247 */ 4058 */
4248 void set exceptionType(TypeName exceptionType) { 4059 void set exceptionType(TypeName exceptionType) {
4249 _exceptionType = becomeParentOf(exceptionType); 4060 _exceptionType = becomeParentOf(exceptionType);
4250 } 4061 }
4251 4062
4252 /** 4063 /**
4253 * Return the parameter whose value will be the stack trace associated with th e exception, or 4064 * Return the parameter whose value will be the stack trace associated with
4254 * `null` if there is no stack trace parameter. 4065 * the exception, or `null` if there is no stack trace parameter.
4255 *
4256 * @return the parameter whose value will be the stack trace associated with t he exception
4257 */ 4066 */
4258 SimpleIdentifier get stackTraceParameter => _stackTraceParameter; 4067 SimpleIdentifier get stackTraceParameter => _stackTraceParameter;
4259 4068
4260 /** 4069 /**
4261 * Set the parameter whose value will be the stack trace associated with the e xception to the 4070 * Set the parameter whose value will be the stack trace associated with the
4262 * given parameter. 4071 * exception to the given [parameter].
4263 *
4264 * @param parameter the parameter whose value will be the stack trace associat ed with the
4265 * exception
4266 */ 4072 */
4267 void set stackTraceParameter(SimpleIdentifier parameter) { 4073 void set stackTraceParameter(SimpleIdentifier parameter) {
4268 _stackTraceParameter = becomeParentOf(parameter); 4074 _stackTraceParameter = becomeParentOf(parameter);
4269 } 4075 }
4270 4076
4271 @override 4077 @override
4272 accept(AstVisitor visitor) => visitor.visitCatchClause(this); 4078 accept(AstVisitor visitor) => visitor.visitCatchClause(this);
4273 4079
4274 @override 4080 @override
4275 void visitChildren(AstVisitor visitor) { 4081 void visitChildren(AstVisitor visitor) {
4276 safelyVisitChild(_exceptionType, visitor); 4082 _safelyVisitChild(_exceptionType, visitor);
4277 safelyVisitChild(_exceptionParameter, visitor); 4083 _safelyVisitChild(_exceptionParameter, visitor);
4278 safelyVisitChild(_stackTraceParameter, visitor); 4084 _safelyVisitChild(_stackTraceParameter, visitor);
4279 safelyVisitChild(_body, visitor); 4085 _safelyVisitChild(_body, visitor);
4280 } 4086 }
4281 } 4087 }
4282 4088
4283 /** 4089 /**
4284 * Helper class to allow iteration of child entities of an AST node. 4090 * Helper class to allow iteration of child entities of an AST node.
4285 */ 4091 */
4286 class ChildEntities extends Object with IterableMixin implements Iterable { 4092 class ChildEntities extends Object with IterableMixin implements Iterable {
4287 List _entities = []; 4093 List _entities = [];
4288 4094
4289 @override 4095 @override
(...skipping 13 matching lines...) Expand all
4303 * Add the given items as the next child entities, if [items] is not null. 4109 * Add the given items as the next child entities, if [items] is not null.
4304 */ 4110 */
4305 void addAll(Iterable items) { 4111 void addAll(Iterable items) {
4306 if (items != null) { 4112 if (items != null) {
4307 _entities.addAll(items); 4113 _entities.addAll(items);
4308 } 4114 }
4309 } 4115 }
4310 } 4116 }
4311 4117
4312 /** 4118 /**
4313 * Instances of the class `ClassDeclaration` represent the declaration of a clas s. 4119 * The declaration of a class.
4314 * 4120 *
4315 * <pre> 4121 * > classDeclaration ::=
4316 * classDeclaration ::= 4122 * > 'abstract'? 'class' [SimpleIdentifier] [TypeParameterList]?
4317 * 'abstract'? 'class' [SimpleIdentifier] [TypeParameterList]? 4123 * > ([ExtendsClause] [WithClause]?)?
4318 * ([ExtendsClause] [WithClause]?)? 4124 * > [ImplementsClause]?
4319 * [ImplementsClause]? 4125 * > '{' [ClassMember]* '}'
4320 * '{' [ClassMember]* '}'
4321 * </pre>
4322 */ 4126 */
4323 class ClassDeclaration extends CompilationUnitMember { 4127 class ClassDeclaration extends CompilationUnitMember {
4324 /** 4128 /**
4325 * The 'abstract' keyword, or `null` if the keyword was absent. 4129 * The 'abstract' keyword, or `null` if the keyword was absent.
4326 */ 4130 */
4327 Token abstractKeyword; 4131 Token abstractKeyword;
4328 4132
4329 /** 4133 /**
4330 * The token representing the 'class' keyword. 4134 * The token representing the 'class' keyword.
4331 */ 4135 */
4332 Token classKeyword; 4136 Token classKeyword;
4333 4137
4334 /** 4138 /**
4335 * The name of the class being declared. 4139 * The name of the class being declared.
4336 */ 4140 */
4337 SimpleIdentifier _name; 4141 SimpleIdentifier _name;
4338 4142
4339 /** 4143 /**
4340 * The type parameters for the class, or `null` if the class does not have any type 4144 * The type parameters for the class, or `null` if the class does not have any
4341 * parameters. 4145 * type parameters.
4342 */ 4146 */
4343 TypeParameterList _typeParameters; 4147 TypeParameterList _typeParameters;
4344 4148
4345 /** 4149 /**
4346 * The extends clause for the class, or `null` if the class does not extend an y other class. 4150 * The extends clause for the class, or `null` if the class does not extend
4151 * any other class.
4347 */ 4152 */
4348 ExtendsClause _extendsClause; 4153 ExtendsClause _extendsClause;
4349 4154
4350 /** 4155 /**
4351 * The with clause for the class, or `null` if the class does not have a with clause. 4156 * The with clause for the class, or `null` if the class does not have a with
4157 * clause.
4352 */ 4158 */
4353 WithClause _withClause; 4159 WithClause _withClause;
4354 4160
4355 /** 4161 /**
4356 * The implements clause for the class, or `null` if the class does not implem ent any 4162 * The implements clause for the class, or `null` if the class does not
4357 * interfaces. 4163 * implement any interfaces.
4358 */ 4164 */
4359 ImplementsClause _implementsClause; 4165 ImplementsClause _implementsClause;
4360 4166
4361 /** 4167 /**
4362 * The native clause for the class, or `null` if the class does not have a nat ive clause. 4168 * The native clause for the class, or `null` if the class does not have a
4169 * native clause.
4363 */ 4170 */
4364 NativeClause _nativeClause; 4171 NativeClause _nativeClause;
4365 4172
4366 /** 4173 /**
4367 * The left curly bracket. 4174 * The left curly bracket.
4368 */ 4175 */
4369 Token leftBracket; 4176 Token leftBracket;
4370 4177
4371 /** 4178 /**
4372 * The members defined by the class. 4179 * The members defined by the class.
4373 */ 4180 */
4374 NodeList<ClassMember> _members; 4181 NodeList<ClassMember> _members;
4375 4182
4376 /** 4183 /**
4377 * The right curly bracket. 4184 * The right curly bracket.
4378 */ 4185 */
4379 Token rightBracket; 4186 Token rightBracket;
4380 4187
4381 /** 4188 /**
4382 * Initialize a newly created class declaration. 4189 * Initialize a newly created class declaration. Either or both of the
4383 * 4190 * [comment] and [metadata] can be `null` if the class does not have the
4384 * @param comment the documentation comment associated with this class 4191 * corresponding attribute. The [abstractKeyword] can be `null` if the class
4385 * @param metadata the annotations associated with this class 4192 * is not abstract. The [typeParameters] can be `null` if the class does not
4386 * @param abstractKeyword the 'abstract' keyword, or `null` if the keyword was absent 4193 * have any type parameters. Any or all of the [extendsClause], [withClause],
4387 * @param classKeyword the token representing the 'class' keyword 4194 * and [implementsClause] can be `null` if the class does not have the
4388 * @param name the name of the class being declared 4195 * corresponding clause. The list of [members] can be `null` if the class does
4389 * @param typeParameters the type parameters for the class 4196 * not have any members.
4390 * @param extendsClause the extends clause for the class
4391 * @param withClause the with clause for the class
4392 * @param implementsClause the implements clause for the class
4393 * @param leftBracket the left curly bracket
4394 * @param members the members defined by the class
4395 * @param rightBracket the right curly bracket
4396 */ 4197 */
4397 ClassDeclaration(Comment comment, List<Annotation> metadata, 4198 ClassDeclaration(Comment comment, List<Annotation> metadata,
4398 this.abstractKeyword, this.classKeyword, SimpleIdentifier name, 4199 this.abstractKeyword, this.classKeyword, SimpleIdentifier name,
4399 TypeParameterList typeParameters, ExtendsClause extendsClause, 4200 TypeParameterList typeParameters, ExtendsClause extendsClause,
4400 WithClause withClause, ImplementsClause implementsClause, this.leftBracket , 4201 WithClause withClause, ImplementsClause implementsClause, this.leftBracket ,
4401 List<ClassMember> members, this.rightBracket) 4202 List<ClassMember> members, this.rightBracket)
4402 : super(comment, metadata) { 4203 : super(comment, metadata) {
4403 _name = becomeParentOf(name); 4204 _name = becomeParentOf(name);
4404 _typeParameters = becomeParentOf(typeParameters); 4205 _typeParameters = becomeParentOf(typeParameters);
4405 _extendsClause = becomeParentOf(extendsClause); 4206 _extendsClause = becomeParentOf(extendsClause);
(...skipping 17 matching lines...) Expand all
4423 ..add(rightBracket); 4224 ..add(rightBracket);
4424 4225
4425 @override 4226 @override
4426 ClassElement get element => 4227 ClassElement get element =>
4427 _name != null ? (_name.staticElement as ClassElement) : null; 4228 _name != null ? (_name.staticElement as ClassElement) : null;
4428 4229
4429 @override 4230 @override
4430 Token get endToken => rightBracket; 4231 Token get endToken => rightBracket;
4431 4232
4432 /** 4233 /**
4433 * Return the extends clause for this class, or `null` if the class does not e xtend any 4234 * Return the extends clause for this class, or `null` if the class does not
4434 * other class. 4235 * extend any other class.
4435 *
4436 * @return the extends clause for this class
4437 */ 4236 */
4438 ExtendsClause get extendsClause => _extendsClause; 4237 ExtendsClause get extendsClause => _extendsClause;
4439 4238
4440 /** 4239 /**
4441 * Set the extends clause for this class to the given clause. 4240 * Set the extends clause for this class to the given [extendsClause].
4442 *
4443 * @param extendsClause the extends clause for this class
4444 */ 4241 */
4445 void set extendsClause(ExtendsClause extendsClause) { 4242 void set extendsClause(ExtendsClause extendsClause) {
4446 _extendsClause = becomeParentOf(extendsClause); 4243 _extendsClause = becomeParentOf(extendsClause);
4447 } 4244 }
4448 4245
4449 @override 4246 @override
4450 Token get firstTokenAfterCommentAndMetadata { 4247 Token get firstTokenAfterCommentAndMetadata {
4451 if (abstractKeyword != null) { 4248 if (abstractKeyword != null) {
4452 return abstractKeyword; 4249 return abstractKeyword;
4453 } 4250 }
4454 return classKeyword; 4251 return classKeyword;
4455 } 4252 }
4456 4253
4457 /** 4254 /**
4458 * Return the implements clause for the class, or `null` if the class does not implement any 4255 * Return the implements clause for the class, or `null` if the class does not
4459 * interfaces. 4256 * implement any interfaces.
4460 *
4461 * @return the implements clause for the class
4462 */ 4257 */
4463 ImplementsClause get implementsClause => _implementsClause; 4258 ImplementsClause get implementsClause => _implementsClause;
4464 4259
4465 /** 4260 /**
4466 * Set the implements clause for the class to the given clause. 4261 * Set the implements clause for the class to the given [implementsClause].
4467 *
4468 * @param implementsClause the implements clause for the class
4469 */ 4262 */
4470 void set implementsClause(ImplementsClause implementsClause) { 4263 void set implementsClause(ImplementsClause implementsClause) {
4471 _implementsClause = becomeParentOf(implementsClause); 4264 _implementsClause = becomeParentOf(implementsClause);
4472 } 4265 }
4473 4266
4474 /** 4267 /**
4475 * Return `true` if this class is declared to be an abstract class. 4268 * Return `true` if this class is declared to be an abstract class.
4476 *
4477 * @return `true` if this class is declared to be an abstract class
4478 */ 4269 */
4479 bool get isAbstract => abstractKeyword != null; 4270 bool get isAbstract => abstractKeyword != null;
4480 4271
4481 /** 4272 /**
4482 * Return the members defined by the class. 4273 * Return the members defined by the class.
4483 *
4484 * @return the members defined by the class
4485 */ 4274 */
4486 NodeList<ClassMember> get members => _members; 4275 NodeList<ClassMember> get members => _members;
4487 4276
4488 /** 4277 /**
4489 * Return the name of the class being declared. 4278 * Return the name of the class being declared.
4490 *
4491 * @return the name of the class being declared
4492 */ 4279 */
4493 SimpleIdentifier get name => _name; 4280 SimpleIdentifier get name => _name;
4494 4281
4495 /** 4282 /**
4496 * Set the name of the class being declared to the given identifier. 4283 * Set the name of the class being declared to the given [identifier].
4497 *
4498 * @param identifier the name of the class being declared
4499 */ 4284 */
4500 void set name(SimpleIdentifier identifier) { 4285 void set name(SimpleIdentifier identifier) {
4501 _name = becomeParentOf(identifier); 4286 _name = becomeParentOf(identifier);
4502 } 4287 }
4503 4288
4504 /** 4289 /**
4505 * Return the native clause for this class, or `null` if the class does not ha ve a native 4290 * Return the native clause for this class, or `null` if the class does not
4506 * cluse. 4291 * have a native clause.
4507 *
4508 * @return the native clause for this class
4509 */ 4292 */
4510 NativeClause get nativeClause => _nativeClause; 4293 NativeClause get nativeClause => _nativeClause;
4511 4294
4512 /** 4295 /**
4513 * Set the native clause for this class to the given clause. 4296 * Set the native clause for this class to the given [nativeClause].
4514 *
4515 * @param nativeClause the native clause for this class
4516 */ 4297 */
4517 void set nativeClause(NativeClause nativeClause) { 4298 void set nativeClause(NativeClause nativeClause) {
4518 _nativeClause = becomeParentOf(nativeClause); 4299 _nativeClause = becomeParentOf(nativeClause);
4519 } 4300 }
4520 4301
4521 /** 4302 /**
4522 * Return the type parameters for the class, or `null` if the class does not h ave any type 4303 * Return the type parameters for the class, or `null` if the class does not
4523 * parameters. 4304 * have any type parameters.
4524 *
4525 * @return the type parameters for the class
4526 */ 4305 */
4527 TypeParameterList get typeParameters => _typeParameters; 4306 TypeParameterList get typeParameters => _typeParameters;
4528 4307
4529 /** 4308 /**
4530 * Set the type parameters for the class to the given list of type parameters. 4309 * Set the type parameters for the class to the given list of [typeParameters] .
4531 *
4532 * @param typeParameters the type parameters for the class
4533 */ 4310 */
4534 void set typeParameters(TypeParameterList typeParameters) { 4311 void set typeParameters(TypeParameterList typeParameters) {
4535 _typeParameters = becomeParentOf(typeParameters); 4312 _typeParameters = becomeParentOf(typeParameters);
4536 } 4313 }
4537 4314
4538 /** 4315 /**
4539 * Return the with clause for the class, or `null` if the class does not have a with clause. 4316 * Return the with clause for the class, or `null` if the class does not have
4540 * 4317 * a with clause.
4541 * @return the with clause for the class
4542 */ 4318 */
4543 WithClause get withClause => _withClause; 4319 WithClause get withClause => _withClause;
4544 4320
4545 /** 4321 /**
4546 * Set the with clause for the class to the given clause. 4322 * Set the with clause for the class to the given [withClause].
4547 *
4548 * @param withClause the with clause for the class
4549 */ 4323 */
4550 void set withClause(WithClause withClause) { 4324 void set withClause(WithClause withClause) {
4551 _withClause = becomeParentOf(withClause); 4325 _withClause = becomeParentOf(withClause);
4552 } 4326 }
4553 4327
4554 @override 4328 @override
4555 accept(AstVisitor visitor) => visitor.visitClassDeclaration(this); 4329 accept(AstVisitor visitor) => visitor.visitClassDeclaration(this);
4556 4330
4557 /** 4331 /**
4558 * Return the constructor declared in the class with the given name. 4332 * Return the constructor declared in the class with the given [name], or
4559 * 4333 * `null` if there is no such constructor. If the [name] is `null` then the
4560 * @param name the name of the constructor to find, `null` for default 4334 * default constructor will be searched for.
4561 * @return the found constructor or `null` if not found
4562 */ 4335 */
4563 ConstructorDeclaration getConstructor(String name) { 4336 ConstructorDeclaration getConstructor(String name) {
4564 for (ClassMember classMember in _members) { 4337 for (ClassMember classMember in _members) {
4565 if (classMember is ConstructorDeclaration) { 4338 if (classMember is ConstructorDeclaration) {
4566 ConstructorDeclaration constructor = classMember; 4339 ConstructorDeclaration constructor = classMember;
4567 SimpleIdentifier constructorName = constructor.name; 4340 SimpleIdentifier constructorName = constructor.name;
4568 if (name == null && constructorName == null) { 4341 if (name == null && constructorName == null) {
4569 return constructor; 4342 return constructor;
4570 } 4343 }
4571 if (constructorName != null && constructorName.name == name) { 4344 if (constructorName != null && constructorName.name == name) {
4572 return constructor; 4345 return constructor;
4573 } 4346 }
4574 } 4347 }
4575 } 4348 }
4576 return null; 4349 return null;
4577 } 4350 }
4578 4351
4579 /** 4352 /**
4580 * Return the field declared in the class with the given name. 4353 * Return the field declared in the class with the given [name], or `null` if
4581 * 4354 * there is no such field.
4582 * @param name the name of the field to find
4583 * @return the found field or `null` if not found
4584 */ 4355 */
4585 VariableDeclaration getField(String name) { 4356 VariableDeclaration getField(String name) {
4586 for (ClassMember classMember in _members) { 4357 for (ClassMember classMember in _members) {
4587 if (classMember is FieldDeclaration) { 4358 if (classMember is FieldDeclaration) {
4588 FieldDeclaration fieldDeclaration = classMember; 4359 FieldDeclaration fieldDeclaration = classMember;
4589 NodeList<VariableDeclaration> fields = 4360 NodeList<VariableDeclaration> fields =
4590 fieldDeclaration.fields.variables; 4361 fieldDeclaration.fields.variables;
4591 for (VariableDeclaration field in fields) { 4362 for (VariableDeclaration field in fields) {
4592 SimpleIdentifier fieldName = field.name; 4363 SimpleIdentifier fieldName = field.name;
4593 if (fieldName != null && name == fieldName.name) { 4364 if (fieldName != null && name == fieldName.name) {
4594 return field; 4365 return field;
4595 } 4366 }
4596 } 4367 }
4597 } 4368 }
4598 } 4369 }
4599 return null; 4370 return null;
4600 } 4371 }
4601 4372
4602 /** 4373 /**
4603 * Return the method declared in the class with the given name. 4374 * Return the method declared in the class with the given [name], or `null` if
4604 * 4375 * there is no such method.
4605 * @param name the name of the method to find
4606 * @return the found method or `null` if not found
4607 */ 4376 */
4608 MethodDeclaration getMethod(String name) { 4377 MethodDeclaration getMethod(String name) {
4609 for (ClassMember classMember in _members) { 4378 for (ClassMember classMember in _members) {
4610 if (classMember is MethodDeclaration) { 4379 if (classMember is MethodDeclaration) {
4611 MethodDeclaration method = classMember; 4380 MethodDeclaration method = classMember;
4612 SimpleIdentifier methodName = method.name; 4381 SimpleIdentifier methodName = method.name;
4613 if (methodName != null && name == methodName.name) { 4382 if (methodName != null && name == methodName.name) {
4614 return method; 4383 return method;
4615 } 4384 }
4616 } 4385 }
4617 } 4386 }
4618 return null; 4387 return null;
4619 } 4388 }
4620 4389
4621 @override 4390 @override
4622 void visitChildren(AstVisitor visitor) { 4391 void visitChildren(AstVisitor visitor) {
4623 super.visitChildren(visitor); 4392 super.visitChildren(visitor);
4624 safelyVisitChild(_name, visitor); 4393 _safelyVisitChild(_name, visitor);
4625 safelyVisitChild(_typeParameters, visitor); 4394 _safelyVisitChild(_typeParameters, visitor);
4626 safelyVisitChild(_extendsClause, visitor); 4395 _safelyVisitChild(_extendsClause, visitor);
4627 safelyVisitChild(_withClause, visitor); 4396 _safelyVisitChild(_withClause, visitor);
4628 safelyVisitChild(_implementsClause, visitor); 4397 _safelyVisitChild(_implementsClause, visitor);
4629 safelyVisitChild(_nativeClause, visitor); 4398 _safelyVisitChild(_nativeClause, visitor);
4630 members.accept(visitor); 4399 members.accept(visitor);
4631 } 4400 }
4632 } 4401 }
4633 4402
4634 /** 4403 /**
4635 * The abstract class `ClassMember` defines the behavior common to nodes that de clare a name 4404 * A node that declares a name within the scope of a class.
4636 * within the scope of a class.
4637 */ 4405 */
4638 abstract class ClassMember extends Declaration { 4406 abstract class ClassMember extends Declaration {
4639 /** 4407 /**
4640 * Initialize a newly created member of a class. 4408 * Initialize a newly created member of a class. Either or both of the
4641 * 4409 * [comment] and [metadata] can be `null` if the member does not have the
4642 * @param comment the documentation comment associated with this member 4410 * corresponding attribute.
4643 * @param metadata the annotations associated with this member
4644 */ 4411 */
4645 ClassMember(Comment comment, List<Annotation> metadata) 4412 ClassMember(Comment comment, List<Annotation> metadata)
4646 : super(comment, metadata); 4413 : super(comment, metadata);
4647 } 4414 }
4648 4415
4649 /** 4416 /**
4650 * Instances of the class `ClassTypeAlias` represent a class type alias. 4417 * A class type alias.
4651 * 4418 *
4652 * <pre> 4419 * > classTypeAlias ::=
4653 * classTypeAlias ::= 4420 * > [SimpleIdentifier] [TypeParameterList]? '=' 'abstract'? mixinApplicatio n
4654 * [SimpleIdentifier] [TypeParameterList]? '=' 'abstract'? mixinApplication 4421 * >
4422 * > mixinApplication ::=
4423 * > [TypeName] [WithClause] [ImplementsClause]? ';'
4655 * 4424 *
4656 * mixinApplication ::= 4425 * Deprecated: This class captures obsolete syntax that is no longer part of the
4657 * [TypeName] [WithClause] [ImplementsClause]? ';' 4426 * Dart language.
4658 * </pre>
4659 */ 4427 */
4428 @deprecated
4660 class ClassTypeAlias extends TypeAlias { 4429 class ClassTypeAlias extends TypeAlias {
4661 /** 4430 /**
4662 * The name of the class being declared. 4431 * The name of the class being declared.
4663 */ 4432 */
4664 SimpleIdentifier _name; 4433 SimpleIdentifier _name;
4665 4434
4666 /** 4435 /**
4667 * The type parameters for the class, or `null` if the class does not have any type 4436 * The type parameters for the class, or `null` if the class does not have any
4668 * parameters. 4437 * type parameters.
4669 */ 4438 */
4670 TypeParameterList _typeParameters; 4439 TypeParameterList _typeParameters;
4671 4440
4672 /** 4441 /**
4673 * The token for the '=' separating the name from the definition. 4442 * The token for the '=' separating the name from the definition.
4674 */ 4443 */
4675 Token equals; 4444 Token equals;
4676 4445
4677 /** 4446 /**
4678 * The token for the 'abstract' keyword, or `null` if this is not defining an abstract 4447 * The token for the 'abstract' keyword, or `null` if this is not defining an
4679 * class. 4448 * abstract class.
4680 */ 4449 */
4681 Token abstractKeyword; 4450 Token abstractKeyword;
4682 4451
4683 /** 4452 /**
4684 * The name of the superclass of the class being declared. 4453 * The name of the superclass of the class being declared.
4685 */ 4454 */
4686 TypeName _superclass; 4455 TypeName _superclass;
4687 4456
4688 /** 4457 /**
4689 * The with clause for this class. 4458 * The with clause for this class.
4690 */ 4459 */
4691 WithClause _withClause; 4460 WithClause _withClause;
4692 4461
4693 /** 4462 /**
4694 * The implements clause for this class, or `null` if there is no implements c lause. 4463 * The implements clause for this class, or `null` if there is no implements
4464 * clause.
4695 */ 4465 */
4696 ImplementsClause _implementsClause; 4466 ImplementsClause _implementsClause;
4697 4467
4698 /** 4468 /**
4699 * Initialize a newly created class type alias. 4469 * Initialize a newly created class type alias. Either or both of the
4700 * 4470 * [comment] and [metadata] can be `null` if the class type alias does not
4701 * @param comment the documentation comment associated with this type alias 4471 * have the corresponding attribute. The [typeParameters] can be `null` if the
4702 * @param metadata the annotations associated with this type alias 4472 * class does not have any type parameters. The [abstractKeyword] can be
4703 * @param keyword the token representing the 'typedef' keyword 4473 * `null` if the class is not abstract. The [implementsClause] can be `null`
4704 * @param name the name of the class being declared 4474 * if the class does not implement any interfaces.
4705 * @param typeParameters the type parameters for the class
4706 * @param equals the token for the '=' separating the name from the definition
4707 * @param abstractKeyword the token for the 'abstract' keyword
4708 * @param superclass the name of the superclass of the class being declared
4709 * @param withClause the with clause for this class
4710 * @param implementsClause the implements clause for this class
4711 * @param semicolon the semicolon terminating the declaration
4712 */ 4475 */
4713 ClassTypeAlias(Comment comment, List<Annotation> metadata, Token keyword, 4476 ClassTypeAlias(Comment comment, List<Annotation> metadata, Token keyword,
4714 SimpleIdentifier name, TypeParameterList typeParameters, this.equals, 4477 SimpleIdentifier name, TypeParameterList typeParameters, this.equals,
4715 this.abstractKeyword, TypeName superclass, WithClause withClause, 4478 this.abstractKeyword, TypeName superclass, WithClause withClause,
4716 ImplementsClause implementsClause, Token semicolon) 4479 ImplementsClause implementsClause, Token semicolon)
4717 : super(comment, metadata, keyword, semicolon) { 4480 : super(comment, metadata, keyword, semicolon) {
4718 _name = becomeParentOf(name); 4481 _name = becomeParentOf(name);
4719 _typeParameters = becomeParentOf(typeParameters); 4482 _typeParameters = becomeParentOf(typeParameters);
4720 _superclass = becomeParentOf(superclass); 4483 _superclass = becomeParentOf(superclass);
4721 _withClause = becomeParentOf(withClause); 4484 _withClause = becomeParentOf(withClause);
(...skipping 10 matching lines...) Expand all
4732 ..add(_superclass) 4495 ..add(_superclass)
4733 ..add(_withClause) 4496 ..add(_withClause)
4734 ..add(_implementsClause) 4497 ..add(_implementsClause)
4735 ..add(semicolon); 4498 ..add(semicolon);
4736 4499
4737 @override 4500 @override
4738 ClassElement get element => 4501 ClassElement get element =>
4739 _name != null ? (_name.staticElement as ClassElement) : null; 4502 _name != null ? (_name.staticElement as ClassElement) : null;
4740 4503
4741 /** 4504 /**
4742 * Return the implements clause for this class, or `null` if there is no imple ments clause. 4505 * Return the implements clause for this class, or `null` if there is no
4743 * 4506 * implements clause.
4744 * @return the implements clause for this class
4745 */ 4507 */
4746 ImplementsClause get implementsClause => _implementsClause; 4508 ImplementsClause get implementsClause => _implementsClause;
4747 4509
4748 /** 4510 /**
4749 * Set the implements clause for this class to the given implements clause. 4511 * Set the implements clause for this class to the given [implementsClause].
4750 *
4751 * @param implementsClause the implements clause for this class
4752 */ 4512 */
4753 void set implementsClause(ImplementsClause implementsClause) { 4513 void set implementsClause(ImplementsClause implementsClause) {
4754 _implementsClause = becomeParentOf(implementsClause); 4514 _implementsClause = becomeParentOf(implementsClause);
4755 } 4515 }
4756 4516
4757 /** 4517 /**
4758 * Return `true` if this class is declared to be an abstract class. 4518 * Return `true` if this class is declared to be an abstract class.
4759 *
4760 * @return `true` if this class is declared to be an abstract class
4761 */ 4519 */
4762 bool get isAbstract => abstractKeyword != null; 4520 bool get isAbstract => abstractKeyword != null;
4763 4521
4764 /** 4522 /**
4765 * Return the name of the class being declared. 4523 * Return the name of the class being declared.
4766 *
4767 * @return the name of the class being declared
4768 */ 4524 */
4769 SimpleIdentifier get name => _name; 4525 SimpleIdentifier get name => _name;
4770 4526
4771 /** 4527 /**
4772 * Set the name of the class being declared to the given identifier. 4528 * Set the name of the class being declared to the given [identifier].
4773 *
4774 * @param name the name of the class being declared
4775 */ 4529 */
4776 void set name(SimpleIdentifier name) { 4530 void set name(SimpleIdentifier name) {
4777 _name = becomeParentOf(name); 4531 _name = becomeParentOf(name);
4778 } 4532 }
4779 4533
4780 /** 4534 /**
4781 * Return the name of the superclass of the class being declared. 4535 * Return the name of the superclass of the class being declared.
4782 *
4783 * @return the name of the superclass of the class being declared
4784 */ 4536 */
4785 TypeName get superclass => _superclass; 4537 TypeName get superclass => _superclass;
4786 4538
4787 /** 4539 /**
4788 * Set the name of the superclass of the class being declared to the given nam e. 4540 * Set the name of the superclass of the class being declared to the given
4789 * 4541 * [superclass] name.
4790 * @param superclass the name of the superclass of the class being declared
4791 */ 4542 */
4792 void set superclass(TypeName superclass) { 4543 void set superclass(TypeName superclass) {
4793 _superclass = becomeParentOf(superclass); 4544 _superclass = becomeParentOf(superclass);
4794 } 4545 }
4795 4546
4796 /** 4547 /**
4797 * Return the type parameters for the class, or `null` if the class does not h ave any type 4548 * Return the type parameters for the class, or `null` if the class does not
4798 * parameters. 4549 * have any type parameters.
4799 *
4800 * @return the type parameters for the class
4801 */ 4550 */
4802 TypeParameterList get typeParameters => _typeParameters; 4551 TypeParameterList get typeParameters => _typeParameters;
4803 4552
4804 /** 4553 /**
4805 * Set the type parameters for the class to the given list of parameters. 4554 * Set the type parameters for the class to the given list of [typeParameters] .
4806 *
4807 * @param typeParameters the type parameters for the class
4808 */ 4555 */
4809 void set typeParameters(TypeParameterList typeParameters) { 4556 void set typeParameters(TypeParameterList typeParameters) {
4810 _typeParameters = becomeParentOf(typeParameters); 4557 _typeParameters = becomeParentOf(typeParameters);
4811 } 4558 }
4812 4559
4813 /** 4560 /**
4814 * Return the with clause for this class. 4561 * Return the with clause for this class.
4815 *
4816 * @return the with clause for this class
4817 */ 4562 */
4818 WithClause get withClause => _withClause; 4563 WithClause get withClause => _withClause;
4819 4564
4820 /** 4565 /**
4821 * Set the with clause for this class to the given with clause. 4566 * Set the with clause for this class to the given with [withClause].
4822 *
4823 * @param withClause the with clause for this class
4824 */ 4567 */
4825 void set withClause(WithClause withClause) { 4568 void set withClause(WithClause withClause) {
4826 _withClause = becomeParentOf(withClause); 4569 _withClause = becomeParentOf(withClause);
4827 } 4570 }
4828 4571
4829 @override 4572 @override
4830 accept(AstVisitor visitor) => visitor.visitClassTypeAlias(this); 4573 accept(AstVisitor visitor) => visitor.visitClassTypeAlias(this);
4831 4574
4832 @override 4575 @override
4833 void visitChildren(AstVisitor visitor) { 4576 void visitChildren(AstVisitor visitor) {
4834 super.visitChildren(visitor); 4577 super.visitChildren(visitor);
4835 safelyVisitChild(_name, visitor); 4578 _safelyVisitChild(_name, visitor);
4836 safelyVisitChild(_typeParameters, visitor); 4579 _safelyVisitChild(_typeParameters, visitor);
4837 safelyVisitChild(_superclass, visitor); 4580 _safelyVisitChild(_superclass, visitor);
4838 safelyVisitChild(_withClause, visitor); 4581 _safelyVisitChild(_withClause, visitor);
4839 safelyVisitChild(_implementsClause, visitor); 4582 _safelyVisitChild(_implementsClause, visitor);
4840 } 4583 }
4841 } 4584 }
4842 4585
4843 /** 4586 /**
4844 * Instances of the class `Combinator` represent the combinator associated with an import 4587 * A combinator associated with an import or export directive.
4845 * directive.
4846 * 4588 *
4847 * <pre> 4589 * > combinator ::=
4848 * combinator ::= 4590 * > [HideCombinator]
4849 * [HideCombinator] 4591 * > | [ShowCombinator]
4850 * | [ShowCombinator]
4851 * </pre>
4852 */ 4592 */
4853 abstract class Combinator extends AstNode { 4593 abstract class Combinator extends AstNode {
4854 /** 4594 /**
4855 * The keyword specifying what kind of processing is to be done on the importe d names. 4595 * The keyword specifying what kind of processing is to be done on the
4596 * imported names.
4856 */ 4597 */
4857 Token keyword; 4598 Token keyword;
4858 4599
4859 /** 4600 /**
4860 * Initialize a newly created import combinator. 4601 * Initialize a newly created import combinator.
4861 *
4862 * @param keyword the keyword specifying what kind of processing is to be done on the imported
4863 * names
4864 */ 4602 */
4865 Combinator(this.keyword); 4603 Combinator(this.keyword);
4866 4604
4867 @override 4605 @override
4868 Token get beginToken => keyword; 4606 Token get beginToken => keyword;
4869 } 4607 }
4870 4608
4871 /** 4609 /**
4872 * Instances of the class `Comment` represent a comment within the source code. 4610 * A comment within the source code.
4873 * 4611 *
4874 * <pre> 4612 * > comment ::=
4875 * comment ::= 4613 * > endOfLineComment
4876 * endOfLineComment 4614 * > | blockComment
4877 * | blockComment 4615 * > | documentationComment
4878 * | documentationComment 4616 * >
4879 * 4617 * > endOfLineComment ::=
4880 * endOfLineComment ::= 4618 * > '//' (CHARACTER - EOL)* EOL
4881 * '//' (CHARACTER - EOL)* EOL 4619 * >
4882 * 4620 * > blockComment ::=
4883 * blockComment ::= 4621 * > '/ *' CHARACTER* '&#42;/'
4884 * '/ *' CHARACTER* '&#42;/' 4622 * >
4885 * 4623 * > documentationComment ::=
4886 * documentationComment ::= 4624 * > '/ **' (CHARACTER | [CommentReference])* '&#42;/'
4887 * '/ **' (CHARACTER | [CommentReference])* '&#42;/' 4625 * > | ('///' (CHARACTER - EOL)* EOL)+
4888 * | ('///' (CHARACTER - EOL)* EOL)+
4889 * </pre>
4890 */ 4626 */
4891 class Comment extends AstNode { 4627 class Comment extends AstNode {
4892 /** 4628 /**
4893 * The tokens representing the comment. 4629 * The tokens representing the comment.
4894 */ 4630 */
4895 final List<Token> tokens; 4631 final List<Token> tokens;
4896 4632
4897 /** 4633 /**
4898 * The type of the comment. 4634 * The type of the comment.
4899 */ 4635 */
4900 final CommentType _type; 4636 final CommentType _type;
4901 4637
4902 /** 4638 /**
4903 * The references embedded within the documentation comment. This list will be empty unless this 4639 * The references embedded within the documentation comment. This list will be
4904 * is a documentation comment that has references embedded within it. 4640 * empty unless this is a documentation comment that has references embedded
4641 * within it.
4905 */ 4642 */
4906 NodeList<CommentReference> _references; 4643 NodeList<CommentReference> _references;
4907 4644
4908 /** 4645 /**
4909 * Initialize a newly created comment. 4646 * Initialize a newly created comment. The list of [tokens] must contain at
4910 * 4647 * least one token. The [type] is the type of the comment. The list of
4911 * @param tokens the tokens representing the comment 4648 * [references] can be empty if the comment does not contain any embedded
4912 * @param type the type of the comment 4649 * references.
4913 * @param references the references embedded within the documentation comment
4914 */ 4650 */
4915 Comment(this.tokens, this._type, List<CommentReference> references) { 4651 Comment(this.tokens, this._type, List<CommentReference> references) {
4916 _references = new NodeList<CommentReference>(this, references); 4652 _references = new NodeList<CommentReference>(this, references);
4917 } 4653 }
4918 4654
4919 @override 4655 @override
4920 Token get beginToken => tokens[0]; 4656 Token get beginToken => tokens[0];
4921 4657
4922 @override 4658 @override
4923 Iterable get childEntities => new ChildEntities()..addAll(tokens); 4659 Iterable get childEntities => new ChildEntities()..addAll(tokens);
4924 4660
4925 @override 4661 @override
4926 Token get endToken => tokens[tokens.length - 1]; 4662 Token get endToken => tokens[tokens.length - 1];
4927 4663
4928 /** 4664 /**
4929 * Return `true` if this is a block comment. 4665 * Return `true` if this is a block comment.
4930 *
4931 * @return `true` if this is a block comment
4932 */ 4666 */
4933 bool get isBlock => _type == CommentType.BLOCK; 4667 bool get isBlock => _type == CommentType.BLOCK;
4934 4668
4935 /** 4669 /**
4936 * Return `true` if this is a documentation comment. 4670 * Return `true` if this is a documentation comment.
4937 *
4938 * @return `true` if this is a documentation comment
4939 */ 4671 */
4940 bool get isDocumentation => _type == CommentType.DOCUMENTATION; 4672 bool get isDocumentation => _type == CommentType.DOCUMENTATION;
4941 4673
4942 /** 4674 /**
4943 * Return `true` if this is an end-of-line comment. 4675 * Return `true` if this is an end-of-line comment.
4944 *
4945 * @return `true` if this is an end-of-line comment
4946 */ 4676 */
4947 bool get isEndOfLine => _type == CommentType.END_OF_LINE; 4677 bool get isEndOfLine => _type == CommentType.END_OF_LINE;
4948 4678
4949 /** 4679 /**
4950 * Return the references embedded within the documentation comment. 4680 * Return the references embedded within the documentation comment.
4951 *
4952 * @return the references embedded within the documentation comment
4953 */ 4681 */
4954 NodeList<CommentReference> get references => _references; 4682 NodeList<CommentReference> get references => _references;
4955 4683
4956 @override 4684 @override
4957 accept(AstVisitor visitor) => visitor.visitComment(this); 4685 accept(AstVisitor visitor) => visitor.visitComment(this);
4958 4686
4959 @override 4687 @override
4960 void visitChildren(AstVisitor visitor) { 4688 void visitChildren(AstVisitor visitor) {
4961 _references.accept(visitor); 4689 _references.accept(visitor);
4962 } 4690 }
4963 4691
4964 /** 4692 /**
4965 * Create a block comment. 4693 * Create a block comment consisting of the given [tokens].
4966 *
4967 * @param tokens the tokens representing the comment
4968 * @return the block comment that was created
4969 */ 4694 */
4970 static Comment createBlockComment(List<Token> tokens) => 4695 static Comment createBlockComment(List<Token> tokens) =>
4971 new Comment(tokens, CommentType.BLOCK, null); 4696 new Comment(tokens, CommentType.BLOCK, null);
4972 4697
4973 /** 4698 /**
4974 * Create a documentation comment. 4699 * Create a documentation comment consisting of the given [tokens].
4975 *
4976 * @param tokens the tokens representing the comment
4977 * @return the documentation comment that was created
4978 */ 4700 */
4979 static Comment createDocumentationComment(List<Token> tokens) => 4701 static Comment createDocumentationComment(List<Token> tokens) =>
4980 new Comment(tokens, CommentType.DOCUMENTATION, new List<CommentReference>( )); 4702 new Comment(tokens, CommentType.DOCUMENTATION, new List<CommentReference>( ));
4981 4703
4982 /** 4704 /**
4983 * Create a documentation comment. 4705 * Create a documentation comment consisting of the given [tokens] and having
4984 * 4706 * the given [references] embedded within it.
4985 * @param tokens the tokens representing the comment
4986 * @param references the references embedded within the documentation comment
4987 * @return the documentation comment that was created
4988 */ 4707 */
4989 static Comment createDocumentationCommentWithReferences(List<Token> tokens, 4708 static Comment createDocumentationCommentWithReferences(List<Token> tokens,
4990 List<CommentReference> references) => 4709 List<CommentReference> references) =>
4991 new Comment(tokens, CommentType.DOCUMENTATION, references); 4710 new Comment(tokens, CommentType.DOCUMENTATION, references);
4992 4711
4993 /** 4712 /**
4994 * Create an end-of-line comment. 4713 * Create an end-of-line comment consisting of the given [tokens].
4995 *
4996 * @param tokens the tokens representing the comment
4997 * @return the end-of-line comment that was created
4998 */ 4714 */
4999 static Comment createEndOfLineComment(List<Token> tokens) => 4715 static Comment createEndOfLineComment(List<Token> tokens) =>
5000 new Comment(tokens, CommentType.END_OF_LINE, null); 4716 new Comment(tokens, CommentType.END_OF_LINE, null);
5001 } 4717 }
5002 4718
5003 /** 4719 /**
5004 * Instances of the class `CommentReference` represent a reference to a Dart ele ment that is 4720 * A reference to a Dart element that is found within a documentation comment.
5005 * found within a documentation comment.
5006 * 4721 *
5007 * <pre> 4722 * > commentReference ::=
5008 * commentReference ::= 4723 * > '[' 'new'? [Identifier] ']'
5009 * '[' 'new'? [Identifier] ']'
5010 * </pre>
5011 */ 4724 */
5012 class CommentReference extends AstNode { 4725 class CommentReference extends AstNode {
5013 /** 4726 /**
5014 * The token representing the 'new' keyword, or `null` if there was no 'new' k eyword. 4727 * The token representing the 'new' keyword, or `null` if there was no 'new'
4728 * keyword.
5015 */ 4729 */
5016 Token newKeyword; 4730 Token newKeyword;
5017 4731
5018 /** 4732 /**
5019 * The identifier being referenced. 4733 * The identifier being referenced.
5020 */ 4734 */
5021 Identifier _identifier; 4735 Identifier _identifier;
5022 4736
5023 /** 4737 /**
5024 * Initialize a newly created reference to a Dart element. 4738 * Initialize a newly created reference to a Dart element. The [newKeyword]
5025 * 4739 * can be `null` if the reference is not to a constructor.
5026 * @param newKeyword the token representing the 'new' keyword
5027 * @param identifier the identifier being referenced
5028 */ 4740 */
5029 CommentReference(this.newKeyword, Identifier identifier) { 4741 CommentReference(this.newKeyword, Identifier identifier) {
5030 _identifier = becomeParentOf(identifier); 4742 _identifier = becomeParentOf(identifier);
5031 } 4743 }
5032 4744
5033 @override 4745 @override
5034 Token get beginToken => _identifier.beginToken; 4746 Token get beginToken => _identifier.beginToken;
5035 4747
5036 @override 4748 @override
5037 Iterable get childEntities => new ChildEntities() 4749 Iterable get childEntities => new ChildEntities()
5038 ..add(newKeyword) 4750 ..add(newKeyword)
5039 ..add(_identifier); 4751 ..add(_identifier);
5040 4752
5041 @override 4753 @override
5042 Token get endToken => _identifier.endToken; 4754 Token get endToken => _identifier.endToken;
5043 4755
5044 /** 4756 /**
5045 * Return the identifier being referenced. 4757 * Return the identifier being referenced.
5046 *
5047 * @return the identifier being referenced
5048 */ 4758 */
5049 Identifier get identifier => _identifier; 4759 Identifier get identifier => _identifier;
5050 4760
5051 /** 4761 /**
5052 * Set the identifier being referenced to the given identifier. 4762 * Set the identifier being referenced to the given [identifier].
5053 *
5054 * @param identifier the identifier being referenced
5055 */ 4763 */
5056 void set identifier(Identifier identifier) { 4764 void set identifier(Identifier identifier) {
5057 _identifier = becomeParentOf(identifier); 4765 _identifier = becomeParentOf(identifier);
5058 } 4766 }
5059 4767
5060 @override 4768 @override
5061 accept(AstVisitor visitor) => visitor.visitCommentReference(this); 4769 accept(AstVisitor visitor) => visitor.visitCommentReference(this);
5062 4770
5063 @override 4771 @override
5064 void visitChildren(AstVisitor visitor) { 4772 void visitChildren(AstVisitor visitor) {
5065 safelyVisitChild(_identifier, visitor); 4773 _safelyVisitChild(_identifier, visitor);
5066 } 4774 }
5067 } 4775 }
5068 4776
5069 /** 4777 /**
5070 * The enumeration `CommentType` encodes all the different types of comments 4778 * The possible types of comments that are recognized by the parser.
5071 * that are recognized by the parser.
5072 */ 4779 */
5073 class CommentType { 4780 class CommentType {
5074 /** 4781 /**
5075 * A block comment. 4782 * A block comment.
5076 */ 4783 */
5077 static const CommentType BLOCK = const CommentType('BLOCK'); 4784 static const CommentType BLOCK = const CommentType('BLOCK');
5078 4785
5079 /** 4786 /**
5080 * A documentation comment. 4787 * A documentation comment.
5081 */ 4788 */
(...skipping 12 matching lines...) Expand all
5094 /** 4801 /**
5095 * Initialize a newly created comment type to have the given [name]. 4802 * Initialize a newly created comment type to have the given [name].
5096 */ 4803 */
5097 const CommentType(this.name); 4804 const CommentType(this.name);
5098 4805
5099 @override 4806 @override
5100 String toString() => name; 4807 String toString() => name;
5101 } 4808 }
5102 4809
5103 /** 4810 /**
5104 * Instances of the class `CompilationUnit` represent a compilation unit. 4811 * A compilation unit.
5105 * 4812 *
5106 * While the grammar restricts the order of the directives and declarations with in a compilation 4813 * While the grammar restricts the order of the directives and declarations
5107 * unit, this class does not enforce those restrictions. In particular, the chil dren of a 4814 * within a compilation unit, this class does not enforce those restrictions.
5108 * compilation unit will be visited in lexical order even if lexical order does not conform to the 4815 * In particular, the children of a compilation unit will be visited in lexical
5109 * restrictions of the grammar. 4816 * order even if lexical order does not conform to the restrictions of the
4817 * grammar.
5110 * 4818 *
5111 * <pre> 4819 * > compilationUnit ::=
5112 * compilationUnit ::= 4820 * > directives declarations
5113 * directives declarations 4821 * >
5114 * 4822 * > directives ::=
5115 * directives ::= 4823 * > [ScriptTag]? [LibraryDirective]? namespaceDirective* [PartDirective]*
5116 * [ScriptTag]? [LibraryDirective]? namespaceDirective* [PartDirective]* 4824 * > | [PartOfDirective]
5117 * | [PartOfDirective] 4825 * >
5118 * 4826 * > namespaceDirective ::=
5119 * namespaceDirective ::= 4827 * > [ImportDirective]
5120 * [ImportDirective] 4828 * > | [ExportDirective]
5121 * | [ExportDirective] 4829 * >
5122 * 4830 * > declarations ::=
5123 * declarations ::= 4831 * > [CompilationUnitMember]*
5124 * [CompilationUnitMember]*
5125 * </pre>
5126 */ 4832 */
5127 class CompilationUnit extends AstNode { 4833 class CompilationUnit extends AstNode {
5128 /** 4834 /**
5129 * The first token in the token stream that was parsed to form this compilatio n unit. 4835 * The first token in the token stream that was parsed to form this
4836 * compilation unit.
5130 */ 4837 */
5131 Token beginToken; 4838 Token beginToken;
5132 4839
5133 /** 4840 /**
5134 * The script tag at the beginning of the compilation unit, or `null` if there is no script 4841 * The script tag at the beginning of the compilation unit, or `null` if there
5135 * tag in this compilation unit. 4842 * is no script tag in this compilation unit.
5136 */ 4843 */
5137 ScriptTag _scriptTag; 4844 ScriptTag _scriptTag;
5138 4845
5139 /** 4846 /**
5140 * The directives contained in this compilation unit. 4847 * The directives contained in this compilation unit.
5141 */ 4848 */
5142 NodeList<Directive> _directives; 4849 NodeList<Directive> _directives;
5143 4850
5144 /** 4851 /**
5145 * The declarations contained in this compilation unit. 4852 * The declarations contained in this compilation unit.
5146 */ 4853 */
5147 NodeList<CompilationUnitMember> _declarations; 4854 NodeList<CompilationUnitMember> _declarations;
5148 4855
5149 /** 4856 /**
5150 * The last token in the token stream that was parsed to form this compilation unit. This token 4857 * The last token in the token stream that was parsed to form this compilation
5151 * should always have a type of [TokenType.EOF]. 4858 * unit. This token should always have a type of [TokenType.EOF].
5152 */ 4859 */
5153 final Token endToken; 4860 final Token endToken;
5154 4861
5155 /** 4862 /**
5156 * The element associated with this compilation unit, or `null` if the AST str ucture has not 4863 * The element associated with this compilation unit, or `null` if the AST
5157 * been resolved. 4864 * structure has not been resolved.
5158 */ 4865 */
5159 CompilationUnitElement element; 4866 CompilationUnitElement element;
5160 4867
5161 /** 4868 /**
5162 * The line information for this compilation unit. 4869 * The line information for this compilation unit.
5163 */ 4870 */
5164 LineInfo lineInfo; 4871 LineInfo lineInfo;
5165 4872
5166 /** 4873 /**
5167 * Initialize a newly created compilation unit to have the given directives an d declarations. 4874 * Initialize a newly created compilation unit to have the given directives
5168 * 4875 * and declarations. The [scriptTag] can be `null` if there is no script tag
5169 * @param beginToken the first token in the token stream 4876 * in the compilation unit. The list of [directives] can be `null` if there
5170 * @param scriptTag the script tag at the beginning of the compilation unit 4877 * are no directives in the compilation unit. The list of [declarations] can
5171 * @param directives the directives contained in this compilation unit 4878 * be `null` if there are no declarations in the compilation unit.
5172 * @param declarations the declarations contained in this compilation unit
5173 * @param endToken the last token in the token stream
5174 */ 4879 */
5175 CompilationUnit(this.beginToken, ScriptTag scriptTag, 4880 CompilationUnit(this.beginToken, ScriptTag scriptTag,
5176 List<Directive> directives, List<CompilationUnitMember> declarations, 4881 List<Directive> directives, List<CompilationUnitMember> declarations,
5177 this.endToken) { 4882 this.endToken) {
5178 _scriptTag = becomeParentOf(scriptTag); 4883 _scriptTag = becomeParentOf(scriptTag);
5179 _directives = new NodeList<Directive>(this, directives); 4884 _directives = new NodeList<Directive>(this, directives);
5180 _declarations = new NodeList<CompilationUnitMember>(this, declarations); 4885 _declarations = new NodeList<CompilationUnitMember>(this, declarations);
5181 } 4886 }
5182 4887
5183 @override 4888 @override
5184 Iterable get childEntities { 4889 Iterable get childEntities {
5185 ChildEntities result = new ChildEntities()..add(_scriptTag); 4890 ChildEntities result = new ChildEntities()..add(_scriptTag);
5186 if (_directivesAreBeforeDeclarations()) { 4891 if (_directivesAreBeforeDeclarations()) {
5187 result 4892 result
5188 ..addAll(_directives) 4893 ..addAll(_directives)
5189 ..addAll(_declarations); 4894 ..addAll(_declarations);
5190 } else { 4895 } else {
5191 result.addAll(sortedDirectivesAndDeclarations); 4896 result.addAll(sortedDirectivesAndDeclarations);
5192 } 4897 }
5193 return result; 4898 return result;
5194 } 4899 }
5195 4900
5196 /** 4901 /**
5197 * Return the declarations contained in this compilation unit. 4902 * Return the declarations contained in this compilation unit.
5198 *
5199 * @return the declarations contained in this compilation unit
5200 */ 4903 */
5201 NodeList<CompilationUnitMember> get declarations => _declarations; 4904 NodeList<CompilationUnitMember> get declarations => _declarations;
5202 4905
5203 /** 4906 /**
5204 * Return the directives contained in this compilation unit. 4907 * Return the directives contained in this compilation unit.
5205 *
5206 * @return the directives contained in this compilation unit
5207 */ 4908 */
5208 NodeList<Directive> get directives => _directives; 4909 NodeList<Directive> get directives => _directives;
5209 4910
5210 @override 4911 @override
5211 int get length { 4912 int get length {
5212 Token endToken = this.endToken; 4913 Token endToken = this.endToken;
5213 if (endToken == null) { 4914 if (endToken == null) {
5214 return 0; 4915 return 0;
5215 } 4916 }
5216 return endToken.offset + endToken.length; 4917 return endToken.offset + endToken.length;
5217 } 4918 }
5218 4919
5219 @override 4920 @override
5220 int get offset => 0; 4921 int get offset => 0;
5221 4922
5222 /** 4923 /**
5223 * Return the script tag at the beginning of the compilation unit, or `null` i f there is no 4924 * Return the script tag at the beginning of the compilation unit, or `null`
5224 * script tag in this compilation unit. 4925 * if there is no script tag in this compilation unit.
5225 *
5226 * @return the script tag at the beginning of the compilation unit
5227 */ 4926 */
5228 ScriptTag get scriptTag => _scriptTag; 4927 ScriptTag get scriptTag => _scriptTag;
5229 4928
5230 /** 4929 /**
5231 * Set the script tag at the beginning of the compilation unit to the given sc ript tag. 4930 * Set the script tag at the beginning of the compilation unit to the given
5232 * 4931 * [scriptTag].
5233 * @param scriptTag the script tag at the beginning of the compilation unit
5234 */ 4932 */
5235 void set scriptTag(ScriptTag scriptTag) { 4933 void set scriptTag(ScriptTag scriptTag) {
5236 _scriptTag = becomeParentOf(scriptTag); 4934 _scriptTag = becomeParentOf(scriptTag);
5237 } 4935 }
5238 4936
5239 /** 4937 /**
5240 * Return an array containing all of the directives and declarations in this c ompilation unit, 4938 * Return a list containing all of the directives and declarations in this
5241 * sorted in lexical order. 4939 * compilation unit, sorted in lexical order.
5242 *
5243 * @return the directives and declarations in this compilation unit in the ord er in which they
5244 * appeared in the original source
5245 */ 4940 */
5246 List<AstNode> get sortedDirectivesAndDeclarations { 4941 List<AstNode> get sortedDirectivesAndDeclarations {
5247 return <AstNode>[] 4942 return <AstNode>[]
5248 ..addAll(_directives) 4943 ..addAll(_directives)
5249 ..addAll(_declarations) 4944 ..addAll(_declarations)
5250 ..sort(AstNode.LEXICAL_ORDER); 4945 ..sort(AstNode.LEXICAL_ORDER);
5251 } 4946 }
5252 4947
5253 @override 4948 @override
5254 accept(AstVisitor visitor) => visitor.visitCompilationUnit(this); 4949 accept(AstVisitor visitor) => visitor.visitCompilationUnit(this);
5255 4950
5256 @override 4951 @override
5257 void visitChildren(AstVisitor visitor) { 4952 void visitChildren(AstVisitor visitor) {
5258 safelyVisitChild(_scriptTag, visitor); 4953 _safelyVisitChild(_scriptTag, visitor);
5259 if (_directivesAreBeforeDeclarations()) { 4954 if (_directivesAreBeforeDeclarations()) {
5260 _directives.accept(visitor); 4955 _directives.accept(visitor);
5261 _declarations.accept(visitor); 4956 _declarations.accept(visitor);
5262 } else { 4957 } else {
5263 for (AstNode child in sortedDirectivesAndDeclarations) { 4958 for (AstNode child in sortedDirectivesAndDeclarations) {
5264 child.accept(visitor); 4959 child.accept(visitor);
5265 } 4960 }
5266 } 4961 }
5267 } 4962 }
5268 4963
5269 /** 4964 /**
5270 * Return `true` if all of the directives are lexically before any declaration s. 4965 * Return `true` if all of the directives are lexically before any
5271 * 4966 * declarations.
5272 * @return `true` if all of the directives are lexically before any declaratio ns
5273 */ 4967 */
5274 bool _directivesAreBeforeDeclarations() { 4968 bool _directivesAreBeforeDeclarations() {
5275 if (_directives.isEmpty || _declarations.isEmpty) { 4969 if (_directives.isEmpty || _declarations.isEmpty) {
5276 return true; 4970 return true;
5277 } 4971 }
5278 Directive lastDirective = _directives[_directives.length - 1]; 4972 Directive lastDirective = _directives[_directives.length - 1];
5279 CompilationUnitMember firstDeclaration = _declarations[0]; 4973 CompilationUnitMember firstDeclaration = _declarations[0];
5280 return lastDirective.offset < firstDeclaration.offset; 4974 return lastDirective.offset < firstDeclaration.offset;
5281 } 4975 }
5282 } 4976 }
5283 4977
5284 /** 4978 /**
5285 * Instances of the class `CompilationUnitMember` defines the behavior common to nodes that 4979 * A node that declares a name within the scope of a compilation unit.
5286 * declare a name within the scope of a compilation unit.
5287 * 4980 *
5288 * <pre> 4981 * > compilationUnitMember ::=
5289 * compilationUnitMember ::= 4982 * > [ClassDeclaration]
5290 * [ClassDeclaration] 4983 * > | [TypeAlias]
5291 * | [TypeAlias] 4984 * > | [FunctionDeclaration]
5292 * | [FunctionDeclaration] 4985 * > | [MethodDeclaration]
5293 * | [MethodDeclaration] 4986 * > | [VariableDeclaration]
5294 * | [VariableDeclaration] 4987 * > | [VariableDeclaration]
5295 * | [VariableDeclaration]
5296 * </pre>
5297 */ 4988 */
5298 abstract class CompilationUnitMember extends Declaration { 4989 abstract class CompilationUnitMember extends Declaration {
5299 /** 4990 /**
5300 * Initialize a newly created generic compilation unit member. 4991 * Initialize a newly created generic compilation unit member. Either or both
5301 * 4992 * of the [comment] and [metadata] can be `null` if the member does not have
5302 * @param comment the documentation comment associated with this member 4993 * the corresponding attribute.
5303 * @param metadata the annotations associated with this member
5304 */ 4994 */
5305 CompilationUnitMember(Comment comment, List<Annotation> metadata) 4995 CompilationUnitMember(Comment comment, List<Annotation> metadata)
5306 : super(comment, metadata); 4996 : super(comment, metadata);
5307 } 4997 }
5308 4998
5309 /** 4999 /**
5310 * Instances of the class `ConditionalExpression` represent a conditional expres sion. 5000 * A conditional expression.
5311 * 5001 *
5312 * <pre> 5002 * > conditionalExpression ::=
5313 * conditionalExpression ::= 5003 * > [Expression] '?' [Expression] ':' [Expression]
5314 * [Expression] '?' [Expression] ':' [Expression]
5315 * </pre>
5316 */ 5004 */
5317 class ConditionalExpression extends Expression { 5005 class ConditionalExpression extends Expression {
5318 /** 5006 /**
5319 * The condition used to determine which of the expressions is executed next. 5007 * The condition used to determine which of the expressions is executed next.
5320 */ 5008 */
5321 Expression _condition; 5009 Expression _condition;
5322 5010
5323 /** 5011 /**
5324 * The token used to separate the condition from the then expression. 5012 * The token used to separate the condition from the then expression.
5325 */ 5013 */
5326 Token question; 5014 Token question;
5327 5015
5328 /** 5016 /**
5329 * The expression that is executed if the condition evaluates to `true`. 5017 * The expression that is executed if the condition evaluates to `true`.
5330 */ 5018 */
5331 Expression _thenExpression; 5019 Expression _thenExpression;
5332 5020
5333 /** 5021 /**
5334 * The token used to separate the then expression from the else expression. 5022 * The token used to separate the then expression from the else expression.
5335 */ 5023 */
5336 Token colon; 5024 Token colon;
5337 5025
5338 /** 5026 /**
5339 * The expression that is executed if the condition evaluates to `false`. 5027 * The expression that is executed if the condition evaluates to `false`.
5340 */ 5028 */
5341 Expression _elseExpression; 5029 Expression _elseExpression;
5342 5030
5343 /** 5031 /**
5344 * Initialize a newly created conditional expression. 5032 * Initialize a newly created conditional expression.
5345 *
5346 * @param condition the condition used to determine which expression is execut ed next
5347 * @param question the token used to separate the condition from the then expr ession
5348 * @param thenExpression the expression that is executed if the condition eval uates to
5349 * `true`
5350 * @param colon the token used to separate the then expression from the else e xpression
5351 * @param elseExpression the expression that is executed if the condition eval uates to
5352 * `false`
5353 */ 5033 */
5354 ConditionalExpression(Expression condition, this.question, 5034 ConditionalExpression(Expression condition, this.question,
5355 Expression thenExpression, this.colon, Expression elseExpression) { 5035 Expression thenExpression, this.colon, Expression elseExpression) {
5356 _condition = becomeParentOf(condition); 5036 _condition = becomeParentOf(condition);
5357 _thenExpression = becomeParentOf(thenExpression); 5037 _thenExpression = becomeParentOf(thenExpression);
5358 _elseExpression = becomeParentOf(elseExpression); 5038 _elseExpression = becomeParentOf(elseExpression);
5359 } 5039 }
5360 5040
5361 @override 5041 @override
5362 Token get beginToken => _condition.beginToken; 5042 Token get beginToken => _condition.beginToken;
5363 5043
5364 /** 5044 /**
5365 * TODO(paulberry): untested. 5045 * TODO(paulberry): untested.
5366 */ 5046 */
5367 @override 5047 @override
5368 Iterable get childEntities => new ChildEntities() 5048 Iterable get childEntities => new ChildEntities()
5369 ..add(_condition) 5049 ..add(_condition)
5370 ..add(question) 5050 ..add(question)
5371 ..add(_thenExpression) 5051 ..add(_thenExpression)
5372 ..add(colon) 5052 ..add(colon)
5373 ..add(_elseExpression); 5053 ..add(_elseExpression);
5374 5054
5375 /** 5055 /**
5376 * Return the condition used to determine which of the expressions is executed next. 5056 * Return the condition used to determine which of the expressions is executed
5377 * 5057 * next.
5378 * @return the condition used to determine which expression is executed next
5379 */ 5058 */
5380 Expression get condition => _condition; 5059 Expression get condition => _condition;
5381 5060
5382 /** 5061 /**
5383 * Set the condition used to determine which of the expressions is executed ne xt to the given 5062 * Set the condition used to determine which of the expressions is executed
5384 * expression. 5063 * next to the given [expression].
5385 *
5386 * @param expression the condition used to determine which expression is execu ted next
5387 */ 5064 */
5388 void set condition(Expression expression) { 5065 void set condition(Expression expression) {
5389 _condition = becomeParentOf(expression); 5066 _condition = becomeParentOf(expression);
5390 } 5067 }
5391 5068
5392 /** 5069 /**
5393 * Return the expression that is executed if the condition evaluates to `false `. 5070 * Return the expression that is executed if the condition evaluates to
5394 * 5071 * `false`.
5395 * @return the expression that is executed if the condition evaluates to `fals e`
5396 */ 5072 */
5397 Expression get elseExpression => _elseExpression; 5073 Expression get elseExpression => _elseExpression;
5398 5074
5399 /** 5075 /**
5400 * Set the expression that is executed if the condition evaluates to `false` t o the given 5076 * Set the expression that is executed if the condition evaluates to `false`
5401 * expression. 5077 * to the given [expression].
5402 *
5403 * @param expression the expression that is executed if the condition evaluate s to `false`
5404 */ 5078 */
5405 void set elseExpression(Expression expression) { 5079 void set elseExpression(Expression expression) {
5406 _elseExpression = becomeParentOf(expression); 5080 _elseExpression = becomeParentOf(expression);
5407 } 5081 }
5408 5082
5409 @override 5083 @override
5410 Token get endToken => _elseExpression.endToken; 5084 Token get endToken => _elseExpression.endToken;
5411 5085
5412 @override 5086 @override
5413 int get precedence => 3; 5087 int get precedence => 3;
5414 5088
5415 /** 5089 /**
5416 * Return the expression that is executed if the condition evaluates to `true` . 5090 * Return the expression that is executed if the condition evaluates to
5417 * 5091 * `true`.
5418 * @return the expression that is executed if the condition evaluates to `true `
5419 */ 5092 */
5420 Expression get thenExpression => _thenExpression; 5093 Expression get thenExpression => _thenExpression;
5421 5094
5422 /** 5095 /**
5423 * Set the expression that is executed if the condition evaluates to `true` to the given 5096 * Set the expression that is executed if the condition evaluates to `true` to
5424 * expression. 5097 * the given [expression].
5425 *
5426 * @param expression the expression that is executed if the condition evaluate s to `true`
5427 */ 5098 */
5428 void set thenExpression(Expression expression) { 5099 void set thenExpression(Expression expression) {
5429 _thenExpression = becomeParentOf(expression); 5100 _thenExpression = becomeParentOf(expression);
5430 } 5101 }
5431 5102
5432 @override 5103 @override
5433 accept(AstVisitor visitor) => visitor.visitConditionalExpression(this); 5104 accept(AstVisitor visitor) => visitor.visitConditionalExpression(this);
5434 5105
5435 @override 5106 @override
5436 void visitChildren(AstVisitor visitor) { 5107 void visitChildren(AstVisitor visitor) {
5437 safelyVisitChild(_condition, visitor); 5108 _safelyVisitChild(_condition, visitor);
5438 safelyVisitChild(_thenExpression, visitor); 5109 _safelyVisitChild(_thenExpression, visitor);
5439 safelyVisitChild(_elseExpression, visitor); 5110 _safelyVisitChild(_elseExpression, visitor);
5440 } 5111 }
5441 } 5112 }
5442 5113
5443 /** 5114 /**
5444 * Instances of the class `ConstantEvaluator` evaluate constant expressions to p roduce their 5115 * An object that can be used to evaluate constant expressions to produce their
5445 * compile-time value. According to the Dart Language Specification: <blockquote > A constant 5116 * compile-time value. According to the Dart Language Specification:
5446 * expression is one of the following: 5117 * <blockquote>A constant expression is one of the following:
5447 * * A literal number. 5118 * * A literal number.
5448 * * A literal boolean. 5119 * * A literal boolean.
5449 * * A literal string where any interpolated expression is a compile-time consta nt that evaluates 5120 * * A literal string where any interpolated expression is a compile-time
5450 * to a numeric, string or boolean value or to `null`. 5121 * constant that evaluates to a numeric, string or boolean value or to `null`.
5451 * * `null`. 5122 * * `null`.
5452 * * A reference to a static constant variable. 5123 * * A reference to a static constant variable.
5453 * * An identifier expression that denotes a constant variable, a class or a typ e parameter. 5124 * * An identifier expression that denotes a constant variable, a class or a
5125 * type parameter.
5454 * * A constant constructor invocation. 5126 * * A constant constructor invocation.
5455 * * A constant list literal. 5127 * * A constant list literal.
5456 * * A constant map literal. 5128 * * A constant map literal.
5457 * * A simple or qualified identifier denoting a top-level function or a static method. 5129 * * A simple or qualified identifier denoting a top-level function or a static
5130 * method.
5458 * * A parenthesized expression `(e)` where `e` is a constant expression. 5131 * * A parenthesized expression `(e)` where `e` is a constant expression.
5459 * * An expression of one of the forms `identical(e1, e2)`, `e1 == e2`, 5132 * * An expression of one of the forms `identical(e1, e2)`, `e1 == e2`,
5460 * `e1 != e2` where `e1` and `e2` are constant expressions that evaluate to a 5133 * `e1 != e2` where `e1` and `e2` are constant expressions that evaluate to a
5461 * numeric, string or boolean value or to `null`. 5134 * numeric, string or boolean value or to `null`.
5462 * * An expression of one of the forms `!e`, `e1 && e2` or `e1 || e2`, where 5135 * * An expression of one of the forms `!e`, `e1 && e2` or `e1 || e2`, where
5463 * `e`, `e1` and `e2` are constant expressions that evaluate to a boolean value or 5136 * `e`, `e1` and `e2` are constant expressions that evaluate to a boolean
5464 * to `null`. 5137 * value or to `null`.
5465 * * An expression of one of the forms `~e`, `e1 ^ e2`, `e1 & e2`, 5138 * * An expression of one of the forms `~e`, `e1 ^ e2`, `e1 & e2`, `e1 | e2`,
5466 * `e1 | e2`, `e1 >> e2` or `e1 << e2`, where `e`, `e1` and `e2` 5139 * `e1 >> e2` or `e1 << e2`, where `e`, `e1` and `e2` are constant expressions
5467 * are constant expressions that evaluate to an integer value or to `null`. 5140 * that evaluate to an integer value or to `null`.
5468 * * An expression of one of the forms `-e`, `e1 + e2`, `e1 - e2`, 5141 * * An expression of one of the forms `-e`, `e1 + e2`, `e1 - e2`, `e1 * e2`,
5469 * `e1 * e2`, `e1 / e2`, `e1 ~/ e2`, `e1 > e2`, `e1 < e2`, 5142 * `e1 / e2`, `e1 ~/ e2`, `e1 > e2`, `e1 < e2`, `e1 >= e2`, `e1 <= e2` or
5470 * `e1 >= e2`, `e1 <= e2` or `e1 % e2`, where `e`, `e1` and `e2` 5143 * `e1 % e2`, where `e`, `e1` and `e2` are constant expressions that evaluate
5471 * are constant expressions that evaluate to a numeric value or to `null`. 5144 * to a numeric value or to `null`.
5472 * </blockquote> The values returned by instances of this class are therefore `n ull` and 5145 * </blockquote>
5146 * The values returned by instances of this class are therefore `null` and
5473 * instances of the classes `Boolean`, `BigInteger`, `Double`, `String`, and 5147 * instances of the classes `Boolean`, `BigInteger`, `Double`, `String`, and
5474 * `DartObject`. 5148 * `DartObject`.
5475 * 5149 *
5476 * In addition, this class defines several values that can be returned to indica te various 5150 * In addition, this class defines several values that can be returned to
5477 * conditions encountered during evaluation. These are documented with the stati c field that define 5151 * indicate various conditions encountered during evaluation. These are
5478 * those values. 5152 * documented with the static fields that define those values.
5479 */ 5153 */
5480 class ConstantEvaluator extends GeneralizingAstVisitor<Object> { 5154 class ConstantEvaluator extends GeneralizingAstVisitor<Object> {
5481 /** 5155 /**
5482 * The value returned for expressions (or non-expression nodes) that are not c ompile-time constant 5156 * The value returned for expressions (or non-expression nodes) that are not
5483 * expressions. 5157 * compile-time constant expressions.
5484 */ 5158 */
5485 static Object NOT_A_CONSTANT = new Object(); 5159 static Object NOT_A_CONSTANT = new Object();
5486 5160
5487 @override 5161 @override
5488 Object visitAdjacentStrings(AdjacentStrings node) { 5162 Object visitAdjacentStrings(AdjacentStrings node) {
5489 StringBuffer buffer = new StringBuffer(); 5163 StringBuffer buffer = new StringBuffer();
5490 for (StringLiteral string in node.strings) { 5164 for (StringLiteral string in node.strings) {
5491 Object value = string.accept(this); 5165 Object value = string.accept(this);
5492 if (identical(value, NOT_A_CONSTANT)) { 5166 if (identical(value, NOT_A_CONSTANT)) {
5493 return value; 5167 return value;
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
5782 for (Token component in node.components) { 5456 for (Token component in node.components) {
5783 if (buffer.length > 0) { 5457 if (buffer.length > 0) {
5784 buffer.writeCharCode(0x2E); 5458 buffer.writeCharCode(0x2E);
5785 } 5459 }
5786 buffer.write(component.lexeme); 5460 buffer.write(component.lexeme);
5787 } 5461 }
5788 return buffer.toString(); 5462 return buffer.toString();
5789 } 5463 }
5790 5464
5791 /** 5465 /**
5792 * Return the constant value of the static constant represented by the given e lement. 5466 * Return the constant value of the static constant represented by the given
5793 * 5467 * [element].
5794 * @param element the element whose value is to be returned
5795 * @return the constant value of the static constant
5796 */ 5468 */
5797 Object _getConstantValue(Element element) { 5469 Object _getConstantValue(Element element) {
5798 // TODO(brianwilkerson) Implement this 5470 // TODO(brianwilkerson) Implement this
5799 if (element is FieldElement) { 5471 if (element is FieldElement) {
5800 FieldElement field = element; 5472 FieldElement field = element;
5801 if (field.isStatic && field.isConst) { 5473 if (field.isStatic && field.isConst) {
5802 //field.getConstantValue(); 5474 //field.getConstantValue();
5803 } 5475 }
5804 // } else if (element instanceof VariableElement) { 5476 // } else if (element instanceof VariableElement) {
5805 // VariableElement variable = (VariableElement) element; 5477 // VariableElement variable = (VariableElement) element;
5806 // if (variable.isStatic() && variable.isConst()) { 5478 // if (variable.isStatic() && variable.isConst()) {
5807 // //variable.getConstantValue(); 5479 // //variable.getConstantValue();
5808 // } 5480 // }
5809 } 5481 }
5810 return NOT_A_CONSTANT; 5482 return NOT_A_CONSTANT;
5811 } 5483 }
5812 } 5484 }
5813 5485
5814 /** 5486 /**
5815 * Instances of the class `ConstructorDeclaration` represent a constructor decla ration. 5487 * A constructor declaration.
5816 * 5488 *
5817 * <pre> 5489 * > constructorDeclaration ::=
5818 * constructorDeclaration ::= 5490 * > constructorSignature [FunctionBody]?
5819 * constructorSignature [FunctionBody]? 5491 * > | constructorName formalParameterList ':' 'this' ('.' [SimpleIdentifier]) ? arguments
5820 * | constructorName formalParameterList ':' 'this' ('.' [SimpleIdentifier])? arguments 5492 * >
5821 * 5493 * > constructorSignature ::=
5822 * constructorSignature ::= 5494 * > 'external'? constructorName formalParameterList initializerList?
5823 * 'external'? constructorName formalParameterList initializerList? 5495 * > | 'external'? 'factory' factoryName formalParameterList initializerList?
5824 * | 'external'? 'factory' factoryName formalParameterList initializerList? 5496 * > | 'external'? 'const' constructorName formalParameterList initializerLis t?
5825 * | 'external'? 'const' constructorName formalParameterList initializerList? 5497 * >
5826 * 5498 * > constructorName ::=
5827 * constructorName ::= 5499 * > [SimpleIdentifier] ('.' [SimpleIdentifier])?
5828 * [SimpleIdentifier] ('.' [SimpleIdentifier])? 5500 * >
5829 * 5501 * > factoryName ::=
5830 * factoryName ::= 5502 * > [Identifier] ('.' [SimpleIdentifier])?
5831 * [Identifier] ('.' [SimpleIdentifier])? 5503 * >
5832 * 5504 * > initializerList ::=
5833 * initializerList ::= 5505 * > ':' [ConstructorInitializer] (',' [ConstructorInitializer])*
5834 * ':' [ConstructorInitializer] (',' [ConstructorInitializer])*
5835 * </pre>
5836 */ 5506 */
5837 class ConstructorDeclaration extends ClassMember { 5507 class ConstructorDeclaration extends ClassMember {
5838 /** 5508 /**
5839 * The token for the 'external' keyword, or `null` if the constructor is not e xternal. 5509 * The token for the 'external' keyword, or `null` if the constructor is not
5510 * external.
5840 */ 5511 */
5841 Token externalKeyword; 5512 Token externalKeyword;
5842 5513
5843 /** 5514 /**
5844 * The token for the 'const' keyword, or `null` if the constructor is not a co nst 5515 * The token for the 'const' keyword, or `null` if the constructor is not a
5845 * constructor. 5516 * const constructor.
5846 */ 5517 */
5847 Token constKeyword; 5518 Token constKeyword;
5848 5519
5849 /** 5520 /**
5850 * The token for the 'factory' keyword, or `null` if the constructor is not a factory 5521 * The token for the 'factory' keyword, or `null` if the constructor is not a
5851 * constructor. 5522 * factory constructor.
5852 */ 5523 */
5853 Token factoryKeyword; 5524 Token factoryKeyword;
5854 5525
5855 /** 5526 /**
5856 * The type of object being created. This can be different than the type in wh ich the constructor 5527 * The type of object being created. This can be different than the type in
5857 * is being declared if the constructor is the implementation of a factory con structor. 5528 * which the constructor is being declared if the constructor is the
5529 * implementation of a factory constructor.
5858 */ 5530 */
5859 Identifier _returnType; 5531 Identifier _returnType;
5860 5532
5861 /** 5533 /**
5862 * The token for the period before the constructor name, or `null` if the cons tructor being 5534 * The token for the period before the constructor name, or `null` if the
5863 * declared is unnamed. 5535 * constructor being declared is unnamed.
5864 */ 5536 */
5865 Token period; 5537 Token period;
5866 5538
5867 /** 5539 /**
5868 * The name of the constructor, or `null` if the constructor being declared is unnamed. 5540 * The name of the constructor, or `null` if the constructor being declared is
5541 * unnamed.
5869 */ 5542 */
5870 SimpleIdentifier _name; 5543 SimpleIdentifier _name;
5871 5544
5872 /** 5545 /**
5873 * The parameters associated with the constructor. 5546 * The parameters associated with the constructor.
5874 */ 5547 */
5875 FormalParameterList _parameters; 5548 FormalParameterList _parameters;
5876 5549
5877 /** 5550 /**
5878 * The token for the separator (colon or equals) before the initializer list o r redirection, or 5551 * The token for the separator (colon or equals) before the initializer list
5879 * `null` if there are no initializers. 5552 * or redirection, or `null` if there are no initializers.
5880 */ 5553 */
5881 Token separator; 5554 Token separator;
5882 5555
5883 /** 5556 /**
5884 * The initializers associated with the constructor. 5557 * The initializers associated with the constructor.
5885 */ 5558 */
5886 NodeList<ConstructorInitializer> _initializers; 5559 NodeList<ConstructorInitializer> _initializers;
5887 5560
5888 /** 5561 /**
5889 * The name of the constructor to which this constructor will be redirected, o r `null` if 5562 * The name of the constructor to which this constructor will be redirected,
5890 * this is not a redirecting factory constructor. 5563 * or `null` if this is not a redirecting factory constructor.
5891 */ 5564 */
5892 ConstructorName _redirectedConstructor; 5565 ConstructorName _redirectedConstructor;
5893 5566
5894 /** 5567 /**
5895 * The body of the constructor, or `null` if the constructor does not have a b ody. 5568 * The body of the constructor, or `null` if the constructor does not have a
5569 * body.
5896 */ 5570 */
5897 FunctionBody _body; 5571 FunctionBody _body;
5898 5572
5899 /** 5573 /**
5900 * The element associated with this constructor, or `null` if the AST structur e has not been 5574 * The element associated with this constructor, or `null` if the AST
5901 * resolved or if this constructor could not be resolved. 5575 * structure has not been resolved or if this constructor could not be
5576 * resolved.
5902 */ 5577 */
5903 ConstructorElement element; 5578 ConstructorElement element;
5904 5579
5905 /** 5580 /**
5906 * Initialize a newly created constructor declaration. 5581 * Initialize a newly created constructor declaration. The [externalKeyword]
5907 * 5582 * can be `null` if the constructor is not external. Either or both of the
5908 * @param externalKeyword the token for the 'external' keyword 5583 * [comment] and [metadata] can be `null` if the constructor does not have the
5909 * @param comment the documentation comment associated with this constructor 5584 * corresponding attribute. The [constKeyword] can be `null` if the
5910 * @param metadata the annotations associated with this constructor 5585 * constructor cannot be used to create a constant. The [factoryKeyword] can
5911 * @param constKeyword the token for the 'const' keyword 5586 * be `null` if the constructor is not a factory. The [period] and [name] can
5912 * @param factoryKeyword the token for the 'factory' keyword 5587 * both be `null` if the constructor is not a named constructor. The
5913 * @param returnType the return type of the constructor 5588 * [separator] can be `null` if the constructor does not have any initializers
5914 * @param period the token for the period before the constructor name 5589 * and does not redirect to a different constructor. The list of
5915 * @param name the name of the constructor 5590 * [initializers] can be `null` if the constructor does not have any
5916 * @param parameters the parameters associated with the constructor 5591 * initializers. The [redirectedConstructor] can be `null` if the constructor
5917 * @param separator the token for the colon or equals before the initializers 5592 * does not redirect to a different constructor. The [body] can be `null` if
5918 * @param initializers the initializers associated with the constructor 5593 * the constructor does not have a body.
5919 * @param redirectedConstructor the name of the constructor to which this cons tructor will be
5920 * redirected
5921 * @param body the body of the constructor
5922 */ 5594 */
5923 ConstructorDeclaration(Comment comment, List<Annotation> metadata, 5595 ConstructorDeclaration(Comment comment, List<Annotation> metadata,
5924 this.externalKeyword, this.constKeyword, this.factoryKeyword, 5596 this.externalKeyword, this.constKeyword, this.factoryKeyword,
5925 Identifier returnType, this.period, SimpleIdentifier name, 5597 Identifier returnType, this.period, SimpleIdentifier name,
5926 FormalParameterList parameters, this.separator, 5598 FormalParameterList parameters, this.separator,
5927 List<ConstructorInitializer> initializers, 5599 List<ConstructorInitializer> initializers,
5928 ConstructorName redirectedConstructor, FunctionBody body) 5600 ConstructorName redirectedConstructor, FunctionBody body)
5929 : super(comment, metadata) { 5601 : super(comment, metadata) {
5930 _returnType = becomeParentOf(returnType); 5602 _returnType = becomeParentOf(returnType);
5931 _name = becomeParentOf(name); 5603 _name = becomeParentOf(name);
5932 _parameters = becomeParentOf(parameters); 5604 _parameters = becomeParentOf(parameters);
5933 _initializers = new NodeList<ConstructorInitializer>(this, initializers); 5605 _initializers = new NodeList<ConstructorInitializer>(this, initializers);
5934 _redirectedConstructor = becomeParentOf(redirectedConstructor); 5606 _redirectedConstructor = becomeParentOf(redirectedConstructor);
5935 _body = becomeParentOf(body); 5607 _body = becomeParentOf(body);
5936 } 5608 }
5937 5609
5938 /** 5610 /**
5939 * Return the body of the constructor, or `null` if the constructor does not h ave a body. 5611 * Return the body of the constructor, or `null` if the constructor does not
5940 * 5612 * have a body.
5941 * @return the body of the constructor
5942 */ 5613 */
5943 FunctionBody get body => _body; 5614 FunctionBody get body => _body;
5944 5615
5945 /** 5616 /**
5946 * Set the body of the constructor to the given function body. 5617 * Set the body of the constructor to the given [functionBody].
5947 *
5948 * @param functionBody the body of the constructor
5949 */ 5618 */
5950 void set body(FunctionBody functionBody) { 5619 void set body(FunctionBody functionBody) {
5951 _body = becomeParentOf(functionBody); 5620 _body = becomeParentOf(functionBody);
5952 } 5621 }
5953 5622
5954 @override 5623 @override
5955 Iterable get childEntities => super._childEntities 5624 Iterable get childEntities => super._childEntities
5956 ..add(externalKeyword) 5625 ..add(externalKeyword)
5957 ..add(constKeyword) 5626 ..add(constKeyword)
5958 ..add(factoryKeyword) 5627 ..add(factoryKeyword)
(...skipping 21 matching lines...) Expand all
5980 Token leftMost = 5649 Token leftMost =
5981 Token.lexicallyFirst([externalKeyword, constKeyword, factoryKeyword]); 5650 Token.lexicallyFirst([externalKeyword, constKeyword, factoryKeyword]);
5982 if (leftMost != null) { 5651 if (leftMost != null) {
5983 return leftMost; 5652 return leftMost;
5984 } 5653 }
5985 return _returnType.beginToken; 5654 return _returnType.beginToken;
5986 } 5655 }
5987 5656
5988 /** 5657 /**
5989 * Return the initializers associated with the constructor. 5658 * Return the initializers associated with the constructor.
5990 *
5991 * @return the initializers associated with the constructor
5992 */ 5659 */
5993 NodeList<ConstructorInitializer> get initializers => _initializers; 5660 NodeList<ConstructorInitializer> get initializers => _initializers;
5994 5661
5995 /** 5662 /**
5996 * Return the name of the constructor, or `null` if the constructor being decl ared is 5663 * Return the name of the constructor, or `null` if the constructor being
5997 * unnamed. 5664 * declared is unnamed.
5998 *
5999 * @return the name of the constructor
6000 */ 5665 */
6001 SimpleIdentifier get name => _name; 5666 SimpleIdentifier get name => _name;
6002 5667
6003 /** 5668 /**
6004 * Set the name of the constructor to the given identifier. 5669 * Set the name of the constructor to the given [identifier].
6005 *
6006 * @param identifier the name of the constructor
6007 */ 5670 */
6008 void set name(SimpleIdentifier identifier) { 5671 void set name(SimpleIdentifier identifier) {
6009 _name = becomeParentOf(identifier); 5672 _name = becomeParentOf(identifier);
6010 } 5673 }
6011 5674
6012 /** 5675 /**
6013 * Return the parameters associated with the constructor. 5676 * Return the parameters associated with the constructor.
6014 *
6015 * @return the parameters associated with the constructor
6016 */ 5677 */
6017 FormalParameterList get parameters => _parameters; 5678 FormalParameterList get parameters => _parameters;
6018 5679
6019 /** 5680 /**
6020 * Set the parameters associated with the constructor to the given list of par ameters. 5681 * Set the parameters associated with the constructor to the given list of
6021 * 5682 * [parameters].
6022 * @param parameters the parameters associated with the constructor
6023 */ 5683 */
6024 void set parameters(FormalParameterList parameters) { 5684 void set parameters(FormalParameterList parameters) {
6025 _parameters = becomeParentOf(parameters); 5685 _parameters = becomeParentOf(parameters);
6026 } 5686 }
6027 5687
6028 /** 5688 /**
6029 * Return the name of the constructor to which this constructor will be redire cted, or 5689 * Return the name of the constructor to which this constructor will be
6030 * `null` if this is not a redirecting factory constructor. 5690 * redirected, or `null` if this is not a redirecting factory constructor.
6031 *
6032 * @return the name of the constructor to which this constructor will be redir ected
6033 */ 5691 */
6034 ConstructorName get redirectedConstructor => _redirectedConstructor; 5692 ConstructorName get redirectedConstructor => _redirectedConstructor;
6035 5693
6036 /** 5694 /**
6037 * Set the name of the constructor to which this constructor will be redirecte d to the given 5695 * Set the name of the constructor to which this constructor will be
6038 * constructor name. 5696 * redirected to the given [redirectedConstructor] name.
6039 *
6040 * @param redirectedConstructor the name of the constructor to which this cons tructor will be
6041 * redirected
6042 */ 5697 */
6043 void set redirectedConstructor(ConstructorName redirectedConstructor) { 5698 void set redirectedConstructor(ConstructorName redirectedConstructor) {
6044 _redirectedConstructor = becomeParentOf(redirectedConstructor); 5699 _redirectedConstructor = becomeParentOf(redirectedConstructor);
6045 } 5700 }
6046 5701
6047 /** 5702 /**
6048 * Return the type of object being created. This can be different than the typ e in which the 5703 * Return the type of object being created. This can be different than the
6049 * constructor is being declared if the constructor is the implementation of a factory 5704 * type in which the constructor is being declared if the constructor is the
6050 * constructor. 5705 * implementation of a factory constructor.
6051 *
6052 * @return the type of object being created
6053 */ 5706 */
6054 Identifier get returnType => _returnType; 5707 Identifier get returnType => _returnType;
6055 5708
6056 /** 5709 /**
6057 * Set the type of object being created to the given type name. 5710 * Set the type of object being created to the given [typeName].
6058 *
6059 * @param typeName the type of object being created
6060 */ 5711 */
6061 void set returnType(Identifier typeName) { 5712 void set returnType(Identifier typeName) {
6062 _returnType = becomeParentOf(typeName); 5713 _returnType = becomeParentOf(typeName);
6063 } 5714 }
6064 5715
6065 @override 5716 @override
6066 accept(AstVisitor visitor) => visitor.visitConstructorDeclaration(this); 5717 accept(AstVisitor visitor) => visitor.visitConstructorDeclaration(this);
6067 5718
6068 @override 5719 @override
6069 void visitChildren(AstVisitor visitor) { 5720 void visitChildren(AstVisitor visitor) {
6070 super.visitChildren(visitor); 5721 super.visitChildren(visitor);
6071 safelyVisitChild(_returnType, visitor); 5722 _safelyVisitChild(_returnType, visitor);
6072 safelyVisitChild(_name, visitor); 5723 _safelyVisitChild(_name, visitor);
6073 safelyVisitChild(_parameters, visitor); 5724 _safelyVisitChild(_parameters, visitor);
6074 _initializers.accept(visitor); 5725 _initializers.accept(visitor);
6075 safelyVisitChild(_redirectedConstructor, visitor); 5726 _safelyVisitChild(_redirectedConstructor, visitor);
6076 safelyVisitChild(_body, visitor); 5727 _safelyVisitChild(_body, visitor);
6077 } 5728 }
6078 } 5729 }
6079 5730
6080 /** 5731 /**
6081 * Instances of the class `ConstructorFieldInitializer` represent the initializa tion of a 5732 * The initialization of a field within a constructor's initialization list.
6082 * field within a constructor's initialization list.
6083 * 5733 *
6084 * <pre> 5734 * > fieldInitializer ::=
6085 * fieldInitializer ::= 5735 * > ('this' '.')? [SimpleIdentifier] '=' [Expression]
6086 * ('this' '.')? [SimpleIdentifier] '=' [Expression]
6087 * </pre>
6088 */ 5736 */
6089 class ConstructorFieldInitializer extends ConstructorInitializer { 5737 class ConstructorFieldInitializer extends ConstructorInitializer {
6090 /** 5738 /**
6091 * The token for the 'this' keyword, or `null` if there is no 'this' keyword. 5739 * The token for the 'this' keyword, or `null` if there is no 'this' keyword.
6092 */ 5740 */
6093 Token keyword; 5741 Token keyword;
6094 5742
6095 /** 5743 /**
6096 * The token for the period after the 'this' keyword, or `null` if there is no 'this' 5744 * The token for the period after the 'this' keyword, or `null` if there is no
6097 * keyword. 5745 * 'this' keyword.
6098 */ 5746 */
6099 Token period; 5747 Token period;
6100 5748
6101 /** 5749 /**
6102 * The name of the field being initialized. 5750 * The name of the field being initialized.
6103 */ 5751 */
6104 SimpleIdentifier _fieldName; 5752 SimpleIdentifier _fieldName;
6105 5753
6106 /** 5754 /**
6107 * The token for the equal sign between the field name and the expression. 5755 * The token for the equal sign between the field name and the expression.
6108 */ 5756 */
6109 Token equals; 5757 Token equals;
6110 5758
6111 /** 5759 /**
6112 * The expression computing the value to which the field will be initialized. 5760 * The expression computing the value to which the field will be initialized.
6113 */ 5761 */
6114 Expression _expression; 5762 Expression _expression;
6115 5763
6116 /** 5764 /**
6117 * Initialize a newly created field initializer to initialize the field with t he given name to the 5765 * Initialize a newly created field initializer to initialize the field with
6118 * value of the given expression. 5766 * the given name to the value of the given expression. The [keyword] and
6119 * 5767 * [period] can be `null` if the 'this' keyword was not specified.
6120 * @param keyword the token for the 'this' keyword
6121 * @param period the token for the period after the 'this' keyword
6122 * @param fieldName the name of the field being initialized
6123 * @param equals the token for the equal sign between the field name and the e xpression
6124 * @param expression the expression computing the value to which the field wil l be initialized
6125 */ 5768 */
6126 ConstructorFieldInitializer(this.keyword, this.period, 5769 ConstructorFieldInitializer(this.keyword, this.period,
6127 SimpleIdentifier fieldName, this.equals, Expression expression) { 5770 SimpleIdentifier fieldName, this.equals, Expression expression) {
6128 _fieldName = becomeParentOf(fieldName); 5771 _fieldName = becomeParentOf(fieldName);
6129 _expression = becomeParentOf(expression); 5772 _expression = becomeParentOf(expression);
6130 } 5773 }
6131 5774
6132 @override 5775 @override
6133 Token get beginToken { 5776 Token get beginToken {
6134 if (keyword != null) { 5777 if (keyword != null) {
6135 return keyword; 5778 return keyword;
6136 } 5779 }
6137 return _fieldName.beginToken; 5780 return _fieldName.beginToken;
6138 } 5781 }
6139 5782
6140 @override 5783 @override
6141 Iterable get childEntities => new ChildEntities() 5784 Iterable get childEntities => new ChildEntities()
6142 ..add(keyword) 5785 ..add(keyword)
6143 ..add(period) 5786 ..add(period)
6144 ..add(_fieldName) 5787 ..add(_fieldName)
6145 ..add(equals) 5788 ..add(equals)
6146 ..add(_expression); 5789 ..add(_expression);
6147 5790
6148 @override 5791 @override
6149 Token get endToken => _expression.endToken; 5792 Token get endToken => _expression.endToken;
6150 5793
6151 /** 5794 /**
6152 * Return the expression computing the value to which the field will be initia lized. 5795 * Return the expression computing the value to which the field will be
6153 * 5796 * initialized.
6154 * @return the expression computing the value to which the field will be initi alized
6155 */ 5797 */
6156 Expression get expression => _expression; 5798 Expression get expression => _expression;
6157 5799
6158 /** 5800 /**
6159 * Set the expression computing the value to which the field will be initializ ed to the given 5801 * Set the expression computing the value to which the field will be
6160 * expression. 5802 * initialized to the given [expression].
6161 *
6162 * @param expression the expression computing the value to which the field wil l be initialized
6163 */ 5803 */
6164 void set expression(Expression expression) { 5804 void set expression(Expression expression) {
6165 _expression = becomeParentOf(expression); 5805 _expression = becomeParentOf(expression);
6166 } 5806 }
6167 5807
6168 /** 5808 /**
6169 * Return the name of the field being initialized. 5809 * Return the name of the field being initialized.
6170 *
6171 * @return the name of the field being initialized
6172 */ 5810 */
6173 SimpleIdentifier get fieldName => _fieldName; 5811 SimpleIdentifier get fieldName => _fieldName;
6174 5812
6175 /** 5813 /**
6176 * Set the name of the field being initialized to the given identifier. 5814 * Set the name of the field being initialized to the given [identifier].
6177 *
6178 * @param identifier the name of the field being initialized
6179 */ 5815 */
6180 void set fieldName(SimpleIdentifier identifier) { 5816 void set fieldName(SimpleIdentifier identifier) {
6181 _fieldName = becomeParentOf(identifier); 5817 _fieldName = becomeParentOf(identifier);
6182 } 5818 }
6183 5819
6184 @override 5820 @override
6185 accept(AstVisitor visitor) => visitor.visitConstructorFieldInitializer(this); 5821 accept(AstVisitor visitor) => visitor.visitConstructorFieldInitializer(this);
6186 5822
6187 @override 5823 @override
6188 void visitChildren(AstVisitor visitor) { 5824 void visitChildren(AstVisitor visitor) {
6189 safelyVisitChild(_fieldName, visitor); 5825 _safelyVisitChild(_fieldName, visitor);
6190 safelyVisitChild(_expression, visitor); 5826 _safelyVisitChild(_expression, visitor);
6191 } 5827 }
6192 } 5828 }
6193 5829
6194 /** 5830 /**
6195 * Instances of the class `ConstructorInitializer` defines the behavior of nodes that can 5831 * A node that can occur in the initializer list of a constructor declaration.
6196 * occur in the initializer list of a constructor declaration.
6197 * 5832 *
6198 * <pre> 5833 * > constructorInitializer ::=
6199 * constructorInitializer ::= 5834 * > [SuperConstructorInvocation]
6200 * [SuperConstructorInvocation] 5835 * > | [ConstructorFieldInitializer]
6201 * | [ConstructorFieldInitializer]
6202 * </pre>
6203 */ 5836 */
6204 abstract class ConstructorInitializer extends AstNode { 5837 abstract class ConstructorInitializer extends AstNode {
6205 } 5838 }
6206 5839
6207 /** 5840 /**
6208 * Instances of the class `ConstructorName` represent the name of the constructo r. 5841 * The name of the constructor.
6209 * 5842 *
6210 * <pre> 5843 * > constructorName ::=
6211 * constructorName: 5844 * > type ('.' identifier)?
6212 * type ('.' identifier)?
6213 * </pre>
6214 */ 5845 */
6215 class ConstructorName extends AstNode { 5846 class ConstructorName extends AstNode {
6216 /** 5847 /**
6217 * The name of the type defining the constructor. 5848 * The name of the type defining the constructor.
6218 */ 5849 */
6219 TypeName _type; 5850 TypeName _type;
6220 5851
6221 /** 5852 /**
6222 * The token for the period before the constructor name, or `null` if the spec ified 5853 * The token for the period before the constructor name, or `null` if the
6223 * constructor is the unnamed constructor. 5854 * specified constructor is the unnamed constructor.
6224 */ 5855 */
6225 Token period; 5856 Token period;
6226 5857
6227 /** 5858 /**
6228 * The name of the constructor, or `null` if the specified constructor is the unnamed 5859 * The name of the constructor, or `null` if the specified constructor is the
6229 * constructor. 5860 * unnamed constructor.
6230 */ 5861 */
6231 SimpleIdentifier _name; 5862 SimpleIdentifier _name;
6232 5863
6233 /** 5864 /**
6234 * The element associated with this constructor name based on static type info rmation, or 5865 * The element associated with this constructor name based on static type
6235 * `null` if the AST structure has not been resolved or if this constructor na me could not 5866 * information, or `null` if the AST structure has not been resolved or if
6236 * be resolved. 5867 * this constructor name could not be resolved.
6237 */ 5868 */
6238 ConstructorElement staticElement; 5869 ConstructorElement staticElement;
6239 5870
6240 /** 5871 /**
6241 * Initialize a newly created constructor name. 5872 * Initialize a newly created constructor name. The [period] and [name] can be
6242 * 5873 * `null` if the constructor being named is the unnamed constructor.
6243 * @param type the name of the type defining the constructor
6244 * @param period the token for the period before the constructor name
6245 * @param name the name of the constructor
6246 */ 5874 */
6247 ConstructorName(TypeName type, this.period, SimpleIdentifier name) { 5875 ConstructorName(TypeName type, this.period, SimpleIdentifier name) {
6248 _type = becomeParentOf(type); 5876 _type = becomeParentOf(type);
6249 _name = becomeParentOf(name); 5877 _name = becomeParentOf(name);
6250 } 5878 }
6251 5879
6252 @override 5880 @override
6253 Token get beginToken => _type.beginToken; 5881 Token get beginToken => _type.beginToken;
6254 5882
6255 @override 5883 @override
6256 Iterable get childEntities => new ChildEntities() 5884 Iterable get childEntities => new ChildEntities()
6257 ..add(_type) 5885 ..add(_type)
6258 ..add(period) 5886 ..add(period)
6259 ..add(_name); 5887 ..add(_name);
6260 5888
6261 @override 5889 @override
6262 Token get endToken { 5890 Token get endToken {
6263 if (_name != null) { 5891 if (_name != null) {
6264 return _name.endToken; 5892 return _name.endToken;
6265 } 5893 }
6266 return _type.endToken; 5894 return _type.endToken;
6267 } 5895 }
6268 5896
6269 /** 5897 /**
6270 * Return the name of the constructor, or `null` if the specified constructor is the unnamed 5898 * Return the name of the constructor, or `null` if the specified constructor
6271 * constructor. 5899 * is the unnamed constructor.
6272 *
6273 * @return the name of the constructor
6274 */ 5900 */
6275 SimpleIdentifier get name => _name; 5901 SimpleIdentifier get name => _name;
6276 5902
6277 /** 5903 /**
6278 * Set the name of the constructor to the given name. 5904 * Set the name of the constructor to the given [name].
6279 *
6280 * @param name the name of the constructor
6281 */ 5905 */
6282 void set name(SimpleIdentifier name) { 5906 void set name(SimpleIdentifier name) {
6283 _name = becomeParentOf(name); 5907 _name = becomeParentOf(name);
6284 } 5908 }
6285 5909
6286 /** 5910 /**
6287 * Return the name of the type defining the constructor. 5911 * Return the name of the type defining the constructor.
6288 *
6289 * @return the name of the type defining the constructor
6290 */ 5912 */
6291 TypeName get type => _type; 5913 TypeName get type => _type;
6292 5914
6293 /** 5915 /**
6294 * Set the name of the type defining the constructor to the given type name. 5916 * Set the name of the type defining the constructor to the given [type] name.
6295 *
6296 * @param type the name of the type defining the constructor
6297 */ 5917 */
6298 void set type(TypeName type) { 5918 void set type(TypeName type) {
6299 _type = becomeParentOf(type); 5919 _type = becomeParentOf(type);
6300 } 5920 }
6301 5921
6302 @override 5922 @override
6303 accept(AstVisitor visitor) => visitor.visitConstructorName(this); 5923 accept(AstVisitor visitor) => visitor.visitConstructorName(this);
6304 5924
6305 @override 5925 @override
6306 void visitChildren(AstVisitor visitor) { 5926 void visitChildren(AstVisitor visitor) {
6307 safelyVisitChild(_type, visitor); 5927 _safelyVisitChild(_type, visitor);
6308 safelyVisitChild(_name, visitor); 5928 _safelyVisitChild(_name, visitor);
6309 } 5929 }
6310 } 5930 }
6311 5931
6312 /** 5932 /**
6313 * Instances of the class `ContinueStatement` represent a continue statement. 5933 * A continue statement.
6314 * 5934 *
6315 * <pre> 5935 * > continueStatement ::=
6316 * continueStatement ::= 5936 * > 'continue' [SimpleIdentifier]? ';'
6317 * 'continue' [SimpleIdentifier]? ';'
6318 * </pre>
6319 */ 5937 */
6320 class ContinueStatement extends Statement { 5938 class ContinueStatement extends Statement {
6321 /** 5939 /**
6322 * The token representing the 'continue' keyword. 5940 * The token representing the 'continue' keyword.
6323 */ 5941 */
6324 Token keyword; 5942 Token keyword;
6325 5943
6326 /** 5944 /**
6327 * The label associated with the statement, or `null` if there is no label. 5945 * The label associated with the statement, or `null` if there is no label.
6328 */ 5946 */
6329 SimpleIdentifier _label; 5947 SimpleIdentifier _label;
6330 5948
6331 /** 5949 /**
6332 * The semicolon terminating the statement. 5950 * The semicolon terminating the statement.
6333 */ 5951 */
6334 Token semicolon; 5952 Token semicolon;
6335 5953
6336 /** 5954 /**
6337 * The AstNode which this continue statement is continuing to. This will be 5955 * The AstNode which this continue statement is continuing to. This will be
6338 * either a Statement (in the case of continuing a loop) or a SwitchMember 5956 * either a Statement (in the case of continuing a loop) or a SwitchMember
6339 * (in the case of continuing from one switch case to another). Null if the 5957 * (in the case of continuing from one switch case to another). Null if the
6340 * AST has not yet been resolved or if the target could not be resolved. 5958 * AST has not yet been resolved or if the target could not be resolved.
6341 * Note that if the source code has errors, the target may be invalid (e.g. 5959 * Note that if the source code has errors, the target may be invalid (e.g.
6342 * the target may be in an enclosing function). 5960 * the target may be in an enclosing function).
6343 */ 5961 */
6344 AstNode target; 5962 AstNode target;
6345 5963
6346 /** 5964 /**
6347 * Initialize a newly created continue statement. 5965 * Initialize a newly created continue statement. The [label] can be `null` if
6348 * 5966 * there is no label associated with the statement.
6349 * @param keyword the token representing the 'continue' keyword
6350 * @param label the label associated with the statement
6351 * @param semicolon the semicolon terminating the statement
6352 */ 5967 */
6353 ContinueStatement(this.keyword, SimpleIdentifier label, this.semicolon) { 5968 ContinueStatement(this.keyword, SimpleIdentifier label, this.semicolon) {
6354 _label = becomeParentOf(label); 5969 _label = becomeParentOf(label);
6355 } 5970 }
6356 5971
6357 @override 5972 @override
6358 Token get beginToken => keyword; 5973 Token get beginToken => keyword;
6359 5974
6360 /** 5975 /**
6361 * TODO(paulberry): untested. 5976 * TODO(paulberry): untested.
6362 */ 5977 */
6363 @override 5978 @override
6364 Iterable get childEntities => new ChildEntities() 5979 Iterable get childEntities => new ChildEntities()
6365 ..add(keyword) 5980 ..add(keyword)
6366 ..add(_label) 5981 ..add(_label)
6367 ..add(semicolon); 5982 ..add(semicolon);
6368 5983
6369 @override 5984 @override
6370 Token get endToken => semicolon; 5985 Token get endToken => semicolon;
6371 5986
6372 /** 5987 /**
6373 * Return the label associated with the statement, or `null` if there is no la bel. 5988 * Return the label associated with the statement, or `null` if there is no
6374 * 5989 * label.
6375 * @return the label associated with the statement
6376 */ 5990 */
6377 SimpleIdentifier get label => _label; 5991 SimpleIdentifier get label => _label;
6378 5992
6379 /** 5993 /**
6380 * Set the label associated with the statement to the given label. 5994 * Set the label associated with the statement to the given [identifier].
6381 *
6382 * @param identifier the label associated with the statement
6383 */ 5995 */
6384 void set label(SimpleIdentifier identifier) { 5996 void set label(SimpleIdentifier identifier) {
6385 _label = becomeParentOf(identifier); 5997 _label = becomeParentOf(identifier);
6386 } 5998 }
6387 5999
6388 @override 6000 @override
6389 accept(AstVisitor visitor) => visitor.visitContinueStatement(this); 6001 accept(AstVisitor visitor) => visitor.visitContinueStatement(this);
6390 6002
6391 @override 6003 @override
6392 void visitChildren(AstVisitor visitor) { 6004 void visitChildren(AstVisitor visitor) {
6393 safelyVisitChild(_label, visitor); 6005 _safelyVisitChild(_label, visitor);
6394 } 6006 }
6395 } 6007 }
6396 6008
6397 /** 6009 /**
6398 * The abstract class `Declaration` defines the behavior common to nodes that re present the 6010 * A node that represents the declaration of a name. Each declared name is
6399 * declaration of a name. Each declared name is visible within a name scope. 6011 * visible within a name scope.
6400 */ 6012 */
6401 abstract class Declaration extends AnnotatedNode { 6013 abstract class Declaration extends AnnotatedNode {
6402 /** 6014 /**
6403 * Initialize a newly created declaration. 6015 * Initialize a newly created declaration. Either or both of the [comment] and
6404 * 6016 * [metadata] can be `null` if the declaration does not have the corresponding
6405 * @param comment the documentation comment associated with this declaration 6017 * attribute.
6406 * @param metadata the annotations associated with this declaration
6407 */ 6018 */
6408 Declaration(Comment comment, List<Annotation> metadata) 6019 Declaration(Comment comment, List<Annotation> metadata)
6409 : super(comment, metadata); 6020 : super(comment, metadata);
6410 6021
6411 /** 6022 /**
6412 * Return the element associated with this declaration, or `null` if either th is node 6023 * Return the element associated with this declaration, or `null` if either
6413 * corresponds to a list of declarations or if the AST structure has not been resolved. 6024 * this node corresponds to a list of declarations or if the AST structure has
6414 * 6025 * not been resolved.
6415 * @return the element associated with this declaration
6416 */ 6026 */
6417 Element get element; 6027 Element get element;
6418 } 6028 }
6419 6029
6420 /** 6030 /**
6421 * Instances of the class `DeclaredIdentifier` represent the declaration of a si ngle 6031 * The declaration of a single identifier.
6422 * identifier.
6423 * 6032 *
6424 * <pre> 6033 * > declaredIdentifier ::=
6425 * declaredIdentifier ::= 6034 * > [Annotation] finalConstVarOrType [SimpleIdentifier]
6426 * [Annotation] finalConstVarOrType [SimpleIdentifier]
6427 * </pre>
6428 */ 6035 */
6429 class DeclaredIdentifier extends Declaration { 6036 class DeclaredIdentifier extends Declaration {
6430 /** 6037 /**
6431 * The token representing either the 'final', 'const' or 'var' keyword, or `nu ll` if no 6038 * The token representing either the 'final', 'const' or 'var' keyword, or
6432 * keyword was used. 6039 * `null` if no keyword was used.
6433 */ 6040 */
6434 Token keyword; 6041 Token keyword;
6435 6042
6436 /** 6043 /**
6437 * The name of the declared type of the parameter, or `null` if the parameter does not have 6044 * The name of the declared type of the parameter, or `null` if the parameter
6438 * a declared type. 6045 * does not have a declared type.
6439 */ 6046 */
6440 TypeName _type; 6047 TypeName _type;
6441 6048
6442 /** 6049 /**
6443 * The name of the variable being declared. 6050 * The name of the variable being declared.
6444 */ 6051 */
6445 SimpleIdentifier _identifier; 6052 SimpleIdentifier _identifier;
6446 6053
6447 /** 6054 /**
6448 * Initialize a newly created formal parameter. 6055 * Initialize a newly created formal parameter. Either or both of the
6449 * 6056 * [comment] and [metadata] can be `null` if the declaration does not have the
6450 * @param comment the documentation comment associated with this parameter 6057 * corresponding attribute. The [keyword] can be `null` if a type name is
6451 * @param metadata the annotations associated with this parameter 6058 * given. The [type] must be `null` if the keyword is 'var'.
6452 * @param keyword the token representing either the 'final', 'const' or 'var' keyword
6453 * @param type the name of the declared type of the parameter
6454 * @param identifier the name of the parameter being declared
6455 */ 6059 */
6456 DeclaredIdentifier(Comment comment, List<Annotation> metadata, this.keyword, 6060 DeclaredIdentifier(Comment comment, List<Annotation> metadata, this.keyword,
6457 TypeName type, SimpleIdentifier identifier) 6061 TypeName type, SimpleIdentifier identifier)
6458 : super(comment, metadata) { 6062 : super(comment, metadata) {
6459 _type = becomeParentOf(type); 6063 _type = becomeParentOf(type);
6460 _identifier = becomeParentOf(identifier); 6064 _identifier = becomeParentOf(identifier);
6461 } 6065 }
6462 6066
6463 /** 6067 /**
6464 * TODO(paulberry): untested. 6068 * TODO(paulberry): untested.
(...skipping 20 matching lines...) Expand all
6485 if (keyword != null) { 6089 if (keyword != null) {
6486 return keyword; 6090 return keyword;
6487 } else if (_type != null) { 6091 } else if (_type != null) {
6488 return _type.beginToken; 6092 return _type.beginToken;
6489 } 6093 }
6490 return _identifier.beginToken; 6094 return _identifier.beginToken;
6491 } 6095 }
6492 6096
6493 /** 6097 /**
6494 * Return the name of the variable being declared. 6098 * Return the name of the variable being declared.
6495 *
6496 * @return the name of the variable being declared
6497 */ 6099 */
6498 SimpleIdentifier get identifier => _identifier; 6100 SimpleIdentifier get identifier => _identifier;
6499 6101
6500 /** 6102 /**
6501 * Set the name of the variable being declared to the given name. 6103 * Set the name of the variable being declared to the given [identifier].
6502 *
6503 * @param identifier the new name of the variable being declared
6504 */ 6104 */
6505 void set identifier(SimpleIdentifier identifier) { 6105 void set identifier(SimpleIdentifier identifier) {
6506 _identifier = becomeParentOf(identifier); 6106 _identifier = becomeParentOf(identifier);
6507 } 6107 }
6508 6108
6509 /** 6109 /**
6510 * Return `true` if this variable was declared with the 'const' modifier. 6110 * Return `true` if this variable was declared with the 'const' modifier.
6511 *
6512 * @return `true` if this variable was declared with the 'const' modifier
6513 */ 6111 */
6514 bool get isConst => 6112 bool get isConst =>
6515 (keyword is KeywordToken) && (keyword as KeywordToken).keyword == Keyword. CONST; 6113 (keyword is KeywordToken) && (keyword as KeywordToken).keyword == Keyword. CONST;
6516 6114
6517 /** 6115 /**
6518 * Return `true` if this variable was declared with the 'final' modifier. Vari ables that are 6116 * Return `true` if this variable was declared with the 'final' modifier.
6519 * declared with the 'const' modifier will return `false` even though they are implicitly 6117 * Variables that are declared with the 'const' modifier will return `false`
6520 * final. 6118 * even though they are implicitly final.
6521 *
6522 * @return `true` if this variable was declared with the 'final' modifier
6523 */ 6119 */
6524 bool get isFinal => 6120 bool get isFinal =>
6525 (keyword is KeywordToken) && (keyword as KeywordToken).keyword == Keyword. FINAL; 6121 (keyword is KeywordToken) && (keyword as KeywordToken).keyword == Keyword. FINAL;
6526 6122
6527 /** 6123 /**
6528 * Return the name of the declared type of the parameter, or `null` if the par ameter does 6124 * Return the name of the declared type of the parameter, or `null` if the
6529 * not have a declared type. 6125 * parameter does not have a declared type.
6530 *
6531 * @return the name of the declared type of the parameter
6532 */ 6126 */
6533 TypeName get type => _type; 6127 TypeName get type => _type;
6534 6128
6535 /** 6129 /**
6536 * Set the name of the declared type of the parameter to the given type name. 6130 * Set the name of the declared type of the parameter to the given [typeName].
6537 *
6538 * @param typeName the name of the declared type of the parameter
6539 */ 6131 */
6540 void set type(TypeName typeName) { 6132 void set type(TypeName typeName) {
6541 _type = becomeParentOf(typeName); 6133 _type = becomeParentOf(typeName);
6542 } 6134 }
6543 6135
6544 @override 6136 @override
6545 accept(AstVisitor visitor) => visitor.visitDeclaredIdentifier(this); 6137 accept(AstVisitor visitor) => visitor.visitDeclaredIdentifier(this);
6546 6138
6547 @override 6139 @override
6548 void visitChildren(AstVisitor visitor) { 6140 void visitChildren(AstVisitor visitor) {
6549 super.visitChildren(visitor); 6141 super.visitChildren(visitor);
6550 safelyVisitChild(_type, visitor); 6142 _safelyVisitChild(_type, visitor);
6551 safelyVisitChild(_identifier, visitor); 6143 _safelyVisitChild(_identifier, visitor);
6552 } 6144 }
6553 } 6145 }
6554 6146
6555 /** 6147 /**
6556 * Instances of the class `DefaultFormalParameter` represent a formal parameter with a default 6148 * A formal parameter with a default value. There are two kinds of parameters
6557 * value. There are two kinds of parameters that are both represented by this cl ass: named formal 6149 * that are both represented by this class: named formal parameters and
6558 * parameters and positional formal parameters. 6150 * positional formal parameters.
6559 * 6151 *
6560 * <pre> 6152 * > defaultFormalParameter ::=
6561 * defaultFormalParameter ::= 6153 * > [NormalFormalParameter] ('=' [Expression])?
6562 * [NormalFormalParameter] ('=' [Expression])? 6154 * >
6563 * 6155 * > defaultNamedParameter ::=
6564 * defaultNamedParameter ::= 6156 * > [NormalFormalParameter] (':' [Expression])?
6565 * [NormalFormalParameter] (':' [Expression])?
6566 * </pre>
6567 */ 6157 */
6568 class DefaultFormalParameter extends FormalParameter { 6158 class DefaultFormalParameter extends FormalParameter {
6569 /** 6159 /**
6570 * The formal parameter with which the default value is associated. 6160 * The formal parameter with which the default value is associated.
6571 */ 6161 */
6572 NormalFormalParameter _parameter; 6162 NormalFormalParameter _parameter;
6573 6163
6574 /** 6164 /**
6575 * The kind of this parameter. 6165 * The kind of this parameter.
6576 */ 6166 */
6577 ParameterKind kind; 6167 ParameterKind kind;
6578 6168
6579 /** 6169 /**
6580 * The token separating the parameter from the default value, or `null` if the re is no 6170 * The token separating the parameter from the default value, or `null` if
6581 * default value. 6171 * there is no default value.
6582 */ 6172 */
6583 Token separator; 6173 Token separator;
6584 6174
6585 /** 6175 /**
6586 * The expression computing the default value for the parameter, or `null` if there is no 6176 * The expression computing the default value for the parameter, or `null` if
6587 * default value. 6177 * there is no default value.
6588 */ 6178 */
6589 Expression _defaultValue; 6179 Expression _defaultValue;
6590 6180
6591 /** 6181 /**
6592 * Initialize a newly created default formal parameter. 6182 * Initialize a newly created default formal parameter. The [separator] and
6593 * 6183 * [defaultValue] can be `null` if there is no default value.
6594 * @param parameter the formal parameter with which the default value is assoc iated
6595 * @param kind the kind of this parameter
6596 * @param separator the token separating the parameter from the default value
6597 * @param defaultValue the expression computing the default value for the para meter
6598 */ 6184 */
6599 DefaultFormalParameter(NormalFormalParameter parameter, this.kind, 6185 DefaultFormalParameter(NormalFormalParameter parameter, this.kind,
6600 this.separator, Expression defaultValue) { 6186 this.separator, Expression defaultValue) {
6601 _parameter = becomeParentOf(parameter); 6187 _parameter = becomeParentOf(parameter);
6602 _defaultValue = becomeParentOf(defaultValue); 6188 _defaultValue = becomeParentOf(defaultValue);
6603 } 6189 }
6604 6190
6605 @override 6191 @override
6606 Token get beginToken => _parameter.beginToken; 6192 Token get beginToken => _parameter.beginToken;
6607 6193
6608 /** 6194 /**
6609 * TODO(paulberry): untested. 6195 * TODO(paulberry): untested.
6610 */ 6196 */
6611 @override 6197 @override
6612 Iterable get childEntities => new ChildEntities() 6198 Iterable get childEntities => new ChildEntities()
6613 ..add(_parameter) 6199 ..add(_parameter)
6614 ..add(separator) 6200 ..add(separator)
6615 ..add(_defaultValue); 6201 ..add(_defaultValue);
6616 6202
6617 /** 6203 /**
6618 * Return the expression computing the default value for the parameter, or `nu ll` if there 6204 * Return the expression computing the default value for the parameter, or
6619 * is no default value. 6205 * `null` if there is no default value.
6620 *
6621 * @return the expression computing the default value for the parameter
6622 */ 6206 */
6623 Expression get defaultValue => _defaultValue; 6207 Expression get defaultValue => _defaultValue;
6624 6208
6625 /** 6209 /**
6626 * Set the expression computing the default value for the parameter to the giv en expression. 6210 * Set the expression computing the default value for the parameter to the
6627 * 6211 * given [expression].
6628 * @param expression the expression computing the default value for the parame ter
6629 */ 6212 */
6630 void set defaultValue(Expression expression) { 6213 void set defaultValue(Expression expression) {
6631 _defaultValue = becomeParentOf(expression); 6214 _defaultValue = becomeParentOf(expression);
6632 } 6215 }
6633 6216
6634 @override 6217 @override
6635 Token get endToken { 6218 Token get endToken {
6636 if (_defaultValue != null) { 6219 if (_defaultValue != null) {
6637 return _defaultValue.endToken; 6220 return _defaultValue.endToken;
6638 } 6221 }
6639 return _parameter.endToken; 6222 return _parameter.endToken;
6640 } 6223 }
6641 6224
6642 @override 6225 @override
6643 SimpleIdentifier get identifier => _parameter.identifier; 6226 SimpleIdentifier get identifier => _parameter.identifier;
6644 6227
6645 @override 6228 @override
6646 bool get isConst => _parameter != null && _parameter.isConst; 6229 bool get isConst => _parameter != null && _parameter.isConst;
6647 6230
6648 @override 6231 @override
6649 bool get isFinal => _parameter != null && _parameter.isFinal; 6232 bool get isFinal => _parameter != null && _parameter.isFinal;
6650 6233
6651 /** 6234 /**
6652 * Return the formal parameter with which the default value is associated. 6235 * Return the formal parameter with which the default value is associated.
6653 *
6654 * @return the formal parameter with which the default value is associated
6655 */ 6236 */
6656 NormalFormalParameter get parameter => _parameter; 6237 NormalFormalParameter get parameter => _parameter;
6657 6238
6658 /** 6239 /**
6659 * Set the formal parameter with which the default value is associated to the given parameter. 6240 * Set the formal parameter with which the default value is associated to the
6660 * 6241 * given [formalParameter].
6661 * @param formalParameter the formal parameter with which the default value is associated
6662 */ 6242 */
6663 void set parameter(NormalFormalParameter formalParameter) { 6243 void set parameter(NormalFormalParameter formalParameter) {
6664 _parameter = becomeParentOf(formalParameter); 6244 _parameter = becomeParentOf(formalParameter);
6665 } 6245 }
6666 6246
6667 @override 6247 @override
6668 accept(AstVisitor visitor) => visitor.visitDefaultFormalParameter(this); 6248 accept(AstVisitor visitor) => visitor.visitDefaultFormalParameter(this);
6669 6249
6670 @override 6250 @override
6671 void visitChildren(AstVisitor visitor) { 6251 void visitChildren(AstVisitor visitor) {
6672 safelyVisitChild(_parameter, visitor); 6252 _safelyVisitChild(_parameter, visitor);
6673 safelyVisitChild(_defaultValue, visitor); 6253 _safelyVisitChild(_defaultValue, visitor);
6674 } 6254 }
6675 } 6255 }
6676 6256
6677 /** 6257 /**
6678 * This recursive Ast visitor is used to run over [Expression]s to determine if the expression 6258 * A recursive AST visitor that is used to run over [Expression]s to determine
6679 * is composed by at least one deferred [PrefixedIdentifier]. 6259 * whether the expression is composed by at least one deferred
6260 * [PrefixedIdentifier].
6680 * 6261 *
6681 * See [PrefixedIdentifier.isDeferred]. 6262 * See [PrefixedIdentifier.isDeferred].
6682 */ 6263 */
6683 class DeferredLibraryReferenceDetector extends RecursiveAstVisitor<Object> { 6264 class DeferredLibraryReferenceDetector extends RecursiveAstVisitor<Object> {
6265 /**
6266 * A flag indicating whether an identifier from a deferred library has been
6267 * found.
6268 */
6684 bool _result = false; 6269 bool _result = false;
6685 6270
6686 /** 6271 /**
6687 * Return `true` if the visitor found a [PrefixedIdentifier] that returned 6272 * Return `true` if the visitor found a [PrefixedIdentifier] that returned
6688 * `true` to the [PrefixedIdentifier.isDeferred] query. 6273 * `true` to the [PrefixedIdentifier.isDeferred] query.
6689 */ 6274 */
6690 bool get result => _result; 6275 bool get result => _result;
6691 6276
6692 @override 6277 @override
6693 Object visitPrefixedIdentifier(PrefixedIdentifier node) { 6278 Object visitPrefixedIdentifier(PrefixedIdentifier node) {
6694 if (!_result) { 6279 if (!_result) {
6695 if (node.isDeferred) { 6280 if (node.isDeferred) {
6696 _result = true; 6281 _result = true;
6697 } 6282 }
6698 } 6283 }
6699 return null; 6284 return null;
6700 } 6285 }
6701 } 6286 }
6702 6287
6703 /** 6288 /**
6704 * The abstract class `Directive` defines the behavior common to nodes that repr esent a 6289 * A node that represents a directive.
6705 * directive.
6706 * 6290 *
6707 * <pre> 6291 * > directive ::=
6708 * directive ::= 6292 * > [ExportDirective]
6709 * [ExportDirective] 6293 * > | [ImportDirective]
6710 * | [ImportDirective] 6294 * > | [LibraryDirective]
6711 * | [LibraryDirective] 6295 * > | [PartDirective]
6712 * | [PartDirective] 6296 * > | [PartOfDirective]
6713 * | [PartOfDirective]
6714 * </pre>
6715 */ 6297 */
6716 abstract class Directive extends AnnotatedNode { 6298 abstract class Directive extends AnnotatedNode {
6717 /** 6299 /**
6718 * The element associated with this directive, or `null` if the AST structure has not been 6300 * The element associated with this directive, or `null` if the AST structure
6719 * resolved or if this directive could not be resolved. 6301 * has not been resolved or if this directive could not be resolved.
6720 */ 6302 */
6721 Element element; 6303 Element element;
6722 6304
6723 /** 6305 /**
6724 * Initialize a newly create directive. 6306 * Initialize a newly create directive. Either or both of the [comment] and
6725 * 6307 * [metadata] can be `null` if the directive does not have the corresponding
6726 * @param comment the documentation comment associated with this directive 6308 * attribute.
6727 * @param metadata the annotations associated with the directive
6728 */ 6309 */
6729 Directive(Comment comment, List<Annotation> metadata) 6310 Directive(Comment comment, List<Annotation> metadata)
6730 : super(comment, metadata); 6311 : super(comment, metadata);
6731 6312
6732 /** 6313 /**
6733 * Return the token representing the keyword that introduces this directive (' import', 'export', 6314 * Return the token representing the keyword that introduces this directive
6734 * 'library' or 'part'). 6315 * ('import', 'export', 'library' or 'part').
6735 *
6736 * @return the token representing the keyword that introduces this directive
6737 */ 6316 */
6738 Token get keyword; 6317 Token get keyword;
6739 } 6318 }
6740 6319
6741 /** 6320 /**
6742 * Instances of the class `DoStatement` represent a do statement. 6321 * A do statement.
6743 * 6322 *
6744 * <pre> 6323 * > doStatement ::=
6745 * doStatement ::= 6324 * > 'do' [Statement] 'while' '(' [Expression] ')' ';'
6746 * 'do' [Statement] 'while' '(' [Expression] ')' ';'
6747 * </pre>
6748 */ 6325 */
6749 class DoStatement extends Statement { 6326 class DoStatement extends Statement {
6750 /** 6327 /**
6751 * The token representing the 'do' keyword. 6328 * The token representing the 'do' keyword.
6752 */ 6329 */
6753 Token doKeyword; 6330 Token doKeyword;
6754 6331
6755 /** 6332 /**
6756 * The body of the loop. 6333 * The body of the loop.
6757 */ 6334 */
(...skipping 19 matching lines...) Expand all
6777 */ 6354 */
6778 Token rightParenthesis; 6355 Token rightParenthesis;
6779 6356
6780 /** 6357 /**
6781 * The semicolon terminating the statement. 6358 * The semicolon terminating the statement.
6782 */ 6359 */
6783 Token semicolon; 6360 Token semicolon;
6784 6361
6785 /** 6362 /**
6786 * Initialize a newly created do loop. 6363 * Initialize a newly created do loop.
6787 *
6788 * @param doKeyword the token representing the 'do' keyword
6789 * @param body the body of the loop
6790 * @param whileKeyword the token representing the 'while' keyword
6791 * @param leftParenthesis the left parenthesis
6792 * @param condition the condition that determines when the loop will terminate
6793 * @param rightParenthesis the right parenthesis
6794 * @param semicolon the semicolon terminating the statement
6795 */ 6364 */
6796 DoStatement(this.doKeyword, Statement body, this.whileKeyword, 6365 DoStatement(this.doKeyword, Statement body, this.whileKeyword,
6797 this.leftParenthesis, Expression condition, this.rightParenthesis, 6366 this.leftParenthesis, Expression condition, this.rightParenthesis,
6798 this.semicolon) { 6367 this.semicolon) {
6799 _body = becomeParentOf(body); 6368 _body = becomeParentOf(body);
6800 _condition = becomeParentOf(condition); 6369 _condition = becomeParentOf(condition);
6801 } 6370 }
6802 6371
6803 @override 6372 @override
6804 Token get beginToken => doKeyword; 6373 Token get beginToken => doKeyword;
6805 6374
6806 /** 6375 /**
6807 * Return the body of the loop. 6376 * Return the body of the loop.
6808 *
6809 * @return the body of the loop
6810 */ 6377 */
6811 Statement get body => _body; 6378 Statement get body => _body;
6812 6379
6813 /** 6380 /**
6814 * Set the body of the loop to the given statement. 6381 * Set the body of the loop to the given [statement].
6815 *
6816 * @param statement the body of the loop
6817 */ 6382 */
6818 void set body(Statement statement) { 6383 void set body(Statement statement) {
6819 _body = becomeParentOf(statement); 6384 _body = becomeParentOf(statement);
6820 } 6385 }
6821 6386
6822 @override 6387 @override
6823 Iterable get childEntities => new ChildEntities() 6388 Iterable get childEntities => new ChildEntities()
6824 ..add(doKeyword) 6389 ..add(doKeyword)
6825 ..add(_body) 6390 ..add(_body)
6826 ..add(whileKeyword) 6391 ..add(whileKeyword)
6827 ..add(leftParenthesis) 6392 ..add(leftParenthesis)
6828 ..add(_condition) 6393 ..add(_condition)
6829 ..add(rightParenthesis) 6394 ..add(rightParenthesis)
6830 ..add(semicolon); 6395 ..add(semicolon);
6831 6396
6832 /** 6397 /**
6833 * Return the condition that determines when the loop will terminate. 6398 * Return the condition that determines when the loop will terminate.
6834 *
6835 * @return the condition that determines when the loop will terminate
6836 */ 6399 */
6837 Expression get condition => _condition; 6400 Expression get condition => _condition;
6838 6401
6839 /** 6402 /**
6840 * Set the condition that determines when the loop will terminate to the given expression. 6403 * Set the condition that determines when the loop will terminate to the given
6841 * 6404 * [expression].
6842 * @param expression the condition that determines when the loop will terminat e
6843 */ 6405 */
6844 void set condition(Expression expression) { 6406 void set condition(Expression expression) {
6845 _condition = becomeParentOf(expression); 6407 _condition = becomeParentOf(expression);
6846 } 6408 }
6847 6409
6848 @override 6410 @override
6849 Token get endToken => semicolon; 6411 Token get endToken => semicolon;
6850 6412
6851 @override 6413 @override
6852 accept(AstVisitor visitor) => visitor.visitDoStatement(this); 6414 accept(AstVisitor visitor) => visitor.visitDoStatement(this);
6853 6415
6854 @override 6416 @override
6855 void visitChildren(AstVisitor visitor) { 6417 void visitChildren(AstVisitor visitor) {
6856 safelyVisitChild(_body, visitor); 6418 _safelyVisitChild(_body, visitor);
6857 safelyVisitChild(_condition, visitor); 6419 _safelyVisitChild(_condition, visitor);
6858 } 6420 }
6859 } 6421 }
6860 6422
6861 /** 6423 /**
6862 * Instances of the class `DoubleLiteral` represent a floating point literal exp ression. 6424 * A floating point literal expression.
6863 * 6425 *
6864 * <pre> 6426 * > doubleLiteral ::=
6865 * doubleLiteral ::= 6427 * > decimalDigit+ ('.' decimalDigit*)? exponent?
6866 * decimalDigit+ ('.' decimalDigit*)? exponent? 6428 * > | '.' decimalDigit+ exponent?
6867 * | '.' decimalDigit+ exponent? 6429 * >
6868 * 6430 * > exponent ::=
6869 * exponent ::= 6431 * > ('e' | 'E') ('+' | '-')? decimalDigit+
6870 * ('e' | 'E') ('+' | '-')? decimalDigit+
6871 * </pre>
6872 */ 6432 */
6873 class DoubleLiteral extends Literal { 6433 class DoubleLiteral extends Literal {
6874 /** 6434 /**
6875 * The token representing the literal. 6435 * The token representing the literal.
6876 */ 6436 */
6877 Token literal; 6437 Token literal;
6878 6438
6879 /** 6439 /**
6880 * The value of the literal. 6440 * The value of the literal.
6881 */ 6441 */
6882 double value = 0.0; 6442 double value = 0.0;
6883 6443
6884 /** 6444 /**
6885 * Initialize a newly created floating point literal. 6445 * Initialize a newly created floating point literal.
6886 *
6887 * @param literal the token representing the literal
6888 * @param value the value of the literal
6889 */ 6446 */
6890 DoubleLiteral(this.literal, this.value); 6447 DoubleLiteral(this.literal, this.value);
6891 6448
6892 @override 6449 @override
6893 Token get beginToken => literal; 6450 Token get beginToken => literal;
6894 6451
6895 /** 6452 /**
6896 * TODO(paulberry): untested. 6453 * TODO(paulberry): untested.
6897 */ 6454 */
6898 @override 6455 @override
6899 Iterable get childEntities => new ChildEntities()..add(literal); 6456 Iterable get childEntities => new ChildEntities()..add(literal);
6900 6457
6901 @override 6458 @override
6902 Token get endToken => literal; 6459 Token get endToken => literal;
6903 6460
6904 @override 6461 @override
6905 accept(AstVisitor visitor) => visitor.visitDoubleLiteral(this); 6462 accept(AstVisitor visitor) => visitor.visitDoubleLiteral(this);
6906 6463
6907 @override 6464 @override
6908 void visitChildren(AstVisitor visitor) { 6465 void visitChildren(AstVisitor visitor) {
6909 // There are no children to visit. 6466 // There are no children to visit.
6910 } 6467 }
6911 } 6468 }
6912 6469
6913 /** 6470 /**
6914 * Instances of the class `ElementLocator` locate the [Element] 6471 * An object used to locate the [Element] associated with a given [AstNode].
6915 * associated with a given [AstNode].
6916 */ 6472 */
6917 class ElementLocator { 6473 class ElementLocator {
6918 /** 6474 /**
6919 * Locate the [Element] associated with the given [AstNode]. 6475 * Return the element associated with the given [node], or `null` if there is
6920 * 6476 * no element associated with the node.
6921 * @param node the node (not `null`)
6922 * @return the associated element, or `null` if none is found
6923 */ 6477 */
6924 static Element locate(AstNode node) { 6478 static Element locate(AstNode node) {
6925 ElementLocator_ElementMapper mapper = new ElementLocator_ElementMapper(); 6479 ElementLocator_ElementMapper mapper = new ElementLocator_ElementMapper();
6926 return node.accept(mapper); 6480 return node.accept(mapper);
6927 } 6481 }
6928 6482
6929 /** 6483 /**
6930 * Locate the [Element] associated with the given [AstNode] and offset. 6484 * Return the element associated with the given [node], or `null` if there is
6931 * 6485 * no element associated with the node.
6932 * @param node the node (not `null`)
6933 * @param offset the offset relative to source
6934 * @return the associated element, or `null` if none is found
6935 */ 6486 */
6936 static Element locateWithOffset(AstNode node, int offset) { 6487 static Element locateWithOffset(AstNode node, int offset) {
6937 if (node == null) { 6488 if (node == null) {
6938 return null; 6489 return null;
6939 } 6490 }
6940 // try to get Element from node 6491 // try to get Element from node
6941 Element nodeElement = locate(node); 6492 Element nodeElement = locate(node);
6942 if (nodeElement != null) { 6493 if (nodeElement != null) {
6943 return nodeElement; 6494 return nodeElement;
6944 } 6495 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
7049 return parent.uriElement; 6600 return parent.uriElement;
7050 } 6601 }
7051 return null; 6602 return null;
7052 } 6603 }
7053 6604
7054 @override 6605 @override
7055 Element visitVariableDeclaration(VariableDeclaration node) => node.element; 6606 Element visitVariableDeclaration(VariableDeclaration node) => node.element;
7056 } 6607 }
7057 6608
7058 /** 6609 /**
7059 * Instances of the class `EmptyFunctionBody` represent an empty function body, which can only 6610 * An empty function body, which can only appear in constructors or abstract
7060 * appear in constructors or abstract methods. 6611 * methods.
7061 * 6612 *
7062 * <pre> 6613 * > emptyFunctionBody ::=
7063 * emptyFunctionBody ::= 6614 * > ';'
7064 * ';'
7065 * </pre>
7066 */ 6615 */
7067 class EmptyFunctionBody extends FunctionBody { 6616 class EmptyFunctionBody extends FunctionBody {
7068 /** 6617 /**
7069 * The token representing the semicolon that marks the end of the function bod y. 6618 * The token representing the semicolon that marks the end of the function
6619 * body.
7070 */ 6620 */
7071 Token semicolon; 6621 Token semicolon;
7072 6622
7073 /** 6623 /**
7074 * Initialize a newly created function body. 6624 * Initialize a newly created function body.
7075 *
7076 * @param semicolon the token representing the semicolon that marks the end of the function body
7077 */ 6625 */
7078 EmptyFunctionBody(this.semicolon); 6626 EmptyFunctionBody(this.semicolon);
7079 6627
7080 @override 6628 @override
7081 Token get beginToken => semicolon; 6629 Token get beginToken => semicolon;
7082 6630
7083 /** 6631 /**
7084 * TODO(paulberry): untested. 6632 * TODO(paulberry): untested.
7085 */ 6633 */
7086 @override 6634 @override
7087 Iterable get childEntities => new ChildEntities()..add(semicolon); 6635 Iterable get childEntities => new ChildEntities()..add(semicolon);
7088 6636
7089 @override 6637 @override
7090 Token get endToken => semicolon; 6638 Token get endToken => semicolon;
7091 6639
7092 @override 6640 @override
7093 accept(AstVisitor visitor) => visitor.visitEmptyFunctionBody(this); 6641 accept(AstVisitor visitor) => visitor.visitEmptyFunctionBody(this);
7094 6642
7095 @override 6643 @override
7096 void visitChildren(AstVisitor visitor) { 6644 void visitChildren(AstVisitor visitor) {
7097 // Empty function bodies have no children. 6645 // Empty function bodies have no children.
7098 } 6646 }
7099 } 6647 }
7100 6648
7101 /** 6649 /**
7102 * Instances of the class `EmptyStatement` represent an empty statement. 6650 * An empty statement.
7103 * 6651 *
7104 * <pre> 6652 * > emptyStatement ::=
7105 * emptyStatement ::= 6653 * > ';'
7106 * ';'
7107 * </pre>
7108 */ 6654 */
7109 class EmptyStatement extends Statement { 6655 class EmptyStatement extends Statement {
7110 /** 6656 /**
7111 * The semicolon terminating the statement. 6657 * The semicolon terminating the statement.
7112 */ 6658 */
7113 Token semicolon; 6659 Token semicolon;
7114 6660
7115 /** 6661 /**
7116 * Initialize a newly created empty statement. 6662 * Initialize a newly created empty statement.
7117 *
7118 * @param semicolon the semicolon terminating the statement
7119 */ 6663 */
7120 EmptyStatement(this.semicolon); 6664 EmptyStatement(this.semicolon);
7121 6665
7122 @override 6666 @override
7123 Token get beginToken => semicolon; 6667 Token get beginToken => semicolon;
7124 6668
7125 /** 6669 /**
7126 * TODO(paulberry): untested. 6670 * TODO(paulberry): untested.
7127 */ 6671 */
7128 @override 6672 @override
7129 Iterable get childEntities => new ChildEntities()..add(semicolon); 6673 Iterable get childEntities => new ChildEntities()..add(semicolon);
7130 6674
7131 @override 6675 @override
7132 Token get endToken => semicolon; 6676 Token get endToken => semicolon;
7133 6677
7134 @override 6678 @override
7135 accept(AstVisitor visitor) => visitor.visitEmptyStatement(this); 6679 accept(AstVisitor visitor) => visitor.visitEmptyStatement(this);
7136 6680
7137 @override 6681 @override
7138 void visitChildren(AstVisitor visitor) { 6682 void visitChildren(AstVisitor visitor) {
7139 // There are no children to visit. 6683 // There are no children to visit.
7140 } 6684 }
7141 } 6685 }
7142 6686
7143 /** 6687 /**
7144 * Instances of the class `EnumConstantDeclaration` represent the declaration of an enum 6688 * The declaration of an enum constant.
7145 * constant.
7146 */ 6689 */
7147 class EnumConstantDeclaration extends Declaration { 6690 class EnumConstantDeclaration extends Declaration {
7148 /** 6691 /**
7149 * The name of the constant. 6692 * The name of the constant.
7150 */ 6693 */
7151 SimpleIdentifier _name; 6694 SimpleIdentifier _name;
7152 6695
7153 /** 6696 /**
7154 * Initialize a newly created enum constant declaration. 6697 * Initialize a newly created enum constant declaration. Either or both of the
7155 * 6698 * [comment] and [metadata] can be `null` if the constant does not have the
7156 * @param comment the documentation comment associated with this declaration 6699 * corresponding attribute. (Technically, enum constants cannot have metadata,
7157 * @param metadata the annotations associated with this declaration 6700 * but we allow it for consistency.)
7158 * @param name the name of the constant
7159 */ 6701 */
7160 EnumConstantDeclaration(Comment comment, List<Annotation> metadata, 6702 EnumConstantDeclaration(Comment comment, List<Annotation> metadata,
7161 SimpleIdentifier name) 6703 SimpleIdentifier name)
7162 : super(comment, metadata) { 6704 : super(comment, metadata) {
7163 _name = becomeParentOf(name); 6705 _name = becomeParentOf(name);
7164 } 6706 }
7165 6707
7166 /** 6708 /**
7167 * TODO(paulberry): untested. 6709 * TODO(paulberry): untested.
7168 */ 6710 */
7169 @override 6711 @override
7170 Iterable get childEntities => super._childEntities..add(_name); 6712 Iterable get childEntities => super._childEntities..add(_name);
7171 6713
7172 @override 6714 @override
7173 FieldElement get element => 6715 FieldElement get element =>
7174 _name == null ? null : (_name.staticElement as FieldElement); 6716 _name == null ? null : (_name.staticElement as FieldElement);
7175 6717
7176 @override 6718 @override
7177 Token get endToken => _name.endToken; 6719 Token get endToken => _name.endToken;
7178 6720
7179 @override 6721 @override
7180 Token get firstTokenAfterCommentAndMetadata => _name.beginToken; 6722 Token get firstTokenAfterCommentAndMetadata => _name.beginToken;
7181 6723
7182 /** 6724 /**
7183 * Return the name of the constant. 6725 * Return the name of the constant.
7184 *
7185 * @return the name of the constant
7186 */ 6726 */
7187 SimpleIdentifier get name => _name; 6727 SimpleIdentifier get name => _name;
7188 6728
7189 /** 6729 /**
7190 * Set the name of the constant to the given name. 6730 * Set the name of the constant to the given [name].
7191 *
7192 * @param name the name of the constant
7193 */ 6731 */
7194 void set name(SimpleIdentifier name) { 6732 void set name(SimpleIdentifier name) {
7195 _name = becomeParentOf(name); 6733 _name = becomeParentOf(name);
7196 } 6734 }
7197 6735
7198 @override 6736 @override
7199 accept(AstVisitor visitor) => visitor.visitEnumConstantDeclaration(this); 6737 accept(AstVisitor visitor) => visitor.visitEnumConstantDeclaration(this);
7200 6738
7201 @override 6739 @override
7202 void visitChildren(AstVisitor visitor) { 6740 void visitChildren(AstVisitor visitor) {
7203 super.visitChildren(visitor); 6741 super.visitChildren(visitor);
7204 safelyVisitChild(_name, visitor); 6742 _safelyVisitChild(_name, visitor);
7205 } 6743 }
7206 } 6744 }
7207 6745
7208 /** 6746 /**
7209 * Instances of the class `EnumDeclaration` represent the declaration of an enum eration. 6747 * The declaration of an enumeration.
7210 * 6748 *
7211 * <pre> 6749 * > enumType ::=
7212 * enumType ::= 6750 * > metadata 'enum' [SimpleIdentifier] '{' [SimpleIdentifier] (',' [SimpleI dentifier])* (',')? '}'
7213 * metadata 'enum' [SimpleIdentifier] '{' [SimpleIdentifier] (',' [SimpleIde ntifier])* (',')? '}'
7214 * </pre>
7215 */ 6751 */
7216 class EnumDeclaration extends CompilationUnitMember { 6752 class EnumDeclaration extends CompilationUnitMember {
7217 /** 6753 /**
7218 * The 'enum' keyword. 6754 * The 'enum' keyword.
7219 */ 6755 */
7220 Token keyword; 6756 Token keyword;
7221 6757
7222 /** 6758 /**
7223 * The name of the enumeration. 6759 * The name of the enumeration.
7224 */ 6760 */
7225 SimpleIdentifier _name; 6761 SimpleIdentifier _name;
7226 6762
7227 /** 6763 /**
7228 * The left curly bracket. 6764 * The left curly bracket.
7229 */ 6765 */
7230 Token leftBracket; 6766 Token leftBracket;
7231 6767
7232 /** 6768 /**
7233 * The enumeration constants being declared. 6769 * The enumeration constants being declared.
7234 */ 6770 */
7235 NodeList<EnumConstantDeclaration> _constants; 6771 NodeList<EnumConstantDeclaration> _constants;
7236 6772
7237 /** 6773 /**
7238 * The right curly bracket. 6774 * The right curly bracket.
7239 */ 6775 */
7240 Token rightBracket; 6776 Token rightBracket;
7241 6777
7242 /** 6778 /**
7243 * Initialize a newly created enumeration declaration. 6779 * Initialize a newly created enumeration declaration. Either or both of the
7244 * 6780 * [comment] and [metadata] can be `null` if the declaration does not have the
7245 * @param comment the documentation comment associated with this member 6781 * corresponding attribute. The list of [constants] must contain at least one
7246 * @param metadata the annotations associated with this member 6782 * value.
7247 * @param keyword the 'enum' keyword
7248 * @param name the name of the enumeration
7249 * @param leftBracket the left curly bracket
7250 * @param constants the enumeration constants being declared
7251 * @param rightBracket the right curly bracket
7252 */ 6783 */
7253 EnumDeclaration(Comment comment, List<Annotation> metadata, this.keyword, 6784 EnumDeclaration(Comment comment, List<Annotation> metadata, this.keyword,
7254 SimpleIdentifier name, this.leftBracket, 6785 SimpleIdentifier name, this.leftBracket,
7255 List<EnumConstantDeclaration> constants, this.rightBracket) 6786 List<EnumConstantDeclaration> constants, this.rightBracket)
7256 : super(comment, metadata) { 6787 : super(comment, metadata) {
7257 _name = becomeParentOf(name); 6788 _name = becomeParentOf(name);
7258 _constants = new NodeList<EnumConstantDeclaration>(this, constants); 6789 _constants = new NodeList<EnumConstantDeclaration>(this, constants);
7259 } 6790 }
7260 6791
7261 /** 6792 /**
7262 * TODO(paulberry): untested. 6793 * TODO(paulberry): untested.
7263 */ 6794 */
7264 @override 6795 @override
7265 Iterable get childEntities => super._childEntities 6796 Iterable get childEntities => super._childEntities
7266 ..add(keyword) 6797 ..add(keyword)
7267 ..add(_name) 6798 ..add(_name)
7268 ..add(leftBracket) 6799 ..add(leftBracket)
7269 ..addAll(_constants) 6800 ..addAll(_constants)
7270 ..add(rightBracket); 6801 ..add(rightBracket);
7271 6802
7272 /** 6803 /**
7273 * Return the enumeration constants being declared. 6804 * Return the enumeration constants being declared.
7274 *
7275 * @return the enumeration constants being declared
7276 */ 6805 */
7277 NodeList<EnumConstantDeclaration> get constants => _constants; 6806 NodeList<EnumConstantDeclaration> get constants => _constants;
7278 6807
7279 @override 6808 @override
7280 ClassElement get element => 6809 ClassElement get element =>
7281 _name != null ? (_name.staticElement as ClassElement) : null; 6810 _name != null ? (_name.staticElement as ClassElement) : null;
7282 6811
7283 @override 6812 @override
7284 Token get endToken => rightBracket; 6813 Token get endToken => rightBracket;
7285 6814
7286 @override 6815 @override
7287 Token get firstTokenAfterCommentAndMetadata => keyword; 6816 Token get firstTokenAfterCommentAndMetadata => keyword;
7288 6817
7289 /** 6818 /**
7290 * Return the name of the enumeration. 6819 * Return the name of the enumeration.
7291 *
7292 * @return the name of the enumeration
7293 */ 6820 */
7294 SimpleIdentifier get name => _name; 6821 SimpleIdentifier get name => _name;
7295 6822
7296 /** 6823 /**
7297 * set the name of the enumeration to the given identifier. 6824 * Set the name of the enumeration to the given [name].
7298 *
7299 * @param name the name of the enumeration
7300 */ 6825 */
7301 void set name(SimpleIdentifier name) { 6826 void set name(SimpleIdentifier name) {
7302 _name = becomeParentOf(name); 6827 _name = becomeParentOf(name);
7303 } 6828 }
7304 6829
7305 @override 6830 @override
7306 accept(AstVisitor visitor) => visitor.visitEnumDeclaration(this); 6831 accept(AstVisitor visitor) => visitor.visitEnumDeclaration(this);
7307 6832
7308 @override 6833 @override
7309 void visitChildren(AstVisitor visitor) { 6834 void visitChildren(AstVisitor visitor) {
7310 super.visitChildren(visitor); 6835 super.visitChildren(visitor);
7311 safelyVisitChild(_name, visitor); 6836 _safelyVisitChild(_name, visitor);
7312 _constants.accept(visitor); 6837 _constants.accept(visitor);
7313 } 6838 }
7314 } 6839 }
7315 6840
7316 /** 6841 /**
7317 * Ephemeral identifiers are created as needed to mimic the presence of an empty identifier. 6842 * Ephemeral identifiers are created as needed to mimic the presence of an empty
6843 * identifier.
7318 */ 6844 */
7319 class EphemeralIdentifier extends SimpleIdentifier { 6845 class EphemeralIdentifier extends SimpleIdentifier {
7320 EphemeralIdentifier(AstNode parent, int location) 6846 EphemeralIdentifier(AstNode parent, int location)
7321 : super(new StringToken(TokenType.IDENTIFIER, "", location)) { 6847 : super(new StringToken(TokenType.IDENTIFIER, "", location)) {
7322 parent.becomeParentOf(this); 6848 parent.becomeParentOf(this);
7323 } 6849 }
7324 } 6850 }
7325 6851
7326 /** 6852 /**
7327 * Instances of the class `ExportDirective` represent an export directive. 6853 * An export directive.
7328 * 6854 *
7329 * <pre> 6855 * > exportDirective ::=
7330 * exportDirective ::= 6856 * > [Annotation] 'export' [StringLiteral] [Combinator]* ';'
7331 * [Annotation] 'export' [StringLiteral] [Combinator]* ';'
7332 * </pre>
7333 */ 6857 */
7334 class ExportDirective extends NamespaceDirective { 6858 class ExportDirective extends NamespaceDirective {
7335 /** 6859 /**
7336 * Initialize a newly created export directive. 6860 * Initialize a newly created export directive. Either or both of the
7337 * 6861 * [comment] and [metadata] can be `null` if the directive does not have the
7338 * @param comment the documentation comment associated with this directive 6862 * corresponding attribute. The list of [combinators] can be `null` if there
7339 * @param metadata the annotations associated with the directive 6863 * are no combinators.
7340 * @param keyword the token representing the 'export' keyword
7341 * @param libraryUri the URI of the library being exported
7342 * @param combinators the combinators used to control which names are exported
7343 * @param semicolon the semicolon terminating the directive
7344 */ 6864 */
7345 ExportDirective(Comment comment, List<Annotation> metadata, Token keyword, 6865 ExportDirective(Comment comment, List<Annotation> metadata, Token keyword,
7346 StringLiteral libraryUri, List<Combinator> combinators, Token semicolon) 6866 StringLiteral libraryUri, List<Combinator> combinators, Token semicolon)
7347 : super(comment, metadata, keyword, libraryUri, combinators, semicolon); 6867 : super(comment, metadata, keyword, libraryUri, combinators, semicolon);
7348 6868
7349 @override 6869 @override
7350 Iterable get childEntities => super._childEntities 6870 Iterable get childEntities => super._childEntities
7351 ..add(_uri) 6871 ..add(_uri)
7352 ..addAll(combinators) 6872 ..addAll(combinators)
7353 ..add(semicolon); 6873 ..add(semicolon);
(...skipping 13 matching lines...) Expand all
7367 accept(AstVisitor visitor) => visitor.visitExportDirective(this); 6887 accept(AstVisitor visitor) => visitor.visitExportDirective(this);
7368 6888
7369 @override 6889 @override
7370 void visitChildren(AstVisitor visitor) { 6890 void visitChildren(AstVisitor visitor) {
7371 super.visitChildren(visitor); 6891 super.visitChildren(visitor);
7372 combinators.accept(visitor); 6892 combinators.accept(visitor);
7373 } 6893 }
7374 } 6894 }
7375 6895
7376 /** 6896 /**
7377 * Instances of the class `Expression` defines the behavior common to nodes that represent an 6897 * A node that represents an expression.
7378 * expression.
7379 * 6898 *
7380 * <pre> 6899 * > expression ::=
7381 * expression ::= 6900 * > [AssignmentExpression]
7382 * [AssignmentExpression] 6901 * > | [ConditionalExpression] cascadeSection*
7383 * | [ConditionalExpression] cascadeSection* 6902 * > | [ThrowExpression]
7384 * | [ThrowExpression]
7385 * </pre>
7386 */ 6903 */
7387 abstract class Expression extends AstNode { 6904 abstract class Expression extends AstNode {
7388 /** 6905 /**
7389 * An empty list of expressions. 6906 * An empty list of expressions.
7390 */ 6907 */
7391 static const List<Expression> EMPTY_ARRAY = const <Expression>[]; 6908 static const List<Expression> EMPTY_ARRAY = const <Expression>[];
7392 6909
7393 /** 6910 /**
7394 * The static type of this expression, or `null` if the AST structure has not been resolved. 6911 * The static type of this expression, or `null` if the AST structure has not
6912 * been resolved.
7395 */ 6913 */
7396 DartType staticType; 6914 DartType staticType;
7397 6915
7398 /** 6916 /**
7399 * The propagated type of this expression, or `null` if type propagation has n ot been 6917 * The propagated type of this expression, or `null` if type propagation has
7400 * performed on the AST structure. 6918 * not been performed on the AST structure.
7401 */ 6919 */
7402 DartType propagatedType; 6920 DartType propagatedType;
7403 6921
7404 /** 6922 /**
7405 * Return the best parameter element information available for this expression . If type 6923 * Return the best parameter element information available for this
7406 * propagation was able to find a better parameter element than static analysi s, that type will be 6924 * expression. If type propagation was able to find a better parameter element
7407 * returned. Otherwise, the result of static analysis will be returned. 6925 * than static analysis, that type will be returned. Otherwise, the result of
7408 * 6926 * static analysis will be returned.
7409 * @return the parameter element representing the parameter to which the value of this expression
7410 * will be bound
7411 */ 6927 */
7412 ParameterElement get bestParameterElement { 6928 ParameterElement get bestParameterElement {
7413 ParameterElement propagatedElement = propagatedParameterElement; 6929 ParameterElement propagatedElement = propagatedParameterElement;
7414 if (propagatedElement != null) { 6930 if (propagatedElement != null) {
7415 return propagatedElement; 6931 return propagatedElement;
7416 } 6932 }
7417 return staticParameterElement; 6933 return staticParameterElement;
7418 } 6934 }
7419 6935
7420 /** 6936 /**
7421 * Return the best type information available for this expression. If type pro pagation was able to 6937 * Return the best type information available for this expression. If type
7422 * find a better type than static analysis, that type will be returned. Otherw ise, the result of 6938 * propagation was able to find a better type than static analysis, that type
7423 * static analysis will be returned. If no type analysis has been performed, t hen the type 6939 * will be returned. Otherwise, the result of static analysis will be
7424 * 'dynamic' will be returned. 6940 * returned. If no type analysis has been performed, then the type 'dynamic'
7425 * 6941 * will be returned.
7426 * @return the best type information available for this expression
7427 */ 6942 */
7428 DartType get bestType { 6943 DartType get bestType {
7429 if (propagatedType != null) { 6944 if (propagatedType != null) {
7430 return propagatedType; 6945 return propagatedType;
7431 } else if (staticType != null) { 6946 } else if (staticType != null) {
7432 return staticType; 6947 return staticType;
7433 } 6948 }
7434 return DynamicTypeImpl.instance; 6949 return DynamicTypeImpl.instance;
7435 } 6950 }
7436 6951
7437 /** 6952 /**
7438 * Return `true` if this expression is syntactically valid for the LHS of an 6953 * Return `true` if this expression is syntactically valid for the LHS of an
7439 * [AssignmentExpression]. 6954 * [AssignmentExpression].
7440 *
7441 * @return `true` if this expression matches the `assignableExpression` produc tion
7442 */ 6955 */
7443 bool get isAssignable => false; 6956 bool get isAssignable => false;
7444 6957
7445 /** 6958 /**
7446 * Return the precedence of this expression. The precedence is a positive inte ger value that 6959 * Return the precedence of this expression. The precedence is a positive
7447 * defines how the source code is parsed into an AST. For example `a * b + c` is parsed as 6960 * integer value that defines how the source code is parsed into an AST. For
7448 * `(a * b) + c` because the precedence of `*` is greater than the precedence of 6961 * example `a * b + c` is parsed as `(a * b) + c` because the precedence of
7449 * `+`. 6962 * `*` is greater than the precedence of `+`.
7450 * 6963 *
7451 * You should not assume that returned values will stay the same, they might c hange as result of 6964 * Clients should not assume that returned values will stay the same, they
7452 * specification change. Only relative order should be used. 6965 * might change as result of specification change. Only relative order should
7453 * 6966 * be used.
7454 * @return the precedence of this expression
7455 */ 6967 */
7456 int get precedence; 6968 int get precedence;
7457 6969
7458 /** 6970 /**
7459 * If this expression is an argument to an invocation, and the AST structure h as been resolved, 6971 * If this expression is an argument to an invocation, and the AST structure
7460 * and the function being invoked is known based on propagated type informatio n, and this 6972 * has been resolved, and the function being invoked is known based on
7461 * expression corresponds to one of the parameters of the function being invok ed, then return the 6973 * propagated type information, and this expression corresponds to one of the
7462 * parameter element representing the parameter to which the value of this exp ression will be 6974 * parameters of the function being invoked, then return the parameter element
6975 * representing the parameter to which the value of this expression will be
7463 * bound. Otherwise, return `null`. 6976 * bound. Otherwise, return `null`.
7464 *
7465 * @return the parameter element representing the parameter to which the value of this expression
7466 * will be bound
7467 */ 6977 */
7468 ParameterElement get propagatedParameterElement { 6978 ParameterElement get propagatedParameterElement {
7469 AstNode parent = this.parent; 6979 AstNode parent = this.parent;
7470 if (parent is ArgumentList) { 6980 if (parent is ArgumentList) {
7471 return parent.getPropagatedParameterElementFor(this); 6981 return parent.getPropagatedParameterElementFor(this);
7472 } else if (parent is IndexExpression) { 6982 } else if (parent is IndexExpression) {
7473 IndexExpression indexExpression = parent; 6983 IndexExpression indexExpression = parent;
7474 if (identical(indexExpression.index, this)) { 6984 if (identical(indexExpression.index, this)) {
7475 return indexExpression.propagatedParameterElementForIndex; 6985 return indexExpression.propagatedParameterElementForIndex;
7476 } 6986 }
7477 } else if (parent is BinaryExpression) { 6987 } else if (parent is BinaryExpression) {
7478 BinaryExpression binaryExpression = parent; 6988 BinaryExpression binaryExpression = parent;
7479 if (identical(binaryExpression.rightOperand, this)) { 6989 if (identical(binaryExpression.rightOperand, this)) {
7480 return binaryExpression.propagatedParameterElementForRightOperand; 6990 return binaryExpression.propagatedParameterElementForRightOperand;
7481 } 6991 }
7482 } else if (parent is AssignmentExpression) { 6992 } else if (parent is AssignmentExpression) {
7483 AssignmentExpression assignmentExpression = parent; 6993 AssignmentExpression assignmentExpression = parent;
7484 if (identical(assignmentExpression.rightHandSide, this)) { 6994 if (identical(assignmentExpression.rightHandSide, this)) {
7485 return assignmentExpression.propagatedParameterElementForRightHandSide; 6995 return assignmentExpression.propagatedParameterElementForRightHandSide;
7486 } 6996 }
7487 } else if (parent is PrefixExpression) { 6997 } else if (parent is PrefixExpression) {
7488 return parent.propagatedParameterElementForOperand; 6998 return parent.propagatedParameterElementForOperand;
7489 } else if (parent is PostfixExpression) { 6999 } else if (parent is PostfixExpression) {
7490 return parent.propagatedParameterElementForOperand; 7000 return parent.propagatedParameterElementForOperand;
7491 } 7001 }
7492 return null; 7002 return null;
7493 } 7003 }
7494 7004
7495 /** 7005 /**
7496 * If this expression is an argument to an invocation, and the AST structure h as been resolved, 7006 * If this expression is an argument to an invocation, and the AST structure
7497 * and the function being invoked is known based on static type information, a nd this expression 7007 * has been resolved, and the function being invoked is known based on static
7498 * corresponds to one of the parameters of the function being invoked, then re turn the parameter 7008 * type information, and this expression corresponds to one of the parameters
7499 * element representing the parameter to which the value of this expression wi ll be bound. 7009 * of the function being invoked, then return the parameter element
7500 * Otherwise, return `null`. 7010 * representing the parameter to which the value of this expression will be
7501 * 7011 * bound. Otherwise, return `null`.
7502 * @return the parameter element representing the parameter to which the value of this expression
7503 * will be bound
7504 */ 7012 */
7505 ParameterElement get staticParameterElement { 7013 ParameterElement get staticParameterElement {
7506 AstNode parent = this.parent; 7014 AstNode parent = this.parent;
7507 if (parent is ArgumentList) { 7015 if (parent is ArgumentList) {
7508 return parent.getStaticParameterElementFor(this); 7016 return parent.getStaticParameterElementFor(this);
7509 } else if (parent is IndexExpression) { 7017 } else if (parent is IndexExpression) {
7510 IndexExpression indexExpression = parent; 7018 IndexExpression indexExpression = parent;
7511 if (identical(indexExpression.index, this)) { 7019 if (identical(indexExpression.index, this)) {
7512 return indexExpression.staticParameterElementForIndex; 7020 return indexExpression.staticParameterElementForIndex;
7513 } 7021 }
(...skipping 10 matching lines...) Expand all
7524 } else if (parent is PrefixExpression) { 7032 } else if (parent is PrefixExpression) {
7525 return parent.staticParameterElementForOperand; 7033 return parent.staticParameterElementForOperand;
7526 } else if (parent is PostfixExpression) { 7034 } else if (parent is PostfixExpression) {
7527 return parent.staticParameterElementForOperand; 7035 return parent.staticParameterElementForOperand;
7528 } 7036 }
7529 return null; 7037 return null;
7530 } 7038 }
7531 } 7039 }
7532 7040
7533 /** 7041 /**
7534 * Instances of the class `ExpressionFunctionBody` represent a function body con sisting of a 7042 * A function body consisting of a single expression.
7535 * single expression.
7536 * 7043 *
7537 * <pre> 7044 * > expressionFunctionBody ::=
7538 * expressionFunctionBody ::= 7045 * > 'async'? '=>' [Expression] ';'
7539 * 'async'? '=>' [Expression] ';'
7540 * </pre>
7541 */ 7046 */
7542 class ExpressionFunctionBody extends FunctionBody { 7047 class ExpressionFunctionBody extends FunctionBody {
7543 /** 7048 /**
7544 * The token representing the 'async' keyword, or `null` if there is no such k eyword. 7049 * The token representing the 'async' keyword, or `null` if there is no such
7050 * keyword.
7545 */ 7051 */
7546 Token keyword; 7052 Token keyword;
7547 7053
7548 /** 7054 /**
7549 * The token introducing the expression that represents the body of the functi on. 7055 * The token introducing the expression that represents the body of the
7056 * function.
7550 */ 7057 */
7551 Token functionDefinition; 7058 Token functionDefinition;
7552 7059
7553 /** 7060 /**
7554 * The expression representing the body of the function. 7061 * The expression representing the body of the function.
7555 */ 7062 */
7556 Expression _expression; 7063 Expression _expression;
7557 7064
7558 /** 7065 /**
7559 * The semicolon terminating the statement. 7066 * The semicolon terminating the statement.
7560 */ 7067 */
7561 Token semicolon; 7068 Token semicolon;
7562 7069
7563 /** 7070 /**
7564 * Initialize a newly created function body consisting of a block of statement s. 7071 * Initialize a newly created function body consisting of a block of
7565 * 7072 * statements. The [keyword] can be `null` if the function body is not an
7566 * @param keyword the token representing the 'async' keyword 7073 * async function body.
7567 * @param functionDefinition the token introducing the expression that represe nts the body of the
7568 * function
7569 * @param expression the expression representing the body of the function
7570 * @param semicolon the semicolon terminating the statement
7571 */ 7074 */
7572 ExpressionFunctionBody(this.keyword, this.functionDefinition, 7075 ExpressionFunctionBody(this.keyword, this.functionDefinition,
7573 Expression expression, this.semicolon) { 7076 Expression expression, this.semicolon) {
7574 _expression = becomeParentOf(expression); 7077 _expression = becomeParentOf(expression);
7575 } 7078 }
7576 7079
7577 @override 7080 @override
7578 Token get beginToken => functionDefinition; 7081 Token get beginToken => functionDefinition;
7579 7082
7580 @override 7083 @override
7581 Iterable get childEntities => new ChildEntities() 7084 Iterable get childEntities => new ChildEntities()
7582 ..add(keyword) 7085 ..add(keyword)
7583 ..add(functionDefinition) 7086 ..add(functionDefinition)
7584 ..add(_expression) 7087 ..add(_expression)
7585 ..add(semicolon); 7088 ..add(semicolon);
7586 7089
7587 @override 7090 @override
7588 Token get endToken { 7091 Token get endToken {
7589 if (semicolon != null) { 7092 if (semicolon != null) {
7590 return semicolon; 7093 return semicolon;
7591 } 7094 }
7592 return _expression.endToken; 7095 return _expression.endToken;
7593 } 7096 }
7594 7097
7595 /** 7098 /**
7596 * Return the expression representing the body of the function. 7099 * Return the expression representing the body of the function.
7597 *
7598 * @return the expression representing the body of the function
7599 */ 7100 */
7600 Expression get expression => _expression; 7101 Expression get expression => _expression;
7601 7102
7602 /** 7103 /**
7603 * Set the expression representing the body of the function to the given expre ssion. 7104 * Set the expression representing the body of the function to the given
7604 * 7105 * [expression].
7605 * @param expression the expression representing the body of the function
7606 */ 7106 */
7607 void set expression(Expression expression) { 7107 void set expression(Expression expression) {
7608 _expression = becomeParentOf(expression); 7108 _expression = becomeParentOf(expression);
7609 } 7109 }
7610 7110
7611 @override 7111 @override
7612 bool get isAsynchronous => keyword != null; 7112 bool get isAsynchronous => keyword != null;
7613 7113
7614 @override 7114 @override
7615 bool get isSynchronous => keyword == null; 7115 bool get isSynchronous => keyword == null;
7616 7116
7617 @override 7117 @override
7618 accept(AstVisitor visitor) => visitor.visitExpressionFunctionBody(this); 7118 accept(AstVisitor visitor) => visitor.visitExpressionFunctionBody(this);
7619 7119
7620 @override 7120 @override
7621 void visitChildren(AstVisitor visitor) { 7121 void visitChildren(AstVisitor visitor) {
7622 safelyVisitChild(_expression, visitor); 7122 _safelyVisitChild(_expression, visitor);
7623 } 7123 }
7624 } 7124 }
7625 7125
7626 /** 7126 /**
7627 * Instances of the class `ExpressionStatement` wrap an expression as a statemen t. 7127 * An expression used as a statement.
7628 * 7128 *
7629 * <pre> 7129 * > expressionStatement ::=
7630 * expressionStatement ::= 7130 * > [Expression]? ';'
7631 * [Expression]? ';'
7632 * </pre>
7633 */ 7131 */
7634 class ExpressionStatement extends Statement { 7132 class ExpressionStatement extends Statement {
7635 /** 7133 /**
7636 * The expression that comprises the statement. 7134 * The expression that comprises the statement.
7637 */ 7135 */
7638 Expression _expression; 7136 Expression _expression;
7639 7137
7640 /** 7138 /**
7641 * The semicolon terminating the statement, or `null` if the expression is a f unction 7139 * The semicolon terminating the statement, or `null` if the expression is a
7642 * expression and therefore isn't followed by a semicolon. 7140 * function expression and therefore isn't followed by a semicolon.
7643 */ 7141 */
7644 Token semicolon; 7142 Token semicolon;
7645 7143
7646 /** 7144 /**
7647 * Initialize a newly created expression statement. 7145 * Initialize a newly created expression statement.
7648 *
7649 * @param expression the expression that comprises the statement
7650 * @param semicolon the semicolon terminating the statement
7651 */ 7146 */
7652 ExpressionStatement(Expression expression, this.semicolon) { 7147 ExpressionStatement(Expression expression, this.semicolon) {
7653 _expression = becomeParentOf(expression); 7148 _expression = becomeParentOf(expression);
7654 } 7149 }
7655 7150
7656 @override 7151 @override
7657 Token get beginToken => _expression.beginToken; 7152 Token get beginToken => _expression.beginToken;
7658 7153
7659 @override 7154 @override
7660 Iterable get childEntities => new ChildEntities() 7155 Iterable get childEntities => new ChildEntities()
7661 ..add(_expression) 7156 ..add(_expression)
7662 ..add(semicolon); 7157 ..add(semicolon);
7663 7158
7664 @override 7159 @override
7665 Token get endToken { 7160 Token get endToken {
7666 if (semicolon != null) { 7161 if (semicolon != null) {
7667 return semicolon; 7162 return semicolon;
7668 } 7163 }
7669 return _expression.endToken; 7164 return _expression.endToken;
7670 } 7165 }
7671 7166
7672 /** 7167 /**
7673 * Return the expression that comprises the statement. 7168 * Return the expression that comprises the statement.
7674 *
7675 * @return the expression that comprises the statement
7676 */ 7169 */
7677 Expression get expression => _expression; 7170 Expression get expression => _expression;
7678 7171
7679 /** 7172 /**
7680 * Set the expression that comprises the statement to the given expression. 7173 * Set the expression that comprises the statement to the given [expression].
7681 *
7682 * @param expression the expression that comprises the statement
7683 */ 7174 */
7684 void set expression(Expression expression) { 7175 void set expression(Expression expression) {
7685 _expression = becomeParentOf(expression); 7176 _expression = becomeParentOf(expression);
7686 } 7177 }
7687 7178
7688 @override 7179 @override
7689 bool get isSynthetic => _expression.isSynthetic && semicolon.isSynthetic; 7180 bool get isSynthetic => _expression.isSynthetic && semicolon.isSynthetic;
7690 7181
7691 @override 7182 @override
7692 accept(AstVisitor visitor) => visitor.visitExpressionStatement(this); 7183 accept(AstVisitor visitor) => visitor.visitExpressionStatement(this);
7693 7184
7694 @override 7185 @override
7695 void visitChildren(AstVisitor visitor) { 7186 void visitChildren(AstVisitor visitor) {
7696 safelyVisitChild(_expression, visitor); 7187 _safelyVisitChild(_expression, visitor);
7697 } 7188 }
7698 } 7189 }
7699 7190
7700 /** 7191 /**
7701 * Instances of the class `ExtendsClause` represent the "extends" clause in a cl ass 7192 * The "extends" clause in a class declaration.
7702 * declaration.
7703 * 7193 *
7704 * <pre> 7194 * > extendsClause ::=
7705 * extendsClause ::= 7195 * > 'extends' [TypeName]
7706 * 'extends' [TypeName]
7707 * </pre>
7708 */ 7196 */
7709 class ExtendsClause extends AstNode { 7197 class ExtendsClause extends AstNode {
7710 /** 7198 /**
7711 * The token representing the 'extends' keyword. 7199 * The token representing the 'extends' keyword.
7712 */ 7200 */
7713 Token keyword; 7201 Token keyword;
7714 7202
7715 /** 7203 /**
7716 * The name of the class that is being extended. 7204 * The name of the class that is being extended.
7717 */ 7205 */
7718 TypeName _superclass; 7206 TypeName _superclass;
7719 7207
7720 /** 7208 /**
7721 * Initialize a newly created extends clause. 7209 * Initialize a newly created extends clause.
7722 *
7723 * @param keyword the token representing the 'extends' keyword
7724 * @param superclass the name of the class that is being extended
7725 */ 7210 */
7726 ExtendsClause(this.keyword, TypeName superclass) { 7211 ExtendsClause(this.keyword, TypeName superclass) {
7727 _superclass = becomeParentOf(superclass); 7212 _superclass = becomeParentOf(superclass);
7728 } 7213 }
7729 7214
7730 @override 7215 @override
7731 Token get beginToken => keyword; 7216 Token get beginToken => keyword;
7732 7217
7733 @override 7218 @override
7734 Iterable get childEntities => new ChildEntities() 7219 Iterable get childEntities => new ChildEntities()
7735 ..add(keyword) 7220 ..add(keyword)
7736 ..add(_superclass); 7221 ..add(_superclass);
7737 7222
7738 @override 7223 @override
7739 Token get endToken => _superclass.endToken; 7224 Token get endToken => _superclass.endToken;
7740 7225
7741 /** 7226 /**
7742 * Return the name of the class that is being extended. 7227 * Return the name of the class that is being extended.
7743 *
7744 * @return the name of the class that is being extended
7745 */ 7228 */
7746 TypeName get superclass => _superclass; 7229 TypeName get superclass => _superclass;
7747 7230
7748 /** 7231 /**
7749 * Set the name of the class that is being extended to the given name. 7232 * Set the name of the class that is being extended to the given [name].
7750 *
7751 * @param name the name of the class that is being extended
7752 */ 7233 */
7753 void set superclass(TypeName name) { 7234 void set superclass(TypeName name) {
7754 _superclass = becomeParentOf(name); 7235 _superclass = becomeParentOf(name);
7755 } 7236 }
7756 7237
7757 @override 7238 @override
7758 accept(AstVisitor visitor) => visitor.visitExtendsClause(this); 7239 accept(AstVisitor visitor) => visitor.visitExtendsClause(this);
7759 7240
7760 @override 7241 @override
7761 void visitChildren(AstVisitor visitor) { 7242 void visitChildren(AstVisitor visitor) {
7762 safelyVisitChild(_superclass, visitor); 7243 _safelyVisitChild(_superclass, visitor);
7763 } 7244 }
7764 } 7245 }
7765 7246
7766 /** 7247 /**
7767 * Instances of the class `FieldDeclaration` represent the declaration of one or more fields 7248 * The declaration of one or more fields of the same type.
7768 * of the same type.
7769 * 7249 *
7770 * <pre> 7250 * > fieldDeclaration ::=
7771 * fieldDeclaration ::= 7251 * > 'static'? [VariableDeclarationList] ';'
7772 * 'static'? [VariableDeclarationList] ';'
7773 * </pre>
7774 */ 7252 */
7775 class FieldDeclaration extends ClassMember { 7253 class FieldDeclaration extends ClassMember {
7776 /** 7254 /**
7777 * The token representing the 'static' keyword, or `null` if the fields are no t static. 7255 * The token representing the 'static' keyword, or `null` if the fields are
7256 * not static.
7778 */ 7257 */
7779 Token staticKeyword; 7258 Token staticKeyword;
7780 7259
7781 /** 7260 /**
7782 * The fields being declared. 7261 * The fields being declared.
7783 */ 7262 */
7784 VariableDeclarationList _fieldList; 7263 VariableDeclarationList _fieldList;
7785 7264
7786 /** 7265 /**
7787 * The semicolon terminating the declaration. 7266 * The semicolon terminating the declaration.
7788 */ 7267 */
7789 Token semicolon; 7268 Token semicolon;
7790 7269
7791 /** 7270 /**
7792 * Initialize a newly created field declaration. 7271 * Initialize a newly created field declaration. Either or both of the
7793 * 7272 * [comment] and [metadata] can be `null` if the declaration does not have the
7794 * @param comment the documentation comment associated with this field 7273 * corresponding attribute. The [staticKeyword] can be `null` if the field is
7795 * @param metadata the annotations associated with this field 7274 * not a static field.
7796 * @param staticKeyword the token representing the 'static' keyword
7797 * @param fieldList the fields being declared
7798 * @param semicolon the semicolon terminating the declaration
7799 */ 7275 */
7800 FieldDeclaration(Comment comment, List<Annotation> metadata, 7276 FieldDeclaration(Comment comment, List<Annotation> metadata,
7801 this.staticKeyword, VariableDeclarationList fieldList, this.semicolon) 7277 this.staticKeyword, VariableDeclarationList fieldList, this.semicolon)
7802 : super(comment, metadata) { 7278 : super(comment, metadata) {
7803 _fieldList = becomeParentOf(fieldList); 7279 _fieldList = becomeParentOf(fieldList);
7804 } 7280 }
7805 7281
7806 @override 7282 @override
7807 Iterable get childEntities => super._childEntities 7283 Iterable get childEntities => super._childEntities
7808 ..add(staticKeyword) 7284 ..add(staticKeyword)
7809 ..add(_fieldList) 7285 ..add(_fieldList)
7810 ..add(semicolon); 7286 ..add(semicolon);
7811 7287
7812 @override 7288 @override
7813 Element get element => null; 7289 Element get element => null;
7814 7290
7815 @override 7291 @override
7816 Token get endToken => semicolon; 7292 Token get endToken => semicolon;
7817 7293
7818 /** 7294 /**
7819 * Return the fields being declared. 7295 * Return the fields being declared.
7820 *
7821 * @return the fields being declared
7822 */ 7296 */
7823 VariableDeclarationList get fields => _fieldList; 7297 VariableDeclarationList get fields => _fieldList;
7824 7298
7825 /** 7299 /**
7826 * Set the fields being declared to the given list of variables. 7300 * Set the fields being declared to the given list of [fields].
7827 *
7828 * @param fieldList the fields being declared
7829 */ 7301 */
7830 void set fields(VariableDeclarationList fieldList) { 7302 void set fields(VariableDeclarationList fields) {
7831 _fieldList = becomeParentOf(fieldList); 7303 _fieldList = becomeParentOf(fields);
7832 } 7304 }
7833 7305
7834 @override 7306 @override
7835 Token get firstTokenAfterCommentAndMetadata { 7307 Token get firstTokenAfterCommentAndMetadata {
7836 if (staticKeyword != null) { 7308 if (staticKeyword != null) {
7837 return staticKeyword; 7309 return staticKeyword;
7838 } 7310 }
7839 return _fieldList.beginToken; 7311 return _fieldList.beginToken;
7840 } 7312 }
7841 7313
7842 /** 7314 /**
7843 * Return `true` if the fields are static. 7315 * Return `true` if the fields are declared to be static.
7844 *
7845 * @return `true` if the fields are declared to be static
7846 */ 7316 */
7847 bool get isStatic => staticKeyword != null; 7317 bool get isStatic => staticKeyword != null;
7848 7318
7849 @override 7319 @override
7850 accept(AstVisitor visitor) => visitor.visitFieldDeclaration(this); 7320 accept(AstVisitor visitor) => visitor.visitFieldDeclaration(this);
7851 7321
7852 @override 7322 @override
7853 void visitChildren(AstVisitor visitor) { 7323 void visitChildren(AstVisitor visitor) {
7854 super.visitChildren(visitor); 7324 super.visitChildren(visitor);
7855 safelyVisitChild(_fieldList, visitor); 7325 _safelyVisitChild(_fieldList, visitor);
7856 } 7326 }
7857 } 7327 }
7858 7328
7859 /** 7329 /**
7860 * Instances of the class `FieldFormalParameter` represent a field formal parame ter. 7330 * A field formal parameter.
7861 * 7331 *
7862 * <pre> 7332 * > fieldFormalParameter ::=
7863 * fieldFormalParameter ::= 7333 * > ('final' [TypeName] | 'const' [TypeName] | 'var' | [TypeName])?
7864 * ('final' [TypeName] | 'const' [TypeName] | 'var' | [TypeName])? 'this' '. ' [SimpleIdentifier] [FormalParameterList]? 7334 * > 'this' '.' [SimpleIdentifier] [FormalParameterList]?
7865 * </pre>
7866 */ 7335 */
7867 class FieldFormalParameter extends NormalFormalParameter { 7336 class FieldFormalParameter extends NormalFormalParameter {
7868 /** 7337 /**
7869 * The token representing either the 'final', 'const' or 'var' keyword, or `nu ll` if no 7338 * The token representing either the 'final', 'const' or 'var' keyword, or
7870 * keyword was used. 7339 * `null` if no keyword was used.
7871 */ 7340 */
7872 Token keyword; 7341 Token keyword;
7873 7342
7874 /** 7343 /**
7875 * The name of the declared type of the parameter, or `null` if the parameter does not have 7344 * The name of the declared type of the parameter, or `null` if the parameter
7876 * a declared type. 7345 * does not have a declared type.
7877 */ 7346 */
7878 TypeName _type; 7347 TypeName _type;
7879 7348
7880 /** 7349 /**
7881 * The token representing the 'this' keyword. 7350 * The token representing the 'this' keyword.
7882 */ 7351 */
7883 Token thisToken; 7352 Token thisToken;
7884 7353
7885 /** 7354 /**
7886 * The token representing the period. 7355 * The token representing the period.
7887 */ 7356 */
7888 Token period; 7357 Token period;
7889 7358
7890 /** 7359 /**
7891 * The parameters of the function-typed parameter, or `null` if this is not a function-typed 7360 * The parameters of the function-typed parameter, or `null` if this is not a
7892 * field formal parameter. 7361 * function-typed field formal parameter.
7893 */ 7362 */
7894 FormalParameterList _parameters; 7363 FormalParameterList _parameters;
7895 7364
7896 /** 7365 /**
7897 * Initialize a newly created formal parameter. 7366 * Initialize a newly created formal parameter. Either or both of the
7898 * 7367 * [comment] and [metadata] can be `null` if the parameter does not have the
7899 * @param comment the documentation comment associated with this parameter 7368 * corresponding attribute. The [keyword] can be `null` if there is a type.
7900 * @param metadata the annotations associated with this parameter 7369 * The [type] must be `null` if the keyword is 'var'. The [thisToken] and
7901 * @param keyword the token representing either the 'final', 'const' or 'var' keyword 7370 * [period] can be `null` if the keyword 'this' was not provided. The
7902 * @param type the name of the declared type of the parameter 7371 * [parameters] can be `null` if this is not a function-typed field formal
7903 * @param thisToken the token representing the 'this' keyword 7372 * parameter.
7904 * @param period the token representing the period
7905 * @param identifier the name of the parameter being declared
7906 * @param parameters the parameters of the function-typed parameter, or `null` if this is
7907 * not a function-typed field formal parameter
7908 */ 7373 */
7909 FieldFormalParameter(Comment comment, List<Annotation> metadata, this.keyword, 7374 FieldFormalParameter(Comment comment, List<Annotation> metadata, this.keyword,
7910 TypeName type, this.thisToken, this.period, SimpleIdentifier identifier, 7375 TypeName type, this.thisToken, this.period, SimpleIdentifier identifier,
7911 FormalParameterList parameters) 7376 FormalParameterList parameters)
7912 : super(comment, metadata, identifier) { 7377 : super(comment, metadata, identifier) {
7913 _type = becomeParentOf(type); 7378 _type = becomeParentOf(type);
7914 _parameters = becomeParentOf(parameters); 7379 _parameters = becomeParentOf(parameters);
7915 } 7380 }
7916 7381
7917 @override 7382 @override
(...skipping 25 matching lines...) Expand all
7943 7408
7944 @override 7409 @override
7945 bool get isConst => 7410 bool get isConst =>
7946 (keyword is KeywordToken) && (keyword as KeywordToken).keyword == Keyword. CONST; 7411 (keyword is KeywordToken) && (keyword as KeywordToken).keyword == Keyword. CONST;
7947 7412
7948 @override 7413 @override
7949 bool get isFinal => 7414 bool get isFinal =>
7950 (keyword is KeywordToken) && (keyword as KeywordToken).keyword == Keyword. FINAL; 7415 (keyword is KeywordToken) && (keyword as KeywordToken).keyword == Keyword. FINAL;
7951 7416
7952 /** 7417 /**
7953 * Return the parameters of the function-typed parameter, or `null` if this is not a 7418 * Return the parameters of the function-typed parameter, or `null` if this is
7954 * function-typed field formal parameter. 7419 * not a function-typed field formal parameter.
7955 *
7956 * @return the parameters of the function-typed parameter
7957 */ 7420 */
7958 FormalParameterList get parameters => _parameters; 7421 FormalParameterList get parameters => _parameters;
7959 7422
7960 /** 7423 /**
7961 * Set the parameters of the function-typed parameter to the given parameters. 7424 * Set the parameters of the function-typed parameter to the given
7962 * 7425 * [parameters].
7963 * @param parameters the parameters of the function-typed parameter
7964 */ 7426 */
7965 void set parameters(FormalParameterList parameters) { 7427 void set parameters(FormalParameterList parameters) {
7966 _parameters = becomeParentOf(parameters); 7428 _parameters = becomeParentOf(parameters);
7967 } 7429 }
7968 7430
7969 /** 7431 /**
7970 * Return the name of the declared type of the parameter, or `null` if the par ameter does 7432 * Return the name of the declared type of the parameter, or `null` if the
7971 * not have a declared type. Note that if this is a function-typed field forma l parameter this is 7433 * parameter does not have a declared type. Note that if this is a
7972 * the return type of the function. 7434 * function-typed field formal parameter this is the return type of the
7973 * 7435 * function.
7974 * @return the name of the declared type of the parameter
7975 */ 7436 */
7976 TypeName get type => _type; 7437 TypeName get type => _type;
7977 7438
7978 /** 7439 /**
7979 * Set the name of the declared type of the parameter to the given type name. 7440 * Set the name of the declared type of the parameter to the given [typeName].
7980 *
7981 * @param typeName the name of the declared type of the parameter
7982 */ 7441 */
7983 void set type(TypeName typeName) { 7442 void set type(TypeName typeName) {
7984 _type = becomeParentOf(typeName); 7443 _type = becomeParentOf(typeName);
7985 } 7444 }
7986 7445
7987 @override 7446 @override
7988 accept(AstVisitor visitor) => visitor.visitFieldFormalParameter(this); 7447 accept(AstVisitor visitor) => visitor.visitFieldFormalParameter(this);
7989 7448
7990 @override 7449 @override
7991 void visitChildren(AstVisitor visitor) { 7450 void visitChildren(AstVisitor visitor) {
7992 super.visitChildren(visitor); 7451 super.visitChildren(visitor);
7993 safelyVisitChild(_type, visitor); 7452 _safelyVisitChild(_type, visitor);
7994 safelyVisitChild(identifier, visitor); 7453 _safelyVisitChild(identifier, visitor);
7995 safelyVisitChild(_parameters, visitor); 7454 _safelyVisitChild(_parameters, visitor);
7996 } 7455 }
7997 } 7456 }
7998 7457
7999 /** 7458 /**
8000 * Instances of the class `ForEachStatement` represent a for-each statement. 7459 * A for-each statement.
8001 * 7460 *
8002 * <pre> 7461 * > forEachStatement ::=
8003 * forEachStatement ::= 7462 * > 'await'? 'for' '(' [DeclaredIdentifier] 'in' [Expression] ')' [Block]
8004 * 'await'? 'for' '(' [DeclaredIdentifier] 'in' [Expression] ')' [Block] 7463 * > | 'await'? 'for' '(' [SimpleIdentifier] 'in' [Expression] ')' [Block]
8005 * | 'await'? 'for' '(' [SimpleIdentifier] 'in' [Expression] ')' [Block]
8006 * </pre>
8007 */ 7464 */
8008 class ForEachStatement extends Statement { 7465 class ForEachStatement extends Statement {
8009 /** 7466 /**
8010 * The token representing the 'await' keyword, or `null` if there is no 'await ' keyword. 7467 * The token representing the 'await' keyword, or `null` if there is no
7468 * 'await' keyword.
8011 */ 7469 */
8012 Token awaitKeyword; 7470 Token awaitKeyword;
8013 7471
8014 /** 7472 /**
8015 * The token representing the 'for' keyword. 7473 * The token representing the 'for' keyword.
8016 */ 7474 */
8017 Token forKeyword; 7475 Token forKeyword;
8018 7476
8019 /** 7477 /**
8020 * The left parenthesis. 7478 * The left parenthesis.
8021 */ 7479 */
8022 Token leftParenthesis; 7480 Token leftParenthesis;
8023 7481
8024 /** 7482 /**
8025 * The declaration of the loop variable, or `null` if the loop variable is a s imple 7483 * The declaration of the loop variable, or `null` if the loop variable is a
8026 * identifier. 7484 * simple identifier.
8027 */ 7485 */
8028 DeclaredIdentifier _loopVariable; 7486 DeclaredIdentifier _loopVariable;
8029 7487
8030 /** 7488 /**
8031 * The loop variable, or `null` if the loop variable is declared in the 'for'. 7489 * The loop variable, or `null` if the loop variable is declared in the 'for'.
8032 */ 7490 */
8033 SimpleIdentifier _identifier; 7491 SimpleIdentifier _identifier;
8034 7492
8035 /** 7493 /**
8036 * The token representing the 'in' keyword. 7494 * The token representing the 'in' keyword.
8037 */ 7495 */
8038 Token inKeyword; 7496 Token inKeyword;
8039 7497
8040 /** 7498 /**
8041 * The expression evaluated to produce the iterator. 7499 * The expression evaluated to produce the iterator.
8042 */ 7500 */
8043 Expression _iterable; 7501 Expression _iterable;
8044 7502
8045 /** 7503 /**
8046 * The right parenthesis. 7504 * The right parenthesis.
8047 */ 7505 */
8048 Token rightParenthesis; 7506 Token rightParenthesis;
8049 7507
8050 /** 7508 /**
8051 * The body of the loop. 7509 * The body of the loop.
8052 */ 7510 */
8053 Statement _body; 7511 Statement _body;
8054 7512
8055 /** 7513 /**
8056 * Initialize a newly created for-each statement. 7514 * Initialize a newly created for-each statement. The [awaitKeyword] can be
8057 * 7515 * `null` if this is not an asynchronous for loop.
8058 * @param awaitKeyword the token representing the 'await' keyword
8059 * @param forKeyword the token representing the 'for' keyword
8060 * @param leftParenthesis the left parenthesis
8061 * @param loopVariable the declaration of the loop variable
8062 * @param iterator the expression evaluated to produce the iterator
8063 * @param rightParenthesis the right parenthesis
8064 * @param body the body of the loop
8065 */ 7516 */
8066 ForEachStatement.con1(this.awaitKeyword, this.forKeyword, 7517 ForEachStatement.con1(this.awaitKeyword, this.forKeyword,
8067 this.leftParenthesis, DeclaredIdentifier loopVariable, this.inKeyword, 7518 this.leftParenthesis, DeclaredIdentifier loopVariable, this.inKeyword,
8068 Expression iterator, this.rightParenthesis, Statement body) { 7519 Expression iterator, this.rightParenthesis, Statement body) {
8069 _loopVariable = becomeParentOf(loopVariable); 7520 _loopVariable = becomeParentOf(loopVariable);
8070 _iterable = becomeParentOf(iterator); 7521 _iterable = becomeParentOf(iterator);
8071 _body = becomeParentOf(body); 7522 _body = becomeParentOf(body);
8072 } 7523 }
8073 7524
8074 /** 7525 /**
8075 * Initialize a newly created for-each statement. 7526 * Initialize a newly created for-each statement. The [awaitKeyword] can be
8076 * 7527 * `null` if this is not an asynchronous for loop.
8077 * @param awaitKeyword the token representing the 'await' keyword
8078 * @param forKeyword the token representing the 'for' keyword
8079 * @param leftParenthesis the left parenthesis
8080 * @param identifier the loop variable
8081 * @param iterator the expression evaluated to produce the iterator
8082 * @param rightParenthesis the right parenthesis
8083 * @param body the body of the loop
8084 */ 7528 */
8085 ForEachStatement.con2(this.awaitKeyword, this.forKeyword, 7529 ForEachStatement.con2(this.awaitKeyword, this.forKeyword,
8086 this.leftParenthesis, SimpleIdentifier identifier, this.inKeyword, 7530 this.leftParenthesis, SimpleIdentifier identifier, this.inKeyword,
8087 Expression iterator, this.rightParenthesis, Statement body) { 7531 Expression iterator, this.rightParenthesis, Statement body) {
8088 _identifier = becomeParentOf(identifier); 7532 _identifier = becomeParentOf(identifier);
8089 _iterable = becomeParentOf(iterator); 7533 _iterable = becomeParentOf(iterator);
8090 _body = becomeParentOf(body); 7534 _body = becomeParentOf(body);
8091 } 7535 }
8092 7536
8093 @override 7537 @override
8094 Token get beginToken => forKeyword; 7538 Token get beginToken => forKeyword;
8095 7539
8096 /** 7540 /**
8097 * Return the body of the loop. 7541 * Return the body of the loop.
8098 *
8099 * @return the body of the loop
8100 */ 7542 */
8101 Statement get body => _body; 7543 Statement get body => _body;
8102 7544
8103 /** 7545 /**
8104 * Set the body of the loop to the given block. 7546 * Set the body of the loop to the given [statement].
8105 *
8106 * @param body the body of the loop
8107 */ 7547 */
8108 void set body(Statement body) { 7548 void set body(Statement statement) {
8109 _body = becomeParentOf(body); 7549 _body = becomeParentOf(statement);
8110 } 7550 }
8111 7551
8112 @override 7552 @override
8113 Iterable get childEntities => new ChildEntities() 7553 Iterable get childEntities => new ChildEntities()
8114 ..add(awaitKeyword) 7554 ..add(awaitKeyword)
8115 ..add(forKeyword) 7555 ..add(forKeyword)
8116 ..add(leftParenthesis) 7556 ..add(leftParenthesis)
8117 ..add(_loopVariable) 7557 ..add(_loopVariable)
8118 ..add(_identifier) 7558 ..add(_identifier)
8119 ..add(inKeyword) 7559 ..add(inKeyword)
8120 ..add(_iterable) 7560 ..add(_iterable)
8121 ..add(rightParenthesis) 7561 ..add(rightParenthesis)
8122 ..add(_body); 7562 ..add(_body);
8123 7563
8124 @override 7564 @override
8125 Token get endToken => _body.endToken; 7565 Token get endToken => _body.endToken;
8126 7566
8127 /** 7567 /**
8128 * Return the loop variable, or `null` if the loop variable is declared in the 'for'. 7568 * Return the loop variable, or `null` if the loop variable is declared in the
8129 * 7569 * 'for'.
8130 * @return the loop variable
8131 */ 7570 */
8132 SimpleIdentifier get identifier => _identifier; 7571 SimpleIdentifier get identifier => _identifier;
8133 7572
8134 /** 7573 /**
8135 * Set the loop variable to the given variable. 7574 * Set the loop variable to the given [identifier].
8136 *
8137 * @param identifier the loop variable
8138 */ 7575 */
8139 void set identifier(SimpleIdentifier identifier) { 7576 void set identifier(SimpleIdentifier identifier) {
8140 _identifier = becomeParentOf(identifier); 7577 _identifier = becomeParentOf(identifier);
8141 } 7578 }
8142 7579
8143 /** 7580 /**
8144 * Return the expression evaluated to produce the iterator. 7581 * Return the expression evaluated to produce the iterator.
8145 *
8146 * @return the expression evaluated to produce the iterator
8147 */ 7582 */
8148 Expression get iterable => _iterable; 7583 Expression get iterable => _iterable;
8149 7584
8150 /** 7585 /**
8151 * Set the expression evaluated to produce the iterator to the given expressio n. 7586 * Set the expression evaluated to produce the iterator to the given
8152 * 7587 * [expression].
8153 * @param expression the expression evaluated to produce the iterator
8154 */ 7588 */
8155 void set iterable(Expression expression) { 7589 void set iterable(Expression expression) {
8156 _iterable = becomeParentOf(expression); 7590 _iterable = becomeParentOf(expression);
8157 } 7591 }
8158 7592
8159 /** 7593 /**
8160 * Return the expression evaluated to produce the iterator. 7594 * Return the expression evaluated to produce the iterator.
8161 * 7595 *
8162 * Deprecated, use [iterable] instead. 7596 * Deprecated, use [iterable] instead.
8163 */ 7597 */
8164 @deprecated 7598 @deprecated
8165 Expression get iterator => iterable; 7599 Expression get iterator => iterable;
8166 7600
8167 /** 7601 /**
8168 * Return the declaration of the loop variable, or `null` if the loop variable is a simple 7602 * Return the declaration of the loop variable, or `null` if the loop variable
8169 * identifier. 7603 * is a simple identifier.
8170 *
8171 * @return the declaration of the loop variable
8172 */ 7604 */
8173 DeclaredIdentifier get loopVariable => _loopVariable; 7605 DeclaredIdentifier get loopVariable => _loopVariable;
8174 7606
8175 /** 7607 /**
8176 * Set the declaration of the loop variable to the given variable. 7608 * Set the declaration of the loop variable to the given [variable].
8177 *
8178 * @param variable the declaration of the loop variable
8179 */ 7609 */
8180 void set loopVariable(DeclaredIdentifier variable) { 7610 void set loopVariable(DeclaredIdentifier variable) {
8181 _loopVariable = becomeParentOf(variable); 7611 _loopVariable = becomeParentOf(variable);
8182 } 7612 }
8183 7613
8184 @override 7614 @override
8185 accept(AstVisitor visitor) => visitor.visitForEachStatement(this); 7615 accept(AstVisitor visitor) => visitor.visitForEachStatement(this);
8186 7616
8187 @override 7617 @override
8188 void visitChildren(AstVisitor visitor) { 7618 void visitChildren(AstVisitor visitor) {
8189 safelyVisitChild(_loopVariable, visitor); 7619 _safelyVisitChild(_loopVariable, visitor);
8190 safelyVisitChild(_identifier, visitor); 7620 _safelyVisitChild(_identifier, visitor);
8191 safelyVisitChild(_iterable, visitor); 7621 _safelyVisitChild(_iterable, visitor);
8192 safelyVisitChild(_body, visitor); 7622 _safelyVisitChild(_body, visitor);
8193 } 7623 }
8194 } 7624 }
8195 7625
8196 /** 7626 /**
8197 * The abstract class `FormalParameter` defines the behavior of objects represen ting a 7627 * A node representing a parameter to a function.
8198 * parameter to a function.
8199 * 7628 *
8200 * <pre> 7629 * > formalParameter ::=
8201 * formalParameter ::= 7630 * > [NormalFormalParameter]
8202 * [NormalFormalParameter] 7631 * > | [DefaultFormalParameter]
8203 * | [DefaultFormalParameter]
8204 * </pre>
8205 */ 7632 */
8206 abstract class FormalParameter extends AstNode { 7633 abstract class FormalParameter extends AstNode {
8207 /** 7634 /**
8208 * Return the element representing this parameter, or `null` if this parameter has not been 7635 * Return the element representing this parameter, or `null` if this parameter
8209 * resolved. 7636 * has not been resolved.
8210 *
8211 * @return the element representing this parameter
8212 */ 7637 */
8213 ParameterElement get element { 7638 ParameterElement get element {
8214 SimpleIdentifier identifier = this.identifier; 7639 SimpleIdentifier identifier = this.identifier;
8215 if (identifier == null) { 7640 if (identifier == null) {
8216 return null; 7641 return null;
8217 } 7642 }
8218 return identifier.staticElement as ParameterElement; 7643 return identifier.staticElement as ParameterElement;
8219 } 7644 }
8220 7645
8221 /** 7646 /**
8222 * Return the name of the parameter being declared. 7647 * Return the name of the parameter being declared.
8223 *
8224 * @return the name of the parameter being declared
8225 */ 7648 */
8226 SimpleIdentifier get identifier; 7649 SimpleIdentifier get identifier;
8227 7650
8228 /** 7651 /**
8229 * Return `true` if this parameter was declared with the 'const' modifier. 7652 * Return `true` if this parameter was declared with the 'const' modifier.
8230 *
8231 * @return `true` if this parameter was declared with the 'const' modifier
8232 */ 7653 */
8233 bool get isConst; 7654 bool get isConst;
8234 7655
8235 /** 7656 /**
8236 * Return `true` if this parameter was declared with the 'final' modifier. Par ameters that 7657 * Return `true` if this parameter was declared with the 'final' modifier.
8237 * are declared with the 'const' modifier will return `false` even though they are 7658 * Parameters that are declared with the 'const' modifier will return `false`
8238 * implicitly final. 7659 * even though they are implicitly final.
8239 *
8240 * @return `true` if this parameter was declared with the 'final' modifier
8241 */ 7660 */
8242 bool get isFinal; 7661 bool get isFinal;
8243 7662
8244 /** 7663 /**
8245 * Return the kind of this parameter. 7664 * Return the kind of this parameter.
8246 *
8247 * @return the kind of this parameter
8248 */ 7665 */
8249 ParameterKind get kind; 7666 ParameterKind get kind;
8250 } 7667 }
8251 7668
8252 /** 7669 /**
8253 * Instances of the class `FormalParameterList` represent the formal parameter l ist of a 7670 * The formal parameter list of a method declaration, function declaration, or
8254 * method declaration, function declaration, or function type alias. 7671 * function type alias.
8255 * 7672 *
8256 * While the grammar requires all optional formal parameters to follow all of th e normal formal 7673 * While the grammar requires all optional formal parameters to follow all of
8257 * parameters and at most one grouping of optional formal parameters, this class does not enforce 7674 * the normal formal parameters and at most one grouping of optional formal
8258 * those constraints. All parameters are flattened into a single list, which can have any or all 7675 * parameters, this class does not enforce those constraints. All parameters are
8259 * kinds of parameters (normal, named, and positional) in any order. 7676 * flattened into a single list, which can have any or all kinds of parameters
7677 * (normal, named, and positional) in any order.
8260 * 7678 *
8261 * <pre> 7679 * > formalParameterList ::=
8262 * formalParameterList ::= 7680 * > '(' ')'
8263 * '(' ')' 7681 * > | '(' normalFormalParameters (',' optionalFormalParameters)? ')'
8264 * | '(' normalFormalParameters (',' optionalFormalParameters)? ')' 7682 * > | '(' optionalFormalParameters ')'
8265 * | '(' optionalFormalParameters ')' 7683 * >
8266 * 7684 * > normalFormalParameters ::=
8267 * normalFormalParameters ::= 7685 * > [NormalFormalParameter] (',' [NormalFormalParameter])*
8268 * [NormalFormalParameter] (',' [NormalFormalParameter])* 7686 * >
8269 * 7687 * > optionalFormalParameters ::=
8270 * optionalFormalParameters ::= 7688 * > optionalPositionalFormalParameters
8271 * optionalPositionalFormalParameters 7689 * > | namedFormalParameters
8272 * | namedFormalParameters 7690 * >
8273 * 7691 * > optionalPositionalFormalParameters ::=
8274 * optionalPositionalFormalParameters ::= 7692 * > '[' [DefaultFormalParameter] (',' [DefaultFormalParameter])* ']'
8275 * '[' [DefaultFormalParameter] (',' [DefaultFormalParameter])* ']' 7693 * >
8276 * 7694 * > namedFormalParameters ::=
8277 * namedFormalParameters ::= 7695 * > '{' [DefaultFormalParameter] (',' [DefaultFormalParameter])* '}'
8278 * '{' [DefaultFormalParameter] (',' [DefaultFormalParameter])* '}'
8279 * </pre>
8280 */ 7696 */
8281 class FormalParameterList extends AstNode { 7697 class FormalParameterList extends AstNode {
8282 /** 7698 /**
8283 * The left parenthesis. 7699 * The left parenthesis.
8284 */ 7700 */
8285 Token leftParenthesis; 7701 Token leftParenthesis;
8286 7702
8287 /** 7703 /**
8288 * The parameters associated with the method. 7704 * The parameters associated with the method.
8289 */ 7705 */
8290 NodeList<FormalParameter> _parameters; 7706 NodeList<FormalParameter> _parameters;
8291 7707
8292 /** 7708 /**
8293 * The left square bracket ('[') or left curly brace ('{') introducing the opt ional parameters, or 7709 * The left square bracket ('[') or left curly brace ('{') introducing the
8294 * `null` if there are no optional parameters. 7710 * optional parameters, or `null` if there are no optional parameters.
8295 */ 7711 */
8296 Token leftDelimiter; 7712 Token leftDelimiter;
8297 7713
8298 /** 7714 /**
8299 * The right square bracket (']') or right curly brace ('}') introducing the o ptional parameters, 7715 * The right square bracket (']') or right curly brace ('}') introducing the
8300 * or `null` if there are no optional parameters. 7716 * optional parameters, or `null` if there are no optional parameters.
8301 */ 7717 */
8302 Token rightDelimiter; 7718 Token rightDelimiter;
8303 7719
8304 /** 7720 /**
8305 * The right parenthesis. 7721 * The right parenthesis.
8306 */ 7722 */
8307 Token rightParenthesis; 7723 Token rightParenthesis;
8308 7724
8309 /** 7725 /**
8310 * Initialize a newly created parameter list. 7726 * Initialize a newly created parameter list. The list of [parameters] can be
8311 * 7727 * `null` if there are no parameters. The [leftDelimiter] and [rightDelimiter]
8312 * @param leftParenthesis the left parenthesis 7728 * can be `null` if there are no optional parameters.
8313 * @param parameters the parameters associated with the method
8314 * @param leftDelimiter the left delimiter introducing the optional parameters
8315 * @param rightDelimiter the right delimiter introducing the optional paramete rs
8316 * @param rightParenthesis the right parenthesis
8317 */ 7729 */
8318 FormalParameterList(this.leftParenthesis, List<FormalParameter> parameters, 7730 FormalParameterList(this.leftParenthesis, List<FormalParameter> parameters,
8319 this.leftDelimiter, this.rightDelimiter, this.rightParenthesis) { 7731 this.leftDelimiter, this.rightDelimiter, this.rightParenthesis) {
8320 _parameters = new NodeList<FormalParameter>(this, parameters); 7732 _parameters = new NodeList<FormalParameter>(this, parameters);
8321 } 7733 }
8322 7734
8323 @override 7735 @override
8324 Token get beginToken => leftParenthesis; 7736 Token get beginToken => leftParenthesis;
8325 7737
8326 @override 7738 @override
(...skipping 10 matching lines...) Expand all
8337 } 7749 }
8338 return result 7750 return result
8339 ..add(rightDelimiter) 7751 ..add(rightDelimiter)
8340 ..add(rightParenthesis); 7752 ..add(rightParenthesis);
8341 } 7753 }
8342 7754
8343 @override 7755 @override
8344 Token get endToken => rightParenthesis; 7756 Token get endToken => rightParenthesis;
8345 7757
8346 /** 7758 /**
8347 * Return an array containing the elements representing the parameters in this list. The array 7759 * Return a list containing the elements representing the parameters in this
8348 * will contain `null`s if the parameters in this list have not been resolved. 7760 * list. The list will contain `null`s if the parameters in this list have not
8349 * 7761 * been resolved.
8350 * @return the elements representing the parameters in this list
8351 */ 7762 */
8352 List<ParameterElement> get parameterElements { 7763 List<ParameterElement> get parameterElements {
8353 int count = _parameters.length; 7764 int count = _parameters.length;
8354 List<ParameterElement> types = new List<ParameterElement>(count); 7765 List<ParameterElement> types = new List<ParameterElement>(count);
8355 for (int i = 0; i < count; i++) { 7766 for (int i = 0; i < count; i++) {
8356 types[i] = _parameters[i].element; 7767 types[i] = _parameters[i].element;
8357 } 7768 }
8358 return types; 7769 return types;
8359 } 7770 }
8360 7771
8361 /** 7772 /**
8362 * Return the parameters associated with the method. 7773 * Return the parameters associated with the method.
8363 *
8364 * @return the parameters associated with the method
8365 */ 7774 */
8366 NodeList<FormalParameter> get parameters => _parameters; 7775 NodeList<FormalParameter> get parameters => _parameters;
8367 7776
8368 @override 7777 @override
8369 accept(AstVisitor visitor) => visitor.visitFormalParameterList(this); 7778 accept(AstVisitor visitor) => visitor.visitFormalParameterList(this);
8370 7779
8371 @override 7780 @override
8372 void visitChildren(AstVisitor visitor) { 7781 void visitChildren(AstVisitor visitor) {
8373 _parameters.accept(visitor); 7782 _parameters.accept(visitor);
8374 } 7783 }
8375 } 7784 }
8376 7785
8377 /** 7786 /**
8378 * Instances of the class `ForStatement` represent a for statement. 7787 * A for statement.
8379 * 7788 *
8380 * <pre> 7789 * > forStatement ::=
8381 * forStatement ::= 7790 * > 'for' '(' forLoopParts ')' [Statement]
8382 * 'for' '(' forLoopParts ')' [Statement] 7791 * >
8383 * 7792 * > forLoopParts ::=
8384 * forLoopParts ::= 7793 * > forInitializerStatement ';' [Expression]? ';' [Expression]?
8385 * forInitializerStatement ';' [Expression]? ';' [Expression]? 7794 * >
8386 * 7795 * > forInitializerStatement ::=
8387 * forInitializerStatement ::= 7796 * > [DefaultFormalParameter]
8388 * [DefaultFormalParameter] 7797 * > | [Expression]?
8389 * | [Expression]?
8390 * </pre>
8391 */ 7798 */
8392 class ForStatement extends Statement { 7799 class ForStatement extends Statement {
8393 /** 7800 /**
8394 * The token representing the 'for' keyword. 7801 * The token representing the 'for' keyword.
8395 */ 7802 */
8396 Token forKeyword; 7803 Token forKeyword;
8397 7804
8398 /** 7805 /**
8399 * The left parenthesis. 7806 * The left parenthesis.
8400 */ 7807 */
8401 Token leftParenthesis; 7808 Token leftParenthesis;
8402 7809
8403 /** 7810 /**
8404 * The declaration of the loop variables, or `null` if there are no variables. Note that a 7811 * The declaration of the loop variables, or `null` if there are no variables.
8405 * for statement cannot have both a variable list and an initialization expres sion, but can 7812 * Note that a for statement cannot have both a variable list and an
8406 * validly have neither. 7813 * initialization expression, but can validly have neither.
8407 */ 7814 */
8408 VariableDeclarationList _variableList; 7815 VariableDeclarationList _variableList;
8409 7816
8410 /** 7817 /**
8411 * The initialization expression, or `null` if there is no initialization expr ession. Note 7818 * The initialization expression, or `null` if there is no initialization
8412 * that a for statement cannot have both a variable list and an initialization expression, but can 7819 * expression. Note that a for statement cannot have both a variable list and
8413 * validly have neither. 7820 * an initialization expression, but can validly have neither.
8414 */ 7821 */
8415 Expression _initialization; 7822 Expression _initialization;
8416 7823
8417 /** 7824 /**
8418 * The semicolon separating the initializer and the condition. 7825 * The semicolon separating the initializer and the condition.
8419 */ 7826 */
8420 Token leftSeparator; 7827 Token leftSeparator;
8421 7828
8422 /** 7829 /**
8423 * The condition used to determine when to terminate the loop, or `null` if th ere is no 7830 * The condition used to determine when to terminate the loop, or `null` if
8424 * condition. 7831 * there is no condition.
8425 */ 7832 */
8426 Expression _condition; 7833 Expression _condition;
8427 7834
8428 /** 7835 /**
8429 * The semicolon separating the condition and the updater. 7836 * The semicolon separating the condition and the updater.
8430 */ 7837 */
8431 Token rightSeparator; 7838 Token rightSeparator;
8432 7839
8433 /** 7840 /**
8434 * The list of expressions run after each execution of the loop body. 7841 * The list of expressions run after each execution of the loop body.
8435 */ 7842 */
8436 NodeList<Expression> _updaters; 7843 NodeList<Expression> _updaters;
8437 7844
8438 /** 7845 /**
8439 * The right parenthesis. 7846 * The right parenthesis.
8440 */ 7847 */
8441 Token rightParenthesis; 7848 Token rightParenthesis;
8442 7849
8443 /** 7850 /**
8444 * The body of the loop. 7851 * The body of the loop.
8445 */ 7852 */
8446 Statement _body; 7853 Statement _body;
8447 7854
8448 /** 7855 /**
8449 * Initialize a newly created for statement. 7856 * Initialize a newly created for statement. Either the [variableList] or the
8450 * 7857 * [initialization] must be `null`. Either the [condition] and the list of
8451 * @param forKeyword the token representing the 'for' keyword 7858 * [updaters] can be `null` if the loop does not have the corresponding
8452 * @param leftParenthesis the left parenthesis 7859 * attribute.
8453 * @param variableList the declaration of the loop variables
8454 * @param initialization the initialization expression
8455 * @param leftSeparator the semicolon separating the initializer and the condi tion
8456 * @param condition the condition used to determine when to terminate the loop
8457 * @param rightSeparator the semicolon separating the condition and the update r
8458 * @param updaters the list of expressions run after each execution of the loo p body
8459 * @param rightParenthesis the right parenthesis
8460 * @param body the body of the loop
8461 */ 7860 */
8462 ForStatement(this.forKeyword, this.leftParenthesis, 7861 ForStatement(this.forKeyword, this.leftParenthesis,
8463 VariableDeclarationList variableList, Expression initialization, 7862 VariableDeclarationList variableList, Expression initialization,
8464 this.leftSeparator, Expression condition, this.rightSeparator, 7863 this.leftSeparator, Expression condition, this.rightSeparator,
8465 List<Expression> updaters, this.rightParenthesis, Statement body) { 7864 List<Expression> updaters, this.rightParenthesis, Statement body) {
8466 _variableList = becomeParentOf(variableList); 7865 _variableList = becomeParentOf(variableList);
8467 _initialization = becomeParentOf(initialization); 7866 _initialization = becomeParentOf(initialization);
8468 _condition = becomeParentOf(condition); 7867 _condition = becomeParentOf(condition);
8469 _updaters = new NodeList<Expression>(this, updaters); 7868 _updaters = new NodeList<Expression>(this, updaters);
8470 _body = becomeParentOf(body); 7869 _body = becomeParentOf(body);
8471 } 7870 }
8472 7871
8473 @override 7872 @override
8474 Token get beginToken => forKeyword; 7873 Token get beginToken => forKeyword;
8475 7874
8476 /** 7875 /**
8477 * Return the body of the loop. 7876 * Return the body of the loop.
8478 *
8479 * @return the body of the loop
8480 */ 7877 */
8481 Statement get body => _body; 7878 Statement get body => _body;
8482 7879
8483 /** 7880 /**
8484 * Set the body of the loop to the given statement. 7881 * Set the body of the loop to the given [statement].
8485 *
8486 * @param body the body of the loop
8487 */ 7882 */
8488 void set body(Statement body) { 7883 void set body(Statement statement) {
8489 _body = becomeParentOf(body); 7884 _body = becomeParentOf(statement);
8490 } 7885 }
8491 7886
8492 @override 7887 @override
8493 Iterable get childEntities => new ChildEntities() 7888 Iterable get childEntities => new ChildEntities()
8494 ..add(forKeyword) 7889 ..add(forKeyword)
8495 ..add(leftParenthesis) 7890 ..add(leftParenthesis)
8496 ..add(_variableList) 7891 ..add(_variableList)
8497 ..add(_initialization) 7892 ..add(_initialization)
8498 ..add(leftSeparator) 7893 ..add(leftSeparator)
8499 ..add(_condition) 7894 ..add(_condition)
8500 ..add(rightSeparator) 7895 ..add(rightSeparator)
8501 ..addAll(_updaters) 7896 ..addAll(_updaters)
8502 ..add(rightParenthesis) 7897 ..add(rightParenthesis)
8503 ..add(_body); 7898 ..add(_body);
8504 7899
8505 /** 7900 /**
8506 * Return the condition used to determine when to terminate the loop, or `null ` if there is 7901 * Return the condition used to determine when to terminate the loop, or
8507 * no condition. 7902 * `null` if there is no condition.
8508 *
8509 * @return the condition used to determine when to terminate the loop
8510 */ 7903 */
8511 Expression get condition => _condition; 7904 Expression get condition => _condition;
8512 7905
8513 /** 7906 /**
8514 * Set the condition used to determine when to terminate the loop to the given expression. 7907 * Set the condition used to determine when to terminate the loop to the given
8515 * 7908 * [expression].
8516 * @param expression the condition used to determine when to terminate the loo p
8517 */ 7909 */
8518 void set condition(Expression expression) { 7910 void set condition(Expression expression) {
8519 _condition = becomeParentOf(expression); 7911 _condition = becomeParentOf(expression);
8520 } 7912 }
8521 7913
8522 @override 7914 @override
8523 Token get endToken => _body.endToken; 7915 Token get endToken => _body.endToken;
8524 7916
8525 /** 7917 /**
8526 * Return the initialization expression, or `null` if there is no initializati on expression. 7918 * Return the initialization expression, or `null` if there is no
8527 * 7919 * initialization expression.
8528 * @return the initialization expression
8529 */ 7920 */
8530 Expression get initialization => _initialization; 7921 Expression get initialization => _initialization;
8531 7922
8532 /** 7923 /**
8533 * Set the initialization expression to the given expression. 7924 * Set the initialization expression to the given [expression].
8534 *
8535 * @param initialization the initialization expression
8536 */ 7925 */
8537 void set initialization(Expression initialization) { 7926 void set initialization(Expression initialization) {
8538 _initialization = becomeParentOf(initialization); 7927 _initialization = becomeParentOf(initialization);
8539 } 7928 }
8540 7929
8541 /** 7930 /**
8542 * Return the list of expressions run after each execution of the loop body. 7931 * Return the list of expressions run after each execution of the loop body.
8543 *
8544 * @return the list of expressions run after each execution of the loop body
8545 */ 7932 */
8546 NodeList<Expression> get updaters => _updaters; 7933 NodeList<Expression> get updaters => _updaters;
8547 7934
8548 /** 7935 /**
8549 * Return the declaration of the loop variables, or `null` if there are no var iables. 7936 * Return the declaration of the loop variables, or `null` if there are no
8550 * 7937 * variables.
8551 * @return the declaration of the loop variables, or `null` if there are no va riables
8552 */ 7938 */
8553 VariableDeclarationList get variables => _variableList; 7939 VariableDeclarationList get variables => _variableList;
8554 7940
8555 /** 7941 /**
8556 * Set the declaration of the loop variables to the given parameter. 7942 * Set the declaration of the loop variables to the given [variableList].
8557 *
8558 * @param variableList the declaration of the loop variables
8559 */ 7943 */
8560 void set variables(VariableDeclarationList variableList) { 7944 void set variables(VariableDeclarationList variableList) {
8561 _variableList = becomeParentOf(variableList); 7945 _variableList = becomeParentOf(variableList);
8562 } 7946 }
8563 7947
8564 @override 7948 @override
8565 accept(AstVisitor visitor) => visitor.visitForStatement(this); 7949 accept(AstVisitor visitor) => visitor.visitForStatement(this);
8566 7950
8567 @override 7951 @override
8568 void visitChildren(AstVisitor visitor) { 7952 void visitChildren(AstVisitor visitor) {
8569 safelyVisitChild(_variableList, visitor); 7953 _safelyVisitChild(_variableList, visitor);
8570 safelyVisitChild(_initialization, visitor); 7954 _safelyVisitChild(_initialization, visitor);
8571 safelyVisitChild(_condition, visitor); 7955 _safelyVisitChild(_condition, visitor);
8572 _updaters.accept(visitor); 7956 _updaters.accept(visitor);
8573 safelyVisitChild(_body, visitor); 7957 _safelyVisitChild(_body, visitor);
8574 } 7958 }
8575 } 7959 }
8576 7960
8577 /** 7961 /**
8578 * The abstract class `FunctionBody` defines the behavior common to objects repr esenting the 7962 * A node representing the body of a function or method.
8579 * body of a function or method.
8580 * 7963 *
8581 * <pre> 7964 * > functionBody ::=
8582 * functionBody ::= 7965 * > [BlockFunctionBody]
8583 * [BlockFunctionBody] 7966 * > | [EmptyFunctionBody]
8584 * | [EmptyFunctionBody] 7967 * > | [ExpressionFunctionBody]
8585 * | [ExpressionFunctionBody]
8586 * </pre>
8587 */ 7968 */
8588 abstract class FunctionBody extends AstNode { 7969 abstract class FunctionBody extends AstNode {
8589 /** 7970 /**
8590 * Return `true` if this function body is asynchronous. 7971 * Return `true` if this function body is asynchronous.
8591 *
8592 * @return `true` if this function body is asynchronous
8593 */ 7972 */
8594 bool get isAsynchronous => false; 7973 bool get isAsynchronous => false;
8595 7974
8596 /** 7975 /**
8597 * Return `true` if this function body is a generator. 7976 * Return `true` if this function body is a generator.
8598 *
8599 * @return `true` if this function body is a generator
8600 */ 7977 */
8601 bool get isGenerator => false; 7978 bool get isGenerator => false;
8602 7979
8603 /** 7980 /**
8604 * Return `true` if this function body is synchronous. 7981 * Return `true` if this function body is synchronous.
8605 *
8606 * @return `true` if this function body is synchronous
8607 */ 7982 */
8608 bool get isSynchronous => true; 7983 bool get isSynchronous => true;
8609 7984
8610 /** 7985 /**
8611 * Return the token representing the 'async' or 'sync' keyword, or `null` if t here is no 7986 * Return the token representing the 'async' or 'sync' keyword, or `null` if
8612 * such keyword. 7987 * there is no such keyword.
8613 *
8614 * @return the token representing the 'async' or 'sync' keyword
8615 */ 7988 */
8616 Token get keyword => null; 7989 Token get keyword => null;
8617 7990
8618 /** 7991 /**
8619 * Return the star following the 'async' or 'sync' keyword, or `null` if there is no star. 7992 * Return the star following the 'async' or 'sync' keyword, or `null` if there
8620 * 7993 * is no star.
8621 * @return the star following the 'async' or 'sync' keyword
8622 */ 7994 */
8623 Token get star => null; 7995 Token get star => null;
8624 } 7996 }
8625 7997
8626 /** 7998 /**
8627 * Instances of the class `FunctionDeclaration` wrap a [FunctionExpression] as a top-level declaration. 7999 * A top-level declaration.
8628 * 8000 *
8629 * <pre> 8001 * > functionDeclaration ::=
8630 * functionDeclaration ::= 8002 * > 'external' functionSignature
8631 * 'external' functionSignature 8003 * > | functionSignature [FunctionBody]
8632 * | functionSignature [FunctionBody] 8004 * >
8633 * 8005 * > functionSignature ::=
8634 * functionSignature ::= 8006 * > [Type]? ('get' | 'set')? [SimpleIdentifier] [FormalParameterList]
8635 * [Type]? ('get' | 'set')? [SimpleIdentifier] [FormalParameterList]
8636 * </pre>
8637 */ 8007 */
8638 class FunctionDeclaration extends CompilationUnitMember { 8008 class FunctionDeclaration extends CompilationUnitMember {
8639 /** 8009 /**
8640 * The token representing the 'external' keyword, or `null` if this is not an external 8010 * The token representing the 'external' keyword, or `null` if this is not an
8641 * function. 8011 * external function.
8642 */ 8012 */
8643 Token externalKeyword; 8013 Token externalKeyword;
8644 8014
8645 /** 8015 /**
8646 * The return type of the function, or `null` if no return type was declared. 8016 * The return type of the function, or `null` if no return type was declared.
8647 */ 8017 */
8648 TypeName _returnType; 8018 TypeName _returnType;
8649 8019
8650 /** 8020 /**
8651 * The token representing the 'get' or 'set' keyword, or `null` if this is a f unction 8021 * The token representing the 'get' or 'set' keyword, or `null` if this is a
8652 * declaration rather than a property declaration. 8022 * function declaration rather than a property declaration.
8653 */ 8023 */
8654 Token propertyKeyword; 8024 Token propertyKeyword;
8655 8025
8656 /** 8026 /**
8657 * The name of the function, or `null` if the function is not named. 8027 * The name of the function, or `null` if the function is not named.
8658 */ 8028 */
8659 SimpleIdentifier _name; 8029 SimpleIdentifier _name;
8660 8030
8661 /** 8031 /**
8662 * The function expression being wrapped. 8032 * The function expression being wrapped.
8663 */ 8033 */
8664 FunctionExpression _functionExpression; 8034 FunctionExpression _functionExpression;
8665 8035
8666 /** 8036 /**
8667 * Initialize a newly created function declaration. 8037 * Initialize a newly created function declaration. Either or both of the
8668 * 8038 * [comment] and [metadata] can be `null` if the function does not have the
8669 * @param comment the documentation comment associated with this function 8039 * corresponding attribute. The [externalKeyword] can be `null` if the
8670 * @param metadata the annotations associated with this function 8040 * function is not an external function. The [returnType] can be `null` if no
8671 * @param externalKeyword the token representing the 'external' keyword 8041 * return type was specified. The [propertyKeyword] can be `null` if the
8672 * @param returnType the return type of the function 8042 * function is neither a getter or a setter.
8673 * @param propertyKeyword the token representing the 'get' or 'set' keyword
8674 * @param name the name of the function
8675 * @param functionExpression the function expression being wrapped
8676 */ 8043 */
8677 FunctionDeclaration(Comment comment, List<Annotation> metadata, 8044 FunctionDeclaration(Comment comment, List<Annotation> metadata,
8678 this.externalKeyword, TypeName returnType, this.propertyKeyword, 8045 this.externalKeyword, TypeName returnType, this.propertyKeyword,
8679 SimpleIdentifier name, FunctionExpression functionExpression) 8046 SimpleIdentifier name, FunctionExpression functionExpression)
8680 : super(comment, metadata) { 8047 : super(comment, metadata) {
8681 _returnType = becomeParentOf(returnType); 8048 _returnType = becomeParentOf(returnType);
8682 _name = becomeParentOf(name); 8049 _name = becomeParentOf(name);
8683 _functionExpression = becomeParentOf(functionExpression); 8050 _functionExpression = becomeParentOf(functionExpression);
8684 } 8051 }
8685 8052
(...skipping 21 matching lines...) Expand all
8707 } else if (propertyKeyword != null) { 8074 } else if (propertyKeyword != null) {
8708 return propertyKeyword; 8075 return propertyKeyword;
8709 } else if (_name != null) { 8076 } else if (_name != null) {
8710 return _name.beginToken; 8077 return _name.beginToken;
8711 } 8078 }
8712 return _functionExpression.beginToken; 8079 return _functionExpression.beginToken;
8713 } 8080 }
8714 8081
8715 /** 8082 /**
8716 * Return the function expression being wrapped. 8083 * Return the function expression being wrapped.
8717 *
8718 * @return the function expression being wrapped
8719 */ 8084 */
8720 FunctionExpression get functionExpression => _functionExpression; 8085 FunctionExpression get functionExpression => _functionExpression;
8721 8086
8722 /** 8087 /**
8723 * Set the function expression being wrapped to the given function expression. 8088 * Set the function expression being wrapped to the given
8724 * 8089 * [functionExpression].
8725 * @param functionExpression the function expression being wrapped
8726 */ 8090 */
8727 void set functionExpression(FunctionExpression functionExpression) { 8091 void set functionExpression(FunctionExpression functionExpression) {
8728 _functionExpression = becomeParentOf(functionExpression); 8092 _functionExpression = becomeParentOf(functionExpression);
8729 } 8093 }
8730 8094
8731 /** 8095 /**
8732 * Return `true` if this function declares a getter. 8096 * Return `true` if this function declares a getter.
8733 *
8734 * @return `true` if this function declares a getter
8735 */ 8097 */
8736 bool get isGetter => 8098 bool get isGetter =>
8737 propertyKeyword != null && 8099 propertyKeyword != null &&
8738 (propertyKeyword as KeywordToken).keyword == Keyword.GET; 8100 (propertyKeyword as KeywordToken).keyword == Keyword.GET;
8739 8101
8740 /** 8102 /**
8741 * Return `true` if this function declares a setter. 8103 * Return `true` if this function declares a setter.
8742 *
8743 * @return `true` if this function declares a setter
8744 */ 8104 */
8745 bool get isSetter => 8105 bool get isSetter =>
8746 propertyKeyword != null && 8106 propertyKeyword != null &&
8747 (propertyKeyword as KeywordToken).keyword == Keyword.SET; 8107 (propertyKeyword as KeywordToken).keyword == Keyword.SET;
8748 8108
8749 /** 8109 /**
8750 * Return the name of the function, or `null` if the function is not named. 8110 * Return the name of the function, or `null` if the function is not named.
8751 *
8752 * @return the name of the function
8753 */ 8111 */
8754 SimpleIdentifier get name => _name; 8112 SimpleIdentifier get name => _name;
8755 8113
8756 /** 8114 /**
8757 * Set the name of the function to the given identifier. 8115 * Set the name of the function to the given [identifier].
8758 *
8759 * @param identifier the name of the function
8760 */ 8116 */
8761 void set name(SimpleIdentifier identifier) { 8117 void set name(SimpleIdentifier identifier) {
8762 _name = becomeParentOf(identifier); 8118 _name = becomeParentOf(identifier);
8763 } 8119 }
8764 8120
8765 /** 8121 /**
8766 * Return the return type of the function, or `null` if no return type was dec lared. 8122 * Return the return type of the function, or `null` if no return type was
8767 * 8123 * declared.
8768 * @return the return type of the function
8769 */ 8124 */
8770 TypeName get returnType => _returnType; 8125 TypeName get returnType => _returnType;
8771 8126
8772 /** 8127 /**
8773 * Set the return type of the function to the given name. 8128 * Set the return type of the function to the given [returnType].
8774 *
8775 * @param returnType the return type of the function
8776 */ 8129 */
8777 void set returnType(TypeName returnType) { 8130 void set returnType(TypeName returnType) {
8778 _returnType = becomeParentOf(returnType); 8131 _returnType = becomeParentOf(returnType);
8779 } 8132 }
8780 8133
8781 @override 8134 @override
8782 accept(AstVisitor visitor) => visitor.visitFunctionDeclaration(this); 8135 accept(AstVisitor visitor) => visitor.visitFunctionDeclaration(this);
8783 8136
8784 @override 8137 @override
8785 void visitChildren(AstVisitor visitor) { 8138 void visitChildren(AstVisitor visitor) {
8786 super.visitChildren(visitor); 8139 super.visitChildren(visitor);
8787 safelyVisitChild(_returnType, visitor); 8140 _safelyVisitChild(_returnType, visitor);
8788 safelyVisitChild(_name, visitor); 8141 _safelyVisitChild(_name, visitor);
8789 safelyVisitChild(_functionExpression, visitor); 8142 _safelyVisitChild(_functionExpression, visitor);
8790 } 8143 }
8791 } 8144 }
8792 8145
8793 /** 8146 /**
8794 * Instances of the class `FunctionDeclarationStatement` wrap a [FunctionDeclara tion 8147 * A [FunctionDeclaration] used as a statement.
8795 ] as a statement.
8796 */ 8148 */
8797 class FunctionDeclarationStatement extends Statement { 8149 class FunctionDeclarationStatement extends Statement {
8798 /** 8150 /**
8799 * The function declaration being wrapped. 8151 * The function declaration being wrapped.
8800 */ 8152 */
8801 FunctionDeclaration _functionDeclaration; 8153 FunctionDeclaration _functionDeclaration;
8802 8154
8803 /** 8155 /**
8804 * Initialize a newly created function declaration statement. 8156 * Initialize a newly created function declaration statement.
8805 *
8806 * @param functionDeclaration the the function declaration being wrapped
8807 */ 8157 */
8808 FunctionDeclarationStatement(FunctionDeclaration functionDeclaration) { 8158 FunctionDeclarationStatement(FunctionDeclaration functionDeclaration) {
8809 _functionDeclaration = becomeParentOf(functionDeclaration); 8159 _functionDeclaration = becomeParentOf(functionDeclaration);
8810 } 8160 }
8811 8161
8812 @override 8162 @override
8813 Token get beginToken => _functionDeclaration.beginToken; 8163 Token get beginToken => _functionDeclaration.beginToken;
8814 8164
8815 @override 8165 @override
8816 Iterable get childEntities => new ChildEntities()..add(_functionDeclaration); 8166 Iterable get childEntities => new ChildEntities()..add(_functionDeclaration);
8817 8167
8818 @override 8168 @override
8819 Token get endToken => _functionDeclaration.endToken; 8169 Token get endToken => _functionDeclaration.endToken;
8820 8170
8821 /** 8171 /**
8822 * Return the function declaration being wrapped. 8172 * Return the function declaration being wrapped.
8823 *
8824 * @return the function declaration being wrapped
8825 */ 8173 */
8826 FunctionDeclaration get functionDeclaration => _functionDeclaration; 8174 FunctionDeclaration get functionDeclaration => _functionDeclaration;
8827 8175
8828 /** 8176 /**
8829 * Set the function declaration being wrapped to the given function declaratio n. 8177 * Set the function declaration being wrapped to the given
8830 * 8178 * [functionDeclaration].
8831 * @param functionDeclaration the function declaration being wrapped
8832 */ 8179 */
8833 void set functionDeclaration(FunctionDeclaration functionDeclaration) { 8180 void set functionDeclaration(FunctionDeclaration functionDeclaration) {
8834 _functionDeclaration = becomeParentOf(functionDeclaration); 8181 _functionDeclaration = becomeParentOf(functionDeclaration);
8835 } 8182 }
8836 8183
8837 @override 8184 @override
8838 accept(AstVisitor visitor) => visitor.visitFunctionDeclarationStatement(this); 8185 accept(AstVisitor visitor) => visitor.visitFunctionDeclarationStatement(this);
8839 8186
8840 @override 8187 @override
8841 void visitChildren(AstVisitor visitor) { 8188 void visitChildren(AstVisitor visitor) {
8842 safelyVisitChild(_functionDeclaration, visitor); 8189 _safelyVisitChild(_functionDeclaration, visitor);
8843 } 8190 }
8844 } 8191 }
8845 8192
8846 /** 8193 /**
8847 * Instances of the class `FunctionExpression` represent a function expression. 8194 * A function expression.
8848 * 8195 *
8849 * <pre> 8196 * > functionExpression ::=
8850 * functionExpression ::= 8197 * > [FormalParameterList] [FunctionBody]
8851 * [FormalParameterList] [FunctionBody]
8852 * </pre>
8853 */ 8198 */
8854 class FunctionExpression extends Expression { 8199 class FunctionExpression extends Expression {
8855 /** 8200 /**
8856 * The parameters associated with the function. 8201 * The parameters associated with the function.
8857 */ 8202 */
8858 FormalParameterList _parameters; 8203 FormalParameterList _parameters;
8859 8204
8860 /** 8205 /**
8861 * The body of the function, or `null` if this is an external function. 8206 * The body of the function, or `null` if this is an external function.
8862 */ 8207 */
8863 FunctionBody _body; 8208 FunctionBody _body;
8864 8209
8865 /** 8210 /**
8866 * The element associated with the function, or `null` if the AST structure ha s not been 8211 * The element associated with the function, or `null` if the AST structure
8867 * resolved. 8212 * has not been resolved.
8868 */ 8213 */
8869 ExecutableElement element; 8214 ExecutableElement element;
8870 8215
8871 /** 8216 /**
8872 * Initialize a newly created function declaration. 8217 * Initialize a newly created function declaration.
8873 *
8874 * @param parameters the parameters associated with the function
8875 * @param body the body of the function
8876 */ 8218 */
8877 FunctionExpression(FormalParameterList parameters, FunctionBody body) { 8219 FunctionExpression(FormalParameterList parameters, FunctionBody body) {
8878 _parameters = becomeParentOf(parameters); 8220 _parameters = becomeParentOf(parameters);
8879 _body = becomeParentOf(body); 8221 _body = becomeParentOf(body);
8880 } 8222 }
8881 8223
8882 @override 8224 @override
8883 Token get beginToken { 8225 Token get beginToken {
8884 if (_parameters != null) { 8226 if (_parameters != null) {
8885 return _parameters.beginToken; 8227 return _parameters.beginToken;
8886 } else if (_body != null) { 8228 } else if (_body != null) {
8887 return _body.beginToken; 8229 return _body.beginToken;
8888 } 8230 }
8889 // This should never be reached because external functions must be named, 8231 // This should never be reached because external functions must be named,
8890 // hence either the body or the name should be non-null. 8232 // hence either the body or the name should be non-null.
8891 throw new IllegalStateException("Non-external functions must have a body"); 8233 throw new IllegalStateException("Non-external functions must have a body");
8892 } 8234 }
8893 8235
8894 /** 8236 /**
8895 * Return the body of the function, or `null` if this is an external function. 8237 * Return the body of the function, or `null` if this is an external function.
8896 *
8897 * @return the body of the function
8898 */ 8238 */
8899 FunctionBody get body => _body; 8239 FunctionBody get body => _body;
8900 8240
8901 /** 8241 /**
8902 * Set the body of the function to the given function body. 8242 * Set the body of the function to the given [functionBody].
8903 *
8904 * @param functionBody the body of the function
8905 */ 8243 */
8906 void set body(FunctionBody functionBody) { 8244 void set body(FunctionBody functionBody) {
8907 _body = becomeParentOf(functionBody); 8245 _body = becomeParentOf(functionBody);
8908 } 8246 }
8909 8247
8910 @override 8248 @override
8911 Iterable get childEntities => new ChildEntities() 8249 Iterable get childEntities => new ChildEntities()
8912 ..add(_parameters) 8250 ..add(_parameters)
8913 ..add(_body); 8251 ..add(_body);
8914 8252
8915 @override 8253 @override
8916 Token get endToken { 8254 Token get endToken {
8917 if (_body != null) { 8255 if (_body != null) {
8918 return _body.endToken; 8256 return _body.endToken;
8919 } else if (_parameters != null) { 8257 } else if (_parameters != null) {
8920 return _parameters.endToken; 8258 return _parameters.endToken;
8921 } 8259 }
8922 // This should never be reached because external functions must be named, 8260 // This should never be reached because external functions must be named,
8923 // hence either the body or the name should be non-null. 8261 // hence either the body or the name should be non-null.
8924 throw new IllegalStateException("Non-external functions must have a body"); 8262 throw new IllegalStateException("Non-external functions must have a body");
8925 } 8263 }
8926 8264
8927 /** 8265 /**
8928 * Return the parameters associated with the function. 8266 * Return the parameters associated with the function.
8929 *
8930 * @return the parameters associated with the function
8931 */ 8267 */
8932 FormalParameterList get parameters => _parameters; 8268 FormalParameterList get parameters => _parameters;
8933 8269
8934 /** 8270 /**
8935 * Set the parameters associated with the function to the given list of parame ters. 8271 * Set the parameters associated with the function to the given list of
8936 * 8272 * [parameters].
8937 * @param parameters the parameters associated with the function
8938 */ 8273 */
8939 void set parameters(FormalParameterList parameters) { 8274 void set parameters(FormalParameterList parameters) {
8940 _parameters = becomeParentOf(parameters); 8275 _parameters = becomeParentOf(parameters);
8941 } 8276 }
8942 8277
8943 @override 8278 @override
8944 int get precedence => 16; 8279 int get precedence => 16;
8945 8280
8946 @override 8281 @override
8947 accept(AstVisitor visitor) => visitor.visitFunctionExpression(this); 8282 accept(AstVisitor visitor) => visitor.visitFunctionExpression(this);
8948 8283
8949 @override 8284 @override
8950 void visitChildren(AstVisitor visitor) { 8285 void visitChildren(AstVisitor visitor) {
8951 safelyVisitChild(_parameters, visitor); 8286 _safelyVisitChild(_parameters, visitor);
8952 safelyVisitChild(_body, visitor); 8287 _safelyVisitChild(_body, visitor);
8953 } 8288 }
8954 } 8289 }
8955 8290
8956 /** 8291 /**
8957 * Instances of the class `FunctionExpressionInvocation` represent the invocatio n of a 8292 * The invocation of a function resulting from evaluating an expression.
8958 * function resulting from evaluating an expression. Invocations of methods and other forms of 8293 * Invocations of methods and other forms of functions are represented by
8959 * functions are represented by [MethodInvocation] nodes. Invocations of 8294 * [MethodInvocation] nodes. Invocations of getters and setters are represented
8960 * getters and setters are represented by either [PrefixedIdentifier] or 8295 * by either [PrefixedIdentifier] or [PropertyAccess] nodes.
8961 * [PropertyAccess] nodes.
8962 * 8296 *
8963 * <pre> 8297 * > functionExpressionInvoction ::=
8964 * functionExpressionInvoction ::= 8298 * > [Expression] [ArgumentList]
8965 * [Expression] [ArgumentList]
8966 * </pre>
8967 */ 8299 */
8968 class FunctionExpressionInvocation extends Expression { 8300 class FunctionExpressionInvocation extends Expression {
8969 /** 8301 /**
8970 * The expression producing the function being invoked. 8302 * The expression producing the function being invoked.
8971 */ 8303 */
8972 Expression _function; 8304 Expression _function;
8973 8305
8974 /** 8306 /**
8975 * The list of arguments to the function. 8307 * The list of arguments to the function.
8976 */ 8308 */
8977 ArgumentList _argumentList; 8309 ArgumentList _argumentList;
8978 8310
8979 /** 8311 /**
8980 * The element associated with the function being invoked based on static type information, or 8312 * The element associated with the function being invoked based on static type
8981 * `null` if the AST structure has not been resolved or the function could not be resolved. 8313 * information, or `null` if the AST structure has not been resolved or the
8314 * function could not be resolved.
8982 */ 8315 */
8983 ExecutableElement staticElement; 8316 ExecutableElement staticElement;
8984 8317
8985 /** 8318 /**
8986 * The element associated with the function being invoked based on propagated type information, or 8319 * The element associated with the function being invoked based on propagated
8987 * `null` if the AST structure has not been resolved or the function could not be resolved. 8320 * type information, or `null` if the AST structure has not been resolved or
8321 * the function could not be resolved.
8988 */ 8322 */
8989 ExecutableElement propagatedElement; 8323 ExecutableElement propagatedElement;
8990 8324
8991 /** 8325 /**
8992 * Initialize a newly created function expression invocation. 8326 * Initialize a newly created function expression invocation.
8993 *
8994 * @param function the expression producing the function being invoked
8995 * @param argumentList the list of arguments to the method
8996 */ 8327 */
8997 FunctionExpressionInvocation(Expression function, ArgumentList argumentList) { 8328 FunctionExpressionInvocation(Expression function, ArgumentList argumentList) {
8998 _function = becomeParentOf(function); 8329 _function = becomeParentOf(function);
8999 _argumentList = becomeParentOf(argumentList); 8330 _argumentList = becomeParentOf(argumentList);
9000 } 8331 }
9001 8332
9002 /** 8333 /**
9003 * Return the list of arguments to the method. 8334 * Return the list of arguments to the method.
9004 *
9005 * @return the list of arguments to the method
9006 */ 8335 */
9007 ArgumentList get argumentList => _argumentList; 8336 ArgumentList get argumentList => _argumentList;
9008 8337
9009 /** 8338 /**
9010 * Set the list of arguments to the method to the given list. 8339 * Set the list of arguments to the method to the given [argumentList].
9011 *
9012 * @param argumentList the list of arguments to the method
9013 */ 8340 */
9014 void set argumentList(ArgumentList argumentList) { 8341 void set argumentList(ArgumentList argumentList) {
9015 _argumentList = becomeParentOf(argumentList); 8342 _argumentList = becomeParentOf(argumentList);
9016 } 8343 }
9017 8344
9018 @override 8345 @override
9019 Token get beginToken => _function.beginToken; 8346 Token get beginToken => _function.beginToken;
9020 8347
9021 /** 8348 /**
9022 * Return the best element available for the function being invoked. If resolu tion was able to 8349 * Return the best element available for the function being invoked. If
9023 * find a better element based on type propagation, that element will be retur ned. Otherwise, the 8350 * resolution was able to find a better element based on type propagation,
9024 * element found using the result of static analysis will be returned. If reso lution has not been 8351 * that element will be returned. Otherwise, the element found using the
8352 * result of static analysis will be returned. If resolution has not been
9025 * performed, then `null` will be returned. 8353 * performed, then `null` will be returned.
9026 *
9027 * @return the best element available for this function
9028 */ 8354 */
9029 ExecutableElement get bestElement { 8355 ExecutableElement get bestElement {
9030 ExecutableElement element = propagatedElement; 8356 ExecutableElement element = propagatedElement;
9031 if (element == null) { 8357 if (element == null) {
9032 element = staticElement; 8358 element = staticElement;
9033 } 8359 }
9034 return element; 8360 return element;
9035 } 8361 }
9036 8362
9037 /** 8363 /**
9038 * TODO(paulberry): untested. 8364 * TODO(paulberry): untested.
9039 */ 8365 */
9040 @override 8366 @override
9041 Iterable get childEntities => new ChildEntities() 8367 Iterable get childEntities => new ChildEntities()
9042 ..add(_function) 8368 ..add(_function)
9043 ..add(_argumentList); 8369 ..add(_argumentList);
9044 8370
9045 @override 8371 @override
9046 Token get endToken => _argumentList.endToken; 8372 Token get endToken => _argumentList.endToken;
9047 8373
9048 /** 8374 /**
9049 * Return the expression producing the function being invoked. 8375 * Return the expression producing the function being invoked.
9050 *
9051 * @return the expression producing the function being invoked
9052 */ 8376 */
9053 Expression get function => _function; 8377 Expression get function => _function;
9054 8378
9055 /** 8379 /**
9056 * Set the expression producing the function being invoked to the given expres sion. 8380 * Set the expression producing the function being invoked to the given
9057 * 8381 * [expression].
9058 * @param function the expression producing the function being invoked
9059 */ 8382 */
9060 void set function(Expression function) { 8383 void set function(Expression expression) {
9061 _function = becomeParentOf(function); 8384 _function = becomeParentOf(expression);
9062 } 8385 }
9063 8386
9064 @override 8387 @override
9065 int get precedence => 15; 8388 int get precedence => 15;
9066 8389
9067 @override 8390 @override
9068 accept(AstVisitor visitor) => visitor.visitFunctionExpressionInvocation(this); 8391 accept(AstVisitor visitor) => visitor.visitFunctionExpressionInvocation(this);
9069 8392
9070 @override 8393 @override
9071 void visitChildren(AstVisitor visitor) { 8394 void visitChildren(AstVisitor visitor) {
9072 safelyVisitChild(_function, visitor); 8395 _safelyVisitChild(_function, visitor);
9073 safelyVisitChild(_argumentList, visitor); 8396 _safelyVisitChild(_argumentList, visitor);
9074 } 8397 }
9075 } 8398 }
9076 8399
9077 /** 8400 /**
9078 * Instances of the class `FunctionTypeAlias` represent a function type alias. 8401 * A function type alias.
9079 * 8402 *
9080 * <pre> 8403 * > functionTypeAlias ::=
9081 * functionTypeAlias ::= 8404 * > functionPrefix [TypeParameterList]? [FormalParameterList] ';'
9082 * functionPrefix [TypeParameterList]? [FormalParameterList] ';' 8405 * >
9083 * 8406 * > functionPrefix ::=
9084 * functionPrefix ::= 8407 * > [TypeName]? [SimpleIdentifier]
9085 * [TypeName]? [SimpleIdentifier]
9086 * </pre>
9087 */ 8408 */
9088 class FunctionTypeAlias extends TypeAlias { 8409 class FunctionTypeAlias extends TypeAlias {
9089 /** 8410 /**
9090 * The name of the return type of the function type being defined, or `null` i f no return 8411 * The name of the return type of the function type being defined, or `null`
9091 * type was given. 8412 * if no return type was given.
9092 */ 8413 */
9093 TypeName _returnType; 8414 TypeName _returnType;
9094 8415
9095 /** 8416 /**
9096 * The name of the function type being declared. 8417 * The name of the function type being declared.
9097 */ 8418 */
9098 SimpleIdentifier _name; 8419 SimpleIdentifier _name;
9099 8420
9100 /** 8421 /**
9101 * The type parameters for the function type, or `null` if the function type d oes not have 8422 * The type parameters for the function type, or `null` if the function type
9102 * any type parameters. 8423 * does not have any type parameters.
9103 */ 8424 */
9104 TypeParameterList _typeParameters; 8425 TypeParameterList _typeParameters;
9105 8426
9106 /** 8427 /**
9107 * The parameters associated with the function type. 8428 * The parameters associated with the function type.
9108 */ 8429 */
9109 FormalParameterList _parameters; 8430 FormalParameterList _parameters;
9110 8431
9111 /** 8432 /**
9112 * Initialize a newly created function type alias. 8433 * Initialize a newly created function type alias. Either or both of the
9113 * 8434 * [comment] and [metadata] can be `null` if the function does not have the
9114 * @param comment the documentation comment associated with this type alias 8435 * corresponding attribute. The [returnType] can be `null` if no return type
9115 * @param metadata the annotations associated with this type alias 8436 * was specified. The [typeParameters] can be `null` if the function has no
9116 * @param keyword the token representing the 'typedef' keyword 8437 * type parameters.
9117 * @param returnType the name of the return type of the function type being de fined
9118 * @param name the name of the type being declared
9119 * @param typeParameters the type parameters for the type
9120 * @param parameters the parameters associated with the function
9121 * @param semicolon the semicolon terminating the declaration
9122 */ 8438 */
9123 FunctionTypeAlias(Comment comment, List<Annotation> metadata, Token keyword, 8439 FunctionTypeAlias(Comment comment, List<Annotation> metadata, Token keyword,
9124 TypeName returnType, SimpleIdentifier name, TypeParameterList typeParamete rs, 8440 TypeName returnType, SimpleIdentifier name, TypeParameterList typeParamete rs,
9125 FormalParameterList parameters, Token semicolon) 8441 FormalParameterList parameters, Token semicolon)
9126 : super(comment, metadata, keyword, semicolon) { 8442 : super(comment, metadata, keyword, semicolon) {
9127 _returnType = becomeParentOf(returnType); 8443 _returnType = becomeParentOf(returnType);
9128 _name = becomeParentOf(name); 8444 _name = becomeParentOf(name);
9129 _typeParameters = becomeParentOf(typeParameters); 8445 _typeParameters = becomeParentOf(typeParameters);
9130 _parameters = becomeParentOf(parameters); 8446 _parameters = becomeParentOf(parameters);
9131 } 8447 }
9132 8448
9133 @override 8449 @override
9134 Iterable get childEntities => super._childEntities 8450 Iterable get childEntities => super._childEntities
9135 ..add(keyword) 8451 ..add(keyword)
9136 ..add(_returnType) 8452 ..add(_returnType)
9137 ..add(_name) 8453 ..add(_name)
9138 ..add(_typeParameters) 8454 ..add(_typeParameters)
9139 ..add(_parameters) 8455 ..add(_parameters)
9140 ..add(semicolon); 8456 ..add(semicolon);
9141 8457
9142 @override 8458 @override
9143 FunctionTypeAliasElement get element => 8459 FunctionTypeAliasElement get element =>
9144 _name != null ? (_name.staticElement as FunctionTypeAliasElement) : null; 8460 _name != null ? (_name.staticElement as FunctionTypeAliasElement) : null;
9145 8461
9146 /** 8462 /**
9147 * Return the name of the function type being declared. 8463 * Return the name of the function type being declared.
9148 *
9149 * @return the name of the function type being declared
9150 */ 8464 */
9151 SimpleIdentifier get name => _name; 8465 SimpleIdentifier get name => _name;
9152 8466
9153 /** 8467 /**
9154 * Set the name of the function type being declared to the given identifier. 8468 * Set the name of the function type being declared to the given [name].
9155 *
9156 * @param name the name of the function type being declared
9157 */ 8469 */
9158 void set name(SimpleIdentifier name) { 8470 void set name(SimpleIdentifier name) {
9159 _name = becomeParentOf(name); 8471 _name = becomeParentOf(name);
9160 } 8472 }
9161 8473
9162 /** 8474 /**
9163 * Return the parameters associated with the function type. 8475 * Return the parameters associated with the function type.
9164 *
9165 * @return the parameters associated with the function type
9166 */ 8476 */
9167 FormalParameterList get parameters => _parameters; 8477 FormalParameterList get parameters => _parameters;
9168 8478
9169 /** 8479 /**
9170 * Set the parameters associated with the function type to the given list of p arameters. 8480 * Set the parameters associated with the function type to the given list of
9171 * 8481 * [parameters].
9172 * @param parameters the parameters associated with the function type
9173 */ 8482 */
9174 void set parameters(FormalParameterList parameters) { 8483 void set parameters(FormalParameterList parameters) {
9175 _parameters = becomeParentOf(parameters); 8484 _parameters = becomeParentOf(parameters);
9176 } 8485 }
9177 8486
9178 /** 8487 /**
9179 * Return the name of the return type of the function type being defined, or ` null` if no 8488 * Return the name of the return type of the function type being defined, or
9180 * return type was given. 8489 * `null` if no return type was given.
9181 *
9182 * @return the name of the return type of the function type being defined
9183 */ 8490 */
9184 TypeName get returnType => _returnType; 8491 TypeName get returnType => _returnType;
9185 8492
9186 /** 8493 /**
9187 * Set the name of the return type of the function type being defined to the g iven type name. 8494 * Set the name of the return type of the function type being defined to the
9188 * 8495 * given [typeName].
9189 * @param typeName the name of the return type of the function type being defi ned
9190 */ 8496 */
9191 void set returnType(TypeName typeName) { 8497 void set returnType(TypeName typeName) {
9192 _returnType = becomeParentOf(typeName); 8498 _returnType = becomeParentOf(typeName);
9193 } 8499 }
9194 8500
9195 /** 8501 /**
9196 * Return the type parameters for the function type, or `null` if the function type does not 8502 * Return the type parameters for the function type, or `null` if the function
9197 * have any type parameters. 8503 * type does not have any type parameters.
9198 *
9199 * @return the type parameters for the function type
9200 */ 8504 */
9201 TypeParameterList get typeParameters => _typeParameters; 8505 TypeParameterList get typeParameters => _typeParameters;
9202 8506
9203 /** 8507 /**
9204 * Set the type parameters for the function type to the given list of paramete rs. 8508 * Set the type parameters for the function type to the given list of
9205 * 8509 * [typeParameters].
9206 * @param typeParameters the type parameters for the function type
9207 */ 8510 */
9208 void set typeParameters(TypeParameterList typeParameters) { 8511 void set typeParameters(TypeParameterList typeParameters) {
9209 _typeParameters = becomeParentOf(typeParameters); 8512 _typeParameters = becomeParentOf(typeParameters);
9210 } 8513 }
9211 8514
9212 @override 8515 @override
9213 accept(AstVisitor visitor) => visitor.visitFunctionTypeAlias(this); 8516 accept(AstVisitor visitor) => visitor.visitFunctionTypeAlias(this);
9214 8517
9215 @override 8518 @override
9216 void visitChildren(AstVisitor visitor) { 8519 void visitChildren(AstVisitor visitor) {
9217 super.visitChildren(visitor); 8520 super.visitChildren(visitor);
9218 safelyVisitChild(_returnType, visitor); 8521 _safelyVisitChild(_returnType, visitor);
9219 safelyVisitChild(_name, visitor); 8522 _safelyVisitChild(_name, visitor);
9220 safelyVisitChild(_typeParameters, visitor); 8523 _safelyVisitChild(_typeParameters, visitor);
9221 safelyVisitChild(_parameters, visitor); 8524 _safelyVisitChild(_parameters, visitor);
9222 } 8525 }
9223 } 8526 }
9224 8527
9225 /** 8528 /**
9226 * Instances of the class `FunctionTypedFormalParameter` represent a function-ty ped formal 8529 * A function-typed formal parameter.
9227 * parameter.
9228 * 8530 *
9229 * <pre> 8531 * > functionSignature ::=
9230 * functionSignature ::= 8532 * > [TypeName]? [SimpleIdentifier] [FormalParameterList]
9231 * [TypeName]? [SimpleIdentifier] [FormalParameterList]
9232 * </pre>
9233 */ 8533 */
9234 class FunctionTypedFormalParameter extends NormalFormalParameter { 8534 class FunctionTypedFormalParameter extends NormalFormalParameter {
9235 /** 8535 /**
9236 * The return type of the function, or `null` if the function does not have a return type. 8536 * The return type of the function, or `null` if the function does not have a
8537 * return type.
9237 */ 8538 */
9238 TypeName _returnType; 8539 TypeName _returnType;
9239 8540
9240 /** 8541 /**
9241 * The parameters of the function-typed parameter. 8542 * The parameters of the function-typed parameter.
9242 */ 8543 */
9243 FormalParameterList _parameters; 8544 FormalParameterList _parameters;
9244 8545
9245 /** 8546 /**
9246 * Initialize a newly created formal parameter. 8547 * Initialize a newly created formal parameter. Either or both of the
9247 * 8548 * [comment] and [metadata] can be `null` if the parameter does not have the
9248 * @param comment the documentation comment associated with this parameter 8549 * corresponding attribute. The [returnType] can be `null` if no return type
9249 * @param metadata the annotations associated with this parameter 8550 * was specified.
9250 * @param returnType the return type of the function, or `null` if the functio n does not
9251 * have a return type
9252 * @param identifier the name of the function-typed parameter
9253 * @param parameters the parameters of the function-typed parameter
9254 */ 8551 */
9255 FunctionTypedFormalParameter(Comment comment, List<Annotation> metadata, 8552 FunctionTypedFormalParameter(Comment comment, List<Annotation> metadata,
9256 TypeName returnType, SimpleIdentifier identifier, 8553 TypeName returnType, SimpleIdentifier identifier,
9257 FormalParameterList parameters) 8554 FormalParameterList parameters)
9258 : super(comment, metadata, identifier) { 8555 : super(comment, metadata, identifier) {
9259 _returnType = becomeParentOf(returnType); 8556 _returnType = becomeParentOf(returnType);
9260 _parameters = becomeParentOf(parameters); 8557 _parameters = becomeParentOf(parameters);
9261 } 8558 }
9262 8559
9263 @override 8560 @override
(...skipping 17 matching lines...) Expand all
9281 Token get endToken => _parameters.endToken; 8578 Token get endToken => _parameters.endToken;
9282 8579
9283 @override 8580 @override
9284 bool get isConst => false; 8581 bool get isConst => false;
9285 8582
9286 @override 8583 @override
9287 bool get isFinal => false; 8584 bool get isFinal => false;
9288 8585
9289 /** 8586 /**
9290 * Return the parameters of the function-typed parameter. 8587 * Return the parameters of the function-typed parameter.
9291 *
9292 * @return the parameters of the function-typed parameter
9293 */ 8588 */
9294 FormalParameterList get parameters => _parameters; 8589 FormalParameterList get parameters => _parameters;
9295 8590
9296 /** 8591 /**
9297 * Set the parameters of the function-typed parameter to the given parameters. 8592 * Set the parameters of the function-typed parameter to the given
9298 * 8593 * [parameters].
9299 * @param parameters the parameters of the function-typed parameter
9300 */ 8594 */
9301 void set parameters(FormalParameterList parameters) { 8595 void set parameters(FormalParameterList parameters) {
9302 _parameters = becomeParentOf(parameters); 8596 _parameters = becomeParentOf(parameters);
9303 } 8597 }
9304 8598
9305 /** 8599 /**
9306 * Return the return type of the function, or `null` if the function does not have a return 8600 * Return the return type of the function, or `null` if the function does not
9307 * type. 8601 * have a return type.
9308 *
9309 * @return the return type of the function
9310 */ 8602 */
9311 TypeName get returnType => _returnType; 8603 TypeName get returnType => _returnType;
9312 8604
9313 /** 8605 /**
9314 * Set the return type of the function to the given type. 8606 * Set the return type of the function to the given [type].
9315 *
9316 * @param returnType the return type of the function
9317 */ 8607 */
9318 void set returnType(TypeName returnType) { 8608 void set returnType(TypeName type) {
9319 _returnType = becomeParentOf(returnType); 8609 _returnType = becomeParentOf(type);
9320 } 8610 }
9321 8611
9322 @override 8612 @override
9323 accept(AstVisitor visitor) => visitor.visitFunctionTypedFormalParameter(this); 8613 accept(AstVisitor visitor) => visitor.visitFunctionTypedFormalParameter(this);
9324 8614
9325 @override 8615 @override
9326 void visitChildren(AstVisitor visitor) { 8616 void visitChildren(AstVisitor visitor) {
9327 super.visitChildren(visitor); 8617 super.visitChildren(visitor);
9328 safelyVisitChild(_returnType, visitor); 8618 _safelyVisitChild(_returnType, visitor);
9329 safelyVisitChild(identifier, visitor); 8619 _safelyVisitChild(identifier, visitor);
9330 safelyVisitChild(_parameters, visitor); 8620 _safelyVisitChild(_parameters, visitor);
9331 } 8621 }
9332 } 8622 }
9333 8623
9334 /** 8624 /**
9335 * Instances of the class `GeneralizingAstVisitor` implement an AST visitor that will 8625 * An AST visitor that will recursively visit all of the nodes in an AST
9336 * recursively visit all of the nodes in an AST structure (like instances of the class 8626 * structure (like instances of the class [RecursiveAstVisitor]). In addition,
9337 * [RecursiveAstVisitor]). In addition, when a node of a specific type is visite d not only 8627 * when a node of a specific type is visited not only will the visit method for
9338 * will the visit method for that specific type of node be invoked, but addition al methods for the 8628 * that specific type of node be invoked, but additional methods for the
9339 * superclasses of that node will also be invoked. For example, using an instanc e of this class to 8629 * superclasses of that node will also be invoked. For example, using an
9340 * visit a [Block] will cause the method [visitBlock] to be invoked but will 8630 * instance of this class to visit a [Block] will cause the method [visitBlock]
9341 * also cause the methods [visitStatement] and [visitNode] to be 8631 * to be invoked but will also cause the methods [visitStatement] and
9342 * subsequently invoked. This allows visitors to be written that visit all state ments without 8632 * [visitNode] to be subsequently invoked. This allows visitors to be written
9343 * needing to override the visit method for each of the specific subclasses of [ Statement]. 8633 * that visit all statements without needing to override the visit method for
8634 * each of the specific subclasses of [Statement].
9344 * 8635 *
9345 * Subclasses that override a visit method must either invoke the overridden vis it method or 8636 * Subclasses that override a visit method must either invoke the overridden
9346 * explicitly invoke the more general visit method. Failure to do so will cause the visit methods 8637 * visit method or explicitly invoke the more general visit method. Failure to
9347 * for superclasses of the node to not be invoked and will cause the children of the visited node to 8638 * do so will cause the visit methods for superclasses of the node to not be
9348 * not be visited. 8639 * invoked and will cause the children of the visited node to not be visited.
9349 */ 8640 */
9350 class GeneralizingAstVisitor<R> implements AstVisitor<R> { 8641 class GeneralizingAstVisitor<R> implements AstVisitor<R> {
9351 @override 8642 @override
9352 R visitAdjacentStrings(AdjacentStrings node) => visitStringLiteral(node); 8643 R visitAdjacentStrings(AdjacentStrings node) => visitStringLiteral(node);
9353 8644
9354 R visitAnnotatedNode(AnnotatedNode node) => visitNode(node); 8645 R visitAnnotatedNode(AnnotatedNode node) => visitNode(node);
9355 8646
9356 @override 8647 @override
9357 R visitAnnotation(Annotation node) => visitNode(node); 8648 R visitAnnotation(Annotation node) => visitNode(node);
9358 8649
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
9756 : super(); 9047 : super();
9757 9048
9758 @override 9049 @override
9759 Object visitNode(AstNode node) { 9050 Object visitNode(AstNode node) {
9760 BreadthFirstVisitor_this._queue.add(node); 9051 BreadthFirstVisitor_this._queue.add(node);
9761 return null; 9052 return null;
9762 } 9053 }
9763 } 9054 }
9764 9055
9765 /** 9056 /**
9766 * Instances of the class `HideCombinator` represent a combinator that restricts the names 9057 * A combinator that restricts the names being imported to those that are not in
9767 * being imported to those that are not in a given list. 9058 * a given list.
9768 * 9059 *
9769 * <pre> 9060 * > hideCombinator ::=
9770 * hideCombinator ::= 9061 * > 'hide' [SimpleIdentifier] (',' [SimpleIdentifier])*
9771 * 'hide' [SimpleIdentifier] (',' [SimpleIdentifier])*
9772 * </pre>
9773 */ 9062 */
9774 class HideCombinator extends Combinator { 9063 class HideCombinator extends Combinator {
9775 /** 9064 /**
9776 * The list of names from the library that are hidden by this combinator. 9065 * The list of names from the library that are hidden by this combinator.
9777 */ 9066 */
9778 NodeList<SimpleIdentifier> _hiddenNames; 9067 NodeList<SimpleIdentifier> _hiddenNames;
9779 9068
9780 /** 9069 /**
9781 * Initialize a newly created import show combinator. 9070 * Initialize a newly created import show combinator.
9782 *
9783 * @param keyword the comma introducing the combinator
9784 * @param hiddenNames the list of names from the library that are hidden by th is combinator
9785 */ 9071 */
9786 HideCombinator(Token keyword, List<SimpleIdentifier> hiddenNames) 9072 HideCombinator(Token keyword, List<SimpleIdentifier> hiddenNames)
9787 : super(keyword) { 9073 : super(keyword) {
9788 _hiddenNames = new NodeList<SimpleIdentifier>(this, hiddenNames); 9074 _hiddenNames = new NodeList<SimpleIdentifier>(this, hiddenNames);
9789 } 9075 }
9790 9076
9791 @override 9077 @override
9792 Iterable get childEntities => new ChildEntities() 9078 Iterable get childEntities => new ChildEntities()
9793 ..add(keyword) 9079 ..add(keyword)
9794 ..addAll(_hiddenNames); 9080 ..addAll(_hiddenNames);
9795 9081
9796 @override 9082 @override
9797 Token get endToken => _hiddenNames.endToken; 9083 Token get endToken => _hiddenNames.endToken;
9798 9084
9799 /** 9085 /**
9800 * Return the list of names from the library that are hidden by this combinato r. 9086 * Return the list of names from the library that are hidden by this
9801 * 9087 * combinator.
9802 * @return the list of names from the library that are hidden by this combinat or
9803 */ 9088 */
9804 NodeList<SimpleIdentifier> get hiddenNames => _hiddenNames; 9089 NodeList<SimpleIdentifier> get hiddenNames => _hiddenNames;
9805 9090
9806 @override 9091 @override
9807 accept(AstVisitor visitor) => visitor.visitHideCombinator(this); 9092 accept(AstVisitor visitor) => visitor.visitHideCombinator(this);
9808 9093
9809 @override 9094 @override
9810 void visitChildren(AstVisitor visitor) { 9095 void visitChildren(AstVisitor visitor) {
9811 _hiddenNames.accept(visitor); 9096 _hiddenNames.accept(visitor);
9812 } 9097 }
9813 } 9098 }
9814 9099
9815 /** 9100 /**
9816 * The abstract class `Identifier` defines the behavior common to nodes that rep resent an 9101 * A node that represents an identifier.
9817 * identifier.
9818 * 9102 *
9819 * <pre> 9103 * > identifier ::=
9820 * identifier ::= 9104 * > [SimpleIdentifier]
9821 * [SimpleIdentifier] 9105 * > | [PrefixedIdentifier]
9822 * | [PrefixedIdentifier]
9823 * </pre>
9824 */ 9106 */
9825 abstract class Identifier extends Expression { 9107 abstract class Identifier extends Expression {
9826 /** 9108 /**
9827 * Return the best element available for this operator. If resolution was able to find a better 9109 * Return the best element available for this operator. If resolution was able
9828 * element based on type propagation, that element will be returned. Otherwise , the element found 9110 * to find a better element based on type propagation, that element will be
9829 * using the result of static analysis will be returned. If resolution has not been performed, 9111 * returned. Otherwise, the element found using the result of static analysis
9830 * then `null` will be returned. 9112 * will be returned. If resolution has not been performed, then `null` will be
9831 * 9113 * returned.
9832 * @return the best element available for this operator
9833 */ 9114 */
9834 Element get bestElement; 9115 Element get bestElement;
9835 9116
9836 @override 9117 @override
9837 bool get isAssignable => true; 9118 bool get isAssignable => true;
9838 9119
9839 /** 9120 /**
9840 * Return the lexical representation of the identifier. 9121 * Return the lexical representation of the identifier.
9841 *
9842 * @return the lexical representation of the identifier
9843 */ 9122 */
9844 String get name; 9123 String get name;
9845 9124
9846 /** 9125 /**
9847 * Return the element associated with this identifier based on propagated type information, or 9126 * Return the element associated with this identifier based on propagated type
9848 * `null` if the AST structure has not been resolved or if this identifier cou ld not be 9127 * information, or `null` if the AST structure has not been resolved or if
9849 * resolved. One example of the latter case is an identifier that is not defin ed within the scope 9128 * this identifier could not be resolved. One example of the latter case is an
9850 * in which it appears. 9129 * identifier that is not defined within the scope in which it appears.
9851 *
9852 * @return the element associated with this identifier
9853 */ 9130 */
9854 Element get propagatedElement; 9131 Element get propagatedElement;
9855 9132
9856 /** 9133 /**
9857 * Return the element associated with this identifier based on static type inf ormation, or 9134 * Return the element associated with this identifier based on static type
9858 * `null` if the AST structure has not been resolved or if this identifier cou ld not be 9135 * information, or `null` if the AST structure has not been resolved or if
9859 * resolved. One example of the latter case is an identifier that is not defin ed within the scope 9136 * this identifier could not be resolved. One example of the latter case is an
9860 * in which it appears 9137 * identifier that is not defined within the scope in which it appears
9861 *
9862 * @return the element associated with the operator
9863 */ 9138 */
9864 Element get staticElement; 9139 Element get staticElement;
9865 9140
9866 /** 9141 /**
9867 * Return `true` if the given name is visible only within the library in which it is 9142 * Return `true` if the given [name] is visible only within the library in
9868 * declared. 9143 * which it is declared.
9869 *
9870 * @param name the name being tested
9871 * @return `true` if the given name is private
9872 */ 9144 */
9873 static bool isPrivateName(String name) => 9145 static bool isPrivateName(String name) =>
9874 StringUtilities.startsWithChar(name, 0x5F); 9146 StringUtilities.startsWithChar(name, 0x5F);
9875 } 9147 }
9876 9148
9877 /** 9149 /**
9878 * Instances of the class `IfStatement` represent an if statement. 9150 * An if statement.
9879 * 9151 *
9880 * <pre> 9152 * > ifStatement ::=
9881 * ifStatement ::= 9153 * > 'if' '(' [Expression] ')' [Statement] ('else' [Statement])?
9882 * 'if' '(' [Expression] ')' [Statement] ('else' [Statement])?
9883 * </pre>
9884 */ 9154 */
9885 class IfStatement extends Statement { 9155 class IfStatement extends Statement {
9886 /** 9156 /**
9887 * The token representing the 'if' keyword. 9157 * The token representing the 'if' keyword.
9888 */ 9158 */
9889 Token ifKeyword; 9159 Token ifKeyword;
9890 9160
9891 /** 9161 /**
9892 * The left parenthesis. 9162 * The left parenthesis.
9893 */ 9163 */
9894 Token leftParenthesis; 9164 Token leftParenthesis;
9895 9165
9896 /** 9166 /**
9897 * The condition used to determine which of the statements is executed next. 9167 * The condition used to determine which of the statements is executed next.
9898 */ 9168 */
9899 Expression _condition; 9169 Expression _condition;
9900 9170
9901 /** 9171 /**
9902 * The right parenthesis. 9172 * The right parenthesis.
9903 */ 9173 */
9904 Token rightParenthesis; 9174 Token rightParenthesis;
9905 9175
9906 /** 9176 /**
9907 * The statement that is executed if the condition evaluates to `true`. 9177 * The statement that is executed if the condition evaluates to `true`.
9908 */ 9178 */
9909 Statement _thenStatement; 9179 Statement _thenStatement;
9910 9180
9911 /** 9181 /**
9912 * The token representing the 'else' keyword, or `null` if there is no else st atement. 9182 * The token representing the 'else' keyword, or `null` if there is no else
9183 * statement.
9913 */ 9184 */
9914 Token elseKeyword; 9185 Token elseKeyword;
9915 9186
9916 /** 9187 /**
9917 * The statement that is executed if the condition evaluates to `false`, or `n ull` if 9188 * The statement that is executed if the condition evaluates to `false`, or
9918 * there is no else statement. 9189 * `null` if there is no else statement.
9919 */ 9190 */
9920 Statement _elseStatement; 9191 Statement _elseStatement;
9921 9192
9922 /** 9193 /**
9923 * Initialize a newly created if statement. 9194 * Initialize a newly created if statement. The [elseKeyword] and
9924 * 9195 * [elseStatement] can be `null` if there is no else clause.
9925 * @param ifKeyword the token representing the 'if' keyword
9926 * @param leftParenthesis the left parenthesis
9927 * @param condition the condition used to determine which of the statements is executed next
9928 * @param rightParenthesis the right parenthesis
9929 * @param thenStatement the statement that is executed if the condition evalua tes to `true`
9930 * @param elseKeyword the token representing the 'else' keyword
9931 * @param elseStatement the statement that is executed if the condition evalua tes to `false`
9932 */ 9196 */
9933 IfStatement(this.ifKeyword, this.leftParenthesis, Expression condition, 9197 IfStatement(this.ifKeyword, this.leftParenthesis, Expression condition,
9934 this.rightParenthesis, Statement thenStatement, this.elseKeyword, 9198 this.rightParenthesis, Statement thenStatement, this.elseKeyword,
9935 Statement elseStatement) { 9199 Statement elseStatement) {
9936 _condition = becomeParentOf(condition); 9200 _condition = becomeParentOf(condition);
9937 _thenStatement = becomeParentOf(thenStatement); 9201 _thenStatement = becomeParentOf(thenStatement);
9938 _elseStatement = becomeParentOf(elseStatement); 9202 _elseStatement = becomeParentOf(elseStatement);
9939 } 9203 }
9940 9204
9941 @override 9205 @override
9942 Token get beginToken => ifKeyword; 9206 Token get beginToken => ifKeyword;
9943 9207
9944 @override 9208 @override
9945 Iterable get childEntities => new ChildEntities() 9209 Iterable get childEntities => new ChildEntities()
9946 ..add(ifKeyword) 9210 ..add(ifKeyword)
9947 ..add(leftParenthesis) 9211 ..add(leftParenthesis)
9948 ..add(_condition) 9212 ..add(_condition)
9949 ..add(rightParenthesis) 9213 ..add(rightParenthesis)
9950 ..add(_thenStatement) 9214 ..add(_thenStatement)
9951 ..add(elseKeyword) 9215 ..add(elseKeyword)
9952 ..add(_elseStatement); 9216 ..add(_elseStatement);
9953 9217
9954 /** 9218 /**
9955 * Return the condition used to determine which of the statements is executed next. 9219 * Return the condition used to determine which of the statements is executed
9956 * 9220 * next.
9957 * @return the condition used to determine which statement is executed next
9958 */ 9221 */
9959 Expression get condition => _condition; 9222 Expression get condition => _condition;
9960 9223
9961 /** 9224 /**
9962 * Set the condition used to determine which of the statements is executed nex t to the given 9225 * Set the condition used to determine which of the statements is executed
9963 * expression. 9226 * next to the given [expression].
9964 *
9965 * @param expression the condition used to determine which statement is execut ed next
9966 */ 9227 */
9967 void set condition(Expression expression) { 9228 void set condition(Expression expression) {
9968 _condition = becomeParentOf(expression); 9229 _condition = becomeParentOf(expression);
9969 } 9230 }
9970 9231
9971 /** 9232 /**
9972 * Return the statement that is executed if the condition evaluates to `false` , or 9233 * Return the statement that is executed if the condition evaluates to
9973 * `null` if there is no else statement. 9234 * `false`, or `null` if there is no else statement.
9974 *
9975 * @return the statement that is executed if the condition evaluates to `false `
9976 */ 9235 */
9977 Statement get elseStatement => _elseStatement; 9236 Statement get elseStatement => _elseStatement;
9978 9237
9979 /** 9238 /**
9980 * Set the statement that is executed if the condition evaluates to `false` to the given 9239 * Set the statement that is executed if the condition evaluates to `false`
9981 * statement. 9240 * to the given [statement].
9982 *
9983 * @param statement the statement that is executed if the condition evaluates to `false`
9984 */ 9241 */
9985 void set elseStatement(Statement statement) { 9242 void set elseStatement(Statement statement) {
9986 _elseStatement = becomeParentOf(statement); 9243 _elseStatement = becomeParentOf(statement);
9987 } 9244 }
9988 9245
9989 @override 9246 @override
9990 Token get endToken { 9247 Token get endToken {
9991 if (_elseStatement != null) { 9248 if (_elseStatement != null) {
9992 return _elseStatement.endToken; 9249 return _elseStatement.endToken;
9993 } 9250 }
9994 return _thenStatement.endToken; 9251 return _thenStatement.endToken;
9995 } 9252 }
9996 9253
9997 /** 9254 /**
9998 * Return the statement that is executed if the condition evaluates to `true`. 9255 * Return the statement that is executed if the condition evaluates to `true`.
9999 *
10000 * @return the statement that is executed if the condition evaluates to `true`
10001 */ 9256 */
10002 Statement get thenStatement => _thenStatement; 9257 Statement get thenStatement => _thenStatement;
10003 9258
10004 /** 9259 /**
10005 * Set the statement that is executed if the condition evaluates to `true` to the given 9260 * Set the statement that is executed if the condition evaluates to `true` to
10006 * statement. 9261 * the given [statement].
10007 *
10008 * @param statement the statement that is executed if the condition evaluates to `true`
10009 */ 9262 */
10010 void set thenStatement(Statement statement) { 9263 void set thenStatement(Statement statement) {
10011 _thenStatement = becomeParentOf(statement); 9264 _thenStatement = becomeParentOf(statement);
10012 } 9265 }
10013 9266
10014 @override 9267 @override
10015 accept(AstVisitor visitor) => visitor.visitIfStatement(this); 9268 accept(AstVisitor visitor) => visitor.visitIfStatement(this);
10016 9269
10017 @override 9270 @override
10018 void visitChildren(AstVisitor visitor) { 9271 void visitChildren(AstVisitor visitor) {
10019 safelyVisitChild(_condition, visitor); 9272 _safelyVisitChild(_condition, visitor);
10020 safelyVisitChild(_thenStatement, visitor); 9273 _safelyVisitChild(_thenStatement, visitor);
10021 safelyVisitChild(_elseStatement, visitor); 9274 _safelyVisitChild(_elseStatement, visitor);
10022 } 9275 }
10023 } 9276 }
10024 9277
10025 /** 9278 /**
10026 * Instances of the class `ImplementsClause` represent the "implements" clause i n an class 9279 * The "implements" clause in an class declaration.
10027 * declaration.
10028 * 9280 *
10029 * <pre> 9281 * > implementsClause ::=
10030 * implementsClause ::= 9282 * > 'implements' [TypeName] (',' [TypeName])*
10031 * 'implements' [TypeName] (',' [TypeName])*
10032 * </pre>
10033 */ 9283 */
10034 class ImplementsClause extends AstNode { 9284 class ImplementsClause extends AstNode {
10035 /** 9285 /**
10036 * The token representing the 'implements' keyword. 9286 * The token representing the 'implements' keyword.
10037 */ 9287 */
10038 Token keyword; 9288 Token keyword;
10039 9289
10040 /** 9290 /**
10041 * The interfaces that are being implemented. 9291 * The interfaces that are being implemented.
10042 */ 9292 */
10043 NodeList<TypeName> _interfaces; 9293 NodeList<TypeName> _interfaces;
10044 9294
10045 /** 9295 /**
10046 * Initialize a newly created implements clause. 9296 * Initialize a newly created implements clause.
10047 *
10048 * @param keyword the token representing the 'implements' keyword
10049 * @param interfaces the interfaces that are being implemented
10050 */ 9297 */
10051 ImplementsClause(this.keyword, List<TypeName> interfaces) { 9298 ImplementsClause(this.keyword, List<TypeName> interfaces) {
10052 _interfaces = new NodeList<TypeName>(this, interfaces); 9299 _interfaces = new NodeList<TypeName>(this, interfaces);
10053 } 9300 }
10054 9301
10055 @override 9302 @override
10056 Token get beginToken => keyword; 9303 Token get beginToken => keyword;
10057 9304
10058 /** 9305 /**
10059 * TODO(paulberry): add commas. 9306 * TODO(paulberry): add commas.
10060 */ 9307 */
10061 @override 9308 @override
10062 Iterable get childEntities => new ChildEntities() 9309 Iterable get childEntities => new ChildEntities()
10063 ..add(keyword) 9310 ..add(keyword)
10064 ..addAll(interfaces); 9311 ..addAll(interfaces);
10065 9312
10066 @override 9313 @override
10067 Token get endToken => _interfaces.endToken; 9314 Token get endToken => _interfaces.endToken;
10068 9315
10069 /** 9316 /**
10070 * Return the list of the interfaces that are being implemented. 9317 * Return the list of the interfaces that are being implemented.
10071 *
10072 * @return the list of the interfaces that are being implemented
10073 */ 9318 */
10074 NodeList<TypeName> get interfaces => _interfaces; 9319 NodeList<TypeName> get interfaces => _interfaces;
10075 9320
10076 @override 9321 @override
10077 accept(AstVisitor visitor) => visitor.visitImplementsClause(this); 9322 accept(AstVisitor visitor) => visitor.visitImplementsClause(this);
10078 9323
10079 @override 9324 @override
10080 void visitChildren(AstVisitor visitor) { 9325 void visitChildren(AstVisitor visitor) {
10081 _interfaces.accept(visitor); 9326 _interfaces.accept(visitor);
10082 } 9327 }
10083 } 9328 }
10084 9329
10085 /** 9330 /**
10086 * Instances of the class `ImportDirective` represent an import directive. 9331 * An import directive.
10087 * 9332 *
10088 * <pre> 9333 * > importDirective ::=
10089 * importDirective ::= 9334 * > [Annotation] 'import' [StringLiteral] ('as' identifier)? [Combinator]* ';'
10090 * [Annotation] 'import' [StringLiteral] ('as' identifier)? [Combinator]* '; ' 9335 * > | [Annotation] 'import' [StringLiteral] 'deferred' 'as' identifier [Combi nator]* ';'
10091 * | [Annotation] 'import' [StringLiteral] 'deferred' 'as' identifier [Combina tor]* ';'
10092 * </pre>
10093 */ 9336 */
10094 class ImportDirective extends NamespaceDirective { 9337 class ImportDirective extends NamespaceDirective {
10095 static Comparator<ImportDirective> COMPARATOR = 9338 static Comparator<ImportDirective> COMPARATOR =
10096 (ImportDirective import1, ImportDirective import2) { 9339 (ImportDirective import1, ImportDirective import2) {
10097 // 9340 //
10098 // uri 9341 // uri
10099 // 9342 //
10100 StringLiteral uri1 = import1.uri; 9343 StringLiteral uri1 = import1.uri;
10101 StringLiteral uri2 = import2.uri; 9344 StringLiteral uri2 = import2.uri;
10102 String uriStr1 = uri1.stringValue; 9345 String uriStr1 = uri1.stringValue;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
10180 if (!javaCollectionContainsAll(allHides1, allHides2)) { 9423 if (!javaCollectionContainsAll(allHides1, allHides2)) {
10181 return -1; 9424 return -1;
10182 } 9425 }
10183 if (!javaCollectionContainsAll(allShows1, allShows2)) { 9426 if (!javaCollectionContainsAll(allShows1, allShows2)) {
10184 return -1; 9427 return -1;
10185 } 9428 }
10186 return 0; 9429 return 0;
10187 }; 9430 };
10188 9431
10189 /** 9432 /**
10190 * The token representing the 'deferred' token, or `null` if the imported is n ot deferred. 9433 * The token representing the 'deferred' token, or `null` if the imported is
9434 * not deferred.
10191 */ 9435 */
10192 Token deferredToken; 9436 Token deferredToken;
10193 9437
10194 /** 9438 /**
10195 * The token representing the 'as' token, or `null` if the imported names are not prefixed. 9439 * The token representing the 'as' token, or `null` if the imported names are
9440 * not prefixed.
10196 */ 9441 */
10197 Token asToken; 9442 Token asToken;
10198 9443
10199 /** 9444 /**
10200 * The prefix to be used with the imported names, or `null` if the imported na mes are not 9445 * The prefix to be used with the imported names, or `null` if the imported
10201 * prefixed. 9446 * names are not prefixed.
10202 */ 9447 */
10203 SimpleIdentifier _prefix; 9448 SimpleIdentifier _prefix;
10204 9449
10205 /** 9450 /**
10206 * Initialize a newly created import directive. 9451 * Initialize a newly created import directive. Either or both of the
10207 * 9452 * [comment] and [metadata] can be `null` if the function does not have the
10208 * @param comment the documentation comment associated with this directive 9453 * corresponding attribute. The [deferredToken] can be `null` if the import is
10209 * @param metadata the annotations associated with the directive 9454 * not deferred. The [asToken] and [prefix] can be `null` if the import does
10210 * @param keyword the token representing the 'import' keyword 9455 * not specify a prefix. The list of [combinators] can be `null` if there are
10211 * @param libraryUri the URI of the library being imported 9456 * no combinators.
10212 * @param deferredToken the token representing the 'deferred' token
10213 * @param asToken the token representing the 'as' token
10214 * @param prefix the prefix to be used with the imported names
10215 * @param combinators the combinators used to control how names are imported
10216 * @param semicolon the semicolon terminating the directive
10217 */ 9457 */
10218 ImportDirective(Comment comment, List<Annotation> metadata, Token keyword, 9458 ImportDirective(Comment comment, List<Annotation> metadata, Token keyword,
10219 StringLiteral libraryUri, this.deferredToken, this.asToken, 9459 StringLiteral libraryUri, this.deferredToken, this.asToken,
10220 SimpleIdentifier prefix, List<Combinator> combinators, Token semicolon) 9460 SimpleIdentifier prefix, List<Combinator> combinators, Token semicolon)
10221 : super(comment, metadata, keyword, libraryUri, combinators, semicolon) { 9461 : super(comment, metadata, keyword, libraryUri, combinators, semicolon) {
10222 _prefix = becomeParentOf(prefix); 9462 _prefix = becomeParentOf(prefix);
10223 } 9463 }
10224 9464
10225 @override 9465 @override
10226 Iterable get childEntities => super._childEntities 9466 Iterable get childEntities => super._childEntities
10227 ..add(_uri) 9467 ..add(_uri)
10228 ..add(deferredToken) 9468 ..add(deferredToken)
10229 ..add(asToken) 9469 ..add(asToken)
10230 ..add(_prefix) 9470 ..add(_prefix)
10231 ..addAll(combinators) 9471 ..addAll(combinators)
10232 ..add(semicolon); 9472 ..add(semicolon);
10233 9473
10234 @override 9474 @override
10235 ImportElement get element => super.element as ImportElement; 9475 ImportElement get element => super.element as ImportElement;
10236 9476
10237 /** 9477 /**
10238 * Return the prefix to be used with the imported names, or `null` if the impo rted names are 9478 * Return the prefix to be used with the imported names, or `null` if the
10239 * not prefixed. 9479 * imported names are not prefixed.
10240 *
10241 * @return the prefix to be used with the imported names
10242 */ 9480 */
10243 SimpleIdentifier get prefix => _prefix; 9481 SimpleIdentifier get prefix => _prefix;
10244 9482
10245 /** 9483 /**
10246 * Set the prefix to be used with the imported names to the given identifier. 9484 * Set the prefix to be used with the imported names to the given [identifier] .
10247 *
10248 * @param prefix the prefix to be used with the imported names
10249 */ 9485 */
10250 void set prefix(SimpleIdentifier prefix) { 9486 void set prefix(SimpleIdentifier identifier) {
10251 _prefix = becomeParentOf(prefix); 9487 _prefix = becomeParentOf(identifier);
10252 } 9488 }
10253 9489
10254 @override 9490 @override
10255 LibraryElement get uriElement { 9491 LibraryElement get uriElement {
10256 ImportElement element = this.element; 9492 ImportElement element = this.element;
10257 if (element == null) { 9493 if (element == null) {
10258 return null; 9494 return null;
10259 } 9495 }
10260 return element.importedLibrary; 9496 return element.importedLibrary;
10261 } 9497 }
10262 9498
10263 @override 9499 @override
10264 accept(AstVisitor visitor) => visitor.visitImportDirective(this); 9500 accept(AstVisitor visitor) => visitor.visitImportDirective(this);
10265 9501
10266 @override 9502 @override
10267 void visitChildren(AstVisitor visitor) { 9503 void visitChildren(AstVisitor visitor) {
10268 super.visitChildren(visitor); 9504 super.visitChildren(visitor);
10269 safelyVisitChild(_prefix, visitor); 9505 _safelyVisitChild(_prefix, visitor);
10270 combinators.accept(visitor); 9506 combinators.accept(visitor);
10271 } 9507 }
10272 } 9508 }
10273 9509
10274 /** 9510 /**
10275 * Instances of the class `IncrementalAstCloner` implement an object that will c lone any AST 9511 * An object that will clone any AST structure that it visits. The cloner will
10276 * structure that it visits. The cloner will clone the structure, replacing the specified ASTNode 9512 * clone the structure, replacing the specified ASTNode with a new ASTNode,
10277 * with a new ASTNode, mapping the old token stream to a new token stream, and p reserving resolution 9513 * mapping the old token stream to a new token stream, and preserving resolution
10278 * results. 9514 * results.
10279 */ 9515 */
10280 class IncrementalAstCloner implements AstVisitor<AstNode> { 9516 class IncrementalAstCloner implements AstVisitor<AstNode> {
10281 /** 9517 /**
10282 * The node to be replaced during the cloning process. 9518 * The node to be replaced during the cloning process.
10283 */ 9519 */
10284 final AstNode _oldNode; 9520 final AstNode _oldNode;
10285 9521
10286 /** 9522 /**
10287 * The replacement node used during the cloning process. 9523 * The replacement node used during the cloning process.
10288 */ 9524 */
10289 final AstNode _newNode; 9525 final AstNode _newNode;
10290 9526
10291 /** 9527 /**
10292 * A mapping of old tokens to new tokens used during the cloning process. 9528 * A mapping of old tokens to new tokens used during the cloning process.
10293 */ 9529 */
10294 final TokenMap _tokenMap; 9530 final TokenMap _tokenMap;
10295 9531
10296 /** 9532 /**
10297 * Construct a new instance that will replace `oldNode` with `newNode` in the process 9533 * Construct a new instance that will replace the [oldNode] with the [newNode]
10298 * of cloning an existing AST structure. 9534 * in the process of cloning an existing AST structure. The [tokenMap] is a
10299 * 9535 * mapping of old tokens to new tokens.
10300 * @param oldNode the node to be replaced
10301 * @param newNode the replacement node
10302 * @param tokenMap a mapping of old tokens to new tokens (not `null`)
10303 */ 9536 */
10304 IncrementalAstCloner(this._oldNode, this._newNode, this._tokenMap); 9537 IncrementalAstCloner(this._oldNode, this._newNode, this._tokenMap);
10305 9538
10306 @override 9539 @override
10307 AdjacentStrings visitAdjacentStrings(AdjacentStrings node) => 9540 AdjacentStrings visitAdjacentStrings(AdjacentStrings node) =>
10308 new AdjacentStrings(_cloneNodeList(node.strings)); 9541 new AdjacentStrings(_cloneNodeList(node.strings));
10309 9542
10310 @override 9543 @override
10311 Annotation visitAnnotation(Annotation node) { 9544 Annotation visitAnnotation(Annotation node) {
10312 Annotation copy = new Annotation( 9545 Annotation copy = new Annotation(
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
11355 List<Token> _mapTokens(List<Token> oldTokens) { 10588 List<Token> _mapTokens(List<Token> oldTokens) {
11356 List<Token> newTokens = new List<Token>(oldTokens.length); 10589 List<Token> newTokens = new List<Token>(oldTokens.length);
11357 for (int index = 0; index < newTokens.length; index++) { 10590 for (int index = 0; index < newTokens.length; index++) {
11358 newTokens[index] = _mapToken(oldTokens[index]); 10591 newTokens[index] = _mapToken(oldTokens[index]);
11359 } 10592 }
11360 return newTokens; 10593 return newTokens;
11361 } 10594 }
11362 } 10595 }
11363 10596
11364 /** 10597 /**
11365 * Instances of the class `IndexExpression` represent an index expression. 10598 * An index expression.
11366 * 10599 *
11367 * <pre> 10600 * > indexExpression ::=
11368 * indexExpression ::= 10601 * > [Expression] '[' [Expression] ']'
11369 * [Expression] '[' [Expression] ']'
11370 * </pre>
11371 */ 10602 */
11372 class IndexExpression extends Expression { 10603 class IndexExpression extends Expression {
11373 /** 10604 /**
11374 * The expression used to compute the object being indexed, or `null` if this index 10605 * The expression used to compute the object being indexed, or `null` if this
11375 * expression is part of a cascade expression. 10606 * index expression is part of a cascade expression.
11376 */ 10607 */
11377 Expression _target; 10608 Expression _target;
11378 10609
11379 /** 10610 /**
11380 * The period ("..") before a cascaded index expression, or `null` if this ind ex expression 10611 * The period ("..") before a cascaded index expression, or `null` if this
11381 * is not part of a cascade expression. 10612 * index expression is not part of a cascade expression.
11382 */ 10613 */
11383 Token period; 10614 Token period;
11384 10615
11385 /** 10616 /**
11386 * The left square bracket. 10617 * The left square bracket.
11387 */ 10618 */
11388 Token leftBracket; 10619 Token leftBracket;
11389 10620
11390 /** 10621 /**
11391 * The expression used to compute the index. 10622 * The expression used to compute the index.
11392 */ 10623 */
11393 Expression _index; 10624 Expression _index;
11394 10625
11395 /** 10626 /**
11396 * The right square bracket. 10627 * The right square bracket.
11397 */ 10628 */
11398 Token rightBracket; 10629 Token rightBracket;
11399 10630
11400 /** 10631 /**
11401 * The element associated with the operator based on the static type of the ta rget, or 10632 * The element associated with the operator based on the static type of the
11402 * `null` if the AST structure has not been resolved or if the operator could not be 10633 * target, or `null` if the AST structure has not been resolved or if the
11403 * resolved. 10634 * operator could not be resolved.
11404 */ 10635 */
11405 MethodElement staticElement; 10636 MethodElement staticElement;
11406 10637
11407 /** 10638 /**
11408 * The element associated with the operator based on the propagated type of th e target, or 10639 * The element associated with the operator based on the propagated type of
11409 * `null` if the AST structure has not been resolved or if the operator could not be 10640 * the target, or `null` if the AST structure has not been resolved or if the
11410 * resolved. 10641 * operator could not be resolved.
11411 */ 10642 */
11412 MethodElement propagatedElement; 10643 MethodElement propagatedElement;
11413 10644
11414 /** 10645 /**
11415 * If this expression is both in a getter and setter context, the [AuxiliaryEl ements] will 10646 * If this expression is both in a getter and setter context, the
11416 * be set to hold onto the static and propagated information. The auxiliary el ement will hold onto 10647 * [AuxiliaryElements] will be set to hold onto the static and propagated
11417 * the elements from the getter context. 10648 * information. The auxiliary element will hold onto the elements from the
10649 * getter context.
11418 */ 10650 */
11419 AuxiliaryElements auxiliaryElements = null; 10651 AuxiliaryElements auxiliaryElements = null;
11420 10652
11421 /** 10653 /**
11422 * Initialize a newly created index expression. 10654 * Initialize a newly created index expression.
11423 *
11424 * @param period the period ("..") before a cascaded index expression
11425 * @param leftBracket the left square bracket
11426 * @param index the expression used to compute the index
11427 * @param rightBracket the right square bracket
11428 */ 10655 */
11429 IndexExpression.forCascade(this.period, this.leftBracket, Expression index, 10656 IndexExpression.forCascade(this.period, this.leftBracket, Expression index,
11430 this.rightBracket) { 10657 this.rightBracket) {
11431 _index = becomeParentOf(index); 10658 _index = becomeParentOf(index);
11432 } 10659 }
11433 10660
11434 /** 10661 /**
11435 * Initialize a newly created index expression. 10662 * Initialize a newly created index expression.
11436 *
11437 * @param target the expression used to compute the object being indexed
11438 * @param leftBracket the left square bracket
11439 * @param index the expression used to compute the index
11440 * @param rightBracket the right square bracket
11441 */ 10663 */
11442 IndexExpression.forTarget(Expression target, this.leftBracket, 10664 IndexExpression.forTarget(Expression target, this.leftBracket,
11443 Expression index, this.rightBracket) { 10665 Expression index, this.rightBracket) {
11444 _target = becomeParentOf(target); 10666 _target = becomeParentOf(target);
11445 _index = becomeParentOf(index); 10667 _index = becomeParentOf(index);
11446 } 10668 }
11447 10669
11448 @override 10670 @override
11449 Token get beginToken { 10671 Token get beginToken {
11450 if (_target != null) { 10672 if (_target != null) {
11451 return _target.beginToken; 10673 return _target.beginToken;
11452 } 10674 }
11453 return period; 10675 return period;
11454 } 10676 }
11455 10677
11456 /** 10678 /**
11457 * Return the best element available for this operator. If resolution was able to find a better 10679 * Return the best element available for this operator. If resolution was able
11458 * element based on type propagation, that element will be returned. Otherwise , the element found 10680 * to find a better element based on type propagation, that element will be
11459 * using the result of static analysis will be returned. If resolution has not been performed, 10681 * returned. Otherwise, the element found using the result of static analysis
11460 * then `null` will be returned. 10682 * will be returned. If resolution has not been performed, then `null` will be
11461 * 10683 * returned.
11462 * @return the best element available for this operator
11463 */ 10684 */
11464 MethodElement get bestElement { 10685 MethodElement get bestElement {
11465 MethodElement element = propagatedElement; 10686 MethodElement element = propagatedElement;
11466 if (element == null) { 10687 if (element == null) {
11467 element = staticElement; 10688 element = staticElement;
11468 } 10689 }
11469 return element; 10690 return element;
11470 } 10691 }
11471 10692
11472 /** 10693 /**
11473 * TODO(paulberry): untested. 10694 * TODO(paulberry): untested.
11474 */ 10695 */
11475 @override 10696 @override
11476 Iterable get childEntities => new ChildEntities() 10697 Iterable get childEntities => new ChildEntities()
11477 ..add(_target) 10698 ..add(_target)
11478 ..add(period) 10699 ..add(period)
11479 ..add(leftBracket) 10700 ..add(leftBracket)
11480 ..add(_index) 10701 ..add(_index)
11481 ..add(rightBracket); 10702 ..add(rightBracket);
11482 10703
11483 @override 10704 @override
11484 Token get endToken => rightBracket; 10705 Token get endToken => rightBracket;
11485 10706
11486 /** 10707 /**
11487 * Return the expression used to compute the index. 10708 * Return the expression used to compute the index.
11488 *
11489 * @return the expression used to compute the index
11490 */ 10709 */
11491 Expression get index => _index; 10710 Expression get index => _index;
11492 10711
11493 /** 10712 /**
11494 * Set the expression used to compute the index to the given expression. 10713 * Set the expression used to compute the index to the given [expression].
11495 *
11496 * @param expression the expression used to compute the index
11497 */ 10714 */
11498 void set index(Expression expression) { 10715 void set index(Expression expression) {
11499 _index = becomeParentOf(expression); 10716 _index = becomeParentOf(expression);
11500 } 10717 }
11501 10718
11502 @override 10719 @override
11503 bool get isAssignable => true; 10720 bool get isAssignable => true;
11504 10721
11505 /** 10722 /**
11506 * Return `true` if this expression is cascaded. If it is, then the target of this 10723 * Return `true` if this expression is cascaded. If it is, then the target of
11507 * expression is not stored locally but is stored in the nearest ancestor that is a 10724 * this expression is not stored locally but is stored in the nearest ancestor
11508 * [CascadeExpression]. 10725 * that is a [CascadeExpression].
11509 *
11510 * @return `true` if this expression is cascaded
11511 */ 10726 */
11512 bool get isCascaded => period != null; 10727 bool get isCascaded => period != null;
11513 10728
11514 @override 10729 @override
11515 int get precedence => 15; 10730 int get precedence => 15;
11516 10731
11517 /** 10732 /**
11518 * If the AST structure has been resolved, and the function being invoked is k nown based on 10733 * If the AST structure has been resolved, and the function being invoked is
11519 * propagated type information, then return the parameter element representing the parameter to 10734 * known based on propagated type information, then return the parameter
11520 * which the value of the index expression will be bound. Otherwise, return `n ull`. 10735 * element representing the parameter to which the value of the index
10736 * expression will be bound. Otherwise, return `null`.
11521 * 10737 *
11522 * This method is only intended to be used by [Expression.propagatedParameterE lement]. 10738 * This method is only intended to be used by
11523 * 10739 * [Expression.propagatedParameterElement].
11524 * @return the parameter element representing the parameter to which the value of the index
11525 * expression will be bound
11526 */ 10740 */
11527 ParameterElement get propagatedParameterElementForIndex { 10741 ParameterElement get propagatedParameterElementForIndex {
11528 if (propagatedElement == null) { 10742 if (propagatedElement == null) {
11529 return null; 10743 return null;
11530 } 10744 }
11531 List<ParameterElement> parameters = propagatedElement.parameters; 10745 List<ParameterElement> parameters = propagatedElement.parameters;
11532 if (parameters.length < 1) { 10746 if (parameters.length < 1) {
11533 return null; 10747 return null;
11534 } 10748 }
11535 return parameters[0]; 10749 return parameters[0];
11536 } 10750 }
11537 10751
11538 /** 10752 /**
11539 * Return the expression used to compute the object being indexed. If this ind ex expression is not 10753 * Return the expression used to compute the object being indexed. If this
11540 * part of a cascade expression, then this is the same as [getTarget]. If this index 10754 * index expression is not part of a cascade expression, then this is the same
11541 * expression is part of a cascade expression, then the target expression stor ed with the cascade 10755 * as [target]. If this index expression is part of a cascade expression, then
11542 * expression is returned. 10756 * the target expression stored with the cascade expression is returned.
11543 *
11544 * @return the expression used to compute the object being indexed
11545 * See [target].
11546 */ 10757 */
11547 Expression get realTarget { 10758 Expression get realTarget {
11548 if (isCascaded) { 10759 if (isCascaded) {
11549 AstNode ancestor = parent; 10760 AstNode ancestor = parent;
11550 while (ancestor is! CascadeExpression) { 10761 while (ancestor is! CascadeExpression) {
11551 if (ancestor == null) { 10762 if (ancestor == null) {
11552 return _target; 10763 return _target;
11553 } 10764 }
11554 ancestor = ancestor.parent; 10765 ancestor = ancestor.parent;
11555 } 10766 }
11556 return (ancestor as CascadeExpression).target; 10767 return (ancestor as CascadeExpression).target;
11557 } 10768 }
11558 return _target; 10769 return _target;
11559 } 10770 }
11560 10771
11561 /** 10772 /**
11562 * If the AST structure has been resolved, and the function being invoked is k nown based on static 10773 * If the AST structure has been resolved, and the function being invoked is
11563 * type information, then return the parameter element representing the parame ter to which the 10774 * known based on static type information, then return the parameter element
11564 * value of the index expression will be bound. Otherwise, return `null`. 10775 * representing the parameter to which the value of the index expression will
10776 * be bound. Otherwise, return `null`.
11565 * 10777 *
11566 * This method is only intended to be used by [Expression.staticParameterEleme nt]. 10778 * This method is only intended to be used by
11567 * 10779 * [Expression.staticParameterElement].
11568 * @return the parameter element representing the parameter to which the value of the index
11569 * expression will be bound
11570 */ 10780 */
11571 ParameterElement get staticParameterElementForIndex { 10781 ParameterElement get staticParameterElementForIndex {
11572 if (staticElement == null) { 10782 if (staticElement == null) {
11573 return null; 10783 return null;
11574 } 10784 }
11575 List<ParameterElement> parameters = staticElement.parameters; 10785 List<ParameterElement> parameters = staticElement.parameters;
11576 if (parameters.length < 1) { 10786 if (parameters.length < 1) {
11577 return null; 10787 return null;
11578 } 10788 }
11579 return parameters[0]; 10789 return parameters[0];
11580 } 10790 }
11581 10791
11582 /** 10792 /**
11583 * Return the expression used to compute the object being indexed, or `null` i f this index 10793 * Return the expression used to compute the object being indexed, or `null`
11584 * expression is part of a cascade expression. 10794 * if this index expression is part of a cascade expression.
11585 * 10795 *
11586 * @return the expression used to compute the object being indexed 10796 * Use [realTarget] to get the target independent of whether this is part of a
11587 * See [realTarget]. 10797 * cascade expression.
11588 */ 10798 */
11589 Expression get target => _target; 10799 Expression get target => _target;
11590 10800
11591 /** 10801 /**
11592 * Set the expression used to compute the object being indexed to the given ex pression. 10802 * Set the expression used to compute the object being indexed to the given
11593 * 10803 * [expression].
11594 * @param expression the expression used to compute the object being indexed
11595 */ 10804 */
11596 void set target(Expression expression) { 10805 void set target(Expression expression) {
11597 _target = becomeParentOf(expression); 10806 _target = becomeParentOf(expression);
11598 } 10807 }
11599 10808
11600 @override 10809 @override
11601 accept(AstVisitor visitor) => visitor.visitIndexExpression(this); 10810 accept(AstVisitor visitor) => visitor.visitIndexExpression(this);
11602 10811
11603 /** 10812 /**
11604 * Return `true` if this expression is computing a right-hand value. 10813 * Return `true` if this expression is computing a right-hand value (that is,
10814 * if this expression is in a context where the operator '[]' will be
10815 * invoked).
11605 * 10816 *
11606 * Note that [inGetterContext] and [inSetterContext] are not opposites, nor ar e 10817 * Note that [inGetterContext] and [inSetterContext] are not opposites, nor
11607 * they mutually exclusive. In other words, it is possible for both methods to return `true` 10818 * are they mutually exclusive. In other words, it is possible for both
11608 * when invoked on the same node. 10819 * methods to return `true` when invoked on the same node.
11609 *
11610 * @return `true` if this expression is in a context where the operator '[]' w ill be invoked
11611 */ 10820 */
11612 bool inGetterContext() { 10821 bool inGetterContext() {
11613 AstNode parent = this.parent; 10822 AstNode parent = this.parent;
11614 if (parent is AssignmentExpression) { 10823 if (parent is AssignmentExpression) {
11615 AssignmentExpression assignment = parent; 10824 AssignmentExpression assignment = parent;
11616 if (identical(assignment.leftHandSide, this) && 10825 if (identical(assignment.leftHandSide, this) &&
11617 assignment.operator.type == TokenType.EQ) { 10826 assignment.operator.type == TokenType.EQ) {
11618 return false; 10827 return false;
11619 } 10828 }
11620 } 10829 }
11621 return true; 10830 return true;
11622 } 10831 }
11623 10832
11624 /** 10833 /**
11625 * Return `true` if this expression is computing a left-hand value. 10834 * Return `true` if this expression is computing a left-hand value (that is,
10835 * if this expression is in a context where the operator '[]=' will be
10836 * invoked).
11626 * 10837 *
11627 * Note that [inGetterContext] and [inSetterContext] are not opposites, nor ar e 10838 * Note that [inGetterContext] and [inSetterContext] are not opposites, nor
11628 * they mutually exclusive. In other words, it is possible for both methods to return `true` 10839 * are they mutually exclusive. In other words, it is possible for both
11629 * when invoked on the same node. 10840 * methods to return `true` when invoked on the same node.
11630 *
11631 * @return `true` if this expression is in a context where the operator '[]=' will be
11632 * invoked
11633 */ 10841 */
11634 bool inSetterContext() { 10842 bool inSetterContext() {
11635 AstNode parent = this.parent; 10843 AstNode parent = this.parent;
11636 if (parent is PrefixExpression) { 10844 if (parent is PrefixExpression) {
11637 return parent.operator.type.isIncrementOperator; 10845 return parent.operator.type.isIncrementOperator;
11638 } else if (parent is PostfixExpression) { 10846 } else if (parent is PostfixExpression) {
11639 return true; 10847 return true;
11640 } else if (parent is AssignmentExpression) { 10848 } else if (parent is AssignmentExpression) {
11641 return identical(parent.leftHandSide, this); 10849 return identical(parent.leftHandSide, this);
11642 } 10850 }
11643 return false; 10851 return false;
11644 } 10852 }
11645 10853
11646 @override 10854 @override
11647 void visitChildren(AstVisitor visitor) { 10855 void visitChildren(AstVisitor visitor) {
11648 safelyVisitChild(_target, visitor); 10856 _safelyVisitChild(_target, visitor);
11649 safelyVisitChild(_index, visitor); 10857 _safelyVisitChild(_index, visitor);
11650 } 10858 }
11651 } 10859 }
11652 10860
11653 /** 10861 /**
11654 * Instances of the class `InstanceCreationExpression` represent an instance cre ation 10862 * An instance creation expression.
11655 * expression.
11656 * 10863 *
11657 * <pre> 10864 * > newExpression ::=
11658 * newExpression ::= 10865 * > ('new' | 'const') [TypeName] ('.' [SimpleIdentifier])? [ArgumentList]
11659 * ('new' | 'const') [TypeName] ('.' [SimpleIdentifier])? [ArgumentList]
11660 * </pre>
11661 */ 10866 */
11662 class InstanceCreationExpression extends Expression { 10867 class InstanceCreationExpression extends Expression {
11663 /** 10868 /**
11664 * The keyword used to indicate how an object should be created. 10869 * The keyword used to indicate how an object should be created.
11665 */ 10870 */
11666 Token keyword; 10871 Token keyword;
11667 10872
11668 /** 10873 /**
11669 * The name of the constructor to be invoked. 10874 * The name of the constructor to be invoked.
11670 */ 10875 */
11671 ConstructorName _constructorName; 10876 ConstructorName _constructorName;
11672 10877
11673 /** 10878 /**
11674 * The list of arguments to the constructor. 10879 * The list of arguments to the constructor.
11675 */ 10880 */
11676 ArgumentList _argumentList; 10881 ArgumentList _argumentList;
11677 10882
11678 /** 10883 /**
11679 * The element associated with the constructor based on static type informatio n, or `null` 10884 * The element associated with the constructor based on static type
11680 * if the AST structure has not been resolved or if the constructor could not be resolved. 10885 * information, or `null` if the AST structure has not been resolved or if the
10886 * constructor could not be resolved.
11681 */ 10887 */
11682 ConstructorElement staticElement; 10888 ConstructorElement staticElement;
11683 10889
11684 /** 10890 /**
11685 * The result of evaluating this expression, if it is constant. 10891 * The result of evaluating this expression, if it is constant.
11686 */ 10892 */
11687 EvaluationResultImpl evaluationResult; 10893 EvaluationResultImpl evaluationResult;
11688 10894
11689 /** 10895 /**
11690 * Initialize a newly created instance creation expression. 10896 * Initialize a newly created instance creation expression.
11691 *
11692 * @param keyword the keyword used to indicate how an object should be created
11693 * @param constructorName the name of the constructor to be invoked
11694 * @param argumentList the list of arguments to the constructor
11695 */ 10897 */
11696 InstanceCreationExpression(this.keyword, ConstructorName constructorName, 10898 InstanceCreationExpression(this.keyword, ConstructorName constructorName,
11697 ArgumentList argumentList) { 10899 ArgumentList argumentList) {
11698 _constructorName = becomeParentOf(constructorName); 10900 _constructorName = becomeParentOf(constructorName);
11699 _argumentList = becomeParentOf(argumentList); 10901 _argumentList = becomeParentOf(argumentList);
11700 } 10902 }
11701 10903
11702 /** 10904 /**
11703 * Return the list of arguments to the constructor. 10905 * Return the list of arguments to the constructor.
11704 *
11705 * @return the list of arguments to the constructor
11706 */ 10906 */
11707 ArgumentList get argumentList => _argumentList; 10907 ArgumentList get argumentList => _argumentList;
11708 10908
11709 /** 10909 /**
11710 * Set the list of arguments to the constructor to the given list. 10910 * Set the list of arguments to the constructor to the given [argumentList].
11711 *
11712 * @param argumentList the list of arguments to the constructor
11713 */ 10911 */
11714 void set argumentList(ArgumentList argumentList) { 10912 void set argumentList(ArgumentList argumentList) {
11715 _argumentList = becomeParentOf(argumentList); 10913 _argumentList = becomeParentOf(argumentList);
11716 } 10914 }
11717 10915
11718 @override 10916 @override
11719 Token get beginToken => keyword; 10917 Token get beginToken => keyword;
11720 10918
11721 @override 10919 @override
11722 Iterable get childEntities => new ChildEntities() 10920 Iterable get childEntities => new ChildEntities()
11723 ..add(keyword) 10921 ..add(keyword)
11724 ..add(_constructorName) 10922 ..add(_constructorName)
11725 ..add(_argumentList); 10923 ..add(_argumentList);
11726 10924
11727 /** 10925 /**
11728 * Return the name of the constructor to be invoked. 10926 * Return the name of the constructor to be invoked.
11729 *
11730 * @return the name of the constructor to be invoked
11731 */ 10927 */
11732 ConstructorName get constructorName => _constructorName; 10928 ConstructorName get constructorName => _constructorName;
11733 10929
11734 /** 10930 /**
11735 * Set the name of the constructor to be invoked to the given name. 10931 * Set the name of the constructor to be invoked to the given [name].
11736 *
11737 * @param constructorName the name of the constructor to be invoked
11738 */ 10932 */
11739 void set constructorName(ConstructorName constructorName) { 10933 void set constructorName(ConstructorName name) {
11740 _constructorName = becomeParentOf(constructorName); 10934 _constructorName = becomeParentOf(name);
11741 } 10935 }
11742 10936
11743 @override 10937 @override
11744 Token get endToken => _argumentList.endToken; 10938 Token get endToken => _argumentList.endToken;
11745 10939
11746 /** 10940 /**
11747 * Return `true` if this creation expression is used to invoke a constant cons tructor. 10941 * Return `true` if this creation expression is used to invoke a constant
11748 * 10942 * constructor.
11749 * @return `true` if this creation expression is used to invoke a constant con structor
11750 */ 10943 */
11751 bool get isConst => 10944 bool get isConst =>
11752 keyword is KeywordToken && (keyword as KeywordToken).keyword == Keyword.CO NST; 10945 keyword is KeywordToken && (keyword as KeywordToken).keyword == Keyword.CO NST;
11753 10946
11754 @override 10947 @override
11755 int get precedence => 16; 10948 int get precedence => 16;
11756 10949
11757 @override 10950 @override
11758 accept(AstVisitor visitor) => visitor.visitInstanceCreationExpression(this); 10951 accept(AstVisitor visitor) => visitor.visitInstanceCreationExpression(this);
11759 10952
11760 @override 10953 @override
11761 void visitChildren(AstVisitor visitor) { 10954 void visitChildren(AstVisitor visitor) {
11762 safelyVisitChild(_constructorName, visitor); 10955 _safelyVisitChild(_constructorName, visitor);
11763 safelyVisitChild(_argumentList, visitor); 10956 _safelyVisitChild(_argumentList, visitor);
11764 } 10957 }
11765 } 10958 }
11766 10959
11767 /** 10960 /**
11768 * Instances of the class `IntegerLiteral` represent an integer literal expressi on. 10961 * An integer literal expression.
11769 * 10962 *
11770 * <pre> 10963 * > integerLiteral ::=
11771 * integerLiteral ::= 10964 * > decimalIntegerLiteral
11772 * decimalIntegerLiteral 10965 * > | hexidecimalIntegerLiteral
11773 * | hexidecimalIntegerLiteral 10966 * >
11774 * 10967 * > decimalIntegerLiteral ::=
11775 * decimalIntegerLiteral ::= 10968 * > decimalDigit+
11776 * decimalDigit+ 10969 * >
11777 * 10970 * > hexidecimalIntegerLiteral ::=
11778 * hexidecimalIntegerLiteral ::= 10971 * > '0x' hexidecimalDigit+
11779 * '0x' hexidecimalDigit+ 10972 * > | '0X' hexidecimalDigit+
11780 * | '0X' hexidecimalDigit+
11781 * </pre>
11782 */ 10973 */
11783 class IntegerLiteral extends Literal { 10974 class IntegerLiteral extends Literal {
11784 /** 10975 /**
11785 * The token representing the literal. 10976 * The token representing the literal.
11786 */ 10977 */
11787 Token literal; 10978 Token literal;
11788 10979
11789 /** 10980 /**
11790 * The value of the literal. 10981 * The value of the literal.
11791 */ 10982 */
11792 int value = 0; 10983 int value = 0;
11793 10984
11794 /** 10985 /**
11795 * Initialize a newly created integer literal. 10986 * Initialize a newly created integer literal.
11796 *
11797 * @param literal the token representing the literal
11798 * @param value the value of the literal
11799 */ 10987 */
11800 IntegerLiteral(this.literal, this.value); 10988 IntegerLiteral(this.literal, this.value);
11801 10989
11802 @override 10990 @override
11803 Token get beginToken => literal; 10991 Token get beginToken => literal;
11804 10992
11805 /** 10993 /**
11806 * TODO(paulberry): untested. 10994 * TODO(paulberry): untested.
11807 */ 10995 */
11808 @override 10996 @override
11809 Iterable get childEntities => new ChildEntities()..add(literal); 10997 Iterable get childEntities => new ChildEntities()..add(literal);
11810 10998
11811 @override 10999 @override
11812 Token get endToken => literal; 11000 Token get endToken => literal;
11813 11001
11814 @override 11002 @override
11815 accept(AstVisitor visitor) => visitor.visitIntegerLiteral(this); 11003 accept(AstVisitor visitor) => visitor.visitIntegerLiteral(this);
11816 11004
11817 @override 11005 @override
11818 void visitChildren(AstVisitor visitor) { 11006 void visitChildren(AstVisitor visitor) {
11819 // There are no children to visit. 11007 // There are no children to visit.
11820 } 11008 }
11821 } 11009 }
11822 11010
11823 /** 11011 /**
11824 * The abstract class `InterpolationElement` defines the behavior common to elem ents within a 11012 * A node within a [StringInterpolation].
11825 * [StringInterpolation].
11826 * 11013 *
11827 * <pre> 11014 * > interpolationElement ::=
11828 * interpolationElement ::= 11015 * > [InterpolationExpression]
11829 * [InterpolationExpression] 11016 * > | [InterpolationString]
11830 * | [InterpolationString]
11831 * </pre>
11832 */ 11017 */
11833 abstract class InterpolationElement extends AstNode { 11018 abstract class InterpolationElement extends AstNode {
11834 } 11019 }
11835 11020
11836 /** 11021 /**
11837 * Instances of the class `InterpolationExpression` represent an expression embe dded in a 11022 * An expression embedded in a string interpolation.
11838 * string interpolation.
11839 * 11023 *
11840 * <pre> 11024 * > interpolationExpression ::=
11841 * interpolationExpression ::= 11025 * > '$' [SimpleIdentifier]
11842 * '$' [SimpleIdentifier] 11026 * > | '$' '{' [Expression] '}'
11843 * | '$' '{' [Expression] '}'
11844 * </pre>
11845 */ 11027 */
11846 class InterpolationExpression extends InterpolationElement { 11028 class InterpolationExpression extends InterpolationElement {
11847 /** 11029 /**
11848 * The token used to introduce the interpolation expression; either '$' if the expression is a 11030 * The token used to introduce the interpolation expression; either '$' if the
11849 * simple identifier or '${' if the expression is a full expression. 11031 * expression is a simple identifier or '${' if the expression is a full
11032 * expression.
11850 */ 11033 */
11851 Token leftBracket; 11034 Token leftBracket;
11852 11035
11853 /** 11036 /**
11854 * The expression to be evaluated for the value to be converted into a string. 11037 * The expression to be evaluated for the value to be converted into a string.
11855 */ 11038 */
11856 Expression _expression; 11039 Expression _expression;
11857 11040
11858 /** 11041 /**
11859 * The right curly bracket, or `null` if the expression is an identifier witho ut brackets. 11042 * The right curly bracket, or `null` if the expression is an identifier
11043 * without brackets.
11860 */ 11044 */
11861 Token rightBracket; 11045 Token rightBracket;
11862 11046
11863 /** 11047 /**
11864 * Initialize a newly created interpolation expression. 11048 * Initialize a newly created interpolation expression.
11865 *
11866 * @param leftBracket the left curly bracket
11867 * @param expression the expression to be evaluated for the value to be conver ted into a string
11868 * @param rightBracket the right curly bracket
11869 */ 11049 */
11870 InterpolationExpression(this.leftBracket, Expression expression, 11050 InterpolationExpression(this.leftBracket, Expression expression,
11871 this.rightBracket) { 11051 this.rightBracket) {
11872 _expression = becomeParentOf(expression); 11052 _expression = becomeParentOf(expression);
11873 } 11053 }
11874 11054
11875 @override 11055 @override
11876 Token get beginToken => leftBracket; 11056 Token get beginToken => leftBracket;
11877 11057
11878 @override 11058 @override
11879 Iterable get childEntities => new ChildEntities() 11059 Iterable get childEntities => new ChildEntities()
11880 ..add(leftBracket) 11060 ..add(leftBracket)
11881 ..add(_expression) 11061 ..add(_expression)
11882 ..add(rightBracket); 11062 ..add(rightBracket);
11883 11063
11884 @override 11064 @override
11885 Token get endToken { 11065 Token get endToken {
11886 if (rightBracket != null) { 11066 if (rightBracket != null) {
11887 return rightBracket; 11067 return rightBracket;
11888 } 11068 }
11889 return _expression.endToken; 11069 return _expression.endToken;
11890 } 11070 }
11891 11071
11892 /** 11072 /**
11893 * Return the expression to be evaluated for the value to be converted into a string. 11073 * Return the expression to be evaluated for the value to be converted into a
11894 * 11074 * string.
11895 * @return the expression to be evaluated for the value to be converted into a string
11896 */ 11075 */
11897 Expression get expression => _expression; 11076 Expression get expression => _expression;
11898 11077
11899 /** 11078 /**
11900 * Set the expression to be evaluated for the value to be converted into a str ing to the given 11079 * Set the expression to be evaluated for the value to be converted into a
11901 * expression. 11080 * string to the given [expression].
11902 *
11903 * @param expression the expression to be evaluated for the value to be conver ted into a string
11904 */ 11081 */
11905 void set expression(Expression expression) { 11082 void set expression(Expression expression) {
11906 _expression = becomeParentOf(expression); 11083 _expression = becomeParentOf(expression);
11907 } 11084 }
11908 11085
11909 @override 11086 @override
11910 accept(AstVisitor visitor) => visitor.visitInterpolationExpression(this); 11087 accept(AstVisitor visitor) => visitor.visitInterpolationExpression(this);
11911 11088
11912 @override 11089 @override
11913 void visitChildren(AstVisitor visitor) { 11090 void visitChildren(AstVisitor visitor) {
11914 safelyVisitChild(_expression, visitor); 11091 _safelyVisitChild(_expression, visitor);
11915 } 11092 }
11916 } 11093 }
11917 11094
11918 /** 11095 /**
11919 * Instances of the class `InterpolationString` represent a non-empty substring of an 11096 * A non-empty substring of an interpolated string.
11920 * interpolated string.
11921 * 11097 *
11922 * <pre> 11098 * > interpolationString ::=
11923 * interpolationString ::= 11099 * > characters
11924 * characters
11925 * </pre>
11926 */ 11100 */
11927 class InterpolationString extends InterpolationElement { 11101 class InterpolationString extends InterpolationElement {
11928 /** 11102 /**
11929 * The characters that will be added to the string. 11103 * The characters that will be added to the string.
11930 */ 11104 */
11931 Token contents; 11105 Token contents;
11932 11106
11933 /** 11107 /**
11934 * The value of the literal. 11108 * The value of the literal.
11935 */ 11109 */
11936 String _value; 11110 String _value;
11937 11111
11938 /** 11112 /**
11939 * Initialize a newly created string of characters that are part of a string i nterpolation. 11113 * Initialize a newly created string of characters that are part of a string
11940 * 11114 * interpolation.
11941 * @param the characters that will be added to the string
11942 * @param value the value of the literal
11943 */ 11115 */
11944 InterpolationString(this.contents, String value) { 11116 InterpolationString(this.contents, String value) {
11945 _value = value; 11117 _value = value;
11946 } 11118 }
11947 11119
11948 @override 11120 @override
11949 Token get beginToken => contents; 11121 Token get beginToken => contents;
11950 11122
11951 /** 11123 /**
11952 * TODO(paulberry): untested. 11124 * TODO(paulberry): untested.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
11985 offset += 1; 11157 offset += 1;
11986 } 11158 }
11987 return offset; 11159 return offset;
11988 } 11160 }
11989 11161
11990 @override 11162 @override
11991 Token get endToken => contents; 11163 Token get endToken => contents;
11992 11164
11993 /** 11165 /**
11994 * Return the value of the literal. 11166 * Return the value of the literal.
11995 *
11996 * @return the value of the literal
11997 */ 11167 */
11998 String get value => _value; 11168 String get value => _value;
11999 11169
12000 /** 11170 /**
12001 * Set the value of the literal to the given string. 11171 * Set the value of the literal to the given [string].
12002 *
12003 * @param string the value of the literal
12004 */ 11172 */
12005 void set value(String string) { 11173 void set value(String string) {
12006 _value = string; 11174 _value = string;
12007 } 11175 }
12008 11176
12009 @override 11177 @override
12010 accept(AstVisitor visitor) => visitor.visitInterpolationString(this); 11178 accept(AstVisitor visitor) => visitor.visitInterpolationString(this);
12011 11179
12012 @override 11180 @override
12013 void visitChildren(AstVisitor visitor) { 11181 void visitChildren(AstVisitor visitor) {
12014 } 11182 }
12015 } 11183 }
12016 11184
12017 /** 11185 /**
12018 * Instances of the class `IsExpression` represent an is expression. 11186 * An is expression.
12019 * 11187 *
12020 * <pre> 11188 * > isExpression ::=
12021 * isExpression ::= 11189 * > [Expression] 'is' '!'? [TypeName]
12022 * [Expression] 'is' '!'? [TypeName]
12023 * </pre>
12024 */ 11190 */
12025 class IsExpression extends Expression { 11191 class IsExpression extends Expression {
12026 /** 11192 /**
12027 * The expression used to compute the value whose type is being tested. 11193 * The expression used to compute the value whose type is being tested.
12028 */ 11194 */
12029 Expression _expression; 11195 Expression _expression;
12030 11196
12031 /** 11197 /**
12032 * The is operator. 11198 * The is operator.
12033 */ 11199 */
12034 Token isOperator; 11200 Token isOperator;
12035 11201
12036 /** 11202 /**
12037 * The not operator, or `null` if the sense of the test is not negated. 11203 * The not operator, or `null` if the sense of the test is not negated.
12038 */ 11204 */
12039 Token notOperator; 11205 Token notOperator;
12040 11206
12041 /** 11207 /**
12042 * The name of the type being tested for. 11208 * The name of the type being tested for.
12043 */ 11209 */
12044 TypeName _type; 11210 TypeName _type;
12045 11211
12046 /** 11212 /**
12047 * Initialize a newly created is expression. 11213 * Initialize a newly created is expression. The [notOperator] can be `null`
12048 * 11214 * if the sense of the test is not negated.
12049 * @param expression the expression used to compute the value whose type is be ing tested
12050 * @param isOperator the is operator
12051 * @param notOperator the not operator, or `null` if the sense of the test is not negated
12052 * @param type the name of the type being tested for
12053 */ 11215 */
12054 IsExpression(Expression expression, this.isOperator, this.notOperator, 11216 IsExpression(Expression expression, this.isOperator, this.notOperator,
12055 TypeName type) { 11217 TypeName type) {
12056 _expression = becomeParentOf(expression); 11218 _expression = becomeParentOf(expression);
12057 _type = becomeParentOf(type); 11219 _type = becomeParentOf(type);
12058 } 11220 }
12059 11221
12060 @override 11222 @override
12061 Token get beginToken => _expression.beginToken; 11223 Token get beginToken => _expression.beginToken;
12062 11224
12063 @override 11225 @override
12064 Iterable get childEntities => new ChildEntities() 11226 Iterable get childEntities => new ChildEntities()
12065 ..add(_expression) 11227 ..add(_expression)
12066 ..add(isOperator) 11228 ..add(isOperator)
12067 ..add(notOperator) 11229 ..add(notOperator)
12068 ..add(_type); 11230 ..add(_type);
12069 11231
12070 @override 11232 @override
12071 Token get endToken => _type.endToken; 11233 Token get endToken => _type.endToken;
12072 11234
12073 /** 11235 /**
12074 * Return the expression used to compute the value whose type is being tested. 11236 * Return the expression used to compute the value whose type is being tested.
12075 *
12076 * @return the expression used to compute the value whose type is being tested
12077 */ 11237 */
12078 Expression get expression => _expression; 11238 Expression get expression => _expression;
12079 11239
12080 /** 11240 /**
12081 * Set the expression used to compute the value whose type is being tested to the given 11241 * Set the expression used to compute the value whose type is being tested to
12082 * expression. 11242 * the given [expression].
12083 *
12084 * @param expression the expression used to compute the value whose type is be ing tested
12085 */ 11243 */
12086 void set expression(Expression expression) { 11244 void set expression(Expression expression) {
12087 _expression = becomeParentOf(expression); 11245 _expression = becomeParentOf(expression);
12088 } 11246 }
12089 11247
12090 @override 11248 @override
12091 int get precedence => 7; 11249 int get precedence => 7;
12092 11250
12093 /** 11251 /**
12094 * Return the name of the type being tested for. 11252 * Return the name of the type being tested for.
12095 *
12096 * @return the name of the type being tested for
12097 */ 11253 */
12098 TypeName get type => _type; 11254 TypeName get type => _type;
12099 11255
12100 /** 11256 /**
12101 * Set the name of the type being tested for to the given name. 11257 * Set the name of the type being tested for to the given [name].
12102 *
12103 * @param name the name of the type being tested for
12104 */ 11258 */
12105 void set type(TypeName name) { 11259 void set type(TypeName name) {
12106 _type = becomeParentOf(name); 11260 _type = becomeParentOf(name);
12107 } 11261 }
12108 11262
12109 @override 11263 @override
12110 accept(AstVisitor visitor) => visitor.visitIsExpression(this); 11264 accept(AstVisitor visitor) => visitor.visitIsExpression(this);
12111 11265
12112 @override 11266 @override
12113 void visitChildren(AstVisitor visitor) { 11267 void visitChildren(AstVisitor visitor) {
12114 safelyVisitChild(_expression, visitor); 11268 _safelyVisitChild(_expression, visitor);
12115 safelyVisitChild(_type, visitor); 11269 _safelyVisitChild(_type, visitor);
12116 } 11270 }
12117 } 11271 }
12118 11272
12119 /** 11273 /**
12120 * Instances of the class `Label` represent a label. 11274 * A label on either a [LabeledStatement] or a [NamedExpression].
12121 * 11275 *
12122 * <pre> 11276 * > label ::=
12123 * label ::= 11277 * > [SimpleIdentifier] ':'
12124 * [SimpleIdentifier] ':'
12125 * </pre>
12126 */ 11278 */
12127 class Label extends AstNode { 11279 class Label extends AstNode {
12128 /** 11280 /**
12129 * The label being associated with the statement. 11281 * The label being associated with the statement.
12130 */ 11282 */
12131 SimpleIdentifier _label; 11283 SimpleIdentifier _label;
12132 11284
12133 /** 11285 /**
12134 * The colon that separates the label from the statement. 11286 * The colon that separates the label from the statement.
12135 */ 11287 */
12136 Token colon; 11288 Token colon;
12137 11289
12138 /** 11290 /**
12139 * Initialize a newly created label. 11291 * Initialize a newly created label.
12140 *
12141 * @param label the label being applied
12142 * @param colon the colon that separates the label from whatever follows
12143 */ 11292 */
12144 Label(SimpleIdentifier label, this.colon) { 11293 Label(SimpleIdentifier label, this.colon) {
12145 _label = becomeParentOf(label); 11294 _label = becomeParentOf(label);
12146 } 11295 }
12147 11296
12148 @override 11297 @override
12149 Token get beginToken => _label.beginToken; 11298 Token get beginToken => _label.beginToken;
12150 11299
12151 /** 11300 /**
12152 * TODO(paulberry): untested. 11301 * TODO(paulberry): untested.
12153 */ 11302 */
12154 @override 11303 @override
12155 Iterable get childEntities => new ChildEntities() 11304 Iterable get childEntities => new ChildEntities()
12156 ..add(_label) 11305 ..add(_label)
12157 ..add(colon); 11306 ..add(colon);
12158 11307
12159 @override 11308 @override
12160 Token get endToken => colon; 11309 Token get endToken => colon;
12161 11310
12162 /** 11311 /**
12163 * Return the label being associated with the statement. 11312 * Return the label being associated with the statement.
12164 *
12165 * @return the label being associated with the statement
12166 */ 11313 */
12167 SimpleIdentifier get label => _label; 11314 SimpleIdentifier get label => _label;
12168 11315
12169 /** 11316 /**
12170 * Set the label being associated with the statement to the given label. 11317 * Set the label being associated with the statement to the given [label].
12171 *
12172 * @param label the label being associated with the statement
12173 */ 11318 */
12174 void set label(SimpleIdentifier label) { 11319 void set label(SimpleIdentifier label) {
12175 _label = becomeParentOf(label); 11320 _label = becomeParentOf(label);
12176 } 11321 }
12177 11322
12178 @override 11323 @override
12179 accept(AstVisitor visitor) => visitor.visitLabel(this); 11324 accept(AstVisitor visitor) => visitor.visitLabel(this);
12180 11325
12181 @override 11326 @override
12182 void visitChildren(AstVisitor visitor) { 11327 void visitChildren(AstVisitor visitor) {
12183 safelyVisitChild(_label, visitor); 11328 _safelyVisitChild(_label, visitor);
12184 } 11329 }
12185 } 11330 }
12186 11331
12187 /** 11332 /**
12188 * Instances of the class `LabeledStatement` represent a statement that has a la bel associated 11333 * A statement that has a label associated with them.
12189 * with them.
12190 * 11334 *
12191 * <pre> 11335 * > labeledStatement ::=
12192 * labeledStatement ::= 11336 * > [Label]+ [Statement]
12193 * [Label]+ [Statement]
12194 * </pre>
12195 */ 11337 */
12196 class LabeledStatement extends Statement { 11338 class LabeledStatement extends Statement {
12197 /** 11339 /**
12198 * The labels being associated with the statement. 11340 * The labels being associated with the statement.
12199 */ 11341 */
12200 NodeList<Label> _labels; 11342 NodeList<Label> _labels;
12201 11343
12202 /** 11344 /**
12203 * The statement with which the labels are being associated. 11345 * The statement with which the labels are being associated.
12204 */ 11346 */
12205 Statement _statement; 11347 Statement _statement;
12206 11348
12207 /** 11349 /**
12208 * Initialize a newly created labeled statement. 11350 * Initialize a newly created labeled statement.
12209 *
12210 * @param labels the labels being associated with the statement
12211 * @param statement the statement with which the labels are being associated
12212 */ 11351 */
12213 LabeledStatement(List<Label> labels, Statement statement) { 11352 LabeledStatement(List<Label> labels, Statement statement) {
12214 _labels = new NodeList<Label>(this, labels); 11353 _labels = new NodeList<Label>(this, labels);
12215 _statement = becomeParentOf(statement); 11354 _statement = becomeParentOf(statement);
12216 } 11355 }
12217 11356
12218 @override 11357 @override
12219 Token get beginToken { 11358 Token get beginToken {
12220 if (!_labels.isEmpty) { 11359 if (!_labels.isEmpty) {
12221 return _labels.beginToken; 11360 return _labels.beginToken;
12222 } 11361 }
12223 return _statement.beginToken; 11362 return _statement.beginToken;
12224 } 11363 }
12225 11364
12226 /** 11365 /**
12227 * TODO(paulberry): untested. 11366 * TODO(paulberry): untested.
12228 */ 11367 */
12229 @override 11368 @override
12230 Iterable get childEntities => new ChildEntities() 11369 Iterable get childEntities => new ChildEntities()
12231 ..addAll(_labels) 11370 ..addAll(_labels)
12232 ..add(_statement); 11371 ..add(_statement);
12233 11372
12234 @override 11373 @override
12235 Token get endToken => _statement.endToken; 11374 Token get endToken => _statement.endToken;
12236 11375
12237 /** 11376 /**
12238 * Return the labels being associated with the statement. 11377 * Return the labels being associated with the statement.
12239 *
12240 * @return the labels being associated with the statement
12241 */ 11378 */
12242 NodeList<Label> get labels => _labels; 11379 NodeList<Label> get labels => _labels;
12243 11380
12244 /** 11381 /**
12245 * Return the statement with which the labels are being associated. 11382 * Return the statement with which the labels are being associated.
12246 *
12247 * @return the statement with which the labels are being associated
12248 */ 11383 */
12249 Statement get statement => _statement; 11384 Statement get statement => _statement;
12250 11385
12251 /** 11386 /**
12252 * Set the statement with which the labels are being associated to the given s tatement. 11387 * Set the statement with which the labels are being associated to the given
12253 * 11388 * [statement].
12254 * @param statement the statement with which the labels are being associated
12255 */ 11389 */
12256 void set statement(Statement statement) { 11390 void set statement(Statement statement) {
12257 _statement = becomeParentOf(statement); 11391 _statement = becomeParentOf(statement);
12258 } 11392 }
12259 11393
12260 @override 11394 @override
12261 Statement get unlabeled => _statement.unlabeled; 11395 Statement get unlabeled => _statement.unlabeled;
12262 11396
12263 @override 11397 @override
12264 accept(AstVisitor visitor) => visitor.visitLabeledStatement(this); 11398 accept(AstVisitor visitor) => visitor.visitLabeledStatement(this);
12265 11399
12266 @override 11400 @override
12267 void visitChildren(AstVisitor visitor) { 11401 void visitChildren(AstVisitor visitor) {
12268 _labels.accept(visitor); 11402 _labels.accept(visitor);
12269 safelyVisitChild(_statement, visitor); 11403 _safelyVisitChild(_statement, visitor);
12270 } 11404 }
12271 } 11405 }
12272 11406
12273 /** 11407 /**
12274 * Instances of the class `LibraryDirective` represent a library directive. 11408 * A library directive.
12275 * 11409 *
12276 * <pre> 11410 * > libraryDirective ::=
12277 * libraryDirective ::= 11411 * > [Annotation] 'library' [Identifier] ';'
12278 * [Annotation] 'library' [Identifier] ';'
12279 * </pre>
12280 */ 11412 */
12281 class LibraryDirective extends Directive { 11413 class LibraryDirective extends Directive {
12282 /** 11414 /**
12283 * The token representing the 'library' token. 11415 * The token representing the 'library' token.
12284 */ 11416 */
12285 Token libraryToken; 11417 Token libraryToken;
12286 11418
12287 /** 11419 /**
12288 * The name of the library being defined. 11420 * The name of the library being defined.
12289 */ 11421 */
12290 LibraryIdentifier _name; 11422 LibraryIdentifier _name;
12291 11423
12292 /** 11424 /**
12293 * The semicolon terminating the directive. 11425 * The semicolon terminating the directive.
12294 */ 11426 */
12295 Token semicolon; 11427 Token semicolon;
12296 11428
12297 /** 11429 /**
12298 * Initialize a newly created library directive. 11430 * Initialize a newly created library directive. Either or both of the
12299 * 11431 * [comment] and [metadata] can be `null` if the directive does not have the
12300 * @param comment the documentation comment associated with this directive 11432 * corresponding attribute.
12301 * @param metadata the annotations associated with the directive
12302 * @param libraryToken the token representing the 'library' token
12303 * @param name the name of the library being defined
12304 * @param semicolon the semicolon terminating the directive
12305 */ 11433 */
12306 LibraryDirective(Comment comment, List<Annotation> metadata, 11434 LibraryDirective(Comment comment, List<Annotation> metadata,
12307 this.libraryToken, LibraryIdentifier name, this.semicolon) 11435 this.libraryToken, LibraryIdentifier name, this.semicolon)
12308 : super(comment, metadata) { 11436 : super(comment, metadata) {
12309 _name = becomeParentOf(name); 11437 _name = becomeParentOf(name);
12310 } 11438 }
12311 11439
12312 @override 11440 @override
12313 Iterable get childEntities => super._childEntities 11441 Iterable get childEntities => super._childEntities
12314 ..add(libraryToken) 11442 ..add(libraryToken)
12315 ..add(_name) 11443 ..add(_name)
12316 ..add(semicolon); 11444 ..add(semicolon);
12317 11445
12318 @override 11446 @override
12319 Token get endToken => semicolon; 11447 Token get endToken => semicolon;
12320 11448
12321 @override 11449 @override
12322 Token get firstTokenAfterCommentAndMetadata => libraryToken; 11450 Token get firstTokenAfterCommentAndMetadata => libraryToken;
12323 11451
12324 @override 11452 @override
12325 Token get keyword => libraryToken; 11453 Token get keyword => libraryToken;
12326 11454
12327 /** 11455 /**
12328 * Return the name of the library being defined. 11456 * Return the name of the library being defined.
12329 *
12330 * @return the name of the library being defined
12331 */ 11457 */
12332 LibraryIdentifier get name => _name; 11458 LibraryIdentifier get name => _name;
12333 11459
12334 /** 11460 /**
12335 * Set the name of the library being defined to the given name. 11461 * Set the name of the library being defined to the given [name].
12336 *
12337 * @param name the name of the library being defined
12338 */ 11462 */
12339 void set name(LibraryIdentifier name) { 11463 void set name(LibraryIdentifier name) {
12340 _name = becomeParentOf(name); 11464 _name = becomeParentOf(name);
12341 } 11465 }
12342 11466
12343 @override 11467 @override
12344 accept(AstVisitor visitor) => visitor.visitLibraryDirective(this); 11468 accept(AstVisitor visitor) => visitor.visitLibraryDirective(this);
12345 11469
12346 @override 11470 @override
12347 void visitChildren(AstVisitor visitor) { 11471 void visitChildren(AstVisitor visitor) {
12348 super.visitChildren(visitor); 11472 super.visitChildren(visitor);
12349 safelyVisitChild(_name, visitor); 11473 _safelyVisitChild(_name, visitor);
12350 } 11474 }
12351 } 11475 }
12352 11476
12353 /** 11477 /**
12354 * Instances of the class `LibraryIdentifier` represent the identifier for a lib rary. 11478 * The identifier for a library.
12355 * 11479 *
12356 * <pre> 11480 * > libraryIdentifier ::=
12357 * libraryIdentifier ::= 11481 * > [SimpleIdentifier] ('.' [SimpleIdentifier])*
12358 * [SimpleIdentifier] ('.' [SimpleIdentifier])*
12359 * </pre>
12360 */ 11482 */
12361 class LibraryIdentifier extends Identifier { 11483 class LibraryIdentifier extends Identifier {
12362 /** 11484 /**
12363 * The components of the identifier. 11485 * The components of the identifier.
12364 */ 11486 */
12365 NodeList<SimpleIdentifier> _components; 11487 NodeList<SimpleIdentifier> _components;
12366 11488
12367 /** 11489 /**
12368 * Initialize a newly created prefixed identifier. 11490 * Initialize a newly created prefixed identifier.
12369 *
12370 * @param components the components of the identifier
12371 */ 11491 */
12372 LibraryIdentifier(List<SimpleIdentifier> components) { 11492 LibraryIdentifier(List<SimpleIdentifier> components) {
12373 _components = new NodeList<SimpleIdentifier>(this, components); 11493 _components = new NodeList<SimpleIdentifier>(this, components);
12374 } 11494 }
12375 11495
12376 @override 11496 @override
12377 Token get beginToken => _components.beginToken; 11497 Token get beginToken => _components.beginToken;
12378 11498
12379 @override 11499 @override
12380 Element get bestElement => staticElement; 11500 Element get bestElement => staticElement;
12381 11501
12382 /** 11502 /**
12383 * TODO(paulberry): add "." tokens. 11503 * TODO(paulberry): add "." tokens.
12384 */ 11504 */
12385 @override 11505 @override
12386 Iterable get childEntities => new ChildEntities()..addAll(_components); 11506 Iterable get childEntities => new ChildEntities()..addAll(_components);
12387 11507
12388 /** 11508 /**
12389 * Return the components of the identifier. 11509 * Return the components of the identifier.
12390 *
12391 * @return the components of the identifier
12392 */ 11510 */
12393 NodeList<SimpleIdentifier> get components => _components; 11511 NodeList<SimpleIdentifier> get components => _components;
12394 11512
12395 @override 11513 @override
12396 Token get endToken => _components.endToken; 11514 Token get endToken => _components.endToken;
12397 11515
12398 @override 11516 @override
12399 String get name { 11517 String get name {
12400 StringBuffer buffer = new StringBuffer(); 11518 StringBuffer buffer = new StringBuffer();
12401 bool needsPeriod = false; 11519 bool needsPeriod = false;
(...skipping 20 matching lines...) Expand all
12422 @override 11540 @override
12423 accept(AstVisitor visitor) => visitor.visitLibraryIdentifier(this); 11541 accept(AstVisitor visitor) => visitor.visitLibraryIdentifier(this);
12424 11542
12425 @override 11543 @override
12426 void visitChildren(AstVisitor visitor) { 11544 void visitChildren(AstVisitor visitor) {
12427 _components.accept(visitor); 11545 _components.accept(visitor);
12428 } 11546 }
12429 } 11547 }
12430 11548
12431 /** 11549 /**
12432 * Instances of the class `ListLiteral` represent a list literal. 11550 * A list literal.
12433 * 11551 *
12434 * <pre> 11552 * > listLiteral ::=
12435 * listLiteral ::= 11553 * > 'const'? ('<' [TypeName] '>')? '[' ([Expression] ','?)? ']'
12436 * 'const'? ('<' [TypeName] '>')? '[' ([Expression] ','?)? ']'
12437 * </pre>
12438 */ 11554 */
12439 class ListLiteral extends TypedLiteral { 11555 class ListLiteral extends TypedLiteral {
12440 /** 11556 /**
12441 * The left square bracket. 11557 * The left square bracket.
12442 */ 11558 */
12443 Token leftBracket; 11559 Token leftBracket;
12444 11560
12445 /** 11561 /**
12446 * The expressions used to compute the elements of the list. 11562 * The expressions used to compute the elements of the list.
12447 */ 11563 */
12448 NodeList<Expression> _elements; 11564 NodeList<Expression> _elements;
12449 11565
12450 /** 11566 /**
12451 * The right square bracket. 11567 * The right square bracket.
12452 */ 11568 */
12453 Token rightBracket; 11569 Token rightBracket;
12454 11570
12455 /** 11571 /**
12456 * Initialize a newly created list literal. 11572 * Initialize a newly created list literal. The [constKeyword] can be `null`
12457 * 11573 * if the literal is not a constant. The [typeArguments] can be `null` if no
12458 * @param constKeyword the token representing the 'const' keyword 11574 * type arguments were declared. The list of [elements] can be `null` if the
12459 * @param typeArguments the type argument associated with this literal, or `nu ll` if no type 11575 * list is empty.
12460 * arguments were declared
12461 * @param leftBracket the left square bracket
12462 * @param elements the expressions used to compute the elements of the list
12463 * @param rightBracket the right square bracket
12464 */ 11576 */
12465 ListLiteral(Token constKeyword, TypeArgumentList typeArguments, 11577 ListLiteral(Token constKeyword, TypeArgumentList typeArguments,
12466 this.leftBracket, List<Expression> elements, this.rightBracket) 11578 this.leftBracket, List<Expression> elements, this.rightBracket)
12467 : super(constKeyword, typeArguments) { 11579 : super(constKeyword, typeArguments) {
12468 _elements = new NodeList<Expression>(this, elements); 11580 _elements = new NodeList<Expression>(this, elements);
12469 } 11581 }
12470 11582
12471 @override 11583 @override
12472 Token get beginToken { 11584 Token get beginToken {
12473 if (constKeyword != null) { 11585 if (constKeyword != null) {
(...skipping 10 matching lines...) Expand all
12484 * TODO(paulberry): add commas. 11596 * TODO(paulberry): add commas.
12485 */ 11597 */
12486 @override 11598 @override
12487 Iterable get childEntities => super._childEntities 11599 Iterable get childEntities => super._childEntities
12488 ..add(leftBracket) 11600 ..add(leftBracket)
12489 ..addAll(_elements) 11601 ..addAll(_elements)
12490 ..add(rightBracket); 11602 ..add(rightBracket);
12491 11603
12492 /** 11604 /**
12493 * Return the expressions used to compute the elements of the list. 11605 * Return the expressions used to compute the elements of the list.
12494 *
12495 * @return the expressions used to compute the elements of the list
12496 */ 11606 */
12497 NodeList<Expression> get elements => _elements; 11607 NodeList<Expression> get elements => _elements;
12498 11608
12499 @override 11609 @override
12500 Token get endToken => rightBracket; 11610 Token get endToken => rightBracket;
12501 11611
12502 @override 11612 @override
12503 accept(AstVisitor visitor) => visitor.visitListLiteral(this); 11613 accept(AstVisitor visitor) => visitor.visitListLiteral(this);
12504 11614
12505 @override 11615 @override
12506 void visitChildren(AstVisitor visitor) { 11616 void visitChildren(AstVisitor visitor) {
12507 super.visitChildren(visitor); 11617 super.visitChildren(visitor);
12508 _elements.accept(visitor); 11618 _elements.accept(visitor);
12509 } 11619 }
12510 } 11620 }
12511 11621
12512 /** 11622 /**
12513 * The abstract class `Literal` defines the behavior common to nodes that repres ent a literal 11623 * A node that represents a literal expression.
12514 * expression.
12515 * 11624 *
12516 * <pre> 11625 * > literal ::=
12517 * literal ::= 11626 * > [BooleanLiteral]
12518 * [BooleanLiteral] 11627 * > | [DoubleLiteral]
12519 * | [DoubleLiteral] 11628 * > | [IntegerLiteral]
12520 * | [IntegerLiteral] 11629 * > | [ListLiteral]
12521 * | [ListLiteral] 11630 * > | [MapLiteral]
12522 * | [MapLiteral] 11631 * > | [NullLiteral]
12523 * | [NullLiteral] 11632 * > | [StringLiteral]
12524 * | [StringLiteral]
12525 * </pre>
12526 */ 11633 */
12527 abstract class Literal extends Expression { 11634 abstract class Literal extends Expression {
12528 @override 11635 @override
12529 int get precedence => 16; 11636 int get precedence => 16;
12530 } 11637 }
12531 11638
12532 /** 11639 /**
12533 * Instances of the class `MapLiteral` represent a literal map. 11640 * A literal map.
12534 * 11641 *
12535 * <pre> 11642 * > mapLiteral ::=
12536 * mapLiteral ::= 11643 * > 'const'? ('<' [TypeName] (',' [TypeName])* '>')?
12537 * 'const'? ('<' [TypeName] (',' [TypeName])* '>')? '{' ([MapLiteralEntry] ( ',' [MapLiteralEntry])* ','?)? '}' 11644 * > '{' ([MapLiteralEntry] (',' [MapLiteralEntry])* ','?)? '}'
12538 * </pre>
12539 */ 11645 */
12540 class MapLiteral extends TypedLiteral { 11646 class MapLiteral extends TypedLiteral {
12541 /** 11647 /**
12542 * The left curly bracket. 11648 * The left curly bracket.
12543 */ 11649 */
12544 Token leftBracket; 11650 Token leftBracket;
12545 11651
12546 /** 11652 /**
12547 * The entries in the map. 11653 * The entries in the map.
12548 */ 11654 */
12549 NodeList<MapLiteralEntry> _entries; 11655 NodeList<MapLiteralEntry> _entries;
12550 11656
12551 /** 11657 /**
12552 * The right curly bracket. 11658 * The right curly bracket.
12553 */ 11659 */
12554 Token rightBracket; 11660 Token rightBracket;
12555 11661
12556 /** 11662 /**
12557 * Initialize a newly created map literal. 11663 * Initialize a newly created map literal. The [constKeyword] can be `null` if
12558 * 11664 * the literal is not a constant. The [typeArguments] can be `null` if no type
12559 * @param constKeyword the token representing the 'const' keyword 11665 * arguments were declared. The [entries] can be `null` if the map is empty.
12560 * @param typeArguments the type argument associated with this literal, or `nu ll` if no type
12561 * arguments were declared
12562 * @param leftBracket the left curly bracket
12563 * @param entries the entries in the map
12564 * @param rightBracket the right curly bracket
12565 */ 11666 */
12566 MapLiteral(Token constKeyword, TypeArgumentList typeArguments, 11667 MapLiteral(Token constKeyword, TypeArgumentList typeArguments,
12567 this.leftBracket, List<MapLiteralEntry> entries, this.rightBracket) 11668 this.leftBracket, List<MapLiteralEntry> entries, this.rightBracket)
12568 : super(constKeyword, typeArguments) { 11669 : super(constKeyword, typeArguments) {
12569 _entries = new NodeList<MapLiteralEntry>(this, entries); 11670 _entries = new NodeList<MapLiteralEntry>(this, entries);
12570 } 11671 }
12571 11672
12572 @override 11673 @override
12573 Token get beginToken { 11674 Token get beginToken {
12574 if (constKeyword != null) { 11675 if (constKeyword != null) {
(...skipping 14 matching lines...) Expand all
12589 Iterable get childEntities => super._childEntities 11690 Iterable get childEntities => super._childEntities
12590 ..add(leftBracket) 11691 ..add(leftBracket)
12591 ..addAll(entries) 11692 ..addAll(entries)
12592 ..add(rightBracket); 11693 ..add(rightBracket);
12593 11694
12594 @override 11695 @override
12595 Token get endToken => rightBracket; 11696 Token get endToken => rightBracket;
12596 11697
12597 /** 11698 /**
12598 * Return the entries in the map. 11699 * Return the entries in the map.
12599 *
12600 * @return the entries in the map
12601 */ 11700 */
12602 NodeList<MapLiteralEntry> get entries => _entries; 11701 NodeList<MapLiteralEntry> get entries => _entries;
12603 11702
12604 @override 11703 @override
12605 accept(AstVisitor visitor) => visitor.visitMapLiteral(this); 11704 accept(AstVisitor visitor) => visitor.visitMapLiteral(this);
12606 11705
12607 @override 11706 @override
12608 void visitChildren(AstVisitor visitor) { 11707 void visitChildren(AstVisitor visitor) {
12609 super.visitChildren(visitor); 11708 super.visitChildren(visitor);
12610 _entries.accept(visitor); 11709 _entries.accept(visitor);
12611 } 11710 }
12612 } 11711 }
12613 11712
12614 /** 11713 /**
12615 * Instances of the class `MapLiteralEntry` represent a single key/value pair in a map 11714 * A single key/value pair in a map literal.
12616 * literal.
12617 * 11715 *
12618 * <pre> 11716 * > mapLiteralEntry ::=
12619 * mapLiteralEntry ::= 11717 * > [Expression] ':' [Expression]
12620 * [Expression] ':' [Expression]
12621 * </pre>
12622 */ 11718 */
12623 class MapLiteralEntry extends AstNode { 11719 class MapLiteralEntry extends AstNode {
12624 /** 11720 /**
12625 * The expression computing the key with which the value will be associated. 11721 * The expression computing the key with which the value will be associated.
12626 */ 11722 */
12627 Expression _key; 11723 Expression _key;
12628 11724
12629 /** 11725 /**
12630 * The colon that separates the key from the value. 11726 * The colon that separates the key from the value.
12631 */ 11727 */
12632 Token separator; 11728 Token separator;
12633 11729
12634 /** 11730 /**
12635 * The expression computing the value that will be associated with the key. 11731 * The expression computing the value that will be associated with the key.
12636 */ 11732 */
12637 Expression _value; 11733 Expression _value;
12638 11734
12639 /** 11735 /**
12640 * Initialize a newly created map literal entry. 11736 * Initialize a newly created map literal entry.
12641 *
12642 * @param key the expression computing the key with which the value will be as sociated
12643 * @param separator the colon that separates the key from the value
12644 * @param value the expression computing the value that will be associated wit h the key
12645 */ 11737 */
12646 MapLiteralEntry(Expression key, this.separator, Expression value) { 11738 MapLiteralEntry(Expression key, this.separator, Expression value) {
12647 _key = becomeParentOf(key); 11739 _key = becomeParentOf(key);
12648 _value = becomeParentOf(value); 11740 _value = becomeParentOf(value);
12649 } 11741 }
12650 11742
12651 @override 11743 @override
12652 Token get beginToken => _key.beginToken; 11744 Token get beginToken => _key.beginToken;
12653 11745
12654 /** 11746 /**
12655 * TODO(paulberry): untested. 11747 * TODO(paulberry): untested.
12656 */ 11748 */
12657 @override 11749 @override
12658 Iterable get childEntities => new ChildEntities() 11750 Iterable get childEntities => new ChildEntities()
12659 ..add(_key) 11751 ..add(_key)
12660 ..add(separator) 11752 ..add(separator)
12661 ..add(_value); 11753 ..add(_value);
12662 11754
12663 @override 11755 @override
12664 Token get endToken => _value.endToken; 11756 Token get endToken => _value.endToken;
12665 11757
12666 /** 11758 /**
12667 * Return the expression computing the key with which the value will be associ ated. 11759 * Return the expression computing the key with which the value will be
12668 * 11760 * associated.
12669 * @return the expression computing the key with which the value will be assoc iated
12670 */ 11761 */
12671 Expression get key => _key; 11762 Expression get key => _key;
12672 11763
12673 /** 11764 /**
12674 * Set the expression computing the key with which the value will be associate d to the given 11765 * Set the expression computing the key with which the value will be
12675 * string. 11766 * associated to the given [string].
12676 *
12677 * @param string the expression computing the key with which the value will be associated
12678 */ 11767 */
12679 void set key(Expression string) { 11768 void set key(Expression string) {
12680 _key = becomeParentOf(string); 11769 _key = becomeParentOf(string);
12681 } 11770 }
12682 11771
12683 /** 11772 /**
12684 * Return the expression computing the value that will be associated with the key. 11773 * Return the expression computing the value that will be associated with the
12685 * 11774 * key.
12686 * @return the expression computing the value that will be associated with the key
12687 */ 11775 */
12688 Expression get value => _value; 11776 Expression get value => _value;
12689 11777
12690 /** 11778 /**
12691 * Set the expression computing the value that will be associated with the key to the given 11779 * Set the expression computing the value that will be associated with the key
12692 * expression. 11780 * to the given [expression].
12693 *
12694 * @param expression the expression computing the value that will be associate d with the key
12695 */ 11781 */
12696 void set value(Expression expression) { 11782 void set value(Expression expression) {
12697 _value = becomeParentOf(expression); 11783 _value = becomeParentOf(expression);
12698 } 11784 }
12699 11785
12700 @override 11786 @override
12701 accept(AstVisitor visitor) => visitor.visitMapLiteralEntry(this); 11787 accept(AstVisitor visitor) => visitor.visitMapLiteralEntry(this);
12702 11788
12703 @override 11789 @override
12704 void visitChildren(AstVisitor visitor) { 11790 void visitChildren(AstVisitor visitor) {
12705 safelyVisitChild(_key, visitor); 11791 _safelyVisitChild(_key, visitor);
12706 safelyVisitChild(_value, visitor); 11792 _safelyVisitChild(_value, visitor);
12707 } 11793 }
12708 } 11794 }
12709 11795
12710 /** 11796 /**
12711 * Instances of the class `MethodDeclaration` represent a method declaration. 11797 * A method declaration.
12712 * 11798 *
12713 * <pre> 11799 * > methodDeclaration ::=
12714 * methodDeclaration ::= 11800 * > methodSignature [FunctionBody]
12715 * methodSignature [FunctionBody] 11801 * >
12716 * 11802 * > methodSignature ::=
12717 * methodSignature ::= 11803 * > 'external'? ('abstract' | 'static')? [Type]? ('get' | 'set')?
12718 * 'external'? ('abstract' | 'static')? [Type]? ('get' | 'set')? methodName 11804 * > methodName [FormalParameterList]
12719 * [FormalParameterList] 11805 * >
12720 * 11806 * > methodName ::=
12721 * methodName ::= 11807 * > [SimpleIdentifier]
12722 * [SimpleIdentifier] 11808 * > | 'operator' [SimpleIdentifier]
12723 * | 'operator' [SimpleIdentifier]
12724 * </pre>
12725 */ 11809 */
12726 class MethodDeclaration extends ClassMember { 11810 class MethodDeclaration extends ClassMember {
12727 /** 11811 /**
12728 * The token for the 'external' keyword, or `null` if the constructor is not e xternal. 11812 * The token for the 'external' keyword, or `null` if the constructor is not
11813 * external.
12729 */ 11814 */
12730 Token externalKeyword; 11815 Token externalKeyword;
12731 11816
12732 /** 11817 /**
12733 * The token representing the 'abstract' or 'static' keyword, or `null` if nei ther modifier 11818 * The token representing the 'abstract' or 'static' keyword, or `null` if
12734 * was specified. 11819 * neither modifier was specified.
12735 */ 11820 */
12736 Token modifierKeyword; 11821 Token modifierKeyword;
12737 11822
12738 /** 11823 /**
12739 * The return type of the method, or `null` if no return type was declared. 11824 * The return type of the method, or `null` if no return type was declared.
12740 */ 11825 */
12741 TypeName _returnType; 11826 TypeName _returnType;
12742 11827
12743 /** 11828 /**
12744 * The token representing the 'get' or 'set' keyword, or `null` if this is a m ethod 11829 * The token representing the 'get' or 'set' keyword, or `null` if this is a
12745 * declaration rather than a property declaration. 11830 * method declaration rather than a property declaration.
12746 */ 11831 */
12747 Token propertyKeyword; 11832 Token propertyKeyword;
12748 11833
12749 /** 11834 /**
12750 * The token representing the 'operator' keyword, or `null` if this method doe s not declare 11835 * The token representing the 'operator' keyword, or `null` if this method
12751 * an operator. 11836 * does not declare an operator.
12752 */ 11837 */
12753 Token operatorKeyword; 11838 Token operatorKeyword;
12754 11839
12755 /** 11840 /**
12756 * The name of the method. 11841 * The name of the method.
12757 */ 11842 */
12758 SimpleIdentifier _name; 11843 SimpleIdentifier _name;
12759 11844
12760 /** 11845 /**
12761 * The parameters associated with the method, or `null` if this method declare s a getter. 11846 * The parameters associated with the method, or `null` if this method
11847 * declares a getter.
12762 */ 11848 */
12763 FormalParameterList _parameters; 11849 FormalParameterList _parameters;
12764 11850
12765 /** 11851 /**
12766 * The body of the method. 11852 * The body of the method.
12767 */ 11853 */
12768 FunctionBody _body; 11854 FunctionBody _body;
12769 11855
12770 /** 11856 /**
12771 * Initialize a newly created method declaration. 11857 * Initialize a newly created method declaration. Either or both of the
12772 * 11858 * [comment] and [metadata] can be `null` if the declaration does not have the
12773 * @param externalKeyword the token for the 'external' keyword 11859 * corresponding attribute. The [externalKeyword] can be `null` if the method
12774 * @param comment the documentation comment associated with this method 11860 * is not external. The [modifierKeyword] can be `null` if the method is
12775 * @param metadata the annotations associated with this method 11861 * neither abstract nor static. The [returnType] can be `null` if no return
12776 * @param modifierKeyword the token representing the 'abstract' or 'static' ke yword 11862 * type was specified. The [propertyKeyword] can be `null` if the method is
12777 * @param returnType the return type of the method 11863 * neither a getter or a setter. The [operatorKeyword] can be `null` if the
12778 * @param propertyKeyword the token representing the 'get' or 'set' keyword 11864 * method does not implement an operator. The [parameters] must be `null` if
12779 * @param operatorKeyword the token representing the 'operator' keyword 11865 * this method declares a getter.
12780 * @param name the name of the method
12781 * @param parameters the parameters associated with the method, or `null` if t his method
12782 * declares a getter
12783 * @param body the body of the method
12784 */ 11866 */
12785 MethodDeclaration(Comment comment, List<Annotation> metadata, 11867 MethodDeclaration(Comment comment, List<Annotation> metadata,
12786 this.externalKeyword, this.modifierKeyword, TypeName returnType, 11868 this.externalKeyword, this.modifierKeyword, TypeName returnType,
12787 this.propertyKeyword, this.operatorKeyword, SimpleIdentifier name, 11869 this.propertyKeyword, this.operatorKeyword, SimpleIdentifier name,
12788 FormalParameterList parameters, FunctionBody body) 11870 FormalParameterList parameters, FunctionBody body)
12789 : super(comment, metadata) { 11871 : super(comment, metadata) {
12790 _returnType = becomeParentOf(returnType); 11872 _returnType = becomeParentOf(returnType);
12791 _name = becomeParentOf(name); 11873 _name = becomeParentOf(name);
12792 _parameters = becomeParentOf(parameters); 11874 _parameters = becomeParentOf(parameters);
12793 _body = becomeParentOf(body); 11875 _body = becomeParentOf(body);
12794 } 11876 }
12795 11877
12796 /** 11878 /**
12797 * Return the body of the method. 11879 * Return the body of the method.
12798 *
12799 * @return the body of the method
12800 */ 11880 */
12801 FunctionBody get body => _body; 11881 FunctionBody get body => _body;
12802 11882
12803 /** 11883 /**
12804 * Set the body of the method to the given function body. 11884 * Set the body of the method to the given [functionBody].
12805 *
12806 * @param functionBody the body of the method
12807 */ 11885 */
12808 void set body(FunctionBody functionBody) { 11886 void set body(FunctionBody functionBody) {
12809 _body = becomeParentOf(functionBody); 11887 _body = becomeParentOf(functionBody);
12810 } 11888 }
12811 11889
12812 @override 11890 @override
12813 Iterable get childEntities => super._childEntities 11891 Iterable get childEntities => super._childEntities
12814 ..add(externalKeyword) 11892 ..add(externalKeyword)
12815 ..add(modifierKeyword) 11893 ..add(modifierKeyword)
12816 ..add(_returnType) 11894 ..add(_returnType)
12817 ..add(propertyKeyword) 11895 ..add(propertyKeyword)
12818 ..add(operatorKeyword) 11896 ..add(operatorKeyword)
12819 ..add(_name) 11897 ..add(_name)
12820 ..add(_parameters) 11898 ..add(_parameters)
12821 ..add(_body); 11899 ..add(_body);
12822 11900
12823 /** 11901 /**
12824 * Return the element associated with this method, or `null` if the AST struct ure has not 11902 * Return the element associated with this method, or `null` if the AST
12825 * been resolved. The element can either be a [MethodElement], if this represe nts the 11903 * structure has not been resolved. The element can either be a
12826 * declaration of a normal method, or a [PropertyAccessorElement] if this repr esents the 11904 * [MethodElement], if this represents the declaration of a normal method, or
12827 * declaration of either a getter or a setter. 11905 * a [PropertyAccessorElement] if this represents the declaration of either a
12828 * 11906 * getter or a setter.
12829 * @return the element associated with this method
12830 */ 11907 */
12831 @override 11908 @override
12832 ExecutableElement get element => 11909 ExecutableElement get element =>
12833 _name != null ? (_name.staticElement as ExecutableElement) : null; 11910 _name != null ? (_name.staticElement as ExecutableElement) : null;
12834 11911
12835 @override 11912 @override
12836 Token get endToken => _body.endToken; 11913 Token get endToken => _body.endToken;
12837 11914
12838 @override 11915 @override
12839 Token get firstTokenAfterCommentAndMetadata { 11916 Token get firstTokenAfterCommentAndMetadata {
12840 if (modifierKeyword != null) { 11917 if (modifierKeyword != null) {
12841 return modifierKeyword; 11918 return modifierKeyword;
12842 } else if (_returnType != null) { 11919 } else if (_returnType != null) {
12843 return _returnType.beginToken; 11920 return _returnType.beginToken;
12844 } else if (propertyKeyword != null) { 11921 } else if (propertyKeyword != null) {
12845 return propertyKeyword; 11922 return propertyKeyword;
12846 } else if (operatorKeyword != null) { 11923 } else if (operatorKeyword != null) {
12847 return operatorKeyword; 11924 return operatorKeyword;
12848 } 11925 }
12849 return _name.beginToken; 11926 return _name.beginToken;
12850 } 11927 }
12851 11928
12852 /** 11929 /**
12853 * Return `true` if this method is declared to be an abstract method. 11930 * Return `true` if this method is declared to be an abstract method.
12854 *
12855 * @return `true` if this method is declared to be an abstract method
12856 */ 11931 */
12857 bool get isAbstract => 11932 bool get isAbstract =>
12858 externalKeyword == null && (_body is EmptyFunctionBody); 11933 externalKeyword == null && (_body is EmptyFunctionBody);
12859 11934
12860 /** 11935 /**
12861 * Return `true` if this method declares a getter. 11936 * Return `true` if this method declares a getter.
12862 *
12863 * @return `true` if this method declares a getter
12864 */ 11937 */
12865 bool get isGetter => 11938 bool get isGetter =>
12866 propertyKeyword != null && 11939 propertyKeyword != null &&
12867 (propertyKeyword as KeywordToken).keyword == Keyword.GET; 11940 (propertyKeyword as KeywordToken).keyword == Keyword.GET;
12868 11941
12869 /** 11942 /**
12870 * Return `true` if this method declares an operator. 11943 * Return `true` if this method declares an operator.
12871 *
12872 * @return `true` if this method declares an operator
12873 */ 11944 */
12874 bool get isOperator => operatorKeyword != null; 11945 bool get isOperator => operatorKeyword != null;
12875 11946
12876 /** 11947 /**
12877 * Return `true` if this method declares a setter. 11948 * Return `true` if this method declares a setter.
12878 *
12879 * @return `true` if this method declares a setter
12880 */ 11949 */
12881 bool get isSetter => 11950 bool get isSetter =>
12882 propertyKeyword != null && 11951 propertyKeyword != null &&
12883 (propertyKeyword as KeywordToken).keyword == Keyword.SET; 11952 (propertyKeyword as KeywordToken).keyword == Keyword.SET;
12884 11953
12885 /** 11954 /**
12886 * Return `true` if this method is declared to be a static method. 11955 * Return `true` if this method is declared to be a static method.
12887 *
12888 * @return `true` if this method is declared to be a static method
12889 */ 11956 */
12890 bool get isStatic => 11957 bool get isStatic =>
12891 modifierKeyword != null && 11958 modifierKeyword != null &&
12892 (modifierKeyword as KeywordToken).keyword == Keyword.STATIC; 11959 (modifierKeyword as KeywordToken).keyword == Keyword.STATIC;
12893 11960
12894 /** 11961 /**
12895 * Return the name of the method. 11962 * Return the name of the method.
12896 *
12897 * @return the name of the method
12898 */ 11963 */
12899 SimpleIdentifier get name => _name; 11964 SimpleIdentifier get name => _name;
12900 11965
12901 /** 11966 /**
12902 * Set the name of the method to the given identifier. 11967 * Set the name of the method to the given [identifier].
12903 *
12904 * @param identifier the name of the method
12905 */ 11968 */
12906 void set name(SimpleIdentifier identifier) { 11969 void set name(SimpleIdentifier identifier) {
12907 _name = becomeParentOf(identifier); 11970 _name = becomeParentOf(identifier);
12908 } 11971 }
12909 11972
12910 /** 11973 /**
12911 * Return the parameters associated with the method, or `null` if this method declares a 11974 * Return the parameters associated with the method, or `null` if this method
12912 * getter. 11975 * declares a getter.
12913 *
12914 * @return the parameters associated with the method
12915 */ 11976 */
12916 FormalParameterList get parameters => _parameters; 11977 FormalParameterList get parameters => _parameters;
12917 11978
12918 /** 11979 /**
12919 * Set the parameters associated with the method to the given list of paramete rs. 11980 * Set the parameters associated with the method to the given list of
12920 * 11981 * [parameters].
12921 * @param parameters the parameters associated with the method
12922 */ 11982 */
12923 void set parameters(FormalParameterList parameters) { 11983 void set parameters(FormalParameterList parameters) {
12924 _parameters = becomeParentOf(parameters); 11984 _parameters = becomeParentOf(parameters);
12925 } 11985 }
12926 11986
12927 /** 11987 /**
12928 * Return the return type of the method, or `null` if no return type was decla red. 11988 * Return the return type of the method, or `null` if no return type was
12929 * 11989 * declared.
12930 * @return the return type of the method
12931 */ 11990 */
12932 TypeName get returnType => _returnType; 11991 TypeName get returnType => _returnType;
12933 11992
12934 /** 11993 /**
12935 * Set the return type of the method to the given type name. 11994 * Set the return type of the method to the given [typeName].
12936 *
12937 * @param typeName the return type of the method
12938 */ 11995 */
12939 void set returnType(TypeName typeName) { 11996 void set returnType(TypeName typeName) {
12940 _returnType = becomeParentOf(typeName); 11997 _returnType = becomeParentOf(typeName);
12941 } 11998 }
12942 11999
12943 @override 12000 @override
12944 accept(AstVisitor visitor) => visitor.visitMethodDeclaration(this); 12001 accept(AstVisitor visitor) => visitor.visitMethodDeclaration(this);
12945 12002
12946 @override 12003 @override
12947 void visitChildren(AstVisitor visitor) { 12004 void visitChildren(AstVisitor visitor) {
12948 super.visitChildren(visitor); 12005 super.visitChildren(visitor);
12949 safelyVisitChild(_returnType, visitor); 12006 _safelyVisitChild(_returnType, visitor);
12950 safelyVisitChild(_name, visitor); 12007 _safelyVisitChild(_name, visitor);
12951 safelyVisitChild(_parameters, visitor); 12008 _safelyVisitChild(_parameters, visitor);
12952 safelyVisitChild(_body, visitor); 12009 _safelyVisitChild(_body, visitor);
12953 } 12010 }
12954 } 12011 }
12955 12012
12956 /** 12013 /**
12957 * Instances of the class `MethodInvocation` represent the invocation of either a function or 12014 * The invocation of either a function or a method. Invocations of functions
12958 * a method. Invocations of functions resulting from evaluating an expression ar e represented by 12015 * resulting from evaluating an expression are represented by
12959 * [FunctionExpressionInvocation] nodes. Invocations of getters 12016 * [FunctionExpressionInvocation] nodes. Invocations of getters and setters are
12960 * and setters are represented by either [PrefixedIdentifier] or 12017 * represented by either [PrefixedIdentifier] or [PropertyAccess] nodes.
12961 * [PropertyAccess] nodes.
12962 * 12018 *
12963 * <pre> 12019 * > methodInvoction ::=
12964 * methodInvoction ::= 12020 * > ([Expression] '.')? [SimpleIdentifier] [ArgumentList]
12965 * ([Expression] '.')? [SimpleIdentifier] [ArgumentList]
12966 * </pre>
12967 */ 12021 */
12968 class MethodInvocation extends Expression { 12022 class MethodInvocation extends Expression {
12969 /** 12023 /**
12970 * The expression producing the object on which the method is defined, or `nul l` if there is 12024 * The expression producing the object on which the method is defined, or
12971 * no target (that is, the target is implicitly `this`). 12025 * `null` if there is no target (that is, the target is implicitly `this`).
12972 */ 12026 */
12973 Expression _target; 12027 Expression _target;
12974 12028
12975 /** 12029 /**
12976 * The period that separates the target from the method name, or `null` if the re is no 12030 * The period that separates the target from the method name, or `null` if
12977 * target. 12031 * there is no target.
12978 */ 12032 */
12979 Token period; 12033 Token period;
12980 12034
12981 /** 12035 /**
12982 * The name of the method being invoked. 12036 * The name of the method being invoked.
12983 */ 12037 */
12984 SimpleIdentifier _methodName; 12038 SimpleIdentifier _methodName;
12985 12039
12986 /** 12040 /**
12987 * The list of arguments to the method. 12041 * The list of arguments to the method.
12988 */ 12042 */
12989 ArgumentList _argumentList; 12043 ArgumentList _argumentList;
12990 12044
12991 /** 12045 /**
12992 * Initialize a newly created method invocation. 12046 * Initialize a newly created method invocation. The [target] and [period] can
12993 * 12047 * be `null` if there is no target.
12994 * @param target the expression producing the object on which the method is de fined
12995 * @param period the period that separates the target from the method name
12996 * @param methodName the name of the method being invoked
12997 * @param argumentList the list of arguments to the method
12998 */ 12048 */
12999 MethodInvocation(Expression target, this.period, SimpleIdentifier methodName, 12049 MethodInvocation(Expression target, this.period, SimpleIdentifier methodName,
13000 ArgumentList argumentList) { 12050 ArgumentList argumentList) {
13001 _target = becomeParentOf(target); 12051 _target = becomeParentOf(target);
13002 _methodName = becomeParentOf(methodName); 12052 _methodName = becomeParentOf(methodName);
13003 _argumentList = becomeParentOf(argumentList); 12053 _argumentList = becomeParentOf(argumentList);
13004 } 12054 }
13005 12055
13006 /** 12056 /**
13007 * Return the list of arguments to the method. 12057 * Return the list of arguments to the method.
13008 *
13009 * @return the list of arguments to the method
13010 */ 12058 */
13011 ArgumentList get argumentList => _argumentList; 12059 ArgumentList get argumentList => _argumentList;
13012 12060
13013 /** 12061 /**
13014 * Set the list of arguments to the method to the given list. 12062 * Set the list of arguments to the method to the given [argumentList].
13015 *
13016 * @param argumentList the list of arguments to the method
13017 */ 12063 */
13018 void set argumentList(ArgumentList argumentList) { 12064 void set argumentList(ArgumentList argumentList) {
13019 _argumentList = becomeParentOf(argumentList); 12065 _argumentList = becomeParentOf(argumentList);
13020 } 12066 }
13021 12067
13022 @override 12068 @override
13023 Token get beginToken { 12069 Token get beginToken {
13024 if (_target != null) { 12070 if (_target != null) {
13025 return _target.beginToken; 12071 return _target.beginToken;
13026 } else if (period != null) { 12072 } else if (period != null) {
13027 return period; 12073 return period;
13028 } 12074 }
13029 return _methodName.beginToken; 12075 return _methodName.beginToken;
13030 } 12076 }
13031 12077
13032 @override 12078 @override
13033 Iterable get childEntities => new ChildEntities() 12079 Iterable get childEntities => new ChildEntities()
13034 ..add(_target) 12080 ..add(_target)
13035 ..add(period) 12081 ..add(period)
13036 ..add(_methodName) 12082 ..add(_methodName)
13037 ..add(_argumentList); 12083 ..add(_argumentList);
13038 12084
13039 @override 12085 @override
13040 Token get endToken => _argumentList.endToken; 12086 Token get endToken => _argumentList.endToken;
13041 12087
13042 /** 12088 /**
13043 * Return `true` if this expression is cascaded. If it is, then the target of this 12089 * Return `true` if this expression is cascaded. If it is, then the target of
13044 * expression is not stored locally but is stored in the nearest ancestor that is a 12090 * this expression is not stored locally but is stored in the nearest ancestor
13045 * [CascadeExpression]. 12091 * that is a [CascadeExpression].
13046 *
13047 * @return `true` if this expression is cascaded
13048 */ 12092 */
13049 bool get isCascaded => 12093 bool get isCascaded =>
13050 period != null && period.type == TokenType.PERIOD_PERIOD; 12094 period != null && period.type == TokenType.PERIOD_PERIOD;
13051 12095
13052 /** 12096 /**
13053 * Return the name of the method being invoked. 12097 * Return the name of the method being invoked.
13054 *
13055 * @return the name of the method being invoked
13056 */ 12098 */
13057 SimpleIdentifier get methodName => _methodName; 12099 SimpleIdentifier get methodName => _methodName;
13058 12100
13059 /** 12101 /**
13060 * Set the name of the method being invoked to the given identifier. 12102 * Set the name of the method being invoked to the given [identifier].
13061 *
13062 * @param identifier the name of the method being invoked
13063 */ 12103 */
13064 void set methodName(SimpleIdentifier identifier) { 12104 void set methodName(SimpleIdentifier identifier) {
13065 _methodName = becomeParentOf(identifier); 12105 _methodName = becomeParentOf(identifier);
13066 } 12106 }
13067 12107
13068 @override 12108 @override
13069 int get precedence => 15; 12109 int get precedence => 15;
13070 12110
13071 /** 12111 /**
13072 * Return the expression used to compute the receiver of the invocation. If th is invocation is not 12112 * Return the expression used to compute the receiver of the invocation. If
13073 * part of a cascade expression, then this is the same as [getTarget]. If this invocation 12113 * this invocation is not part of a cascade expression, then this is the same
13074 * is part of a cascade expression, then the target stored with the cascade ex pression is 12114 * as [target]. If this invocation is part of a cascade expression, then the
13075 * returned. 12115 * target stored with the cascade expression is returned.
13076 *
13077 * @return the expression used to compute the receiver of the invocation
13078 * See [target].
13079 */ 12116 */
13080 Expression get realTarget { 12117 Expression get realTarget {
13081 if (isCascaded) { 12118 if (isCascaded) {
13082 AstNode ancestor = parent; 12119 AstNode ancestor = parent;
13083 while (ancestor is! CascadeExpression) { 12120 while (ancestor is! CascadeExpression) {
13084 if (ancestor == null) { 12121 if (ancestor == null) {
13085 return _target; 12122 return _target;
13086 } 12123 }
13087 ancestor = ancestor.parent; 12124 ancestor = ancestor.parent;
13088 } 12125 }
13089 return (ancestor as CascadeExpression).target; 12126 return (ancestor as CascadeExpression).target;
13090 } 12127 }
13091 return _target; 12128 return _target;
13092 } 12129 }
13093 12130
13094 /** 12131 /**
13095 * Return the expression producing the object on which the method is defined, or `null` if 12132 * Return the expression producing the object on which the method is defined,
13096 * there is no target (that is, the target is implicitly `this`) or if this me thod 12133 * or `null` if there is no target (that is, the target is implicitly `this`)
13097 * invocation is part of a cascade expression. 12134 * or if this method invocation is part of a cascade expression.
13098 * 12135 *
13099 * @return the expression producing the object on which the method is defined 12136 * Use [realTarget] to get the target independent of whether this is part of a
13100 * See [realTarget]. 12137 * cascade expression.
13101 */ 12138 */
13102 Expression get target => _target; 12139 Expression get target => _target;
13103 12140
13104 /** 12141 /**
13105 * Set the expression producing the object on which the method is defined to t he given expression. 12142 * Set the expression producing the object on which the method is defined to
13106 * 12143 * the given [expression].
13107 * @param expression the expression producing the object on which the method i s defined
13108 */ 12144 */
13109 void set target(Expression expression) { 12145 void set target(Expression expression) {
13110 _target = becomeParentOf(expression); 12146 _target = becomeParentOf(expression);
13111 } 12147 }
13112 12148
13113 @override 12149 @override
13114 accept(AstVisitor visitor) => visitor.visitMethodInvocation(this); 12150 accept(AstVisitor visitor) => visitor.visitMethodInvocation(this);
13115 12151
13116 @override 12152 @override
13117 void visitChildren(AstVisitor visitor) { 12153 void visitChildren(AstVisitor visitor) {
13118 safelyVisitChild(_target, visitor); 12154 _safelyVisitChild(_target, visitor);
13119 safelyVisitChild(_methodName, visitor); 12155 _safelyVisitChild(_methodName, visitor);
13120 safelyVisitChild(_argumentList, visitor); 12156 _safelyVisitChild(_argumentList, visitor);
13121 } 12157 }
13122 } 12158 }
13123 12159
13124 /** 12160 /**
13125 * Instances of the class `NamedExpression` represent an expression that has a n ame associated 12161 * An expression that has a name associated with it. They are used in method
13126 * with it. They are used in method invocations when there are named parameters. 12162 * invocations when there are named parameters.
13127 * 12163 *
13128 * <pre> 12164 * > namedExpression ::=
13129 * namedExpression ::= 12165 * > [Label] [Expression]
13130 * [Label] [Expression]
13131 * </pre>
13132 */ 12166 */
13133 class NamedExpression extends Expression { 12167 class NamedExpression extends Expression {
13134 /** 12168 /**
13135 * The name associated with the expression. 12169 * The name associated with the expression.
13136 */ 12170 */
13137 Label _name; 12171 Label _name;
13138 12172
13139 /** 12173 /**
13140 * The expression with which the name is associated. 12174 * The expression with which the name is associated.
13141 */ 12175 */
13142 Expression _expression; 12176 Expression _expression;
13143 12177
13144 /** 12178 /**
13145 * Initialize a newly created named expression. 12179 * Initialize a newly created named expression..
13146 *
13147 * @param name the name associated with the expression
13148 * @param expression the expression with which the name is associated
13149 */ 12180 */
13150 NamedExpression(Label name, Expression expression) { 12181 NamedExpression(Label name, Expression expression) {
13151 _name = becomeParentOf(name); 12182 _name = becomeParentOf(name);
13152 _expression = becomeParentOf(expression); 12183 _expression = becomeParentOf(expression);
13153 } 12184 }
13154 12185
13155 @override 12186 @override
13156 Token get beginToken => _name.beginToken; 12187 Token get beginToken => _name.beginToken;
13157 12188
13158 @override 12189 @override
13159 Iterable get childEntities => new ChildEntities() 12190 Iterable get childEntities => new ChildEntities()
13160 ..add(_name) 12191 ..add(_name)
13161 ..add(_expression); 12192 ..add(_expression);
13162 12193
13163 /** 12194 /**
13164 * Return the element representing the parameter being named by this expressio n, or `null` 12195 * Return the element representing the parameter being named by this
13165 * if the AST structure has not been resolved or if there is no parameter with the same name as 12196 * expression, or `null` if the AST structure has not been resolved or if
13166 * this expression. 12197 * there is no parameter with the same name as this expression.
13167 *
13168 * @return the element representing the parameter being named by this expressi on
13169 */ 12198 */
13170 ParameterElement get element { 12199 ParameterElement get element {
13171 Element element = _name.label.staticElement; 12200 Element element = _name.label.staticElement;
13172 if (element is ParameterElement) { 12201 if (element is ParameterElement) {
13173 return element; 12202 return element;
13174 } 12203 }
13175 return null; 12204 return null;
13176 } 12205 }
13177 12206
13178 @override 12207 @override
13179 Token get endToken => _expression.endToken; 12208 Token get endToken => _expression.endToken;
13180 12209
13181 /** 12210 /**
13182 * Return the expression with which the name is associated. 12211 * Return the expression with which the name is associated.
13183 *
13184 * @return the expression with which the name is associated
13185 */ 12212 */
13186 Expression get expression => _expression; 12213 Expression get expression => _expression;
13187 12214
13188 /** 12215 /**
13189 * Set the expression with which the name is associated to the given expressio n. 12216 * Set the expression with which the name is associated to the given
13190 * 12217 * [expression].
13191 * @param expression the expression with which the name is associated
13192 */ 12218 */
13193 void set expression(Expression expression) { 12219 void set expression(Expression expression) {
13194 _expression = becomeParentOf(expression); 12220 _expression = becomeParentOf(expression);
13195 } 12221 }
13196 12222
13197 /** 12223 /**
13198 * Return the name associated with the expression. 12224 * Return the name associated with the expression.
13199 *
13200 * @return the name associated with the expression
13201 */ 12225 */
13202 Label get name => _name; 12226 Label get name => _name;
13203 12227
13204 /** 12228 /**
13205 * Set the name associated with the expression to the given identifier. 12229 * Set the name associated with the expression to the given [identifier].
13206 *
13207 * @param identifier the name associated with the expression
13208 */ 12230 */
13209 void set name(Label identifier) { 12231 void set name(Label identifier) {
13210 _name = becomeParentOf(identifier); 12232 _name = becomeParentOf(identifier);
13211 } 12233 }
13212 12234
13213 @override 12235 @override
13214 int get precedence => 0; 12236 int get precedence => 0;
13215 12237
13216 @override 12238 @override
13217 accept(AstVisitor visitor) => visitor.visitNamedExpression(this); 12239 accept(AstVisitor visitor) => visitor.visitNamedExpression(this);
13218 12240
13219 @override 12241 @override
13220 void visitChildren(AstVisitor visitor) { 12242 void visitChildren(AstVisitor visitor) {
13221 safelyVisitChild(_name, visitor); 12243 _safelyVisitChild(_name, visitor);
13222 safelyVisitChild(_expression, visitor); 12244 _safelyVisitChild(_expression, visitor);
13223 } 12245 }
13224 } 12246 }
13225 12247
13226 /** 12248 /**
13227 * The abstract class `NamespaceDirective` defines the behavior common to nodes that represent 12249 * A node that represents a directive that impacts the namespace of a library.
13228 * a directive that impacts the namespace of a library.
13229 * 12250 *
13230 * <pre> 12251 * > directive ::=
13231 * directive ::= 12252 * > [ExportDirective]
13232 * [ExportDirective] 12253 * > | [ImportDirective]
13233 * | [ImportDirective]
13234 * </pre>
13235 */ 12254 */
13236 abstract class NamespaceDirective extends UriBasedDirective { 12255 abstract class NamespaceDirective extends UriBasedDirective {
13237 /** 12256 /**
13238 * The token representing the 'import' or 'export' keyword. 12257 * The token representing the 'import' or 'export' keyword.
13239 */ 12258 */
13240 Token keyword; 12259 Token keyword;
13241 12260
13242 /** 12261 /**
13243 * The combinators used to control which names are imported or exported. 12262 * The combinators used to control which names are imported or exported.
13244 */ 12263 */
13245 NodeList<Combinator> _combinators; 12264 NodeList<Combinator> _combinators;
13246 12265
13247 /** 12266 /**
13248 * The semicolon terminating the directive. 12267 * The semicolon terminating the directive.
13249 */ 12268 */
13250 Token semicolon; 12269 Token semicolon;
13251 12270
13252 /** 12271 /**
13253 * Initialize a newly created namespace directive. 12272 * Initialize a newly created namespace directive. Either or both of the
13254 * 12273 * [comment] and [metadata] can be `null` if the directive does not have the
13255 * @param comment the documentation comment associated with this directive 12274 * corresponding attribute. The list of [combinators] can be `null` if there
13256 * @param metadata the annotations associated with the directive 12275 * are no combinators.
13257 * @param keyword the token representing the 'import' or 'export' keyword
13258 * @param libraryUri the URI of the library being imported or exported
13259 * @param combinators the combinators used to control which names are imported or exported
13260 * @param semicolon the semicolon terminating the directive
13261 */ 12276 */
13262 NamespaceDirective(Comment comment, List<Annotation> metadata, this.keyword, 12277 NamespaceDirective(Comment comment, List<Annotation> metadata, this.keyword,
13263 StringLiteral libraryUri, List<Combinator> combinators, this.semicolon) 12278 StringLiteral libraryUri, List<Combinator> combinators, this.semicolon)
13264 : super(comment, metadata, libraryUri) { 12279 : super(comment, metadata, libraryUri) {
13265 _combinators = new NodeList<Combinator>(this, combinators); 12280 _combinators = new NodeList<Combinator>(this, combinators);
13266 } 12281 }
13267 12282
13268 /** 12283 /**
13269 * Return the combinators used to control how names are imported or exported. 12284 * Return the combinators used to control how names are imported or exported.
13270 *
13271 * @return the combinators used to control how names are imported or exported
13272 */ 12285 */
13273 NodeList<Combinator> get combinators => _combinators; 12286 NodeList<Combinator> get combinators => _combinators;
13274 12287
13275 @override 12288 @override
13276 Token get endToken => semicolon; 12289 Token get endToken => semicolon;
13277 12290
13278 @override 12291 @override
13279 Token get firstTokenAfterCommentAndMetadata => keyword; 12292 Token get firstTokenAfterCommentAndMetadata => keyword;
13280 12293
13281 @override 12294 @override
13282 LibraryElement get uriElement; 12295 LibraryElement get uriElement;
13283 } 12296 }
13284 12297
13285 /** 12298 /**
13286 * Instances of the class `NativeClause` represent the "native" clause in an cla ss 12299 * The "native" clause in an class declaration.
13287 * declaration.
13288 * 12300 *
13289 * <pre> 12301 * > nativeClause ::=
13290 * nativeClause ::= 12302 * > 'native' [StringLiteral]
13291 * 'native' [StringLiteral]
13292 * </pre>
13293 */ 12303 */
13294 class NativeClause extends AstNode { 12304 class NativeClause extends AstNode {
13295 /** 12305 /**
13296 * The token representing the 'native' keyword. 12306 * The token representing the 'native' keyword.
13297 */ 12307 */
13298 Token keyword; 12308 Token keyword;
13299 12309
13300 /** 12310 /**
13301 * The name of the native object that implements the class. 12311 * The name of the native object that implements the class.
13302 */ 12312 */
13303 StringLiteral _name; 12313 StringLiteral _name;
13304 12314
13305 /** 12315 /**
13306 * Initialize a newly created native clause. 12316 * Initialize a newly created native clause.
13307 *
13308 * @param keyword the token representing the 'native' keyword
13309 * @param name the name of the native object that implements the class.
13310 */ 12317 */
13311 NativeClause(this.keyword, StringLiteral name) { 12318 NativeClause(this.keyword, StringLiteral name) {
13312 _name = becomeParentOf(name); 12319 _name = becomeParentOf(name);
13313 } 12320 }
13314 12321
13315 @override 12322 @override
13316 Token get beginToken => keyword; 12323 Token get beginToken => keyword;
13317 12324
13318 /** 12325 /**
13319 * TODO(paulberry): untested. 12326 * TODO(paulberry): untested.
13320 */ 12327 */
13321 @override 12328 @override
13322 Iterable get childEntities => new ChildEntities() 12329 Iterable get childEntities => new ChildEntities()
13323 ..add(keyword) 12330 ..add(keyword)
13324 ..add(_name); 12331 ..add(_name);
13325 12332
13326 @override 12333 @override
13327 Token get endToken => _name.endToken; 12334 Token get endToken => _name.endToken;
13328 12335
13329 /** 12336 /**
13330 * Return the name of the native object that implements the class. 12337 * Return the name of the native object that implements the class.
13331 *
13332 * @return the name of the native object that implements the class
13333 */ 12338 */
13334 StringLiteral get name => _name; 12339 StringLiteral get name => _name;
13335 12340
13336 /** 12341 /**
13337 * Sets the name of the native object that implements the class. 12342 * Sets the name of the native object that implements the class to the given
13338 * 12343 * [name].
13339 * @param name the name of the native object that implements the class.
13340 */ 12344 */
13341 void set name(StringLiteral name) { 12345 void set name(StringLiteral name) {
13342 _name = becomeParentOf(name); 12346 _name = becomeParentOf(name);
13343 } 12347 }
13344 12348
13345 @override 12349 @override
13346 accept(AstVisitor visitor) => visitor.visitNativeClause(this); 12350 accept(AstVisitor visitor) => visitor.visitNativeClause(this);
13347 12351
13348 @override 12352 @override
13349 void visitChildren(AstVisitor visitor) { 12353 void visitChildren(AstVisitor visitor) {
13350 safelyVisitChild(_name, visitor); 12354 _safelyVisitChild(_name, visitor);
13351 } 12355 }
13352 } 12356 }
13353 12357
13354 /** 12358 /**
13355 * Instances of the class `NativeFunctionBody` represent a function body that co nsists of a 12359 * A function body that consists of a native keyword followed by a string
13356 * native keyword followed by a string literal. 12360 * literal.
13357 * 12361 *
13358 * <pre> 12362 * > nativeFunctionBody ::=
13359 * nativeFunctionBody ::= 12363 * > 'native' [SimpleStringLiteral] ';'
13360 * 'native' [SimpleStringLiteral] ';'
13361 * </pre>
13362 */ 12364 */
13363 class NativeFunctionBody extends FunctionBody { 12365 class NativeFunctionBody extends FunctionBody {
13364 /** 12366 /**
13365 * The token representing 'native' that marks the start of the function body. 12367 * The token representing 'native' that marks the start of the function body.
13366 */ 12368 */
13367 Token nativeToken; 12369 Token nativeToken;
13368 12370
13369 /** 12371 /**
13370 * The string literal, after the 'native' token. 12372 * The string literal, after the 'native' token.
13371 */ 12373 */
13372 StringLiteral _stringLiteral; 12374 StringLiteral _stringLiteral;
13373 12375
13374 /** 12376 /**
13375 * The token representing the semicolon that marks the end of the function bod y. 12377 * The token representing the semicolon that marks the end of the function
12378 * body.
13376 */ 12379 */
13377 Token semicolon; 12380 Token semicolon;
13378 12381
13379 /** 12382 /**
13380 * Initialize a newly created function body consisting of the 'native' token, a string literal, 12383 * Initialize a newly created function body consisting of the 'native' token,
13381 * and a semicolon. 12384 * a string literal, and a semicolon.
13382 *
13383 * @param nativeToken the token representing 'native' that marks the start of the function body
13384 * @param stringLiteral the string literal
13385 * @param semicolon the token representing the semicolon that marks the end of the function body
13386 */ 12385 */
13387 NativeFunctionBody(this.nativeToken, StringLiteral stringLiteral, 12386 NativeFunctionBody(this.nativeToken, StringLiteral stringLiteral,
13388 this.semicolon) { 12387 this.semicolon) {
13389 _stringLiteral = becomeParentOf(stringLiteral); 12388 _stringLiteral = becomeParentOf(stringLiteral);
13390 } 12389 }
13391 12390
13392 @override 12391 @override
13393 Token get beginToken => nativeToken; 12392 Token get beginToken => nativeToken;
13394 12393
13395 /** 12394 /**
13396 * TODO(paulberry): untested. 12395 * TODO(paulberry): untested.
13397 */ 12396 */
13398 @override 12397 @override
13399 Iterable get childEntities => new ChildEntities() 12398 Iterable get childEntities => new ChildEntities()
13400 ..add(nativeToken) 12399 ..add(nativeToken)
13401 ..add(_stringLiteral) 12400 ..add(_stringLiteral)
13402 ..add(semicolon); 12401 ..add(semicolon);
13403 12402
13404 @override 12403 @override
13405 Token get endToken => semicolon; 12404 Token get endToken => semicolon;
13406 12405
13407 /** 12406 /**
13408 * Return the string literal representing the string after the 'native' token. 12407 * Return the string literal representing the string after the 'native' token.
13409 *
13410 * @return the string literal representing the string after the 'native' token
13411 */ 12408 */
13412 StringLiteral get stringLiteral => _stringLiteral; 12409 StringLiteral get stringLiteral => _stringLiteral;
13413 12410
13414 /** 12411 /**
13415 * Set the string literal representing the string after the 'native' token to the given string. 12412 * Set the string literal representing the string after the 'native' token to
13416 * 12413 * the given [stringLiteral].
13417 * @param stringLiteral the string literal representing the string after the ' native' token
13418 */ 12414 */
13419 void set stringLiteral(StringLiteral stringLiteral) { 12415 void set stringLiteral(StringLiteral stringLiteral) {
13420 _stringLiteral = becomeParentOf(stringLiteral); 12416 _stringLiteral = becomeParentOf(stringLiteral);
13421 } 12417 }
13422 12418
13423 @override 12419 @override
13424 accept(AstVisitor visitor) => visitor.visitNativeFunctionBody(this); 12420 accept(AstVisitor visitor) => visitor.visitNativeFunctionBody(this);
13425 12421
13426 @override 12422 @override
13427 void visitChildren(AstVisitor visitor) { 12423 void visitChildren(AstVisitor visitor) {
13428 safelyVisitChild(_stringLiteral, visitor); 12424 _safelyVisitChild(_stringLiteral, visitor);
13429 } 12425 }
13430 } 12426 }
13431 12427
13432 /** 12428 /**
13433 * Instances of the class `NodeList` represent a list of AST nodes that have a 12429 * A list of AST nodes that have a common parent.
13434 * common parent.
13435 */ 12430 */
13436 class NodeList<E extends AstNode> extends Object with ListMixin<E> { 12431 class NodeList<E extends AstNode> extends Object with ListMixin<E> {
13437 /** 12432 /**
13438 * The node that is the parent of each of the elements in the list. 12433 * The node that is the parent of each of the elements in the list.
13439 */ 12434 */
13440 AstNode owner; 12435 AstNode owner;
13441 12436
13442 /** 12437 /**
13443 * The elements contained in the list. 12438 * The elements contained in the list.
13444 */ 12439 */
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
13557 /** 12552 /**
13558 * Create an empty list with the given [owner]. 12553 * Create an empty list with the given [owner].
13559 * 12554 *
13560 * Use "new NodeList<E>(owner)" 12555 * Use "new NodeList<E>(owner)"
13561 */ 12556 */
13562 @deprecated 12557 @deprecated
13563 static NodeList create(AstNode owner) => new NodeList(owner); 12558 static NodeList create(AstNode owner) => new NodeList(owner);
13564 } 12559 }
13565 12560
13566 /** 12561 /**
13567 * Instances of the class `NodeLocator` locate the [AstNode] associated with a 12562 * An object used to locate the [AstNode] associated with a source range, given
13568 * source range, given the AST structure built from the source. More specificall y, they will return 12563 * the AST structure built from the source. More specifically, they will return
13569 * the [AstNode] with the shortest length whose source range completely encompas ses 12564 * the [AstNode] with the shortest length whose source range completely
13570 * the specified range. 12565 * encompasses the specified range.
13571 */ 12566 */
13572 class NodeLocator extends UnifyingAstVisitor<Object> { 12567 class NodeLocator extends UnifyingAstVisitor<Object> {
13573 /** 12568 /**
13574 * The start offset of the range used to identify the node. 12569 * The start offset of the range used to identify the node.
13575 */ 12570 */
13576 int _startOffset = 0; 12571 int _startOffset = 0;
13577 12572
13578 /** 12573 /**
13579 * The end offset of the range used to identify the node. 12574 * The end offset of the range used to identify the node.
13580 */ 12575 */
13581 int _endOffset = 0; 12576 int _endOffset = 0;
13582 12577
13583 /** 12578 /**
13584 * The element that was found that corresponds to the given source range, or ` null` if there 12579 * The element that was found that corresponds to the given source range, or
13585 * is no such element. 12580 * `null` if there is no such element.
13586 */ 12581 */
13587 AstNode _foundNode; 12582 AstNode _foundNode;
13588 12583
13589 /** 12584 /**
13590 * Initialize a newly created locator to locate one or more [AstNode] by locat ing 12585 * Initialize a newly created locator to locate an [AstNode] by locating the
13591 * the node within an AST structure that corresponds to the given offset in th e source. 12586 * node within an AST structure that corresponds to the given [offset] in the
13592 * 12587 * source.
13593 * @param offset the offset used to identify the node
13594 */ 12588 */
13595 NodeLocator.con1(int offset) : this.con2(offset, offset); 12589 NodeLocator.con1(int offset) : this.con2(offset, offset);
13596 12590
13597 /** 12591 /**
13598 * Initialize a newly created locator to locate one or more [AstNode] by locat ing 12592 * Initialize a newly created locator to locate an [AstNode] by locating the
13599 * the node within an AST structure that corresponds to the given range of cha racters in the 12593 * node within an AST structure that corresponds to the given range of
13600 * source. 12594 * characters (between the [startOffset] and [endOffset] in the source.
13601 *
13602 * @param start the start offset of the range used to identify the node
13603 * @param end the end offset of the range used to identify the node
13604 */ 12595 */
13605 NodeLocator.con2(this._startOffset, this._endOffset); 12596 NodeLocator.con2(this._startOffset, this._endOffset);
13606 12597
13607 /** 12598 /**
13608 * Return the node that was found that corresponds to the given source range, or `null` if 12599 * Return the node that was found that corresponds to the given source range
13609 * there is no such node. 12600 * or `null` if there is no such node.
13610 *
13611 * @return the node that was found
13612 */ 12601 */
13613 AstNode get foundNode => _foundNode; 12602 AstNode get foundNode => _foundNode;
13614 12603
13615 /** 12604 /**
13616 * Search within the given AST node for an identifier representing a [DartElem ent] in the specified source range. Return the element that was found, or `null` if 12605 * Search within the given AST [node] for an identifier representing an
13617 * no element was found. 12606 * element in the specified source range. Return the element that was found,
13618 * 12607 * or `null` if no element was found.
13619 * @param node the AST node within which to search
13620 * @return the element that was found
13621 */ 12608 */
13622 AstNode searchWithin(AstNode node) { 12609 AstNode searchWithin(AstNode node) {
13623 if (node == null) { 12610 if (node == null) {
13624 return null; 12611 return null;
13625 } 12612 }
13626 try { 12613 try {
13627 node.accept(this); 12614 node.accept(this);
13628 } on NodeLocator_NodeFoundException catch (exception) { 12615 } on NodeLocator_NodeFoundException catch (exception) {
13629 // A node with the right source position was found. 12616 // A node with the right source position was found.
13630 } catch (exception, stackTrace) { 12617 } catch (exception, stackTrace) {
(...skipping 28 matching lines...) Expand all
13659 } 12646 }
13660 if (start <= _startOffset && _endOffset <= end) { 12647 if (start <= _startOffset && _endOffset <= end) {
13661 _foundNode = node; 12648 _foundNode = node;
13662 throw new NodeLocator_NodeFoundException(); 12649 throw new NodeLocator_NodeFoundException();
13663 } 12650 }
13664 return null; 12651 return null;
13665 } 12652 }
13666 } 12653 }
13667 12654
13668 /** 12655 /**
13669 * Instances of the class `NodeFoundException` are used to cancel visiting after a node has 12656 * An exception used by [NodeLocator] to cancel visiting after a node has been
13670 * been found. 12657 * found.
13671 */ 12658 */
13672 class NodeLocator_NodeFoundException extends RuntimeException { 12659 class NodeLocator_NodeFoundException extends RuntimeException {
13673 } 12660 }
13674 12661
13675 /** 12662 /**
13676 * Instances of the class `NodeReplacer` implement an object that will replace o ne child node 12663 * An object that will replace one child node in an AST node with another node.
13677 * in an AST node with another node.
13678 */ 12664 */
13679 class NodeReplacer implements AstVisitor<bool> { 12665 class NodeReplacer implements AstVisitor<bool> {
12666 /**
12667 * The node being replaced.
12668 */
13680 final AstNode _oldNode; 12669 final AstNode _oldNode;
13681 12670
12671 /**
12672 * The node that is replacing the old node.
12673 */
13682 final AstNode _newNode; 12674 final AstNode _newNode;
13683 12675
12676 /**
12677 * Initialize a newly created node locator to replace the [_oldNode] with the
12678 * [_newNode].
12679 */
13684 NodeReplacer(this._oldNode, this._newNode); 12680 NodeReplacer(this._oldNode, this._newNode);
13685 12681
13686 @override 12682 @override
13687 bool visitAdjacentStrings(AdjacentStrings node) { 12683 bool visitAdjacentStrings(AdjacentStrings node) {
13688 if (_replaceInList(node.strings)) { 12684 if (_replaceInList(node.strings)) {
13689 return true; 12685 return true;
13690 } 12686 }
13691 return visitNode(node); 12687 return visitNode(node);
13692 } 12688 }
13693 12689
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
14796 for (int i = 0; i < count; i++) { 13792 for (int i = 0; i < count; i++) {
14797 if (identical(_oldNode, list[i])) { 13793 if (identical(_oldNode, list[i])) {
14798 list[i] = _newNode; 13794 list[i] = _newNode;
14799 return true; 13795 return true;
14800 } 13796 }
14801 } 13797 }
14802 return false; 13798 return false;
14803 } 13799 }
14804 13800
14805 /** 13801 /**
14806 * Replace the old node with the new node in the AST structure containing the old node. 13802 * Replace the [oldNode] with the [newNode] in the AST structure containing
13803 * the old node. Return `true` if the replacement was successful.
14807 * 13804 *
14808 * @param oldNode 13805 * Throws an [IllegalArgumentException] if either node is `null`, if the old
14809 * @param newNode 13806 * node does not have a parent node, or if the AST structure has been
14810 * @return `true` if the replacement was successful 13807 * corrupted.
14811 * @throws IllegalArgumentException if either node is `null`, if the old node does not have
14812 * a parent node, or if the AST structure has been corrupted
14813 */ 13808 */
14814 static bool replace(AstNode oldNode, AstNode newNode) { 13809 static bool replace(AstNode oldNode, AstNode newNode) {
14815 if (oldNode == null || newNode == null) { 13810 if (oldNode == null || newNode == null) {
14816 throw new IllegalArgumentException( 13811 throw new IllegalArgumentException(
14817 "The old and new nodes must be non-null"); 13812 "The old and new nodes must be non-null");
14818 } else if (identical(oldNode, newNode)) { 13813 } else if (identical(oldNode, newNode)) {
14819 return true; 13814 return true;
14820 } 13815 }
14821 AstNode parent = oldNode.parent; 13816 AstNode parent = oldNode.parent;
14822 if (parent == null) { 13817 if (parent == null) {
14823 throw new IllegalArgumentException( 13818 throw new IllegalArgumentException(
14824 "The old node is not a child of another node"); 13819 "The old node is not a child of another node");
14825 } 13820 }
14826 NodeReplacer replacer = new NodeReplacer(oldNode, newNode); 13821 NodeReplacer replacer = new NodeReplacer(oldNode, newNode);
14827 return parent.accept(replacer); 13822 return parent.accept(replacer);
14828 } 13823 }
14829 } 13824 }
14830 13825
14831 /** 13826 /**
14832 * The abstract class `NormalFormalParameter` defines the behavior common to for mal parameters 13827 * A formal parameter that is required (is not optional).
14833 * that are required (are not optional).
14834 * 13828 *
14835 * <pre> 13829 * > normalFormalParameter ::=
14836 * normalFormalParameter ::= 13830 * > [FunctionTypedFormalParameter]
14837 * [FunctionTypedFormalParameter] 13831 * > | [FieldFormalParameter]
14838 * | [FieldFormalParameter] 13832 * > | [SimpleFormalParameter]
14839 * | [SimpleFormalParameter]
14840 * </pre>
14841 */ 13833 */
14842 abstract class NormalFormalParameter extends FormalParameter { 13834 abstract class NormalFormalParameter extends FormalParameter {
14843 /** 13835 /**
14844 * The documentation comment associated with this parameter, or `null` if this parameter 13836 * The documentation comment associated with this parameter, or `null` if this
14845 * does not have a documentation comment associated with it. 13837 * parameter does not have a documentation comment associated with it.
14846 */ 13838 */
14847 Comment _comment; 13839 Comment _comment;
14848 13840
14849 /** 13841 /**
14850 * The annotations associated with this parameter. 13842 * The annotations associated with this parameter.
14851 */ 13843 */
14852 NodeList<Annotation> _metadata; 13844 NodeList<Annotation> _metadata;
14853 13845
14854 /** 13846 /**
14855 * The name of the parameter being declared. 13847 * The name of the parameter being declared.
14856 */ 13848 */
14857 SimpleIdentifier _identifier; 13849 SimpleIdentifier _identifier;
14858 13850
14859 /** 13851 /**
14860 * Initialize a newly created formal parameter. 13852 * Initialize a newly created formal parameter. Either or both of the
14861 * 13853 * [comment] and [metadata] can be `null` if the parameter does not have the
14862 * @param comment the documentation comment associated with this parameter 13854 * corresponding attribute.
14863 * @param metadata the annotations associated with this parameter
14864 * @param identifier the name of the parameter being declared
14865 */ 13855 */
14866 NormalFormalParameter(Comment comment, List<Annotation> metadata, 13856 NormalFormalParameter(Comment comment, List<Annotation> metadata,
14867 SimpleIdentifier identifier) { 13857 SimpleIdentifier identifier) {
14868 _comment = becomeParentOf(comment); 13858 _comment = becomeParentOf(comment);
14869 _metadata = new NodeList<Annotation>(this, metadata); 13859 _metadata = new NodeList<Annotation>(this, metadata);
14870 _identifier = becomeParentOf(identifier); 13860 _identifier = becomeParentOf(identifier);
14871 } 13861 }
14872 13862
14873 /** 13863 /**
14874 * Return the documentation comment associated with this parameter, or `null` if this 13864 * Return the documentation comment associated with this parameter, or `null`
14875 * parameter does not have a documentation comment associated with it. 13865 * if this parameter does not have a documentation comment associated with it.
14876 *
14877 * @return the documentation comment associated with this parameter
14878 */ 13866 */
14879 Comment get documentationComment => _comment; 13867 Comment get documentationComment => _comment;
14880 13868
14881 /** 13869 /**
14882 * Set the documentation comment associated with this parameter to the given c omment 13870 * Set the documentation comment associated with this parameter to the given
14883 * 13871 * [comment].
14884 * @param comment the documentation comment to be associated with this paramet er
14885 */ 13872 */
14886 void set documentationComment(Comment comment) { 13873 void set documentationComment(Comment comment) {
14887 _comment = becomeParentOf(comment); 13874 _comment = becomeParentOf(comment);
14888 } 13875 }
14889 13876
14890 @override 13877 @override
14891 SimpleIdentifier get identifier => _identifier; 13878 SimpleIdentifier get identifier => _identifier;
14892 13879
14893 /** 13880 /**
14894 * Set the name of the parameter being declared to the given identifier. 13881 * Set the name of the parameter being declared to the given [identifier].
14895 *
14896 * @param identifier the name of the parameter being declared
14897 */ 13882 */
14898 void set identifier(SimpleIdentifier identifier) { 13883 void set identifier(SimpleIdentifier identifier) {
14899 _identifier = becomeParentOf(identifier); 13884 _identifier = becomeParentOf(identifier);
14900 } 13885 }
14901 13886
14902 @override 13887 @override
14903 ParameterKind get kind { 13888 ParameterKind get kind {
14904 AstNode parent = this.parent; 13889 AstNode parent = this.parent;
14905 if (parent is DefaultFormalParameter) { 13890 if (parent is DefaultFormalParameter) {
14906 return parent.kind; 13891 return parent.kind;
14907 } 13892 }
14908 return ParameterKind.REQUIRED; 13893 return ParameterKind.REQUIRED;
14909 } 13894 }
14910 13895
14911 /** 13896 /**
14912 * Return the annotations associated with this parameter. 13897 * Return the annotations associated with this parameter.
14913 *
14914 * @return the annotations associated with this parameter
14915 */ 13898 */
14916 NodeList<Annotation> get metadata => _metadata; 13899 NodeList<Annotation> get metadata => _metadata;
14917 13900
14918 /** 13901 /**
14919 * Set the metadata associated with this node to the given metadata. 13902 * Set the metadata associated with this node to the given [metadata].
14920 *
14921 * @param metadata the metadata to be associated with this node
14922 */ 13903 */
14923 void set metadata(List<Annotation> metadata) { 13904 void set metadata(List<Annotation> metadata) {
14924 _metadata.clear(); 13905 _metadata.clear();
14925 _metadata.addAll(metadata); 13906 _metadata.addAll(metadata);
14926 } 13907 }
14927 13908
14928 /** 13909 /**
14929 * Return an array containing the comment and annotations associated with this parameter, sorted 13910 * Return a list containing the comment and annotations associated with this
14930 * in lexical order. 13911 * parameter, sorted in lexical order.
14931 *
14932 * @return the comment and annotations associated with this parameter in the o rder in which they
14933 * appeared in the original source
14934 */ 13912 */
14935 List<AstNode> get sortedCommentAndAnnotations { 13913 List<AstNode> get sortedCommentAndAnnotations {
14936 return <AstNode>[] 13914 return <AstNode>[]
14937 ..add(_comment) 13915 ..add(_comment)
14938 ..addAll(_metadata) 13916 ..addAll(_metadata)
14939 ..sort(AstNode.LEXICAL_ORDER); 13917 ..sort(AstNode.LEXICAL_ORDER);
14940 } 13918 }
14941 13919
14942 ChildEntities get _childEntities { 13920 ChildEntities get _childEntities {
14943 ChildEntities result = new ChildEntities(); 13921 ChildEntities result = new ChildEntities();
14944 if (_commentIsBeforeAnnotations()) { 13922 if (_commentIsBeforeAnnotations()) {
14945 result 13923 result
14946 ..add(_comment) 13924 ..add(_comment)
14947 ..addAll(_metadata); 13925 ..addAll(_metadata);
14948 } else { 13926 } else {
14949 result.addAll(sortedCommentAndAnnotations); 13927 result.addAll(sortedCommentAndAnnotations);
14950 } 13928 }
14951 return result; 13929 return result;
14952 } 13930 }
14953 13931
14954 @override 13932 @override
14955 void visitChildren(AstVisitor visitor) { 13933 void visitChildren(AstVisitor visitor) {
14956 // 13934 //
14957 // Note that subclasses are responsible for visiting the identifier because 13935 // Note that subclasses are responsible for visiting the identifier because
14958 // they often need to visit other nodes before visiting the identifier. 13936 // they often need to visit other nodes before visiting the identifier.
14959 // 13937 //
14960 if (_commentIsBeforeAnnotations()) { 13938 if (_commentIsBeforeAnnotations()) {
14961 safelyVisitChild(_comment, visitor); 13939 _safelyVisitChild(_comment, visitor);
14962 _metadata.accept(visitor); 13940 _metadata.accept(visitor);
14963 } else { 13941 } else {
14964 for (AstNode child in sortedCommentAndAnnotations) { 13942 for (AstNode child in sortedCommentAndAnnotations) {
14965 child.accept(visitor); 13943 child.accept(visitor);
14966 } 13944 }
14967 } 13945 }
14968 } 13946 }
14969 13947
14970 /** 13948 /**
14971 * Return `true` if the comment is lexically before any annotations. 13949 * Return `true` if the comment is lexically before any annotations.
14972 *
14973 * @return `true` if the comment is lexically before any annotations
14974 */ 13950 */
14975 bool _commentIsBeforeAnnotations() { 13951 bool _commentIsBeforeAnnotations() {
14976 if (_comment == null || _metadata.isEmpty) { 13952 if (_comment == null || _metadata.isEmpty) {
14977 return true; 13953 return true;
14978 } 13954 }
14979 Annotation firstAnnotation = _metadata[0]; 13955 Annotation firstAnnotation = _metadata[0];
14980 return _comment.offset < firstAnnotation.offset; 13956 return _comment.offset < firstAnnotation.offset;
14981 } 13957 }
14982 } 13958 }
14983 13959
14984 /** 13960 /**
14985 * Instances of the class `NullLiteral` represent a null literal expression. 13961 * A null literal expression.
14986 * 13962 *
14987 * <pre> 13963 * > nullLiteral ::=
14988 * nullLiteral ::= 13964 * > 'null'
14989 * 'null'
14990 * </pre>
14991 */ 13965 */
14992 class NullLiteral extends Literal { 13966 class NullLiteral extends Literal {
14993 /** 13967 /**
14994 * The token representing the literal. 13968 * The token representing the literal.
14995 */ 13969 */
14996 Token literal; 13970 Token literal;
14997 13971
14998 /** 13972 /**
14999 * Initialize a newly created null literal. 13973 * Initialize a newly created null literal.
15000 *
15001 * @param token the token representing the literal
15002 */ 13974 */
15003 NullLiteral(this.literal); 13975 NullLiteral(this.literal);
15004 13976
15005 @override 13977 @override
15006 Token get beginToken => literal; 13978 Token get beginToken => literal;
15007 13979
15008 /** 13980 /**
15009 * TODO(paulberry): untested. 13981 * TODO(paulberry): untested.
15010 */ 13982 */
15011 @override 13983 @override
15012 Iterable get childEntities => new ChildEntities()..add(literal); 13984 Iterable get childEntities => new ChildEntities()..add(literal);
15013 13985
15014 @override 13986 @override
15015 Token get endToken => literal; 13987 Token get endToken => literal;
15016 13988
15017 @override 13989 @override
15018 accept(AstVisitor visitor) => visitor.visitNullLiteral(this); 13990 accept(AstVisitor visitor) => visitor.visitNullLiteral(this);
15019 13991
15020 @override 13992 @override
15021 void visitChildren(AstVisitor visitor) { 13993 void visitChildren(AstVisitor visitor) {
15022 // There are no children to visit. 13994 // There are no children to visit.
15023 } 13995 }
15024 } 13996 }
15025 13997
15026 /** 13998 /**
15027 * Instances of the class `ParenthesizedExpression` represent a parenthesized ex pression. 13999 * A parenthesized expression.
15028 * 14000 *
15029 * <pre> 14001 * > parenthesizedExpression ::=
15030 * parenthesizedExpression ::= 14002 * > '(' [Expression] ')'
15031 * '(' [Expression] ')'
15032 * </pre>
15033 */ 14003 */
15034 class ParenthesizedExpression extends Expression { 14004 class ParenthesizedExpression extends Expression {
15035 /** 14005 /**
15036 * The left parenthesis. 14006 * The left parenthesis.
15037 */ 14007 */
15038 Token leftParenthesis; 14008 Token leftParenthesis;
15039 14009
15040 /** 14010 /**
15041 * The expression within the parentheses. 14011 * The expression within the parentheses.
15042 */ 14012 */
15043 Expression _expression; 14013 Expression _expression;
15044 14014
15045 /** 14015 /**
15046 * The right parenthesis. 14016 * The right parenthesis.
15047 */ 14017 */
15048 Token rightParenthesis; 14018 Token rightParenthesis;
15049 14019
15050 /** 14020 /**
15051 * Initialize a newly created parenthesized expression. 14021 * Initialize a newly created parenthesized expression.
15052 *
15053 * @param leftParenthesis the left parenthesis
15054 * @param expression the expression within the parentheses
15055 * @param rightParenthesis the right parenthesis
15056 */ 14022 */
15057 ParenthesizedExpression(this.leftParenthesis, Expression expression, 14023 ParenthesizedExpression(this.leftParenthesis, Expression expression,
15058 this.rightParenthesis) { 14024 this.rightParenthesis) {
15059 _expression = becomeParentOf(expression); 14025 _expression = becomeParentOf(expression);
15060 } 14026 }
15061 14027
15062 @override 14028 @override
15063 Token get beginToken => leftParenthesis; 14029 Token get beginToken => leftParenthesis;
15064 14030
15065 @override 14031 @override
15066 Iterable get childEntities => new ChildEntities() 14032 Iterable get childEntities => new ChildEntities()
15067 ..add(leftParenthesis) 14033 ..add(leftParenthesis)
15068 ..add(_expression) 14034 ..add(_expression)
15069 ..add(rightParenthesis); 14035 ..add(rightParenthesis);
15070 14036
15071 @override 14037 @override
15072 Token get endToken => rightParenthesis; 14038 Token get endToken => rightParenthesis;
15073 14039
15074 /** 14040 /**
15075 * Return the expression within the parentheses. 14041 * Return the expression within the parentheses.
15076 *
15077 * @return the expression within the parentheses
15078 */ 14042 */
15079 Expression get expression => _expression; 14043 Expression get expression => _expression;
15080 14044
15081 /** 14045 /**
15082 * Set the expression within the parentheses to the given expression. 14046 * Set the expression within the parentheses to the given [expression].
15083 *
15084 * @param expression the expression within the parentheses
15085 */ 14047 */
15086 void set expression(Expression expression) { 14048 void set expression(Expression expression) {
15087 _expression = becomeParentOf(expression); 14049 _expression = becomeParentOf(expression);
15088 } 14050 }
15089 14051
15090 @override 14052 @override
15091 int get precedence => 15; 14053 int get precedence => 15;
15092 14054
15093 @override 14055 @override
15094 accept(AstVisitor visitor) => visitor.visitParenthesizedExpression(this); 14056 accept(AstVisitor visitor) => visitor.visitParenthesizedExpression(this);
15095 14057
15096 @override 14058 @override
15097 void visitChildren(AstVisitor visitor) { 14059 void visitChildren(AstVisitor visitor) {
15098 safelyVisitChild(_expression, visitor); 14060 _safelyVisitChild(_expression, visitor);
15099 } 14061 }
15100 } 14062 }
15101 14063
15102 /** 14064 /**
15103 * Instances of the class `PartDirective` represent a part directive. 14065 * A part directive.
15104 * 14066 *
15105 * <pre> 14067 * > partDirective ::=
15106 * partDirective ::= 14068 * > [Annotation] 'part' [StringLiteral] ';'
15107 * [Annotation] 'part' [StringLiteral] ';'
15108 * </pre>
15109 */ 14069 */
15110 class PartDirective extends UriBasedDirective { 14070 class PartDirective extends UriBasedDirective {
15111 /** 14071 /**
15112 * The token representing the 'part' token. 14072 * The token representing the 'part' token.
15113 */ 14073 */
15114 Token partToken; 14074 Token partToken;
15115 14075
15116 /** 14076 /**
15117 * The semicolon terminating the directive. 14077 * The semicolon terminating the directive.
15118 */ 14078 */
15119 Token semicolon; 14079 Token semicolon;
15120 14080
15121 /** 14081 /**
15122 * Initialize a newly created part directive. 14082 * Initialize a newly created part directive. Either or both of the [comment]
15123 * 14083 * and [metadata] can be `null` if the directive does not have the
15124 * @param comment the documentation comment associated with this directive 14084 * corresponding attribute.
15125 * @param metadata the annotations associated with the directive
15126 * @param partToken the token representing the 'part' token
15127 * @param partUri the URI of the part being included
15128 * @param semicolon the semicolon terminating the directive
15129 */ 14085 */
15130 PartDirective(Comment comment, List<Annotation> metadata, this.partToken, 14086 PartDirective(Comment comment, List<Annotation> metadata, this.partToken,
15131 StringLiteral partUri, this.semicolon) 14087 StringLiteral partUri, this.semicolon)
15132 : super(comment, metadata, partUri); 14088 : super(comment, metadata, partUri);
15133 14089
15134 /** 14090 /**
15135 * TODO(paulberry): untested. 14091 * TODO(paulberry): untested.
15136 */ 14092 */
15137 @override 14093 @override
15138 Iterable get childEntities => super._childEntities 14094 Iterable get childEntities => super._childEntities
(...skipping 11 matching lines...) Expand all
15150 Token get keyword => partToken; 14106 Token get keyword => partToken;
15151 14107
15152 @override 14108 @override
15153 CompilationUnitElement get uriElement => element as CompilationUnitElement; 14109 CompilationUnitElement get uriElement => element as CompilationUnitElement;
15154 14110
15155 @override 14111 @override
15156 accept(AstVisitor visitor) => visitor.visitPartDirective(this); 14112 accept(AstVisitor visitor) => visitor.visitPartDirective(this);
15157 } 14113 }
15158 14114
15159 /** 14115 /**
15160 * Instances of the class `PartOfDirective` represent a part-of directive. 14116 * A part-of directive.
15161 * 14117 *
15162 * <pre> 14118 * > partOfDirective ::=
15163 * partOfDirective ::= 14119 * > [Annotation] 'part' 'of' [Identifier] ';'
15164 * [Annotation] 'part' 'of' [Identifier] ';'
15165 * </pre>
15166 */ 14120 */
15167 class PartOfDirective extends Directive { 14121 class PartOfDirective extends Directive {
15168 /** 14122 /**
15169 * The token representing the 'part' token. 14123 * The token representing the 'part' token.
15170 */ 14124 */
15171 Token partToken; 14125 Token partToken;
15172 14126
15173 /** 14127 /**
15174 * The token representing the 'of' token. 14128 * The token representing the 'of' token.
15175 */ 14129 */
15176 Token ofToken; 14130 Token ofToken;
15177 14131
15178 /** 14132 /**
15179 * The name of the library that the containing compilation unit is part of. 14133 * The name of the library that the containing compilation unit is part of.
15180 */ 14134 */
15181 LibraryIdentifier _libraryName; 14135 LibraryIdentifier _libraryName;
15182 14136
15183 /** 14137 /**
15184 * The semicolon terminating the directive. 14138 * The semicolon terminating the directive.
15185 */ 14139 */
15186 Token semicolon; 14140 Token semicolon;
15187 14141
15188 /** 14142 /**
15189 * Initialize a newly created part-of directive. 14143 * Initialize a newly created part-of directive. Either or both of the
15190 * 14144 * [comment] and [metadata] can be `null` if the directive does not have the
15191 * @param comment the documentation comment associated with this directive 14145 * corresponding attribute.
15192 * @param metadata the annotations associated with the directive
15193 * @param partToken the token representing the 'part' token
15194 * @param ofToken the token representing the 'of' token
15195 * @param libraryName the name of the library that the containing compilation unit is part of
15196 * @param semicolon the semicolon terminating the directive
15197 */ 14146 */
15198 PartOfDirective(Comment comment, List<Annotation> metadata, this.partToken, 14147 PartOfDirective(Comment comment, List<Annotation> metadata, this.partToken,
15199 this.ofToken, LibraryIdentifier libraryName, this.semicolon) 14148 this.ofToken, LibraryIdentifier libraryName, this.semicolon)
15200 : super(comment, metadata) { 14149 : super(comment, metadata) {
15201 _libraryName = becomeParentOf(libraryName); 14150 _libraryName = becomeParentOf(libraryName);
15202 } 14151 }
15203 14152
15204 @override 14153 @override
15205 Iterable get childEntities => super._childEntities 14154 Iterable get childEntities => super._childEntities
15206 ..add(partToken) 14155 ..add(partToken)
15207 ..add(ofToken) 14156 ..add(ofToken)
15208 ..add(_libraryName) 14157 ..add(_libraryName)
15209 ..add(semicolon); 14158 ..add(semicolon);
15210 14159
15211 @override 14160 @override
15212 Token get endToken => semicolon; 14161 Token get endToken => semicolon;
15213 14162
15214 @override 14163 @override
15215 Token get firstTokenAfterCommentAndMetadata => partToken; 14164 Token get firstTokenAfterCommentAndMetadata => partToken;
15216 14165
15217 @override 14166 @override
15218 Token get keyword => partToken; 14167 Token get keyword => partToken;
15219 14168
15220 /** 14169 /**
15221 * Return the name of the library that the containing compilation unit is part of. 14170 * Return the name of the library that the containing compilation unit is part
15222 * 14171 * of.
15223 * @return the name of the library that the containing compilation unit is par t of
15224 */ 14172 */
15225 LibraryIdentifier get libraryName => _libraryName; 14173 LibraryIdentifier get libraryName => _libraryName;
15226 14174
15227 /** 14175 /**
15228 * Set the name of the library that the containing compilation unit is part of to the given name. 14176 * Set the name of the library that the containing compilation unit is part of
15229 * 14177 * to the given [libraryName].
15230 * @param libraryName the name of the library that the containing compilation unit is part of
15231 */ 14178 */
15232 void set libraryName(LibraryIdentifier libraryName) { 14179 void set libraryName(LibraryIdentifier libraryName) {
15233 _libraryName = becomeParentOf(libraryName); 14180 _libraryName = becomeParentOf(libraryName);
15234 } 14181 }
15235 14182
15236 @override 14183 @override
15237 accept(AstVisitor visitor) => visitor.visitPartOfDirective(this); 14184 accept(AstVisitor visitor) => visitor.visitPartOfDirective(this);
15238 14185
15239 @override 14186 @override
15240 void visitChildren(AstVisitor visitor) { 14187 void visitChildren(AstVisitor visitor) {
15241 super.visitChildren(visitor); 14188 super.visitChildren(visitor);
15242 safelyVisitChild(_libraryName, visitor); 14189 _safelyVisitChild(_libraryName, visitor);
15243 } 14190 }
15244 } 14191 }
15245 14192
15246 /** 14193 /**
15247 * Instances of the class `PostfixExpression` represent a postfix unary expressi on. 14194 * A postfix unary expression.
15248 * 14195 *
15249 * <pre> 14196 * > postfixExpression ::=
15250 * postfixExpression ::= 14197 * > [Expression] [Token]
15251 * [Expression] [Token]
15252 * </pre>
15253 */ 14198 */
15254 class PostfixExpression extends Expression { 14199 class PostfixExpression extends Expression {
15255 /** 14200 /**
15256 * The expression computing the operand for the operator. 14201 * The expression computing the operand for the operator.
15257 */ 14202 */
15258 Expression _operand; 14203 Expression _operand;
15259 14204
15260 /** 14205 /**
15261 * The postfix operator being applied to the operand. 14206 * The postfix operator being applied to the operand.
15262 */ 14207 */
15263 Token operator; 14208 Token operator;
15264 14209
15265 /** 14210 /**
15266 * The element associated with this the operator based on the propagated type of the operand, or 14211 * The element associated with this the operator based on the propagated type
15267 * `null` if the AST structure has not been resolved, if the operator is not u ser definable, 14212 * of the operand, or `null` if the AST structure has not been resolved, if
15268 * or if the operator could not be resolved. 14213 * the operator is not user definable, or if the operator could not be
14214 * resolved.
15269 */ 14215 */
15270 MethodElement propagatedElement; 14216 MethodElement propagatedElement;
15271 14217
15272 /** 14218 /**
15273 * The element associated with the operator based on the static type of the op erand, or 14219 * The element associated with the operator based on the static type of the
15274 * `null` if the AST structure has not been resolved, if the operator is not u ser definable, 14220 * operand, or `null` if the AST structure has not been resolved, if the
15275 * or if the operator could not be resolved. 14221 * operator is not user definable, or if the operator could not be resolved.
15276 */ 14222 */
15277 MethodElement staticElement; 14223 MethodElement staticElement;
15278 14224
15279 /** 14225 /**
15280 * Initialize a newly created postfix expression. 14226 * Initialize a newly created postfix expression.
15281 *
15282 * @param operand the expression computing the operand for the operator
15283 * @param operator the postfix operator being applied to the operand
15284 */ 14227 */
15285 PostfixExpression(Expression operand, this.operator) { 14228 PostfixExpression(Expression operand, this.operator) {
15286 _operand = becomeParentOf(operand); 14229 _operand = becomeParentOf(operand);
15287 } 14230 }
15288 14231
15289 @override 14232 @override
15290 Token get beginToken => _operand.beginToken; 14233 Token get beginToken => _operand.beginToken;
15291 14234
15292 /** 14235 /**
15293 * Return the best element available for this operator. If resolution was able to find a better 14236 * Return the best element available for this operator. If resolution was able
15294 * element based on type propagation, that element will be returned. Otherwise , the element found 14237 * to find a better element based on type propagation, that element will be
15295 * using the result of static analysis will be returned. If resolution has not been performed, 14238 * returned. Otherwise, the element found using the result of static analysis
15296 * then `null` will be returned. 14239 * will be returned. If resolution has not been performed, then `null` will be
15297 * 14240 * returned.
15298 * @return the best element available for this operator
15299 */ 14241 */
15300 MethodElement get bestElement { 14242 MethodElement get bestElement {
15301 MethodElement element = propagatedElement; 14243 MethodElement element = propagatedElement;
15302 if (element == null) { 14244 if (element == null) {
15303 element = staticElement; 14245 element = staticElement;
15304 } 14246 }
15305 return element; 14247 return element;
15306 } 14248 }
15307 14249
15308 /** 14250 /**
15309 * TODO(paulberry): untested. 14251 * TODO(paulberry): untested.
15310 */ 14252 */
15311 @override 14253 @override
15312 Iterable get childEntities => new ChildEntities() 14254 Iterable get childEntities => new ChildEntities()
15313 ..add(_operand) 14255 ..add(_operand)
15314 ..add(operator); 14256 ..add(operator);
15315 14257
15316 @override 14258 @override
15317 Token get endToken => operator; 14259 Token get endToken => operator;
15318 14260
15319 /** 14261 /**
15320 * Return the expression computing the operand for the operator. 14262 * Return the expression computing the operand for the operator.
15321 *
15322 * @return the expression computing the operand for the operator
15323 */ 14263 */
15324 Expression get operand => _operand; 14264 Expression get operand => _operand;
15325 14265
15326 /** 14266 /**
15327 * Set the expression computing the operand for the operator to the given expr ession. 14267 * Set the expression computing the operand for the operator to the given
15328 * 14268 * [expression].
15329 * @param expression the expression computing the operand for the operator
15330 */ 14269 */
15331 void set operand(Expression expression) { 14270 void set operand(Expression expression) {
15332 _operand = becomeParentOf(expression); 14271 _operand = becomeParentOf(expression);
15333 } 14272 }
15334 14273
15335 @override 14274 @override
15336 int get precedence => 15; 14275 int get precedence => 15;
15337 14276
15338 /** 14277 /**
15339 * If the AST structure has been resolved, and the function being invoked is k nown based on 14278 * If the AST structure has been resolved, and the function being invoked is
15340 * propagated type information, then return the parameter element representing the parameter to 14279 * known based on propagated type information, then return the parameter
15341 * which the value of the operand will be bound. Otherwise, return `null`. 14280 * element representing the parameter to which the value of the operand will
14281 * be bound. Otherwise, return `null`.
15342 * 14282 *
15343 * This method is only intended to be used by [Expression.propagatedParameterE lement]. 14283 * This method is only intended to be used by
15344 * 14284 * [Expression.propagatedParameterElement].
15345 * @return the parameter element representing the parameter to which the value of the right
15346 * operand will be bound
15347 */ 14285 */
15348 ParameterElement get propagatedParameterElementForOperand { 14286 ParameterElement get propagatedParameterElementForOperand {
15349 if (propagatedElement == null) { 14287 if (propagatedElement == null) {
15350 return null; 14288 return null;
15351 } 14289 }
15352 List<ParameterElement> parameters = propagatedElement.parameters; 14290 List<ParameterElement> parameters = propagatedElement.parameters;
15353 if (parameters.length < 1) { 14291 if (parameters.length < 1) {
15354 return null; 14292 return null;
15355 } 14293 }
15356 return parameters[0]; 14294 return parameters[0];
15357 } 14295 }
15358 14296
15359 /** 14297 /**
15360 * If the AST structure has been resolved, and the function being invoked is k nown based on static 14298 * If the AST structure has been resolved, and the function being invoked is
15361 * type information, then return the parameter element representing the parame ter to which the 14299 * known based on static type information, then return the parameter element
15362 * value of the operand will be bound. Otherwise, return `null`. 14300 * representing the parameter to which the value of the operand will be bound.
14301 * Otherwise, return `null`.
15363 * 14302 *
15364 * This method is only intended to be used by [Expression.staticParameterEleme nt]. 14303 * This method is only intended to be used by
15365 * 14304 * [Expression.staticParameterElement].
15366 * @return the parameter element representing the parameter to which the value of the right
15367 * operand will be bound
15368 */ 14305 */
15369 ParameterElement get staticParameterElementForOperand { 14306 ParameterElement get staticParameterElementForOperand {
15370 if (staticElement == null) { 14307 if (staticElement == null) {
15371 return null; 14308 return null;
15372 } 14309 }
15373 List<ParameterElement> parameters = staticElement.parameters; 14310 List<ParameterElement> parameters = staticElement.parameters;
15374 if (parameters.length < 1) { 14311 if (parameters.length < 1) {
15375 return null; 14312 return null;
15376 } 14313 }
15377 return parameters[0]; 14314 return parameters[0];
15378 } 14315 }
15379 14316
15380 @override 14317 @override
15381 accept(AstVisitor visitor) => visitor.visitPostfixExpression(this); 14318 accept(AstVisitor visitor) => visitor.visitPostfixExpression(this);
15382 14319
15383 @override 14320 @override
15384 void visitChildren(AstVisitor visitor) { 14321 void visitChildren(AstVisitor visitor) {
15385 safelyVisitChild(_operand, visitor); 14322 _safelyVisitChild(_operand, visitor);
15386 } 14323 }
15387 } 14324 }
15388 14325
15389 /** 14326 /**
15390 * Instances of the class `PrefixedIdentifier` represent either an identifier th at is prefixed 14327 * An identifier that is prefixed or an access to an object property where the
15391 * or an access to an object property where the target of the property access is a simple 14328 * target of the property access is a simple identifier.
15392 * identifier.
15393 * 14329 *
15394 * <pre> 14330 * > prefixedIdentifier ::=
15395 * prefixedIdentifier ::= 14331 * > [SimpleIdentifier] '.' [SimpleIdentifier]
15396 * [SimpleIdentifier] '.' [SimpleIdentifier]
15397 * </pre>
15398 */ 14332 */
15399 class PrefixedIdentifier extends Identifier { 14333 class PrefixedIdentifier extends Identifier {
15400 /** 14334 /**
15401 * The prefix associated with the library in which the identifier is defined. 14335 * The prefix associated with the library in which the identifier is defined.
15402 */ 14336 */
15403 SimpleIdentifier _prefix; 14337 SimpleIdentifier _prefix;
15404 14338
15405 /** 14339 /**
15406 * The period used to separate the prefix from the identifier. 14340 * The period used to separate the prefix from the identifier.
15407 */ 14341 */
15408 Token period; 14342 Token period;
15409 14343
15410 /** 14344 /**
15411 * The identifier being prefixed. 14345 * The identifier being prefixed.
15412 */ 14346 */
15413 SimpleIdentifier _identifier; 14347 SimpleIdentifier _identifier;
15414 14348
15415 /** 14349 /**
15416 * Initialize a newly created prefixed identifier. 14350 * Initialize a newly created prefixed identifier.
15417 *
15418 * @param prefix the identifier being prefixed
15419 * @param period the period used to separate the prefix from the identifier
15420 * @param identifier the prefix associated with the library in which the ident ifier is defined
15421 */ 14351 */
15422 PrefixedIdentifier(SimpleIdentifier prefix, this.period, 14352 PrefixedIdentifier(SimpleIdentifier prefix, this.period,
15423 SimpleIdentifier identifier) { 14353 SimpleIdentifier identifier) {
15424 _prefix = becomeParentOf(prefix); 14354 _prefix = becomeParentOf(prefix);
15425 _identifier = becomeParentOf(identifier); 14355 _identifier = becomeParentOf(identifier);
15426 } 14356 }
15427 14357
15428 @override 14358 @override
15429 Token get beginToken => _prefix.beginToken; 14359 Token get beginToken => _prefix.beginToken;
15430 14360
15431 @override 14361 @override
15432 Element get bestElement { 14362 Element get bestElement {
15433 if (_identifier == null) { 14363 if (_identifier == null) {
15434 return null; 14364 return null;
15435 } 14365 }
15436 return _identifier.bestElement; 14366 return _identifier.bestElement;
15437 } 14367 }
15438 14368
15439 @override 14369 @override
15440 Iterable get childEntities => new ChildEntities() 14370 Iterable get childEntities => new ChildEntities()
15441 ..add(_prefix) 14371 ..add(_prefix)
15442 ..add(period) 14372 ..add(period)
15443 ..add(_identifier); 14373 ..add(_identifier);
15444 14374
15445 @override 14375 @override
15446 Token get endToken => _identifier.endToken; 14376 Token get endToken => _identifier.endToken;
15447 14377
15448 /** 14378 /**
15449 * Return the identifier being prefixed. 14379 * Return the identifier being prefixed.
15450 *
15451 * @return the identifier being prefixed
15452 */ 14380 */
15453 SimpleIdentifier get identifier => _identifier; 14381 SimpleIdentifier get identifier => _identifier;
15454 14382
15455 /** 14383 /**
15456 * Set the identifier being prefixed to the given identifier. 14384 * Set the identifier being prefixed to the given [identifier].
15457 *
15458 * @param identifier the identifier being prefixed
15459 */ 14385 */
15460 void set identifier(SimpleIdentifier identifier) { 14386 void set identifier(SimpleIdentifier identifier) {
15461 _identifier = becomeParentOf(identifier); 14387 _identifier = becomeParentOf(identifier);
15462 } 14388 }
15463 14389
15464 /** 14390 /**
15465 * Return `true` if this type is a deferred type. 14391 * Return `true` if this type is a deferred type. If the AST structure has not
14392 * been resolved, then return `false`.
15466 * 14393 *
15467 * 15.1 Static Types: A type <i>T</i> is deferred iff it is of the form </i>p. T</i> where <i>p</i> 14394 * 15.1 Static Types: A type <i>T</i> is deferred iff it is of the form
15468 * is a deferred prefix. 14395 * </i>p.T</i> where <i>p</i> is a deferred prefix.
15469 *
15470 * @return `true` if this type is a deferred type
15471 */ 14396 */
15472 bool get isDeferred { 14397 bool get isDeferred {
15473 Element element = _prefix.staticElement; 14398 Element element = _prefix.staticElement;
15474 if (element is! PrefixElement) { 14399 if (element is! PrefixElement) {
15475 return false; 14400 return false;
15476 } 14401 }
15477 PrefixElement prefixElement = element as PrefixElement; 14402 PrefixElement prefixElement = element as PrefixElement;
15478 List<ImportElement> imports = 14403 List<ImportElement> imports =
15479 prefixElement.enclosingElement.getImportsWithPrefix(prefixElement); 14404 prefixElement.enclosingElement.getImportsWithPrefix(prefixElement);
15480 if (imports.length != 1) { 14405 if (imports.length != 1) {
15481 return false; 14406 return false;
15482 } 14407 }
15483 return imports[0].isDeferred; 14408 return imports[0].isDeferred;
15484 } 14409 }
15485 14410
15486 @override 14411 @override
15487 String get name => "${_prefix.name}.${_identifier.name}"; 14412 String get name => "${_prefix.name}.${_identifier.name}";
15488 14413
15489 @override 14414 @override
15490 int get precedence => 15; 14415 int get precedence => 15;
15491 14416
15492 /** 14417 /**
15493 * Return the prefix associated with the library in which the identifier is de fined. 14418 * Return the prefix associated with the library in which the identifier is
15494 * 14419 * defined.
15495 * @return the prefix associated with the library in which the identifier is d efined
15496 */ 14420 */
15497 SimpleIdentifier get prefix => _prefix; 14421 SimpleIdentifier get prefix => _prefix;
15498 14422
15499 /** 14423 /**
15500 * Set the prefix associated with the library in which the identifier is defin ed to the given 14424 * Set the prefix associated with the library in which the identifier is
15501 * identifier. 14425 * defined to the given [identifier].
15502 *
15503 * @param identifier the prefix associated with the library in which the ident ifier is defined
15504 */ 14426 */
15505 void set prefix(SimpleIdentifier identifier) { 14427 void set prefix(SimpleIdentifier identifier) {
15506 _prefix = becomeParentOf(identifier); 14428 _prefix = becomeParentOf(identifier);
15507 } 14429 }
15508 14430
15509 @override 14431 @override
15510 Element get propagatedElement { 14432 Element get propagatedElement {
15511 if (_identifier == null) { 14433 if (_identifier == null) {
15512 return null; 14434 return null;
15513 } 14435 }
15514 return _identifier.propagatedElement; 14436 return _identifier.propagatedElement;
15515 } 14437 }
15516 14438
15517 @override 14439 @override
15518 Element get staticElement { 14440 Element get staticElement {
15519 if (_identifier == null) { 14441 if (_identifier == null) {
15520 return null; 14442 return null;
15521 } 14443 }
15522 return _identifier.staticElement; 14444 return _identifier.staticElement;
15523 } 14445 }
15524 14446
15525 @override 14447 @override
15526 accept(AstVisitor visitor) => visitor.visitPrefixedIdentifier(this); 14448 accept(AstVisitor visitor) => visitor.visitPrefixedIdentifier(this);
15527 14449
15528 @override 14450 @override
15529 void visitChildren(AstVisitor visitor) { 14451 void visitChildren(AstVisitor visitor) {
15530 safelyVisitChild(_prefix, visitor); 14452 _safelyVisitChild(_prefix, visitor);
15531 safelyVisitChild(_identifier, visitor); 14453 _safelyVisitChild(_identifier, visitor);
15532 } 14454 }
15533 } 14455 }
15534 14456
15535 /** 14457 /**
15536 * Instances of the class `PrefixExpression` represent a prefix unary expression . 14458 * A prefix unary expression.
15537 * 14459 *
15538 * <pre> 14460 * > prefixExpression ::=
15539 * prefixExpression ::= 14461 * > [Token] [Expression]
15540 * [Token] [Expression]
15541 * </pre>
15542 */ 14462 */
15543 class PrefixExpression extends Expression { 14463 class PrefixExpression extends Expression {
15544 /** 14464 /**
15545 * The prefix operator being applied to the operand. 14465 * The prefix operator being applied to the operand.
15546 */ 14466 */
15547 Token operator; 14467 Token operator;
15548 14468
15549 /** 14469 /**
15550 * The expression computing the operand for the operator. 14470 * The expression computing the operand for the operator.
15551 */ 14471 */
15552 Expression _operand; 14472 Expression _operand;
15553 14473
15554 /** 14474 /**
15555 * The element associated with the operator based on the static type of the op erand, or 14475 * The element associated with the operator based on the static type of the
15556 * `null` if the AST structure has not been resolved, if the operator is not u ser definable, 14476 * operand, or `null` if the AST structure has not been resolved, if the
15557 * or if the operator could not be resolved. 14477 * operator is not user definable, or if the operator could not be resolved.
15558 */ 14478 */
15559 MethodElement staticElement; 14479 MethodElement staticElement;
15560 14480
15561 /** 14481 /**
15562 * The element associated with the operator based on the propagated type of th e operand, or 14482 * The element associated with the operator based on the propagated type of
15563 * `null` if the AST structure has not been resolved, if the operator is not u ser definable, 14483 * the operand, or `null` if the AST structure has not been resolved, if the
15564 * or if the operator could not be resolved. 14484 * operator is not user definable, or if the operator could not be resolved.
15565 */ 14485 */
15566 MethodElement propagatedElement; 14486 MethodElement propagatedElement;
15567 14487
15568 /** 14488 /**
15569 * Initialize a newly created prefix expression. 14489 * Initialize a newly created prefix expression.
15570 *
15571 * @param operator the prefix operator being applied to the operand
15572 * @param operand the expression computing the operand for the operator
15573 */ 14490 */
15574 PrefixExpression(this.operator, Expression operand) { 14491 PrefixExpression(this.operator, Expression operand) {
15575 _operand = becomeParentOf(operand); 14492 _operand = becomeParentOf(operand);
15576 } 14493 }
15577 14494
15578 @override 14495 @override
15579 Token get beginToken => operator; 14496 Token get beginToken => operator;
15580 14497
15581 /** 14498 /**
15582 * Return the best element available for this operator. If resolution was able to find a better 14499 * Return the best element available for this operator. If resolution was able
15583 * element based on type propagation, that element will be returned. Otherwise , the element found 14500 * to find a better element based on type propagation, that element will be
15584 * using the result of static analysis will be returned. If resolution has not been performed, 14501 * returned. Otherwise, the element found using the result of static analysis
15585 * then `null` will be returned. 14502 * will be returned. If resolution has not been performed, then `null` will be
15586 * 14503 * returned.
15587 * @return the best element available for this operator
15588 */ 14504 */
15589 MethodElement get bestElement { 14505 MethodElement get bestElement {
15590 MethodElement element = propagatedElement; 14506 MethodElement element = propagatedElement;
15591 if (element == null) { 14507 if (element == null) {
15592 element = staticElement; 14508 element = staticElement;
15593 } 14509 }
15594 return element; 14510 return element;
15595 } 14511 }
15596 14512
15597 @override 14513 @override
15598 Iterable get childEntities => new ChildEntities() 14514 Iterable get childEntities => new ChildEntities()
15599 ..add(operator) 14515 ..add(operator)
15600 ..add(_operand); 14516 ..add(_operand);
15601 14517
15602 @override 14518 @override
15603 Token get endToken => _operand.endToken; 14519 Token get endToken => _operand.endToken;
15604 14520
15605 /** 14521 /**
15606 * Return the expression computing the operand for the operator. 14522 * Return the expression computing the operand for the operator.
15607 *
15608 * @return the expression computing the operand for the operator
15609 */ 14523 */
15610 Expression get operand => _operand; 14524 Expression get operand => _operand;
15611 14525
15612 /** 14526 /**
15613 * Set the expression computing the operand for the operator to the given expr ession. 14527 * Set the expression computing the operand for the operator to the given
15614 * 14528 * [expression].
15615 * @param expression the expression computing the operand for the operator
15616 */ 14529 */
15617 void set operand(Expression expression) { 14530 void set operand(Expression expression) {
15618 _operand = becomeParentOf(expression); 14531 _operand = becomeParentOf(expression);
15619 } 14532 }
15620 14533
15621 @override 14534 @override
15622 int get precedence => 14; 14535 int get precedence => 14;
15623 14536
15624 /** 14537 /**
15625 * If the AST structure has been resolved, and the function being invoked is k nown based on 14538 * If the AST structure has been resolved, and the function being invoked is
15626 * propagated type information, then return the parameter element representing the parameter to 14539 * known based on propagated type information, then return the parameter
15627 * which the value of the operand will be bound. Otherwise, return `null`. 14540 * element representing the parameter to which the value of the operand will
14541 * be bound. Otherwise, return `null`.
15628 * 14542 *
15629 * This method is only intended to be used by [Expression.propagatedParameterE lement]. 14543 * This method is only intended to be used by
15630 * 14544 * [Expression.propagatedParameterElement].
15631 * @return the parameter element representing the parameter to which the value of the right
15632 * operand will be bound
15633 */ 14545 */
15634 ParameterElement get propagatedParameterElementForOperand { 14546 ParameterElement get propagatedParameterElementForOperand {
15635 if (propagatedElement == null) { 14547 if (propagatedElement == null) {
15636 return null; 14548 return null;
15637 } 14549 }
15638 List<ParameterElement> parameters = propagatedElement.parameters; 14550 List<ParameterElement> parameters = propagatedElement.parameters;
15639 if (parameters.length < 1) { 14551 if (parameters.length < 1) {
15640 return null; 14552 return null;
15641 } 14553 }
15642 return parameters[0]; 14554 return parameters[0];
15643 } 14555 }
15644 14556
15645 /** 14557 /**
15646 * If the AST structure has been resolved, and the function being invoked is k nown based on static 14558 * If the AST structure has been resolved, and the function being invoked is
15647 * type information, then return the parameter element representing the parame ter to which the 14559 * known based on static type information, then return the parameter element
15648 * value of the operand will be bound. Otherwise, return `null`. 14560 * representing the parameter to which the value of the operand will be bound.
14561 * Otherwise, return `null`.
15649 * 14562 *
15650 * This method is only intended to be used by [Expression.staticParameterEleme nt]. 14563 * This method is only intended to be used by
15651 * 14564 * [Expression.staticParameterElement].
15652 * @return the parameter element representing the parameter to which the value of the right
15653 * operand will be bound
15654 */ 14565 */
15655 ParameterElement get staticParameterElementForOperand { 14566 ParameterElement get staticParameterElementForOperand {
15656 if (staticElement == null) { 14567 if (staticElement == null) {
15657 return null; 14568 return null;
15658 } 14569 }
15659 List<ParameterElement> parameters = staticElement.parameters; 14570 List<ParameterElement> parameters = staticElement.parameters;
15660 if (parameters.length < 1) { 14571 if (parameters.length < 1) {
15661 return null; 14572 return null;
15662 } 14573 }
15663 return parameters[0]; 14574 return parameters[0];
15664 } 14575 }
15665 14576
15666 @override 14577 @override
15667 accept(AstVisitor visitor) => visitor.visitPrefixExpression(this); 14578 accept(AstVisitor visitor) => visitor.visitPrefixExpression(this);
15668 14579
15669 @override 14580 @override
15670 void visitChildren(AstVisitor visitor) { 14581 void visitChildren(AstVisitor visitor) {
15671 safelyVisitChild(_operand, visitor); 14582 _safelyVisitChild(_operand, visitor);
15672 } 14583 }
15673 } 14584 }
15674 14585
15675 /** 14586 /**
15676 * Instances of the class `PropertyAccess` represent the access of a property of an object. 14587 * The access of a property of an object.
15677 * 14588 *
15678 * Note, however, that accesses to properties of objects can also be represented as 14589 * Note, however, that accesses to properties of objects can also be represented
15679 * [PrefixedIdentifier] nodes in cases where the target is also a simple 14590 * as [PrefixedIdentifier] nodes in cases where the target is also a simple
15680 * identifier. 14591 * identifier.
15681 * 14592 *
15682 * <pre> 14593 * > propertyAccess ::=
15683 * propertyAccess ::= 14594 * > [Expression] '.' [SimpleIdentifier]
15684 * [Expression] '.' [SimpleIdentifier]
15685 * </pre>
15686 */ 14595 */
15687 class PropertyAccess extends Expression { 14596 class PropertyAccess extends Expression {
15688 /** 14597 /**
15689 * The expression computing the object defining the property being accessed. 14598 * The expression computing the object defining the property being accessed.
15690 */ 14599 */
15691 Expression _target; 14600 Expression _target;
15692 14601
15693 /** 14602 /**
15694 * The property access operator. 14603 * The property access operator.
15695 */ 14604 */
15696 Token operator; 14605 Token operator;
15697 14606
15698 /** 14607 /**
15699 * The name of the property being accessed. 14608 * The name of the property being accessed.
15700 */ 14609 */
15701 SimpleIdentifier _propertyName; 14610 SimpleIdentifier _propertyName;
15702 14611
15703 /** 14612 /**
15704 * Initialize a newly created property access expression. 14613 * Initialize a newly created property access expression.
15705 *
15706 * @param target the expression computing the object defining the property bei ng accessed
15707 * @param operator the property access operator
15708 * @param propertyName the name of the property being accessed
15709 */ 14614 */
15710 PropertyAccess(Expression target, this.operator, 14615 PropertyAccess(Expression target, this.operator,
15711 SimpleIdentifier propertyName) { 14616 SimpleIdentifier propertyName) {
15712 _target = becomeParentOf(target); 14617 _target = becomeParentOf(target);
15713 _propertyName = becomeParentOf(propertyName); 14618 _propertyName = becomeParentOf(propertyName);
15714 } 14619 }
15715 14620
15716 @override 14621 @override
15717 Token get beginToken { 14622 Token get beginToken {
15718 if (_target != null) { 14623 if (_target != null) {
15719 return _target.beginToken; 14624 return _target.beginToken;
15720 } 14625 }
15721 return operator; 14626 return operator;
15722 } 14627 }
15723 14628
15724 @override 14629 @override
15725 Iterable get childEntities => new ChildEntities() 14630 Iterable get childEntities => new ChildEntities()
15726 ..add(_target) 14631 ..add(_target)
15727 ..add(operator) 14632 ..add(operator)
15728 ..add(_propertyName); 14633 ..add(_propertyName);
15729 14634
15730 @override 14635 @override
15731 Token get endToken => _propertyName.endToken; 14636 Token get endToken => _propertyName.endToken;
15732 14637
15733 @override 14638 @override
15734 bool get isAssignable => true; 14639 bool get isAssignable => true;
15735 14640
15736 /** 14641 /**
15737 * Return `true` if this expression is cascaded. If it is, then the target of this 14642 * Return `true` if this expression is cascaded. If it is, then the target of
15738 * expression is not stored locally but is stored in the nearest ancestor that is a 14643 * this expression is not stored locally but is stored in the nearest ancestor
15739 * [CascadeExpression]. 14644 * that is a [CascadeExpression].
15740 *
15741 * @return `true` if this expression is cascaded
15742 */ 14645 */
15743 bool get isCascaded => 14646 bool get isCascaded =>
15744 operator != null && operator.type == TokenType.PERIOD_PERIOD; 14647 operator != null && operator.type == TokenType.PERIOD_PERIOD;
15745 14648
15746 @override 14649 @override
15747 int get precedence => 15; 14650 int get precedence => 15;
15748 14651
15749 /** 14652 /**
15750 * Return the name of the property being accessed. 14653 * Return the name of the property being accessed.
15751 *
15752 * @return the name of the property being accessed
15753 */ 14654 */
15754 SimpleIdentifier get propertyName => _propertyName; 14655 SimpleIdentifier get propertyName => _propertyName;
15755 14656
15756 /** 14657 /**
15757 * Set the name of the property being accessed to the given identifier. 14658 * Set the name of the property being accessed to the given [identifier].
15758 *
15759 * @param identifier the name of the property being accessed
15760 */ 14659 */
15761 void set propertyName(SimpleIdentifier identifier) { 14660 void set propertyName(SimpleIdentifier identifier) {
15762 _propertyName = becomeParentOf(identifier); 14661 _propertyName = becomeParentOf(identifier);
15763 } 14662 }
15764 14663
15765 /** 14664 /**
15766 * Return the expression used to compute the receiver of the invocation. If th is invocation is not 14665 * Return the expression used to compute the receiver of the invocation. If
15767 * part of a cascade expression, then this is the same as [getTarget]. If this invocation 14666 * this invocation is not part of a cascade expression, then this is the same
15768 * is part of a cascade expression, then the target stored with the cascade ex pression is 14667 * as [target]. If this invocation is part of a cascade expression, then the
15769 * returned. 14668 * target stored with the cascade expression is returned.
15770 *
15771 * @return the expression used to compute the receiver of the invocation
15772 * See [target].
15773 */ 14669 */
15774 Expression get realTarget { 14670 Expression get realTarget {
15775 if (isCascaded) { 14671 if (isCascaded) {
15776 AstNode ancestor = parent; 14672 AstNode ancestor = parent;
15777 while (ancestor is! CascadeExpression) { 14673 while (ancestor is! CascadeExpression) {
15778 if (ancestor == null) { 14674 if (ancestor == null) {
15779 return _target; 14675 return _target;
15780 } 14676 }
15781 ancestor = ancestor.parent; 14677 ancestor = ancestor.parent;
15782 } 14678 }
15783 return (ancestor as CascadeExpression).target; 14679 return (ancestor as CascadeExpression).target;
15784 } 14680 }
15785 return _target; 14681 return _target;
15786 } 14682 }
15787 14683
15788 /** 14684 /**
15789 * Return the expression computing the object defining the property being acce ssed, or 14685 * Return the expression computing the object defining the property being
15790 * `null` if this property access is part of a cascade expression. 14686 * accessed, or `null` if this property access is part of a cascade expression .
15791 * 14687 *
15792 * @return the expression computing the object defining the property being acc essed 14688 * Use [realTarget] to get the target independent of whether this is part of a
15793 * See [realTarget]. 14689 * cascade expression.
15794 */ 14690 */
15795 Expression get target => _target; 14691 Expression get target => _target;
15796 14692
15797 /** 14693 /**
15798 * Set the expression computing the object defining the property being accesse d to the given 14694 * Set the expression computing the object defining the property being
15799 * expression. 14695 * accessed to the given [expression].
15800 *
15801 * @param expression the expression computing the object defining the property being accessed
15802 */ 14696 */
15803 void set target(Expression expression) { 14697 void set target(Expression expression) {
15804 _target = becomeParentOf(expression); 14698 _target = becomeParentOf(expression);
15805 } 14699 }
15806 14700
15807 @override 14701 @override
15808 accept(AstVisitor visitor) => visitor.visitPropertyAccess(this); 14702 accept(AstVisitor visitor) => visitor.visitPropertyAccess(this);
15809 14703
15810 @override 14704 @override
15811 void visitChildren(AstVisitor visitor) { 14705 void visitChildren(AstVisitor visitor) {
15812 safelyVisitChild(_target, visitor); 14706 _safelyVisitChild(_target, visitor);
15813 safelyVisitChild(_propertyName, visitor); 14707 _safelyVisitChild(_propertyName, visitor);
15814 } 14708 }
15815 } 14709 }
15816 14710
15817 /** 14711 /**
15818 * Instances of the class `RecursiveAstVisitor` implement an AST visitor that wi ll recursively 14712 * An AST visitor that will recursively visit all of the nodes in an AST
15819 * visit all of the nodes in an AST structure. For example, using an instance of this class to visit 14713 * structure. For example, using an instance of this class to visit a [Block]
15820 * a [Block] will also cause all of the statements in the block to be visited. 14714 * will also cause all of the statements in the block to be visited.
15821 * 14715 *
15822 * Subclasses that override a visit method must either invoke the overridden vis it method or must 14716 * Subclasses that override a visit method must either invoke the overridden
15823 * explicitly ask the visited node to visit its children. Failure to do so will cause the children 14717 * visit method or must explicitly ask the visited node to visit its children.
15824 * of the visited node to not be visited. 14718 * Failure to do so will cause the children of the visited node to not be
14719 * visited.
15825 */ 14720 */
15826 class RecursiveAstVisitor<R> implements AstVisitor<R> { 14721 class RecursiveAstVisitor<R> implements AstVisitor<R> {
15827 @override 14722 @override
15828 R visitAdjacentStrings(AdjacentStrings node) { 14723 R visitAdjacentStrings(AdjacentStrings node) {
15829 node.visitChildren(this); 14724 node.visitChildren(this);
15830 return null; 14725 return null;
15831 } 14726 }
15832 14727
15833 @override 14728 @override
15834 R visitAnnotation(Annotation node) { 14729 R visitAnnotation(Annotation node) {
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
16456 } 15351 }
16457 15352
16458 @override 15353 @override
16459 R visitYieldStatement(YieldStatement node) { 15354 R visitYieldStatement(YieldStatement node) {
16460 node.visitChildren(this); 15355 node.visitChildren(this);
16461 return null; 15356 return null;
16462 } 15357 }
16463 } 15358 }
16464 15359
16465 /** 15360 /**
16466 * Instances of the class `RedirectingConstructorInvocation` represent the invoc ation of a 15361 * The invocation of a constructor in the same class from within a constructor's
16467 * another constructor in the same class from within a constructor's initializat ion list. 15362 * initialization list.
16468 * 15363 *
16469 * <pre> 15364 * > redirectingConstructorInvocation ::=
16470 * redirectingConstructorInvocation ::= 15365 * > 'this' ('.' identifier)? arguments
16471 * 'this' ('.' identifier)? arguments
16472 * </pre>
16473 */ 15366 */
16474 class RedirectingConstructorInvocation extends ConstructorInitializer { 15367 class RedirectingConstructorInvocation extends ConstructorInitializer {
16475 /** 15368 /**
16476 * The token for the 'this' keyword. 15369 * The token for the 'this' keyword.
16477 */ 15370 */
16478 Token keyword; 15371 Token keyword;
16479 15372
16480 /** 15373 /**
16481 * The token for the period before the name of the constructor that is being i nvoked, or 15374 * The token for the period before the name of the constructor that is being
16482 * `null` if the unnamed constructor is being invoked. 15375 * invoked, or `null` if the unnamed constructor is being invoked.
16483 */ 15376 */
16484 Token period; 15377 Token period;
16485 15378
16486 /** 15379 /**
16487 * The name of the constructor that is being invoked, or `null` if the unnamed constructor 15380 * The name of the constructor that is being invoked, or `null` if the unnamed
16488 * is being invoked. 15381 * constructor is being invoked.
16489 */ 15382 */
16490 SimpleIdentifier _constructorName; 15383 SimpleIdentifier _constructorName;
16491 15384
16492 /** 15385 /**
16493 * The list of arguments to the constructor. 15386 * The list of arguments to the constructor.
16494 */ 15387 */
16495 ArgumentList _argumentList; 15388 ArgumentList _argumentList;
16496 15389
16497 /** 15390 /**
16498 * The element associated with the constructor based on static type informatio n, or `null` 15391 * The element associated with the constructor based on static type
16499 * if the AST structure has not been resolved or if the constructor could not be resolved. 15392 * information, or `null` if the AST structure has not been resolved or if the
15393 * constructor could not be resolved.
16500 */ 15394 */
16501 ConstructorElement staticElement; 15395 ConstructorElement staticElement;
16502 15396
16503 /** 15397 /**
16504 * Initialize a newly created redirecting invocation to invoke the constructor with the given name 15398 * Initialize a newly created redirecting invocation to invoke the constructor
16505 * with the given arguments. 15399 * with the given name with the given arguments. The [constructorName] can be
16506 * 15400 * `null` if the constructor being invoked is the unnamed constructor.
16507 * @param keyword the token for the 'this' keyword
16508 * @param period the token for the period before the name of the constructor t hat is being invoked
16509 * @param constructorName the name of the constructor that is being invoked
16510 * @param argumentList the list of arguments to the constructor
16511 */ 15401 */
16512 RedirectingConstructorInvocation(this.keyword, this.period, 15402 RedirectingConstructorInvocation(this.keyword, this.period,
16513 SimpleIdentifier constructorName, ArgumentList argumentList) { 15403 SimpleIdentifier constructorName, ArgumentList argumentList) {
16514 _constructorName = becomeParentOf(constructorName); 15404 _constructorName = becomeParentOf(constructorName);
16515 _argumentList = becomeParentOf(argumentList); 15405 _argumentList = becomeParentOf(argumentList);
16516 } 15406 }
16517 15407
16518 /** 15408 /**
16519 * Return the list of arguments to the constructor. 15409 * Return the list of arguments to the constructor.
16520 *
16521 * @return the list of arguments to the constructor
16522 */ 15410 */
16523 ArgumentList get argumentList => _argumentList; 15411 ArgumentList get argumentList => _argumentList;
16524 15412
16525 /** 15413 /**
16526 * Set the list of arguments to the constructor to the given list. 15414 * Set the list of arguments to the constructor to the given [argumentList].
16527 *
16528 * @param argumentList the list of arguments to the constructor
16529 */ 15415 */
16530 void set argumentList(ArgumentList argumentList) { 15416 void set argumentList(ArgumentList argumentList) {
16531 _argumentList = becomeParentOf(argumentList); 15417 _argumentList = becomeParentOf(argumentList);
16532 } 15418 }
16533 15419
16534 @override 15420 @override
16535 Token get beginToken => keyword; 15421 Token get beginToken => keyword;
16536 15422
16537 @override 15423 @override
16538 Iterable get childEntities => new ChildEntities() 15424 Iterable get childEntities => new ChildEntities()
16539 ..add(keyword) 15425 ..add(keyword)
16540 ..add(period) 15426 ..add(period)
16541 ..add(_constructorName) 15427 ..add(_constructorName)
16542 ..add(_argumentList); 15428 ..add(_argumentList);
16543 15429
16544 /** 15430 /**
16545 * Return the name of the constructor that is being invoked, or `null` if the unnamed 15431 * Return the name of the constructor that is being invoked, or `null` if the
16546 * constructor is being invoked. 15432 * unnamed constructor is being invoked.
16547 *
16548 * @return the name of the constructor that is being invoked
16549 */ 15433 */
16550 SimpleIdentifier get constructorName => _constructorName; 15434 SimpleIdentifier get constructorName => _constructorName;
16551 15435
16552 /** 15436 /**
16553 * Set the name of the constructor that is being invoked to the given identifi er. 15437 * Set the name of the constructor that is being invoked to the given
16554 * 15438 * [identifier].
16555 * @param identifier the name of the constructor that is being invoked
16556 */ 15439 */
16557 void set constructorName(SimpleIdentifier identifier) { 15440 void set constructorName(SimpleIdentifier identifier) {
16558 _constructorName = becomeParentOf(identifier); 15441 _constructorName = becomeParentOf(identifier);
16559 } 15442 }
16560 15443
16561 @override 15444 @override
16562 Token get endToken => _argumentList.endToken; 15445 Token get endToken => _argumentList.endToken;
16563 15446
16564 @override 15447 @override
16565 accept(AstVisitor visitor) => 15448 accept(AstVisitor visitor) =>
16566 visitor.visitRedirectingConstructorInvocation(this); 15449 visitor.visitRedirectingConstructorInvocation(this);
16567 15450
16568 @override 15451 @override
16569 void visitChildren(AstVisitor visitor) { 15452 void visitChildren(AstVisitor visitor) {
16570 safelyVisitChild(_constructorName, visitor); 15453 _safelyVisitChild(_constructorName, visitor);
16571 safelyVisitChild(_argumentList, visitor); 15454 _safelyVisitChild(_argumentList, visitor);
16572 } 15455 }
16573 } 15456 }
16574 15457
16575 /** 15458 /**
16576 * Instances of the class `RethrowExpression` represent a rethrow expression. 15459 * A rethrow expression.
16577 * 15460 *
16578 * <pre> 15461 * > rethrowExpression ::=
16579 * rethrowExpression ::= 15462 * > 'rethrow'
16580 * 'rethrow'
16581 * </pre>
16582 */ 15463 */
16583 class RethrowExpression extends Expression { 15464 class RethrowExpression extends Expression {
16584 /** 15465 /**
16585 * The token representing the 'rethrow' keyword. 15466 * The token representing the 'rethrow' keyword.
16586 */ 15467 */
16587 Token keyword; 15468 Token keyword;
16588 15469
16589 /** 15470 /**
16590 * Initialize a newly created rethrow expression. 15471 * Initialize a newly created rethrow expression.
16591 *
16592 * @param keyword the token representing the 'rethrow' keyword
16593 */ 15472 */
16594 RethrowExpression(this.keyword); 15473 RethrowExpression(this.keyword);
16595 15474
16596 @override 15475 @override
16597 Token get beginToken => keyword; 15476 Token get beginToken => keyword;
16598 15477
16599 /** 15478 /**
16600 * TODO(paulberry): untested. 15479 * TODO(paulberry): untested.
16601 */ 15480 */
16602 @override 15481 @override
16603 Iterable get childEntities => new ChildEntities()..add(keyword); 15482 Iterable get childEntities => new ChildEntities()..add(keyword);
16604 15483
16605 @override 15484 @override
16606 Token get endToken => keyword; 15485 Token get endToken => keyword;
16607 15486
16608 @override 15487 @override
16609 int get precedence => 0; 15488 int get precedence => 0;
16610 15489
16611 @override 15490 @override
16612 accept(AstVisitor visitor) => visitor.visitRethrowExpression(this); 15491 accept(AstVisitor visitor) => visitor.visitRethrowExpression(this);
16613 15492
16614 @override 15493 @override
16615 void visitChildren(AstVisitor visitor) { 15494 void visitChildren(AstVisitor visitor) {
16616 // There are no children to visit. 15495 // There are no children to visit.
16617 } 15496 }
16618 } 15497 }
16619 15498
16620 /** 15499 /**
16621 * Instances of the class `ReturnStatement` represent a return statement. 15500 * A return statement.
16622 * 15501 *
16623 * <pre> 15502 * > returnStatement ::=
16624 * returnStatement ::= 15503 * > 'return' [Expression]? ';'
16625 * 'return' [Expression]? ';'
16626 * </pre>
16627 */ 15504 */
16628 class ReturnStatement extends Statement { 15505 class ReturnStatement extends Statement {
16629 /** 15506 /**
16630 * The token representing the 'return' keyword. 15507 * The token representing the 'return' keyword.
16631 */ 15508 */
16632 Token keyword; 15509 Token keyword;
16633 15510
16634 /** 15511 /**
16635 * The expression computing the value to be returned, or `null` if no explicit value was 15512 * The expression computing the value to be returned, or `null` if no explicit
16636 * provided. 15513 * value was provided.
16637 */ 15514 */
16638 Expression _expression; 15515 Expression _expression;
16639 15516
16640 /** 15517 /**
16641 * The semicolon terminating the statement. 15518 * The semicolon terminating the statement.
16642 */ 15519 */
16643 Token semicolon; 15520 Token semicolon;
16644 15521
16645 /** 15522 /**
16646 * Initialize a newly created return statement. 15523 * Initialize a newly created return statement. The [expression] can be `null`
16647 * 15524 * if no explicit value was provided.
16648 * @param keyword the token representing the 'return' keyword
16649 * @param expression the expression computing the value to be returned
16650 * @param semicolon the semicolon terminating the statement
16651 */ 15525 */
16652 ReturnStatement(this.keyword, Expression expression, this.semicolon) { 15526 ReturnStatement(this.keyword, Expression expression, this.semicolon) {
16653 _expression = becomeParentOf(expression); 15527 _expression = becomeParentOf(expression);
16654 } 15528 }
16655 15529
16656 @override 15530 @override
16657 Token get beginToken => keyword; 15531 Token get beginToken => keyword;
16658 15532
16659 @override 15533 @override
16660 Iterable get childEntities => new ChildEntities() 15534 Iterable get childEntities => new ChildEntities()
16661 ..add(keyword) 15535 ..add(keyword)
16662 ..add(_expression) 15536 ..add(_expression)
16663 ..add(semicolon); 15537 ..add(semicolon);
16664 15538
16665 @override 15539 @override
16666 Token get endToken => semicolon; 15540 Token get endToken => semicolon;
16667 15541
16668 /** 15542 /**
16669 * Return the expression computing the value to be returned, or `null` if no e xplicit value 15543 * Return the expression computing the value to be returned, or `null` if no
16670 * was provided. 15544 * explicit value was provided.
16671 *
16672 * @return the expression computing the value to be returned
16673 */ 15545 */
16674 Expression get expression => _expression; 15546 Expression get expression => _expression;
16675 15547
16676 /** 15548 /**
16677 * Set the expression computing the value to be returned to the given expressi on. 15549 * Set the expression computing the value to be returned to the given
16678 * 15550 * [expression].
16679 * @param expression the expression computing the value to be returned
16680 */ 15551 */
16681 void set expression(Expression expression) { 15552 void set expression(Expression expression) {
16682 _expression = becomeParentOf(expression); 15553 _expression = becomeParentOf(expression);
16683 } 15554 }
16684 15555
16685 @override 15556 @override
16686 accept(AstVisitor visitor) => visitor.visitReturnStatement(this); 15557 accept(AstVisitor visitor) => visitor.visitReturnStatement(this);
16687 15558
16688 @override 15559 @override
16689 void visitChildren(AstVisitor visitor) { 15560 void visitChildren(AstVisitor visitor) {
16690 safelyVisitChild(_expression, visitor); 15561 _safelyVisitChild(_expression, visitor);
16691 } 15562 }
16692 } 15563 }
16693 15564
16694 /** 15565 /**
16695 * Traverse the AST from initial child node to successive parents, building a co llection of local 15566 * Traverse the AST from initial child node to successive parents, building a
16696 * variable and parameter names visible to the initial child node. In case of na me shadowing, the 15567 * collection of local variable and parameter names visible to the initial child
16697 * first name seen is the most specific one so names are not redefined. 15568 * node. In case of name shadowing, the first name seen is the most specific one
15569 * so names are not redefined.
16698 * 15570 *
16699 * Completion test code coverage is 95%. The two basic blocks that are not execu ted cannot be 15571 * Completion test code coverage is 95%. The two basic blocks that are not
16700 * executed. They are included for future reference. 15572 * executed cannot be executed. They are included for future reference.
16701 */ 15573 */
16702 class ScopedNameFinder extends GeneralizingAstVisitor<Object> { 15574 class ScopedNameFinder extends GeneralizingAstVisitor<Object> {
16703 Declaration _declarationNode; 15575 Declaration _declarationNode;
16704 15576
16705 AstNode _immediateChild; 15577 AstNode _immediateChild;
16706 15578
16707 Map<String, SimpleIdentifier> _locals = 15579 Map<String, SimpleIdentifier> _locals =
16708 new HashMap<String, SimpleIdentifier>(); 15580 new HashMap<String, SimpleIdentifier>();
16709 15581
16710 final int _position; 15582 final int _position;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
16834 15706
16835 void _addToScope(SimpleIdentifier identifier) { 15707 void _addToScope(SimpleIdentifier identifier) {
16836 if (identifier != null && _isInRange(identifier)) { 15708 if (identifier != null && _isInRange(identifier)) {
16837 String name = identifier.name; 15709 String name = identifier.name;
16838 if (!_locals.containsKey(name)) { 15710 if (!_locals.containsKey(name)) {
16839 _locals[name] = identifier; 15711 _locals[name] = identifier;
16840 } 15712 }
16841 } 15713 }
16842 } 15714 }
16843 15715
16844 void _addVariables(NodeList<VariableDeclaration> vars) { 15716 void _addVariables(NodeList<VariableDeclaration> variables) {
16845 for (VariableDeclaration var2 in vars) { 15717 for (VariableDeclaration variable in variables) {
16846 _addToScope(var2.name); 15718 _addToScope(variable.name);
16847 } 15719 }
16848 } 15720 }
16849 15721
16850 /** 15722 /**
16851 * Some statements define names that are visible downstream. There aren't many of these. 15723 * Check the given list of [statements] for any that come before the immediate
16852 * 15724 * child and that define a name that would be visible to the immediate child.
16853 * @param statements the list of statements to check for name definitions
16854 */ 15725 */
16855 void _checkStatements(List<Statement> statements) { 15726 void _checkStatements(List<Statement> statements) {
16856 for (Statement stmt in statements) { 15727 for (Statement statement in statements) {
16857 if (identical(stmt, _immediateChild)) { 15728 if (identical(statement, _immediateChild)) {
16858 return; 15729 return;
16859 } 15730 }
16860 if (stmt is VariableDeclarationStatement) { 15731 if (statement is VariableDeclarationStatement) {
16861 _addVariables(stmt.variables.variables); 15732 _addVariables(statement.variables.variables);
16862 } else if (stmt is FunctionDeclarationStatement && 15733 } else if (statement is FunctionDeclarationStatement &&
16863 !_referenceIsWithinLocalFunction) { 15734 !_referenceIsWithinLocalFunction) {
16864 _addToScope(stmt.functionDeclaration.name); 15735 _addToScope(statement.functionDeclaration.name);
16865 } 15736 }
16866 } 15737 }
16867 } 15738 }
16868 15739
16869 bool _isInRange(AstNode node) { 15740 bool _isInRange(AstNode node) {
16870 if (_position < 0) { 15741 if (_position < 0) {
16871 // if source position is not set then all nodes are in range 15742 // if source position is not set then all nodes are in range
16872 return true; 15743 return true;
16873 // not reached 15744 // not reached
16874 } 15745 }
16875 return node.end < _position; 15746 return node.end < _position;
16876 } 15747 }
16877 } 15748 }
16878 15749
16879 /** 15750 /**
16880 * Instances of the class `ScriptTag` represent the script tag that can optional ly occur at 15751 * A script tag that can optionally occur at the beginning of a compilation unit .
16881 * the beginning of a compilation unit.
16882 * 15752 *
16883 * <pre> 15753 * > scriptTag ::=
16884 * scriptTag ::= 15754 * > '#!' (~NEWLINE)* NEWLINE
16885 * '#!' (~NEWLINE)* NEWLINE
16886 * </pre>
16887 */ 15755 */
16888 class ScriptTag extends AstNode { 15756 class ScriptTag extends AstNode {
16889 /** 15757 /**
16890 * The token representing this script tag. 15758 * The token representing this script tag.
16891 */ 15759 */
16892 Token scriptTag; 15760 Token scriptTag;
16893 15761
16894 /** 15762 /**
16895 * Initialize a newly created script tag. 15763 * Initialize a newly created script tag.
16896 *
16897 * @param scriptTag the token representing this script tag
16898 */ 15764 */
16899 ScriptTag(this.scriptTag); 15765 ScriptTag(this.scriptTag);
16900 15766
16901 @override 15767 @override
16902 Token get beginToken => scriptTag; 15768 Token get beginToken => scriptTag;
16903 15769
16904 /** 15770 /**
16905 * TODO(paulberry): untested. 15771 * TODO(paulberry): untested.
16906 */ 15772 */
16907 @override 15773 @override
16908 Iterable get childEntities => new ChildEntities()..add(scriptTag); 15774 Iterable get childEntities => new ChildEntities()..add(scriptTag);
16909 15775
16910 @override 15776 @override
16911 Token get endToken => scriptTag; 15777 Token get endToken => scriptTag;
16912 15778
16913 @override 15779 @override
16914 accept(AstVisitor visitor) => visitor.visitScriptTag(this); 15780 accept(AstVisitor visitor) => visitor.visitScriptTag(this);
16915 15781
16916 @override 15782 @override
16917 void visitChildren(AstVisitor visitor) { 15783 void visitChildren(AstVisitor visitor) {
16918 // There are no children to visit. 15784 // There are no children to visit.
16919 } 15785 }
16920 } 15786 }
16921 15787
16922 /** 15788 /**
16923 * Instances of the class `ShowCombinator` represent a combinator that restricts the names 15789 * A combinator that restricts the names being imported to those in a given list .
16924 * being imported to those in a given list.
16925 * 15790 *
16926 * <pre> 15791 * > showCombinator ::=
16927 * showCombinator ::= 15792 * > 'show' [SimpleIdentifier] (',' [SimpleIdentifier])*
16928 * 'show' [SimpleIdentifier] (',' [SimpleIdentifier])*
16929 * </pre>
16930 */ 15793 */
16931 class ShowCombinator extends Combinator { 15794 class ShowCombinator extends Combinator {
16932 /** 15795 /**
16933 * The list of names from the library that are made visible by this combinator . 15796 * The list of names from the library that are made visible by this combinator .
16934 */ 15797 */
16935 NodeList<SimpleIdentifier> _shownNames; 15798 NodeList<SimpleIdentifier> _shownNames;
16936 15799
16937 /** 15800 /**
16938 * Initialize a newly created import show combinator. 15801 * Initialize a newly created import show combinator.
16939 *
16940 * @param keyword the comma introducing the combinator
16941 * @param shownNames the list of names from the library that are made visible by this combinator
16942 */ 15802 */
16943 ShowCombinator(Token keyword, List<SimpleIdentifier> shownNames) 15803 ShowCombinator(Token keyword, List<SimpleIdentifier> shownNames)
16944 : super(keyword) { 15804 : super(keyword) {
16945 _shownNames = new NodeList<SimpleIdentifier>(this, shownNames); 15805 _shownNames = new NodeList<SimpleIdentifier>(this, shownNames);
16946 } 15806 }
16947 15807
16948 /** 15808 /**
16949 * TODO(paulberry): add commas. 15809 * TODO(paulberry): add commas.
16950 */ 15810 */
16951 @override 15811 @override
16952 Iterable get childEntities => new ChildEntities() 15812 Iterable get childEntities => new ChildEntities()
16953 ..add(keyword) 15813 ..add(keyword)
16954 ..addAll(_shownNames); 15814 ..addAll(_shownNames);
16955 15815
16956 @override 15816 @override
16957 Token get endToken => _shownNames.endToken; 15817 Token get endToken => _shownNames.endToken;
16958 15818
16959 /** 15819 /**
16960 * Return the list of names from the library that are made visible by this com binator. 15820 * Return the list of names from the library that are made visible by this
16961 * 15821 * combinator.
16962 * @return the list of names from the library that are made visible by this co mbinator
16963 */ 15822 */
16964 NodeList<SimpleIdentifier> get shownNames => _shownNames; 15823 NodeList<SimpleIdentifier> get shownNames => _shownNames;
16965 15824
16966 @override 15825 @override
16967 accept(AstVisitor visitor) => visitor.visitShowCombinator(this); 15826 accept(AstVisitor visitor) => visitor.visitShowCombinator(this);
16968 15827
16969 @override 15828 @override
16970 void visitChildren(AstVisitor visitor) { 15829 void visitChildren(AstVisitor visitor) {
16971 _shownNames.accept(visitor); 15830 _shownNames.accept(visitor);
16972 } 15831 }
16973 } 15832 }
16974 15833
16975 /** 15834 /**
16976 * Instances of the class `SimpleAstVisitor` implement an AST visitor that will do nothing 15835 * An AST visitor that will do nothing when visiting an AST node. It is intended
16977 * when visiting an AST node. It is intended to be a superclass for classes that use the visitor 15836 * to be a superclass for classes that use the visitor pattern primarily as a
16978 * pattern primarily as a dispatch mechanism (and hence don't need to recursivel y visit a whole 15837 * dispatch mechanism (and hence don't need to recursively visit a whole
16979 * structure) and that only need to visit a small number of node types. 15838 * structure) and that only need to visit a small number of node types.
16980 */ 15839 */
16981 class SimpleAstVisitor<R> implements AstVisitor<R> { 15840 class SimpleAstVisitor<R> implements AstVisitor<R> {
16982 @override 15841 @override
16983 R visitAdjacentStrings(AdjacentStrings node) => null; 15842 R visitAdjacentStrings(AdjacentStrings node) => null;
16984 15843
16985 @override 15844 @override
16986 R visitAnnotation(Annotation node) => null; 15845 R visitAnnotation(Annotation node) => null;
16987 15846
16988 @override 15847 @override
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
17298 R visitWhileStatement(WhileStatement node) => null; 16157 R visitWhileStatement(WhileStatement node) => null;
17299 16158
17300 @override 16159 @override
17301 R visitWithClause(WithClause node) => null; 16160 R visitWithClause(WithClause node) => null;
17302 16161
17303 @override 16162 @override
17304 R visitYieldStatement(YieldStatement node) => null; 16163 R visitYieldStatement(YieldStatement node) => null;
17305 } 16164 }
17306 16165
17307 /** 16166 /**
17308 * Instances of the class `SimpleFormalParameter` represent a simple formal para meter. 16167 * A simple formal parameter.
17309 * 16168 *
17310 * <pre> 16169 * > simpleFormalParameter ::=
17311 * simpleFormalParameter ::= 16170 * > ('final' [TypeName] | 'var' | [TypeName])? [SimpleIdentifier]
17312 * ('final' [TypeName] | 'var' | [TypeName])? [SimpleIdentifier]
17313 * </pre>
17314 */ 16171 */
17315 class SimpleFormalParameter extends NormalFormalParameter { 16172 class SimpleFormalParameter extends NormalFormalParameter {
17316 /** 16173 /**
17317 * The token representing either the 'final', 'const' or 'var' keyword, or `nu ll` if no 16174 * The token representing either the 'final', 'const' or 'var' keyword, or
17318 * keyword was used. 16175 * `null` if no keyword was used.
17319 */ 16176 */
17320 Token keyword; 16177 Token keyword;
17321 16178
17322 /** 16179 /**
17323 * The name of the declared type of the parameter, or `null` if the parameter does not have 16180 * The name of the declared type of the parameter, or `null` if the parameter
17324 * a declared type. 16181 * does not have a declared type.
17325 */ 16182 */
17326 TypeName _type; 16183 TypeName _type;
17327 16184
17328 /** 16185 /**
17329 * Initialize a newly created formal parameter. 16186 * Initialize a newly created formal parameter. Either or both of the
17330 * 16187 * [comment] and [metadata] can be `null` if the parameter does not have the
17331 * @param comment the documentation comment associated with this parameter 16188 * corresponding attribute. The [keyword] can be `null` if a type was
17332 * @param metadata the annotations associated with this parameter 16189 * specified. The [type] must be `null` if the keyword is 'var'.
17333 * @param keyword the token representing either the 'final', 'const' or 'var' keyword
17334 * @param type the name of the declared type of the parameter
17335 * @param identifier the name of the parameter being declared
17336 */ 16190 */
17337 SimpleFormalParameter(Comment comment, List<Annotation> metadata, 16191 SimpleFormalParameter(Comment comment, List<Annotation> metadata,
17338 this.keyword, TypeName type, SimpleIdentifier identifier) 16192 this.keyword, TypeName type, SimpleIdentifier identifier)
17339 : super(comment, metadata, identifier) { 16193 : super(comment, metadata, identifier) {
17340 _type = becomeParentOf(type); 16194 _type = becomeParentOf(type);
17341 } 16195 }
17342 16196
17343 @override 16197 @override
17344 Token get beginToken { 16198 Token get beginToken {
17345 NodeList<Annotation> metadata = this.metadata; 16199 NodeList<Annotation> metadata = this.metadata;
(...skipping 21 matching lines...) Expand all
17367 16221
17368 @override 16222 @override
17369 bool get isConst => 16223 bool get isConst =>
17370 (keyword is KeywordToken) && (keyword as KeywordToken).keyword == Keyword. CONST; 16224 (keyword is KeywordToken) && (keyword as KeywordToken).keyword == Keyword. CONST;
17371 16225
17372 @override 16226 @override
17373 bool get isFinal => 16227 bool get isFinal =>
17374 (keyword is KeywordToken) && (keyword as KeywordToken).keyword == Keyword. FINAL; 16228 (keyword is KeywordToken) && (keyword as KeywordToken).keyword == Keyword. FINAL;
17375 16229
17376 /** 16230 /**
17377 * Return the name of the declared type of the parameter, or `null` if the par ameter does 16231 * Return the name of the declared type of the parameter, or `null` if the
17378 * not have a declared type. 16232 * parameter does not have a declared type.
17379 *
17380 * @return the name of the declared type of the parameter
17381 */ 16233 */
17382 TypeName get type => _type; 16234 TypeName get type => _type;
17383 16235
17384 /** 16236 /**
17385 * Set the name of the declared type of the parameter to the given type name. 16237 * Set the name of the declared type of the parameter to the given [typeName].
17386 *
17387 * @param typeName the name of the declared type of the parameter
17388 */ 16238 */
17389 void set type(TypeName typeName) { 16239 void set type(TypeName typeName) {
17390 _type = becomeParentOf(typeName); 16240 _type = becomeParentOf(typeName);
17391 } 16241 }
17392 16242
17393 @override 16243 @override
17394 accept(AstVisitor visitor) => visitor.visitSimpleFormalParameter(this); 16244 accept(AstVisitor visitor) => visitor.visitSimpleFormalParameter(this);
17395 16245
17396 @override 16246 @override
17397 void visitChildren(AstVisitor visitor) { 16247 void visitChildren(AstVisitor visitor) {
17398 super.visitChildren(visitor); 16248 super.visitChildren(visitor);
17399 safelyVisitChild(_type, visitor); 16249 _safelyVisitChild(_type, visitor);
17400 safelyVisitChild(identifier, visitor); 16250 _safelyVisitChild(identifier, visitor);
17401 } 16251 }
17402 } 16252 }
17403 16253
17404 /** 16254 /**
17405 * Instances of the class `SimpleIdentifier` represent a simple identifier. 16255 * A simple identifier.
17406 * 16256 *
17407 * <pre> 16257 * > simpleIdentifier ::=
17408 * simpleIdentifier ::= 16258 * > initialCharacter internalCharacter*
17409 * initialCharacter internalCharacter* 16259 * >
17410 * 16260 * > initialCharacter ::= '_' | '$' | letter
17411 * initialCharacter ::= '_' | '$' | letter 16261 * >
17412 * 16262 * > internalCharacter ::= '_' | '$' | letter | digit
17413 * internalCharacter ::= '_' | '$' | letter | digit
17414 * </pre>
17415 */ 16263 */
17416 class SimpleIdentifier extends Identifier { 16264 class SimpleIdentifier extends Identifier {
17417 /** 16265 /**
17418 * The token representing the identifier. 16266 * The token representing the identifier.
17419 */ 16267 */
17420 Token token; 16268 Token token;
17421 16269
17422 /** 16270 /**
17423 * The element associated with this identifier based on static type informatio n, or `null` 16271 * The element associated with this identifier based on static type
17424 * if the AST structure has not been resolved or if this identifier could not be resolved. 16272 * information, or `null` if the AST structure has not been resolved or if
16273 * this identifier could not be resolved.
17425 */ 16274 */
17426 Element _staticElement; 16275 Element _staticElement;
17427 16276
17428 /** 16277 /**
17429 * The element associated with this identifier based on propagated type inform ation, or 16278 * The element associated with this identifier based on propagated type
17430 * `null` if the AST structure has not been resolved or if this identifier cou ld not be 16279 * information, or `null` if the AST structure has not been resolved or if
17431 * resolved. 16280 * this identifier could not be resolved.
17432 */ 16281 */
17433 Element _propagatedElement; 16282 Element _propagatedElement;
17434 16283
17435 /** 16284 /**
17436 * If this expression is both in a getter and setter context, the [AuxiliaryEl ements] will 16285 * If this expression is both in a getter and setter context, the
17437 * be set to hold onto the static and propagated information. The auxiliary el ement will hold onto 16286 * [AuxiliaryElements] will be set to hold onto the static and propagated
17438 * the elements from the getter context. 16287 * information. The auxiliary element will hold onto the elements from the
16288 * getter context.
17439 */ 16289 */
17440 AuxiliaryElements auxiliaryElements = null; 16290 AuxiliaryElements auxiliaryElements = null;
17441 16291
17442 /** 16292 /**
17443 * Initialize a newly created identifier. 16293 * Initialize a newly created identifier.
17444 *
17445 * @param token the token representing the identifier
17446 */ 16294 */
17447 SimpleIdentifier(this.token); 16295 SimpleIdentifier(this.token);
17448 16296
17449 @override 16297 @override
17450 Token get beginToken => token; 16298 Token get beginToken => token;
17451 16299
17452 @override 16300 @override
17453 Element get bestElement { 16301 Element get bestElement {
17454 if (_propagatedElement == null) { 16302 if (_propagatedElement == null) {
17455 return _staticElement; 16303 return _staticElement;
17456 } 16304 }
17457 return _propagatedElement; 16305 return _propagatedElement;
17458 } 16306 }
17459 16307
17460 /** 16308 /**
17461 * TODO(paulberry): untested. 16309 * TODO(paulberry): untested.
17462 */ 16310 */
17463 @override 16311 @override
17464 Iterable get childEntities => new ChildEntities()..add(token); 16312 Iterable get childEntities => new ChildEntities()..add(token);
17465 16313
17466 @override 16314 @override
17467 Token get endToken => token; 16315 Token get endToken => token;
17468 16316
17469 /** 16317 /**
17470 * Returns `true` if this identifier is the "name" part of a prefixed identifi er or a method 16318 * Returns `true` if this identifier is the "name" part of a prefixed
17471 * invocation. 16319 * identifier or a method invocation.
17472 *
17473 * @return `true` if this identifier is the "name" part of a prefixed identifi er or a method
17474 * invocation
17475 */ 16320 */
17476 bool get isQualified { 16321 bool get isQualified {
17477 AstNode parent = this.parent; 16322 AstNode parent = this.parent;
17478 if (parent is PrefixedIdentifier) { 16323 if (parent is PrefixedIdentifier) {
17479 return identical(parent.identifier, this); 16324 return identical(parent.identifier, this);
17480 } 16325 }
17481 if (parent is PropertyAccess) { 16326 if (parent is PropertyAccess) {
17482 return identical(parent.propertyName, this); 16327 return identical(parent.propertyName, this);
17483 } 16328 }
17484 if (parent is MethodInvocation) { 16329 if (parent is MethodInvocation) {
(...skipping 10 matching lines...) Expand all
17495 @override 16340 @override
17496 String get name => token.lexeme; 16341 String get name => token.lexeme;
17497 16342
17498 @override 16343 @override
17499 int get precedence => 16; 16344 int get precedence => 16;
17500 16345
17501 @override 16346 @override
17502 Element get propagatedElement => _propagatedElement; 16347 Element get propagatedElement => _propagatedElement;
17503 16348
17504 /** 16349 /**
17505 * Set the element associated with this identifier based on propagated type in formation to the 16350 * Set the element associated with this identifier based on propagated type
17506 * given element. 16351 * information to the given [element].
17507 *
17508 * @param element the element to be associated with this identifier
17509 */ 16352 */
17510 void set propagatedElement(Element element) { 16353 void set propagatedElement(Element element) {
17511 _propagatedElement = _validateElement(element); 16354 _propagatedElement = _validateElement(element);
17512 } 16355 }
17513 16356
17514 @override 16357 @override
17515 Element get staticElement => _staticElement; 16358 Element get staticElement => _staticElement;
17516 16359
17517 /** 16360 /**
17518 * Set the element associated with this identifier based on static type inform ation to the given 16361 * Set the element associated with this identifier based on static type
17519 * element. 16362 * information to the given [element].
17520 *
17521 * @param element the element to be associated with this identifier
17522 */ 16363 */
17523 void set staticElement(Element element) { 16364 void set staticElement(Element element) {
17524 _staticElement = _validateElement(element); 16365 _staticElement = _validateElement(element);
17525 } 16366 }
17526 16367
17527 @override 16368 @override
17528 accept(AstVisitor visitor) => visitor.visitSimpleIdentifier(this); 16369 accept(AstVisitor visitor) => visitor.visitSimpleIdentifier(this);
17529 16370
17530 /** 16371 /**
17531 * Return `true` if this identifier is the name being declared in a declaratio n. 16372 * Return `true` if this identifier is the name being declared in a
17532 * 16373 * declaration.
17533 * @return `true` if this identifier is the name being declared in a declarati on
17534 */ 16374 */
17535 bool inDeclarationContext() { 16375 bool inDeclarationContext() {
17536 AstNode parent = this.parent; 16376 AstNode parent = this.parent;
17537 if (parent is CatchClause) { 16377 if (parent is CatchClause) {
17538 CatchClause clause = parent; 16378 CatchClause clause = parent;
17539 return identical(this, clause.exceptionParameter) || 16379 return identical(this, clause.exceptionParameter) ||
17540 identical(this, clause.stackTraceParameter); 16380 identical(this, clause.stackTraceParameter);
17541 } else if (parent is ClassDeclaration) { 16381 } else if (parent is ClassDeclaration) {
17542 return identical(this, parent.name); 16382 return identical(this, parent.name);
17543 } else if (parent is ClassTypeAlias) { 16383 } else if (parent is ClassTypeAlias) {
(...skipping 24 matching lines...) Expand all
17568 return identical(this, parent.name); 16408 return identical(this, parent.name);
17569 } else if (parent is VariableDeclaration) { 16409 } else if (parent is VariableDeclaration) {
17570 return identical(this, parent.name); 16410 return identical(this, parent.name);
17571 } 16411 }
17572 return false; 16412 return false;
17573 } 16413 }
17574 16414
17575 /** 16415 /**
17576 * Return `true` if this expression is computing a right-hand value. 16416 * Return `true` if this expression is computing a right-hand value.
17577 * 16417 *
17578 * Note that [inGetterContext] and [inSetterContext] are not opposites, nor ar e 16418 * Note that [inGetterContext] and [inSetterContext] are not opposites, nor
17579 * they mutually exclusive. In other words, it is possible for both methods to return `true` 16419 * are they mutually exclusive. In other words, it is possible for both
17580 * when invoked on the same node. 16420 * methods to return `true` when invoked on the same node.
17581 *
17582 * @return `true` if this expression is in a context where a getter will be in voked
17583 */ 16421 */
17584 bool inGetterContext() { 16422 bool inGetterContext() {
17585 AstNode parent = this.parent; 16423 AstNode parent = this.parent;
17586 AstNode target = this; 16424 AstNode target = this;
17587 // skip prefix 16425 // skip prefix
17588 if (parent is PrefixedIdentifier) { 16426 if (parent is PrefixedIdentifier) {
17589 PrefixedIdentifier prefixed = parent as PrefixedIdentifier; 16427 PrefixedIdentifier prefixed = parent as PrefixedIdentifier;
17590 if (identical(prefixed.prefix, this)) { 16428 if (identical(prefixed.prefix, this)) {
17591 return true; 16429 return true;
17592 } 16430 }
(...skipping 24 matching lines...) Expand all
17617 if (identical(stmt.identifier, target)) { 16455 if (identical(stmt.identifier, target)) {
17618 return false; 16456 return false;
17619 } 16457 }
17620 } 16458 }
17621 return true; 16459 return true;
17622 } 16460 }
17623 16461
17624 /** 16462 /**
17625 * Return `true` if this expression is computing a left-hand value. 16463 * Return `true` if this expression is computing a left-hand value.
17626 * 16464 *
17627 * Note that [inGetterContext] and [inSetterContext] are not opposites, nor ar e 16465 * Note that [inGetterContext] and [inSetterContext] are not opposites, nor
17628 * they mutually exclusive. In other words, it is possible for both methods to return `true` 16466 * are they mutually exclusive. In other words, it is possible for both
17629 * when invoked on the same node. 16467 * methods to return `true` when invoked on the same node.
17630 *
17631 * @return `true` if this expression is in a context where a setter will be in voked
17632 */ 16468 */
17633 bool inSetterContext() { 16469 bool inSetterContext() {
17634 AstNode parent = this.parent; 16470 AstNode parent = this.parent;
17635 AstNode target = this; 16471 AstNode target = this;
17636 // skip prefix 16472 // skip prefix
17637 if (parent is PrefixedIdentifier) { 16473 if (parent is PrefixedIdentifier) {
17638 PrefixedIdentifier prefixed = parent as PrefixedIdentifier; 16474 PrefixedIdentifier prefixed = parent as PrefixedIdentifier;
17639 // if this is the prefix, then return false 16475 // if this is the prefix, then return false
17640 if (identical(prefixed.prefix, this)) { 16476 if (identical(prefixed.prefix, this)) {
17641 return false; 16477 return false;
(...skipping 20 matching lines...) Expand all
17662 } 16498 }
17663 return false; 16499 return false;
17664 } 16500 }
17665 16501
17666 @override 16502 @override
17667 void visitChildren(AstVisitor visitor) { 16503 void visitChildren(AstVisitor visitor) {
17668 // There are no children to visit. 16504 // There are no children to visit.
17669 } 16505 }
17670 16506
17671 /** 16507 /**
17672 * Return the given element if it is valid, or report the problem and return ` null` if it is 16508 * Return the given element if it is valid, or report the problem and return
17673 * not appropriate. 16509 * `null` if it is not appropriate.
17674 * 16510 *
17675 * @param parent the parent of the element, used for reporting when there is a problem 16511 * The [parent] is the parent of the element, used for reporting when there is
17676 * @param isValid `true` if the element is appropriate 16512 * a problem.
17677 * @param element the element to be associated with this identifier 16513 * The [isValid] is `true` if the element is appropriate.
17678 * @return the element to be associated with this identifier 16514 * The [element] is the element to be associated with this identifier.
17679 */ 16515 */
17680 Element _returnOrReportElement(AstNode parent, bool isValid, 16516 Element _returnOrReportElement(AstNode parent, bool isValid,
17681 Element element) { 16517 Element element) {
17682 if (!isValid) { 16518 if (!isValid) {
17683 AnalysisEngine.instance.logger.logInformation( 16519 AnalysisEngine.instance.logger.logInformation(
17684 "Internal error: attempting to set the name of a ${parent.runtimeType} to a ${element.runtimeType}", 16520 "Internal error: attempting to set the name of a ${parent.runtimeType} to a ${element.runtimeType}",
17685 new CaughtException(new AnalysisException(), null)); 16521 new CaughtException(new AnalysisException(), null));
17686 return null; 16522 return null;
17687 } 16523 }
17688 return element; 16524 return element;
17689 } 16525 }
17690 16526
17691 /** 16527 /**
17692 * Return the given element if it is an appropriate element based on the paren t of this 16528 * Return the given [element] if it is an appropriate element based on the
17693 * identifier, or `null` if it is not appropriate. 16529 * parent of this identifier, or `null` if it is not appropriate.
17694 *
17695 * @param element the element to be associated with this identifier
17696 * @return the element to be associated with this identifier
17697 */ 16530 */
17698 Element _validateElement(Element element) { 16531 Element _validateElement(Element element) {
17699 if (element == null) { 16532 if (element == null) {
17700 return null; 16533 return null;
17701 } 16534 }
17702 AstNode parent = this.parent; 16535 AstNode parent = this.parent;
17703 if (parent is ClassDeclaration && identical(parent.name, this)) { 16536 if (parent is ClassDeclaration && identical(parent.name, this)) {
17704 return _returnOrReportElement(parent, element is ClassElement, element); 16537 return _returnOrReportElement(parent, element is ClassElement, element);
17705 } else if (parent is ClassTypeAlias && identical(parent.name, this)) { 16538 } else if (parent is ClassTypeAlias && identical(parent.name, this)) {
17706 return _returnOrReportElement(parent, element is ClassElement, element); 16539 return _returnOrReportElement(parent, element is ClassElement, element);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
17740 return _returnOrReportElement( 16573 return _returnOrReportElement(
17741 parent, 16574 parent,
17742 element is VariableElement, 16575 element is VariableElement,
17743 element); 16576 element);
17744 } 16577 }
17745 return element; 16578 return element;
17746 } 16579 }
17747 } 16580 }
17748 16581
17749 /** 16582 /**
17750 * Instances of the class `SimpleStringLiteral` represent a string literal expre ssion that 16583 * A string literal expression that does not contain any interpolations.
17751 * does not contain any interpolations.
17752 * 16584 *
17753 * <pre> 16585 * > simpleStringLiteral ::=
17754 * simpleStringLiteral ::= 16586 * > rawStringLiteral
17755 * rawStringLiteral 16587 * > | basicStringLiteral
17756 * | basicStringLiteral 16588 * >
17757 * 16589 * > rawStringLiteral ::=
17758 * rawStringLiteral ::= 16590 * > 'r' basicStringLiteral
17759 * 'r' basicStringLiteral 16591 * >
17760 * 16592 * > simpleStringLiteral ::=
17761 * simpleStringLiteral ::= 16593 * > multiLineStringLiteral
17762 * multiLineStringLiteral 16594 * > | singleLineStringLiteral
17763 * | singleLineStringLiteral 16595 * >
17764 * 16596 * > multiLineStringLiteral ::=
17765 * multiLineStringLiteral ::= 16597 * > "'''" characters "'''"
17766 * "'''" characters "'''" 16598 * > | '"""' characters '"""'
17767 * | '"""' characters '"""' 16599 * >
17768 * 16600 * > singleLineStringLiteral ::=
17769 * singleLineStringLiteral ::= 16601 * > "'" characters "'"
17770 * "'" characters "'" 16602 * > | '"' characters '"'
17771 * '"' characters '"'
17772 * </pre>
17773 */ 16603 */
17774 class SimpleStringLiteral extends SingleStringLiteral { 16604 class SimpleStringLiteral extends SingleStringLiteral {
17775 /** 16605 /**
17776 * The token representing the literal. 16606 * The token representing the literal.
17777 */ 16607 */
17778 Token literal; 16608 Token literal;
17779 16609
17780 /** 16610 /**
17781 * The value of the literal. 16611 * The value of the literal.
17782 */ 16612 */
17783 String _value; 16613 String _value;
17784 16614
17785 /** 16615 /**
17786 * The toolkit specific element associated with this literal, or `null`. 16616 * The toolkit specific element associated with this literal, or `null`.
17787 */ 16617 */
17788 Element toolkitElement; 16618 Element toolkitElement;
17789 16619
17790 /** 16620 /**
17791 * Initialize a newly created simple string literal. 16621 * Initialize a newly created simple string literal.
17792 *
17793 * @param literal the token representing the literal
17794 * @param value the value of the literal
17795 */ 16622 */
17796 SimpleStringLiteral(this.literal, String value) { 16623 SimpleStringLiteral(this.literal, String value) {
17797 _value = StringUtilities.intern(value); 16624 _value = StringUtilities.intern(value);
17798 } 16625 }
17799 16626
17800 @override 16627 @override
17801 Token get beginToken => literal; 16628 Token get beginToken => literal;
17802 16629
17803 @override 16630 @override
17804 Iterable get childEntities => new ChildEntities()..add(literal); 16631 Iterable get childEntities => new ChildEntities()..add(literal);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
17855 return lexeme.length > 1 && lexeme.codeUnitAt(1) == 0x27; 16682 return lexeme.length > 1 && lexeme.codeUnitAt(1) == 0x27;
17856 } 16683 }
17857 return codeZero == 0x27; 16684 return codeZero == 0x27;
17858 } 16685 }
17859 16686
17860 @override 16687 @override
17861 bool get isSynthetic => literal.isSynthetic; 16688 bool get isSynthetic => literal.isSynthetic;
17862 16689
17863 /** 16690 /**
17864 * Return the value of the literal. 16691 * Return the value of the literal.
17865 *
17866 * @return the value of the literal
17867 */ 16692 */
17868 String get value => _value; 16693 String get value => _value;
17869 16694
17870 /** 16695 /**
17871 * Set the value of the literal to the given string. 16696 * Set the value of the literal to the given [string].
17872 *
17873 * @param string the value of the literal
17874 */ 16697 */
17875 void set value(String string) { 16698 void set value(String string) {
17876 _value = StringUtilities.intern(_value); 16699 _value = StringUtilities.intern(_value);
17877 } 16700 }
17878 16701
17879 @override 16702 @override
17880 accept(AstVisitor visitor) => visitor.visitSimpleStringLiteral(this); 16703 accept(AstVisitor visitor) => visitor.visitSimpleStringLiteral(this);
17881 16704
17882 @override 16705 @override
17883 void appendStringValue(StringBuffer buffer) { 16706 void appendStringValue(StringBuffer buffer) {
17884 buffer.write(value); 16707 buffer.write(value);
17885 } 16708 }
17886 16709
17887 @override 16710 @override
17888 void visitChildren(AstVisitor visitor) { 16711 void visitChildren(AstVisitor visitor) {
17889 // There are no children to visit. 16712 // There are no children to visit.
17890 } 16713 }
17891 } 16714 }
17892 16715
17893 /** 16716 /**
17894 * Instances of the class [SingleStringLiteral] represent a single string 16717 * A single string literal expression.
17895 * literal expression.
17896 * 16718 *
17897 * <pre> 16719 * > singleStringLiteral ::=
17898 * singleStringLiteral ::= 16720 * > [SimpleStringLiteral]
17899 * [SimpleStringLiteral] 16721 * > | [StringInterpolation]
17900 * | [StringInterpolation]
17901 * </pre>
17902 */ 16722 */
17903 abstract class SingleStringLiteral extends StringLiteral { 16723 abstract class SingleStringLiteral extends StringLiteral {
17904 /** 16724 /**
17905 * Return the offset of the after-last contents character. 16725 * Return the offset of the after-last contents character.
17906 */ 16726 */
17907 int get contentsEnd; 16727 int get contentsEnd;
17908 16728
17909 /** 16729 /**
17910 * Return the offset of the first contents character. 16730 * Return the offset of the first contents character.
17911 */ 16731 */
(...skipping 10 matching lines...) Expand all
17922 bool get isRaw; 16742 bool get isRaw;
17923 16743
17924 /** 16744 /**
17925 * Return `true` if this string literal uses single qoutes (' or '''). 16745 * Return `true` if this string literal uses single qoutes (' or ''').
17926 * Return `false` if this string literal uses double qoutes (" or """). 16746 * Return `false` if this string literal uses double qoutes (" or """).
17927 */ 16747 */
17928 bool get isSingleQuoted; 16748 bool get isSingleQuoted;
17929 } 16749 }
17930 16750
17931 /** 16751 /**
17932 * Instances of the class `Statement` defines the behavior common to nodes that represent a 16752 * A node that represents a statement.
17933 * statement.
17934 * 16753 *
17935 * <pre> 16754 * > statement ::=
17936 * statement ::= 16755 * > [Block]
17937 * [Block] 16756 * > | [VariableDeclarationStatement]
17938 * | [VariableDeclarationStatement] 16757 * > | [ForStatement]
17939 * | [ForStatement] 16758 * > | [ForEachStatement]
17940 * | [ForEachStatement] 16759 * > | [WhileStatement]
17941 * | [WhileStatement] 16760 * > | [DoStatement]
17942 * | [DoStatement] 16761 * > | [SwitchStatement]
17943 * | [SwitchStatement] 16762 * > | [IfStatement]
17944 * | [IfStatement] 16763 * > | [TryStatement]
17945 * | [TryStatement] 16764 * > | [BreakStatement]
17946 * | [BreakStatement] 16765 * > | [ContinueStatement]
17947 * | [ContinueStatement] 16766 * > | [ReturnStatement]
17948 * | [ReturnStatement] 16767 * > | [ExpressionStatement]
17949 * | [ExpressionStatement] 16768 * > | [FunctionDeclarationStatement]
17950 * | [FunctionDeclarationStatement]
17951 * </pre>
17952 */ 16769 */
17953 abstract class Statement extends AstNode { 16770 abstract class Statement extends AstNode {
17954 /** 16771 /**
17955 * If this is a labeled statement, return the unlabeled portion of the 16772 * If this is a labeled statement, return the unlabeled portion of the
17956 * statement. Otherwise return the statement itself. 16773 * statement. Otherwise return the statement itself.
17957 */ 16774 */
17958 Statement get unlabeled => this; 16775 Statement get unlabeled => this;
17959 } 16776 }
17960 16777
17961 /** 16778 /**
17962 * Instances of the class `StringInterpolation` represent a string interpolation literal. 16779 * A string interpolation literal.
17963 * 16780 *
17964 * <pre> 16781 * > stringInterpolation ::=
17965 * stringInterpolation ::= 16782 * > ''' [InterpolationElement]* '''
17966 * ''' [InterpolationElement]* ''' 16783 * > | '"' [InterpolationElement]* '"'
17967 * | '"' [InterpolationElement]* '"'
17968 * </pre>
17969 */ 16784 */
17970 class StringInterpolation extends SingleStringLiteral { 16785 class StringInterpolation extends SingleStringLiteral {
17971 /** 16786 /**
17972 * The elements that will be composed to produce the resulting string. 16787 * The elements that will be composed to produce the resulting string.
17973 */ 16788 */
17974 NodeList<InterpolationElement> _elements; 16789 NodeList<InterpolationElement> _elements;
17975 16790
17976 /** 16791 /**
17977 * Initialize a newly created string interpolation expression. 16792 * Initialize a newly created string interpolation expression.
17978 *
17979 * @param elements the elements that will be composed to produce the resulting string
17980 */ 16793 */
17981 StringInterpolation(List<InterpolationElement> elements) { 16794 StringInterpolation(List<InterpolationElement> elements) {
17982 _elements = new NodeList<InterpolationElement>(this, elements); 16795 _elements = new NodeList<InterpolationElement>(this, elements);
17983 } 16796 }
17984 16797
17985 @override 16798 @override
17986 Token get beginToken => _elements.beginToken; 16799 Token get beginToken => _elements.beginToken;
17987 16800
17988 @override 16801 @override
17989 Iterable get childEntities => new ChildEntities()..addAll(_elements); 16802 Iterable get childEntities => new ChildEntities()..addAll(_elements);
17990 16803
17991 @override 16804 @override
17992 int get contentsEnd { 16805 int get contentsEnd {
17993 InterpolationString element = _elements.last; 16806 InterpolationString element = _elements.last;
17994 return element.contentsEnd; 16807 return element.contentsEnd;
17995 } 16808 }
17996 16809
17997 @override 16810 @override
17998 int get contentsOffset { 16811 int get contentsOffset {
17999 InterpolationString element = _elements.first; 16812 InterpolationString element = _elements.first;
18000 return element.contentsOffset; 16813 return element.contentsOffset;
18001 } 16814 }
18002 16815
18003 /** 16816 /**
18004 * Return the elements that will be composed to produce the resulting string. 16817 * Return the elements that will be composed to produce the resulting string.
18005 *
18006 * @return the elements that will be composed to produce the resulting string
18007 */ 16818 */
18008 NodeList<InterpolationElement> get elements => _elements; 16819 NodeList<InterpolationElement> get elements => _elements;
18009 16820
18010 @override 16821 @override
18011 Token get endToken => _elements.endToken; 16822 Token get endToken => _elements.endToken;
18012 16823
18013 @override 16824 @override
18014 bool get isMultiline { 16825 bool get isMultiline {
18015 InterpolationString element = _elements.first; 16826 InterpolationString element = _elements.first;
18016 String lexeme = element.contents.lexeme; 16827 String lexeme = element.contents.lexeme;
(...skipping 22 matching lines...) Expand all
18039 throw new IllegalArgumentException(); 16850 throw new IllegalArgumentException();
18040 } 16851 }
18041 16852
18042 @override 16853 @override
18043 void visitChildren(AstVisitor visitor) { 16854 void visitChildren(AstVisitor visitor) {
18044 _elements.accept(visitor); 16855 _elements.accept(visitor);
18045 } 16856 }
18046 } 16857 }
18047 16858
18048 /** 16859 /**
18049 * Instances of the class `StringLiteral` represent a string literal expression. 16860 * A string literal expression.
18050 * 16861 *
18051 * <pre> 16862 * > stringLiteral ::=
18052 * stringLiteral ::= 16863 * > [SimpleStringLiteral]
18053 * [SimpleStringLiteral] 16864 * > | [AdjacentStrings]
18054 * | [AdjacentStrings] 16865 * > | [StringInterpolation]
18055 * | [StringInterpolation]
18056 * </pre>
18057 */ 16866 */
18058 abstract class StringLiteral extends Literal { 16867 abstract class StringLiteral extends Literal {
18059 /** 16868 /**
18060 * Return the value of the string literal, or `null` if the string is not a 16869 * Return the value of the string literal, or `null` if the string is not a
18061 * constant string without any string interpolation. 16870 * constant string without any string interpolation.
18062 */ 16871 */
18063 String get stringValue { 16872 String get stringValue {
18064 StringBuffer buffer = new StringBuffer(); 16873 StringBuffer buffer = new StringBuffer();
18065 try { 16874 try {
18066 appendStringValue(buffer); 16875 appendStringValue(buffer);
18067 } on IllegalArgumentException catch (exception) { 16876 } on IllegalArgumentException catch (exception) {
18068 return null; 16877 return null;
18069 } 16878 }
18070 return buffer.toString(); 16879 return buffer.toString();
18071 } 16880 }
18072 16881
18073 /** 16882 /**
18074 * Append the value of this string literal to the given [buffer]. Throw an 16883 * Append the value of this string literal to the given [buffer]. Throw an
18075 * [IllegalArgumentException] if the string is not a constant string without 16884 * [IllegalArgumentException] if the string is not a constant string without
18076 * any string interpolation. 16885 * any string interpolation.
18077 */ 16886 */
18078 void appendStringValue(StringBuffer buffer); 16887 void appendStringValue(StringBuffer buffer);
18079 } 16888 }
18080 16889
18081 /** 16890 /**
18082 * Instances of the class `SuperConstructorInvocation` represent the invocation of a 16891 * The invocation of a superclass' constructor from within a constructor's
18083 * superclass' constructor from within a constructor's initialization list. 16892 * initialization list.
18084 * 16893 *
18085 * <pre> 16894 * > superInvocation ::=
18086 * superInvocation ::= 16895 * > 'super' ('.' [SimpleIdentifier])? [ArgumentList]
18087 * 'super' ('.' [SimpleIdentifier])? [ArgumentList]
18088 * </pre>
18089 */ 16896 */
18090 class SuperConstructorInvocation extends ConstructorInitializer { 16897 class SuperConstructorInvocation extends ConstructorInitializer {
18091 /** 16898 /**
18092 * The token for the 'super' keyword. 16899 * The token for the 'super' keyword.
18093 */ 16900 */
18094 Token keyword; 16901 Token keyword;
18095 16902
18096 /** 16903 /**
18097 * The token for the period before the name of the constructor that is being i nvoked, or 16904 * The token for the period before the name of the constructor that is being
18098 * `null` if the unnamed constructor is being invoked. 16905 * invoked, or `null` if the unnamed constructor is being invoked.
18099 */ 16906 */
18100 Token period; 16907 Token period;
18101 16908
18102 /** 16909 /**
18103 * The name of the constructor that is being invoked, or `null` if the unnamed constructor 16910 * The name of the constructor that is being invoked, or `null` if the unnamed
18104 * is being invoked. 16911 * constructor is being invoked.
18105 */ 16912 */
18106 SimpleIdentifier _constructorName; 16913 SimpleIdentifier _constructorName;
18107 16914
18108 /** 16915 /**
18109 * The list of arguments to the constructor. 16916 * The list of arguments to the constructor.
18110 */ 16917 */
18111 ArgumentList _argumentList; 16918 ArgumentList _argumentList;
18112 16919
18113 /** 16920 /**
18114 * The element associated with the constructor based on static type informatio n, or `null` 16921 * The element associated with the constructor based on static type
18115 * if the AST structure has not been resolved or if the constructor could not be resolved. 16922 * information, or `null` if the AST structure has not been resolved or if the
16923 * constructor could not be resolved.
18116 */ 16924 */
18117 ConstructorElement staticElement; 16925 ConstructorElement staticElement;
18118 16926
18119 /** 16927 /**
18120 * Initialize a newly created super invocation to invoke the inherited constru ctor with the given 16928 * Initialize a newly created super invocation to invoke the inherited
18121 * name with the given arguments. 16929 * constructor with the given name with the given arguments. The [period] and
18122 * 16930 * [constructorName] can be `null` if the constructor being invoked is the
18123 * @param keyword the token for the 'super' keyword 16931 * unnamed constructor.
18124 * @param period the token for the period before the name of the constructor t hat is being invoked
18125 * @param constructorName the name of the constructor that is being invoked
18126 * @param argumentList the list of arguments to the constructor
18127 */ 16932 */
18128 SuperConstructorInvocation(this.keyword, this.period, 16933 SuperConstructorInvocation(this.keyword, this.period,
18129 SimpleIdentifier constructorName, ArgumentList argumentList) { 16934 SimpleIdentifier constructorName, ArgumentList argumentList) {
18130 _constructorName = becomeParentOf(constructorName); 16935 _constructorName = becomeParentOf(constructorName);
18131 _argumentList = becomeParentOf(argumentList); 16936 _argumentList = becomeParentOf(argumentList);
18132 } 16937 }
18133 16938
18134 /** 16939 /**
18135 * Return the list of arguments to the constructor. 16940 * Return the list of arguments to the constructor.
18136 *
18137 * @return the list of arguments to the constructor
18138 */ 16941 */
18139 ArgumentList get argumentList => _argumentList; 16942 ArgumentList get argumentList => _argumentList;
18140 16943
18141 /** 16944 /**
18142 * Set the list of arguments to the constructor to the given list. 16945 * Set the list of arguments to the constructor to the given [argumentList].
18143 *
18144 * @param argumentList the list of arguments to the constructor
18145 */ 16946 */
18146 void set argumentList(ArgumentList argumentList) { 16947 void set argumentList(ArgumentList argumentList) {
18147 _argumentList = becomeParentOf(argumentList); 16948 _argumentList = becomeParentOf(argumentList);
18148 } 16949 }
18149 16950
18150 @override 16951 @override
18151 Token get beginToken => keyword; 16952 Token get beginToken => keyword;
18152 16953
18153 @override 16954 @override
18154 Iterable get childEntities => new ChildEntities() 16955 Iterable get childEntities => new ChildEntities()
18155 ..add(keyword) 16956 ..add(keyword)
18156 ..add(period) 16957 ..add(period)
18157 ..add(_constructorName) 16958 ..add(_constructorName)
18158 ..add(_argumentList); 16959 ..add(_argumentList);
18159 16960
18160 /** 16961 /**
18161 * Return the name of the constructor that is being invoked, or `null` if the unnamed 16962 * Return the name of the constructor that is being invoked, or `null` if the
18162 * constructor is being invoked. 16963 * unnamed constructor is being invoked.
18163 *
18164 * @return the name of the constructor that is being invoked
18165 */ 16964 */
18166 SimpleIdentifier get constructorName => _constructorName; 16965 SimpleIdentifier get constructorName => _constructorName;
18167 16966
18168 /** 16967 /**
18169 * Set the name of the constructor that is being invoked to the given identifi er. 16968 * Set the name of the constructor that is being invoked to the given
18170 * 16969 * [identifier].
18171 * @param identifier the name of the constructor that is being invoked
18172 */ 16970 */
18173 void set constructorName(SimpleIdentifier identifier) { 16971 void set constructorName(SimpleIdentifier identifier) {
18174 _constructorName = becomeParentOf(identifier); 16972 _constructorName = becomeParentOf(identifier);
18175 } 16973 }
18176 16974
18177 @override 16975 @override
18178 Token get endToken => _argumentList.endToken; 16976 Token get endToken => _argumentList.endToken;
18179 16977
18180 @override 16978 @override
18181 accept(AstVisitor visitor) => visitor.visitSuperConstructorInvocation(this); 16979 accept(AstVisitor visitor) => visitor.visitSuperConstructorInvocation(this);
18182 16980
18183 @override 16981 @override
18184 void visitChildren(AstVisitor visitor) { 16982 void visitChildren(AstVisitor visitor) {
18185 safelyVisitChild(_constructorName, visitor); 16983 _safelyVisitChild(_constructorName, visitor);
18186 safelyVisitChild(_argumentList, visitor); 16984 _safelyVisitChild(_argumentList, visitor);
18187 } 16985 }
18188 } 16986 }
18189 16987
18190 /** 16988 /**
18191 * Instances of the class `SuperExpression` represent a super expression. 16989 * A super expression.
18192 * 16990 *
18193 * <pre> 16991 * > superExpression ::=
18194 * superExpression ::= 16992 * > 'super'
18195 * 'super'
18196 * </pre>
18197 */ 16993 */
18198 class SuperExpression extends Expression { 16994 class SuperExpression extends Expression {
18199 /** 16995 /**
18200 * The token representing the keyword. 16996 * The token representing the keyword.
18201 */ 16997 */
18202 Token keyword; 16998 Token keyword;
18203 16999
18204 /** 17000 /**
18205 * Initialize a newly created super expression. 17001 * Initialize a newly created super expression.
18206 *
18207 * @param keyword the token representing the keyword
18208 */ 17002 */
18209 SuperExpression(this.keyword); 17003 SuperExpression(this.keyword);
18210 17004
18211 @override 17005 @override
18212 Token get beginToken => keyword; 17006 Token get beginToken => keyword;
18213 17007
18214 /** 17008 /**
18215 * TODO(paulberry): untested. 17009 * TODO(paulberry): untested.
18216 */ 17010 */
18217 @override 17011 @override
18218 Iterable get childEntities => new ChildEntities()..add(keyword); 17012 Iterable get childEntities => new ChildEntities()..add(keyword);
18219 17013
18220 @override 17014 @override
18221 Token get endToken => keyword; 17015 Token get endToken => keyword;
18222 17016
18223 @override 17017 @override
18224 int get precedence => 16; 17018 int get precedence => 16;
18225 17019
18226 @override 17020 @override
18227 accept(AstVisitor visitor) => visitor.visitSuperExpression(this); 17021 accept(AstVisitor visitor) => visitor.visitSuperExpression(this);
18228 17022
18229 @override 17023 @override
18230 void visitChildren(AstVisitor visitor) { 17024 void visitChildren(AstVisitor visitor) {
18231 // There are no children to visit. 17025 // There are no children to visit.
18232 } 17026 }
18233 } 17027 }
18234 17028
18235 /** 17029 /**
18236 * Instances of the class `SwitchCase` represent the case in a switch statement. 17030 * A case in a switch statement.
18237 * 17031 *
18238 * <pre> 17032 * > switchCase ::=
18239 * switchCase ::= 17033 * > [SimpleIdentifier]* 'case' [Expression] ':' [Statement]*
18240 * [SimpleIdentifier]* 'case' [Expression] ':' [Statement]*
18241 * </pre>
18242 */ 17034 */
18243 class SwitchCase extends SwitchMember { 17035 class SwitchCase extends SwitchMember {
18244 /** 17036 /**
18245 * The expression controlling whether the statements will be executed. 17037 * The expression controlling whether the statements will be executed.
18246 */ 17038 */
18247 Expression _expression; 17039 Expression _expression;
18248 17040
18249 /** 17041 /**
18250 * Initialize a newly created switch case. 17042 * Initialize a newly created switch case. The list of [labels] can be `null`
18251 * 17043 * if there are no labels.
18252 * @param labels the labels associated with the switch member
18253 * @param keyword the token representing the 'case' or 'default' keyword
18254 * @param expression the expression controlling whether the statements will be executed
18255 * @param colon the colon separating the keyword or the expression from the st atements
18256 * @param statements the statements that will be executed if this switch membe r is selected
18257 */ 17044 */
18258 SwitchCase(List<Label> labels, Token keyword, Expression expression, 17045 SwitchCase(List<Label> labels, Token keyword, Expression expression,
18259 Token colon, List<Statement> statements) 17046 Token colon, List<Statement> statements)
18260 : super(labels, keyword, colon, statements) { 17047 : super(labels, keyword, colon, statements) {
18261 _expression = becomeParentOf(expression); 17048 _expression = becomeParentOf(expression);
18262 } 17049 }
18263 17050
18264 @override 17051 @override
18265 Iterable get childEntities => new ChildEntities() 17052 Iterable get childEntities => new ChildEntities()
18266 ..addAll(labels) 17053 ..addAll(labels)
18267 ..add(keyword) 17054 ..add(keyword)
18268 ..add(_expression) 17055 ..add(_expression)
18269 ..add(colon) 17056 ..add(colon)
18270 ..addAll(statements); 17057 ..addAll(statements);
18271 17058
18272 /** 17059 /**
18273 * Return the expression controlling whether the statements will be executed. 17060 * Return the expression controlling whether the statements will be executed.
18274 *
18275 * @return the expression controlling whether the statements will be executed
18276 */ 17061 */
18277 Expression get expression => _expression; 17062 Expression get expression => _expression;
18278 17063
18279 /** 17064 /**
18280 * Set the expression controlling whether the statements will be executed to t he given expression. 17065 * Set the expression controlling whether the statements will be executed to
18281 * 17066 * the given [expression].
18282 * @param expression the expression controlling whether the statements will be executed
18283 */ 17067 */
18284 void set expression(Expression expression) { 17068 void set expression(Expression expression) {
18285 _expression = becomeParentOf(expression); 17069 _expression = becomeParentOf(expression);
18286 } 17070 }
18287 17071
18288 @override 17072 @override
18289 accept(AstVisitor visitor) => visitor.visitSwitchCase(this); 17073 accept(AstVisitor visitor) => visitor.visitSwitchCase(this);
18290 17074
18291 @override 17075 @override
18292 void visitChildren(AstVisitor visitor) { 17076 void visitChildren(AstVisitor visitor) {
18293 labels.accept(visitor); 17077 labels.accept(visitor);
18294 safelyVisitChild(_expression, visitor); 17078 _safelyVisitChild(_expression, visitor);
18295 statements.accept(visitor); 17079 statements.accept(visitor);
18296 } 17080 }
18297 } 17081 }
18298 17082
18299 /** 17083 /**
18300 * Instances of the class `SwitchDefault` represent the default case in a switch statement. 17084 * The default case in a switch statement.
18301 * 17085 *
18302 * <pre> 17086 * > switchDefault ::=
18303 * switchDefault ::= 17087 * > [SimpleIdentifier]* 'default' ':' [Statement]*
18304 * [SimpleIdentifier]* 'default' ':' [Statement]*
18305 * </pre>
18306 */ 17088 */
18307 class SwitchDefault extends SwitchMember { 17089 class SwitchDefault extends SwitchMember {
18308 /** 17090 /**
18309 * Initialize a newly created switch default. 17091 * Initialize a newly created switch default. The list of [labels] can be
18310 * 17092 * `null` if there are no labels.
18311 * @param labels the labels associated with the switch member
18312 * @param keyword the token representing the 'case' or 'default' keyword
18313 * @param colon the colon separating the keyword or the expression from the st atements
18314 * @param statements the statements that will be executed if this switch membe r is selected
18315 */ 17093 */
18316 SwitchDefault(List<Label> labels, Token keyword, Token colon, 17094 SwitchDefault(List<Label> labels, Token keyword, Token colon,
18317 List<Statement> statements) 17095 List<Statement> statements)
18318 : super(labels, keyword, colon, statements); 17096 : super(labels, keyword, colon, statements);
18319 17097
18320 /** 17098 /**
18321 * TODO(paulberry): untested. 17099 * TODO(paulberry): untested.
18322 */ 17100 */
18323 @override 17101 @override
18324 Iterable get childEntities => new ChildEntities() 17102 Iterable get childEntities => new ChildEntities()
18325 ..addAll(labels) 17103 ..addAll(labels)
18326 ..add(keyword) 17104 ..add(keyword)
18327 ..add(colon) 17105 ..add(colon)
18328 ..addAll(statements); 17106 ..addAll(statements);
18329 17107
18330 @override 17108 @override
18331 accept(AstVisitor visitor) => visitor.visitSwitchDefault(this); 17109 accept(AstVisitor visitor) => visitor.visitSwitchDefault(this);
18332 17110
18333 @override 17111 @override
18334 void visitChildren(AstVisitor visitor) { 17112 void visitChildren(AstVisitor visitor) {
18335 labels.accept(visitor); 17113 labels.accept(visitor);
18336 statements.accept(visitor); 17114 statements.accept(visitor);
18337 } 17115 }
18338 } 17116 }
18339 17117
18340 /** 17118 /**
18341 * The abstract class `SwitchMember` defines the behavior common to objects repr esenting 17119 * An element within a switch statement.
18342 * elements within a switch statement.
18343 * 17120 *
18344 * <pre> 17121 * > switchMember ::=
18345 * switchMember ::= 17122 * > switchCase
18346 * switchCase 17123 * > | switchDefault
18347 * | switchDefault
18348 * </pre>
18349 */ 17124 */
18350 abstract class SwitchMember extends AstNode { 17125 abstract class SwitchMember extends AstNode {
18351 /** 17126 /**
18352 * The labels associated with the switch member. 17127 * The labels associated with the switch member.
18353 */ 17128 */
18354 NodeList<Label> _labels; 17129 NodeList<Label> _labels;
18355 17130
18356 /** 17131 /**
18357 * The token representing the 'case' or 'default' keyword. 17132 * The token representing the 'case' or 'default' keyword.
18358 */ 17133 */
18359 Token keyword; 17134 Token keyword;
18360 17135
18361 /** 17136 /**
18362 * The colon separating the keyword or the expression from the statements. 17137 * The colon separating the keyword or the expression from the statements.
18363 */ 17138 */
18364 Token colon; 17139 Token colon;
18365 17140
18366 /** 17141 /**
18367 * The statements that will be executed if this switch member is selected. 17142 * The statements that will be executed if this switch member is selected.
18368 */ 17143 */
18369 NodeList<Statement> _statements; 17144 NodeList<Statement> _statements;
18370 17145
18371 /** 17146 /**
18372 * Initialize a newly created switch member. 17147 * Initialize a newly created switch member. The list of [labels] can be
18373 * 17148 * `null` if there are no labels.
18374 * @param labels the labels associated with the switch member
18375 * @param keyword the token representing the 'case' or 'default' keyword
18376 * @param colon the colon separating the keyword or the expression from the st atements
18377 * @param statements the statements that will be executed if this switch membe r is selected
18378 */ 17149 */
18379 SwitchMember(List<Label> labels, this.keyword, this.colon, 17150 SwitchMember(List<Label> labels, this.keyword, this.colon,
18380 List<Statement> statements) { 17151 List<Statement> statements) {
18381 _labels = new NodeList<Label>(this, labels); 17152 _labels = new NodeList<Label>(this, labels);
18382 _statements = new NodeList<Statement>(this, statements); 17153 _statements = new NodeList<Statement>(this, statements);
18383 } 17154 }
18384 17155
18385 @override 17156 @override
18386 Token get beginToken { 17157 Token get beginToken {
18387 if (!_labels.isEmpty) { 17158 if (!_labels.isEmpty) {
18388 return _labels.beginToken; 17159 return _labels.beginToken;
18389 } 17160 }
18390 return keyword; 17161 return keyword;
18391 } 17162 }
18392 17163
18393 @override 17164 @override
18394 Token get endToken { 17165 Token get endToken {
18395 if (!_statements.isEmpty) { 17166 if (!_statements.isEmpty) {
18396 return _statements.endToken; 17167 return _statements.endToken;
18397 } 17168 }
18398 return colon; 17169 return colon;
18399 } 17170 }
18400 17171
18401 /** 17172 /**
18402 * Return the labels associated with the switch member. 17173 * Return the labels associated with the switch member.
18403 *
18404 * @return the labels associated with the switch member
18405 */ 17174 */
18406 NodeList<Label> get labels => _labels; 17175 NodeList<Label> get labels => _labels;
18407 17176
18408 /** 17177 /**
18409 * Return the statements that will be executed if this switch member is select ed. 17178 * Return the statements that will be executed if this switch member is
18410 * 17179 * selected.
18411 * @return the statements that will be executed if this switch member is selec ted
18412 */ 17180 */
18413 NodeList<Statement> get statements => _statements; 17181 NodeList<Statement> get statements => _statements;
18414 } 17182 }
18415 17183
18416 /** 17184 /**
18417 * Instances of the class `SwitchStatement` represent a switch statement. 17185 * A switch statement.
18418 * 17186 *
18419 * <pre> 17187 * > switchStatement ::=
18420 * switchStatement ::= 17188 * > 'switch' '(' [Expression] ')' '{' [SwitchCase]* [SwitchDefault]? '}'
18421 * 'switch' '(' [Expression] ')' '{' [SwitchCase]* [SwitchDefault]? '}'
18422 * </pre>
18423 */ 17189 */
18424 class SwitchStatement extends Statement { 17190 class SwitchStatement extends Statement {
18425 /** 17191 /**
18426 * The token representing the 'switch' keyword. 17192 * The token representing the 'switch' keyword.
18427 */ 17193 */
18428 Token keyword; 17194 Token keyword;
18429 17195
18430 /** 17196 /**
18431 * The left parenthesis. 17197 * The left parenthesis.
18432 */ 17198 */
18433 Token leftParenthesis; 17199 Token leftParenthesis;
18434 17200
18435 /** 17201 /**
18436 * The expression used to determine which of the switch members will be select ed. 17202 * The expression used to determine which of the switch members will be
17203 * selected.
18437 */ 17204 */
18438 Expression _expression; 17205 Expression _expression;
18439 17206
18440 /** 17207 /**
18441 * The right parenthesis. 17208 * The right parenthesis.
18442 */ 17209 */
18443 Token rightParenthesis; 17210 Token rightParenthesis;
18444 17211
18445 /** 17212 /**
18446 * The left curly bracket. 17213 * The left curly bracket.
18447 */ 17214 */
18448 Token leftBracket; 17215 Token leftBracket;
18449 17216
18450 /** 17217 /**
18451 * The switch members that can be selected by the expression. 17218 * The switch members that can be selected by the expression.
18452 */ 17219 */
18453 NodeList<SwitchMember> _members; 17220 NodeList<SwitchMember> _members;
18454 17221
18455 /** 17222 /**
18456 * The right curly bracket. 17223 * The right curly bracket.
18457 */ 17224 */
18458 Token rightBracket; 17225 Token rightBracket;
18459 17226
18460 /** 17227 /**
18461 * Initialize a newly created switch statement. 17228 * Initialize a newly created switch statement. The list of [members] can be
18462 * 17229 * `null` if there are no switch members.
18463 * @param keyword the token representing the 'switch' keyword
18464 * @param leftParenthesis the left parenthesis
18465 * @param expression the expression used to determine which of the switch memb ers will be selected
18466 * @param rightParenthesis the right parenthesis
18467 * @param leftBracket the left curly bracket
18468 * @param members the switch members that can be selected by the expression
18469 * @param rightBracket the right curly bracket
18470 */ 17230 */
18471 SwitchStatement(this.keyword, this.leftParenthesis, Expression expression, 17231 SwitchStatement(this.keyword, this.leftParenthesis, Expression expression,
18472 this.rightParenthesis, this.leftBracket, List<SwitchMember> members, 17232 this.rightParenthesis, this.leftBracket, List<SwitchMember> members,
18473 this.rightBracket) { 17233 this.rightBracket) {
18474 _expression = becomeParentOf(expression); 17234 _expression = becomeParentOf(expression);
18475 _members = new NodeList<SwitchMember>(this, members); 17235 _members = new NodeList<SwitchMember>(this, members);
18476 } 17236 }
18477 17237
18478 @override 17238 @override
18479 Token get beginToken => keyword; 17239 Token get beginToken => keyword;
18480 17240
18481 @override 17241 @override
18482 Iterable get childEntities => new ChildEntities() 17242 Iterable get childEntities => new ChildEntities()
18483 ..add(keyword) 17243 ..add(keyword)
18484 ..add(leftParenthesis) 17244 ..add(leftParenthesis)
18485 ..add(_expression) 17245 ..add(_expression)
18486 ..add(rightParenthesis) 17246 ..add(rightParenthesis)
18487 ..add(leftBracket) 17247 ..add(leftBracket)
18488 ..addAll(_members) 17248 ..addAll(_members)
18489 ..add(rightBracket); 17249 ..add(rightBracket);
18490 17250
18491 @override 17251 @override
18492 Token get endToken => rightBracket; 17252 Token get endToken => rightBracket;
18493 17253
18494 /** 17254 /**
18495 * Return the expression used to determine which of the switch members will be selected. 17255 * Return the expression used to determine which of the switch members will be
18496 * 17256 * selected.
18497 * @return the expression used to determine which of the switch members will b e selected
18498 */ 17257 */
18499 Expression get expression => _expression; 17258 Expression get expression => _expression;
18500 17259
18501 /** 17260 /**
18502 * Set the expression used to determine which of the switch members will be se lected to the given 17261 * Set the expression used to determine which of the switch members will be
18503 * expression. 17262 * selected to the given [expression].
18504 *
18505 * @param expression the expression used to determine which of the switch memb ers will be selected
18506 */ 17263 */
18507 void set expression(Expression expression) { 17264 void set expression(Expression expression) {
18508 _expression = becomeParentOf(expression); 17265 _expression = becomeParentOf(expression);
18509 } 17266 }
18510 17267
18511 /** 17268 /**
18512 * Return the switch members that can be selected by the expression. 17269 * Return the switch members that can be selected by the expression.
18513 *
18514 * @return the switch members that can be selected by the expression
18515 */ 17270 */
18516 NodeList<SwitchMember> get members => _members; 17271 NodeList<SwitchMember> get members => _members;
18517 17272
18518 @override 17273 @override
18519 accept(AstVisitor visitor) => visitor.visitSwitchStatement(this); 17274 accept(AstVisitor visitor) => visitor.visitSwitchStatement(this);
18520 17275
18521 @override 17276 @override
18522 void visitChildren(AstVisitor visitor) { 17277 void visitChildren(AstVisitor visitor) {
18523 safelyVisitChild(_expression, visitor); 17278 _safelyVisitChild(_expression, visitor);
18524 _members.accept(visitor); 17279 _members.accept(visitor);
18525 } 17280 }
18526 } 17281 }
18527 17282
18528 /** 17283 /**
18529 * Instances of the class `SymbolLiteral` represent a symbol literal expression. 17284 * A symbol literal expression.
18530 * 17285 *
18531 * <pre> 17286 * > symbolLiteral ::=
18532 * symbolLiteral ::= 17287 * > '#' (operator | (identifier ('.' identifier)*))
18533 * '#' (operator | (identifier ('.' identifier)*))
18534 * </pre>
18535 */ 17288 */
18536 class SymbolLiteral extends Literal { 17289 class SymbolLiteral extends Literal {
18537 /** 17290 /**
18538 * The token introducing the literal. 17291 * The token introducing the literal.
18539 */ 17292 */
18540 Token poundSign; 17293 Token poundSign;
18541 17294
18542 /** 17295 /**
18543 * The components of the literal. 17296 * The components of the literal.
18544 */ 17297 */
18545 final List<Token> components; 17298 final List<Token> components;
18546 17299
18547 /** 17300 /**
18548 * Initialize a newly created symbol literal. 17301 * Initialize a newly created symbol literal.
18549 *
18550 * @param poundSign the token introducing the literal
18551 * @param components the components of the literal
18552 */ 17302 */
18553 SymbolLiteral(this.poundSign, this.components); 17303 SymbolLiteral(this.poundSign, this.components);
18554 17304
18555 @override 17305 @override
18556 Token get beginToken => poundSign; 17306 Token get beginToken => poundSign;
18557 17307
18558 /** 17308 /**
18559 * TODO(paulberry): untested. 17309 * TODO(paulberry): untested.
18560 * TODO(paulberry): add "." tokens. 17310 * TODO(paulberry): add "." tokens.
18561 */ 17311 */
18562 @override 17312 @override
18563 Iterable get childEntities => new ChildEntities() 17313 Iterable get childEntities => new ChildEntities()
18564 ..add(poundSign) 17314 ..add(poundSign)
18565 ..addAll(components); 17315 ..addAll(components);
18566 17316
18567 @override 17317 @override
18568 Token get endToken => components[components.length - 1]; 17318 Token get endToken => components[components.length - 1];
18569 17319
18570 @override 17320 @override
18571 accept(AstVisitor visitor) => visitor.visitSymbolLiteral(this); 17321 accept(AstVisitor visitor) => visitor.visitSymbolLiteral(this);
18572 17322
18573 @override 17323 @override
18574 void visitChildren(AstVisitor visitor) { 17324 void visitChildren(AstVisitor visitor) {
18575 // There are no children to visit. 17325 // There are no children to visit.
18576 } 17326 }
18577 } 17327 }
18578 17328
18579 /** 17329 /**
18580 * Instances of the class `ThisExpression` represent a this expression. 17330 * A this expression.
18581 * 17331 *
18582 * <pre> 17332 * > thisExpression ::=
18583 * thisExpression ::= 17333 * > 'this'
18584 * 'this'
18585 * </pre>
18586 */ 17334 */
18587 class ThisExpression extends Expression { 17335 class ThisExpression extends Expression {
18588 /** 17336 /**
18589 * The token representing the keyword. 17337 * The token representing the keyword.
18590 */ 17338 */
18591 Token keyword; 17339 Token keyword;
18592 17340
18593 /** 17341 /**
18594 * Initialize a newly created this expression. 17342 * Initialize a newly created this expression.
18595 *
18596 * @param keyword the token representing the keyword
18597 */ 17343 */
18598 ThisExpression(this.keyword); 17344 ThisExpression(this.keyword);
18599 17345
18600 @override 17346 @override
18601 Token get beginToken => keyword; 17347 Token get beginToken => keyword;
18602 17348
18603 /** 17349 /**
18604 * TODO(paulberry): untested. 17350 * TODO(paulberry): untested.
18605 */ 17351 */
18606 @override 17352 @override
18607 Iterable get childEntities => new ChildEntities()..add(keyword); 17353 Iterable get childEntities => new ChildEntities()..add(keyword);
18608 17354
18609 @override 17355 @override
18610 Token get endToken => keyword; 17356 Token get endToken => keyword;
18611 17357
18612 @override 17358 @override
18613 int get precedence => 16; 17359 int get precedence => 16;
18614 17360
18615 @override 17361 @override
18616 accept(AstVisitor visitor) => visitor.visitThisExpression(this); 17362 accept(AstVisitor visitor) => visitor.visitThisExpression(this);
18617 17363
18618 @override 17364 @override
18619 void visitChildren(AstVisitor visitor) { 17365 void visitChildren(AstVisitor visitor) {
18620 // There are no children to visit. 17366 // There are no children to visit.
18621 } 17367 }
18622 } 17368 }
18623 17369
18624 /** 17370 /**
18625 * Instances of the class `ThrowExpression` represent a throw expression. 17371 * A throw expression.
18626 * 17372 *
18627 * <pre> 17373 * > throwExpression ::=
18628 * throwExpression ::= 17374 * > 'throw' [Expression]
18629 * 'throw' [Expression]
18630 * </pre>
18631 */ 17375 */
18632 class ThrowExpression extends Expression { 17376 class ThrowExpression extends Expression {
18633 /** 17377 /**
18634 * The token representing the 'throw' keyword. 17378 * The token representing the 'throw' keyword.
18635 */ 17379 */
18636 Token keyword; 17380 Token keyword;
18637 17381
18638 /** 17382 /**
18639 * The expression computing the exception to be thrown. 17383 * The expression computing the exception to be thrown.
18640 */ 17384 */
18641 Expression _expression; 17385 Expression _expression;
18642 17386
18643 /** 17387 /**
18644 * Initialize a newly created throw expression. 17388 * Initialize a newly created throw expression.
18645 *
18646 * @param keyword the token representing the 'throw' keyword
18647 * @param expression the expression computing the exception to be thrown
18648 */ 17389 */
18649 ThrowExpression(this.keyword, Expression expression) { 17390 ThrowExpression(this.keyword, Expression expression) {
18650 _expression = becomeParentOf(expression); 17391 _expression = becomeParentOf(expression);
18651 } 17392 }
18652 17393
18653 @override 17394 @override
18654 Token get beginToken => keyword; 17395 Token get beginToken => keyword;
18655 17396
18656 @override 17397 @override
18657 Iterable get childEntities => new ChildEntities() 17398 Iterable get childEntities => new ChildEntities()
18658 ..add(keyword) 17399 ..add(keyword)
18659 ..add(_expression); 17400 ..add(_expression);
18660 17401
18661 @override 17402 @override
18662 Token get endToken { 17403 Token get endToken {
18663 if (_expression != null) { 17404 if (_expression != null) {
18664 return _expression.endToken; 17405 return _expression.endToken;
18665 } 17406 }
18666 return keyword; 17407 return keyword;
18667 } 17408 }
18668 17409
18669 /** 17410 /**
18670 * Return the expression computing the exception to be thrown. 17411 * Return the expression computing the exception to be thrown.
18671 *
18672 * @return the expression computing the exception to be thrown
18673 */ 17412 */
18674 Expression get expression => _expression; 17413 Expression get expression => _expression;
18675 17414
18676 /** 17415 /**
18677 * Set the expression computing the exception to be thrown to the given expres sion. 17416 * Set the expression computing the exception to be thrown to the given
18678 * 17417 * [expression].
18679 * @param expression the expression computing the exception to be thrown
18680 */ 17418 */
18681 void set expression(Expression expression) { 17419 void set expression(Expression expression) {
18682 _expression = becomeParentOf(expression); 17420 _expression = becomeParentOf(expression);
18683 } 17421 }
18684 17422
18685 @override 17423 @override
18686 int get precedence => 0; 17424 int get precedence => 0;
18687 17425
18688 @override 17426 @override
18689 accept(AstVisitor visitor) => visitor.visitThrowExpression(this); 17427 accept(AstVisitor visitor) => visitor.visitThrowExpression(this);
18690 17428
18691 @override 17429 @override
18692 void visitChildren(AstVisitor visitor) { 17430 void visitChildren(AstVisitor visitor) {
18693 safelyVisitChild(_expression, visitor); 17431 _safelyVisitChild(_expression, visitor);
18694 } 17432 }
18695 } 17433 }
18696 17434
18697 /** 17435 /**
18698 * Instances of the class `TopLevelVariableDeclaration` represent the declaratio n of one or 17436 * The declaration of one or more top-level variables of the same type.
18699 * more top-level variables of the same type.
18700 * 17437 *
18701 * <pre> 17438 * > topLevelVariableDeclaration ::=
18702 * topLevelVariableDeclaration ::= 17439 * > ('final' | 'const') type? staticFinalDeclarationList ';'
18703 * ('final' | 'const') type? staticFinalDeclarationList ';' 17440 * > | variableDeclaration ';'
18704 * | variableDeclaration ';'
18705 * </pre>
18706 */ 17441 */
18707 class TopLevelVariableDeclaration extends CompilationUnitMember { 17442 class TopLevelVariableDeclaration extends CompilationUnitMember {
18708 /** 17443 /**
18709 * The top-level variables being declared. 17444 * The top-level variables being declared.
18710 */ 17445 */
18711 VariableDeclarationList _variableList; 17446 VariableDeclarationList _variableList;
18712 17447
18713 /** 17448 /**
18714 * The semicolon terminating the declaration. 17449 * The semicolon terminating the declaration.
18715 */ 17450 */
18716 Token semicolon; 17451 Token semicolon;
18717 17452
18718 /** 17453 /**
18719 * Initialize a newly created top-level variable declaration. 17454 * Initialize a newly created top-level variable declaration. Either or both
18720 * 17455 * of the [comment] and [metadata] can be `null` if the variable does not have
18721 * @param comment the documentation comment associated with this variable 17456 * the corresponding attribute.
18722 * @param metadata the annotations associated with this variable
18723 * @param variableList the top-level variables being declared
18724 * @param semicolon the semicolon terminating the declaration
18725 */ 17457 */
18726 TopLevelVariableDeclaration(Comment comment, List<Annotation> metadata, 17458 TopLevelVariableDeclaration(Comment comment, List<Annotation> metadata,
18727 VariableDeclarationList variableList, this.semicolon) 17459 VariableDeclarationList variableList, this.semicolon)
18728 : super(comment, metadata) { 17460 : super(comment, metadata) {
18729 _variableList = becomeParentOf(variableList); 17461 _variableList = becomeParentOf(variableList);
18730 } 17462 }
18731 17463
18732 @override 17464 @override
18733 Iterable get childEntities => super._childEntities 17465 Iterable get childEntities => super._childEntities
18734 ..add(_variableList) 17466 ..add(_variableList)
18735 ..add(semicolon); 17467 ..add(semicolon);
18736 17468
18737 @override 17469 @override
18738 Element get element => null; 17470 Element get element => null;
18739 17471
18740 @override 17472 @override
18741 Token get endToken => semicolon; 17473 Token get endToken => semicolon;
18742 17474
18743 @override 17475 @override
18744 Token get firstTokenAfterCommentAndMetadata => _variableList.beginToken; 17476 Token get firstTokenAfterCommentAndMetadata => _variableList.beginToken;
18745 17477
18746 /** 17478 /**
18747 * Return the top-level variables being declared. 17479 * Return the top-level variables being declared.
18748 *
18749 * @return the top-level variables being declared
18750 */ 17480 */
18751 VariableDeclarationList get variables => _variableList; 17481 VariableDeclarationList get variables => _variableList;
18752 17482
18753 /** 17483 /**
18754 * Set the top-level variables being declared to the given list of variables. 17484 * Set the top-level variables being declared to the given list of
18755 * 17485 * [variables].
18756 * @param variableList the top-level variables being declared
18757 */ 17486 */
18758 void set variables(VariableDeclarationList variableList) { 17487 void set variables(VariableDeclarationList variables) {
18759 _variableList = becomeParentOf(variableList); 17488 _variableList = becomeParentOf(variables);
18760 } 17489 }
18761 17490
18762 @override 17491 @override
18763 accept(AstVisitor visitor) => visitor.visitTopLevelVariableDeclaration(this); 17492 accept(AstVisitor visitor) => visitor.visitTopLevelVariableDeclaration(this);
18764 17493
18765 @override 17494 @override
18766 void visitChildren(AstVisitor visitor) { 17495 void visitChildren(AstVisitor visitor) {
18767 super.visitChildren(visitor); 17496 super.visitChildren(visitor);
18768 safelyVisitChild(_variableList, visitor); 17497 _safelyVisitChild(_variableList, visitor);
18769 } 17498 }
18770 } 17499 }
18771 17500
18772 /** 17501 /**
18773 * Instances of the class `ToSourceVisitor` write a source representation of a v isited AST 17502 * A visitor used to write a source representation of a visited AST node (and
18774 * node (and all of it's children) to a writer. 17503 * all of it's children) to a writer.
18775 */ 17504 */
18776 class ToSourceVisitor implements AstVisitor<Object> { 17505 class ToSourceVisitor implements AstVisitor<Object> {
18777 /** 17506 /**
18778 * The writer to which the source is to be written. 17507 * The writer to which the source is to be written.
18779 */ 17508 */
18780 final PrintWriter _writer; 17509 final PrintWriter _writer;
18781 17510
18782 /** 17511 /**
18783 * Initialize a newly created visitor to write source code representing the vi sited nodes to the 17512 * Initialize a newly created visitor to write source code representing the
18784 * given writer. 17513 * visited nodes to the given [writer].
18785 *
18786 * @param writer the writer to which the source is to be written
18787 */ 17514 */
18788 ToSourceVisitor(this._writer); 17515 ToSourceVisitor(this._writer);
18789 17516
18790 @override 17517 @override
18791 Object visitAdjacentStrings(AdjacentStrings node) { 17518 Object visitAdjacentStrings(AdjacentStrings node) {
18792 _visitNodeListWithSeparator(node.strings, " "); 17519 _visitNodeListWithSeparator(node.strings, " ");
18793 return null; 17520 return null;
18794 } 17521 }
18795 17522
18796 @override 17523 @override
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
19758 _writer.print("yield* "); 18485 _writer.print("yield* ");
19759 } else { 18486 } else {
19760 _writer.print("yield "); 18487 _writer.print("yield ");
19761 } 18488 }
19762 _visitNode(node.expression); 18489 _visitNode(node.expression);
19763 _writer.print(";"); 18490 _writer.print(";");
19764 return null; 18491 return null;
19765 } 18492 }
19766 18493
19767 /** 18494 /**
19768 * Visit the given function body, printing the prefix before if given body is not empty. 18495 * Visit the given function [body], printing the [prefix] before if the body
19769 * 18496 * is not empty.
19770 * @param prefix the prefix to be printed if there is a node to visit
19771 * @param body the function body to be visited
19772 */ 18497 */
19773 void _visitFunctionWithPrefix(String prefix, FunctionBody body) { 18498 void _visitFunctionWithPrefix(String prefix, FunctionBody body) {
19774 if (body is! EmptyFunctionBody) { 18499 if (body is! EmptyFunctionBody) {
19775 _writer.print(prefix); 18500 _writer.print(prefix);
19776 } 18501 }
19777 _visitNode(body); 18502 _visitNode(body);
19778 } 18503 }
19779 18504
19780 /** 18505 /**
19781 * Safely visit the given node. 18506 * Safely visit the given [node].
19782 *
19783 * @param node the node to be visited
19784 */ 18507 */
19785 void _visitNode(AstNode node) { 18508 void _visitNode(AstNode node) {
19786 if (node != null) { 18509 if (node != null) {
19787 node.accept(this); 18510 node.accept(this);
19788 } 18511 }
19789 } 18512 }
19790 18513
19791 /** 18514 /**
19792 * Print a list of nodes without any separation. 18515 * Print a list of [nodes] without any separation.
19793 *
19794 * @param nodes the nodes to be printed
19795 * @param separator the separator to be printed between adjacent nodes
19796 */ 18516 */
19797 void _visitNodeList(NodeList<AstNode> nodes) { 18517 void _visitNodeList(NodeList<AstNode> nodes) {
19798 _visitNodeListWithSeparator(nodes, ""); 18518 _visitNodeListWithSeparator(nodes, "");
19799 } 18519 }
19800 18520
19801 /** 18521 /**
19802 * Print a list of nodes, separated by the given separator. 18522 * Print a list of [nodes], separated by the given [separator].
19803 *
19804 * @param nodes the nodes to be printed
19805 * @param separator the separator to be printed between adjacent nodes
19806 */ 18523 */
19807 void _visitNodeListWithSeparator(NodeList<AstNode> nodes, String separator) { 18524 void _visitNodeListWithSeparator(NodeList<AstNode> nodes, String separator) {
19808 if (nodes != null) { 18525 if (nodes != null) {
19809 int size = nodes.length; 18526 int size = nodes.length;
19810 for (int i = 0; i < size; i++) { 18527 for (int i = 0; i < size; i++) {
19811 if (i > 0) { 18528 if (i > 0) {
19812 _writer.print(separator); 18529 _writer.print(separator);
19813 } 18530 }
19814 nodes[i].accept(this); 18531 nodes[i].accept(this);
19815 } 18532 }
19816 } 18533 }
19817 } 18534 }
19818 18535
19819 /** 18536 /**
19820 * Print a list of nodes, separated by the given separator. 18537 * Print a list of [nodes], prefixed by the given [prefix] if the list is not
19821 * 18538 * empty, and separated by the given [separator].
19822 * @param prefix the prefix to be printed if the list is not empty
19823 * @param nodes the nodes to be printed
19824 * @param separator the separator to be printed between adjacent nodes
19825 */ 18539 */
19826 void _visitNodeListWithSeparatorAndPrefix(String prefix, 18540 void _visitNodeListWithSeparatorAndPrefix(String prefix,
19827 NodeList<AstNode> nodes, String separator) { 18541 NodeList<AstNode> nodes, String separator) {
19828 if (nodes != null) { 18542 if (nodes != null) {
19829 int size = nodes.length; 18543 int size = nodes.length;
19830 if (size > 0) { 18544 if (size > 0) {
19831 _writer.print(prefix); 18545 _writer.print(prefix);
19832 for (int i = 0; i < size; i++) { 18546 for (int i = 0; i < size; i++) {
19833 if (i > 0) { 18547 if (i > 0) {
19834 _writer.print(separator); 18548 _writer.print(separator);
19835 } 18549 }
19836 nodes[i].accept(this); 18550 nodes[i].accept(this);
19837 } 18551 }
19838 } 18552 }
19839 } 18553 }
19840 } 18554 }
19841 18555
19842 /** 18556 /**
19843 * Print a list of nodes, separated by the given separator. 18557 * Print a list of [nodes], separated by the given [separator], followed by
19844 * 18558 * the given [suffix] if the list is not empty.
19845 * @param nodes the nodes to be printed
19846 * @param separator the separator to be printed between adjacent nodes
19847 * @param suffix the suffix to be printed if the list is not empty
19848 */ 18559 */
19849 void _visitNodeListWithSeparatorAndSuffix(NodeList<AstNode> nodes, 18560 void _visitNodeListWithSeparatorAndSuffix(NodeList<AstNode> nodes,
19850 String separator, String suffix) { 18561 String separator, String suffix) {
19851 if (nodes != null) { 18562 if (nodes != null) {
19852 int size = nodes.length; 18563 int size = nodes.length;
19853 if (size > 0) { 18564 if (size > 0) {
19854 for (int i = 0; i < size; i++) { 18565 for (int i = 0; i < size; i++) {
19855 if (i > 0) { 18566 if (i > 0) {
19856 _writer.print(separator); 18567 _writer.print(separator);
19857 } 18568 }
19858 nodes[i].accept(this); 18569 nodes[i].accept(this);
19859 } 18570 }
19860 _writer.print(suffix); 18571 _writer.print(suffix);
19861 } 18572 }
19862 } 18573 }
19863 } 18574 }
19864 18575
19865 /** 18576 /**
19866 * Safely visit the given node, printing the prefix before the node if it is n on-`null`. 18577 * Safely visit the given [node], printing the [prefix] before the node if it
19867 * 18578 * is non-`null`.
19868 * @param prefix the prefix to be printed if there is a node to visit
19869 * @param node the node to be visited
19870 */ 18579 */
19871 void _visitNodeWithPrefix(String prefix, AstNode node) { 18580 void _visitNodeWithPrefix(String prefix, AstNode node) {
19872 if (node != null) { 18581 if (node != null) {
19873 _writer.print(prefix); 18582 _writer.print(prefix);
19874 node.accept(this); 18583 node.accept(this);
19875 } 18584 }
19876 } 18585 }
19877 18586
19878 /** 18587 /**
19879 * Safely visit the given node, printing the suffix after the node if it is no n-`null`. 18588 * Safely visit the given [node], printing the [suffix] after the node if it
19880 * 18589 * is non-`null`.
19881 * @param suffix the suffix to be printed if there is a node to visit
19882 * @param node the node to be visited
19883 */ 18590 */
19884 void _visitNodeWithSuffix(AstNode node, String suffix) { 18591 void _visitNodeWithSuffix(AstNode node, String suffix) {
19885 if (node != null) { 18592 if (node != null) {
19886 node.accept(this); 18593 node.accept(this);
19887 _writer.print(suffix); 18594 _writer.print(suffix);
19888 } 18595 }
19889 } 18596 }
19890 18597
19891 /** 18598 /**
19892 * Safely visit the given node, printing the suffix after the node if it is no n-`null`. 18599 * Safely visit the given [token], printing the [suffix] after the token if it
19893 * 18600 * is non-`null`.
19894 * @param suffix the suffix to be printed if there is a node to visit
19895 * @param node the node to be visited
19896 */ 18601 */
19897 void _visitTokenWithSuffix(Token token, String suffix) { 18602 void _visitTokenWithSuffix(Token token, String suffix) {
19898 if (token != null) { 18603 if (token != null) {
19899 _writer.print(token.lexeme); 18604 _writer.print(token.lexeme);
19900 _writer.print(suffix); 18605 _writer.print(suffix);
19901 } 18606 }
19902 } 18607 }
19903 } 18608 }
19904 18609
19905 /** 18610 /**
19906 * Instances of the class `TryStatement` represent a try statement. 18611 * A try statement.
19907 * 18612 *
19908 * <pre> 18613 * > tryStatement ::=
19909 * tryStatement ::= 18614 * > 'try' [Block] ([CatchClause]+ finallyClause? | finallyClause)
19910 * 'try' [Block] ([CatchClause]+ finallyClause? | finallyClause) 18615 * >
19911 * 18616 * > finallyClause ::=
19912 * finallyClause ::= 18617 * > 'finally' [Block]
19913 * 'finally' [Block]
19914 * </pre>
19915 */ 18618 */
19916 class TryStatement extends Statement { 18619 class TryStatement extends Statement {
19917 /** 18620 /**
19918 * The token representing the 'try' keyword. 18621 * The token representing the 'try' keyword.
19919 */ 18622 */
19920 Token tryKeyword; 18623 Token tryKeyword;
19921 18624
19922 /** 18625 /**
19923 * The body of the statement. 18626 * The body of the statement.
19924 */ 18627 */
19925 Block _body; 18628 Block _body;
19926 18629
19927 /** 18630 /**
19928 * The catch clauses contained in the try statement. 18631 * The catch clauses contained in the try statement.
19929 */ 18632 */
19930 NodeList<CatchClause> _catchClauses; 18633 NodeList<CatchClause> _catchClauses;
19931 18634
19932 /** 18635 /**
19933 * The token representing the 'finally' keyword, or `null` if the statement do es not contain 18636 * The token representing the 'finally' keyword, or `null` if the statement
19934 * a finally clause. 18637 * does not contain a finally clause.
19935 */ 18638 */
19936 Token finallyKeyword; 18639 Token finallyKeyword;
19937 18640
19938 /** 18641 /**
19939 * The finally block contained in the try statement, or `null` if the statemen t does not 18642 * The finally block contained in the try statement, or `null` if the
19940 * contain a finally clause. 18643 * statement does not contain a finally clause.
19941 */ 18644 */
19942 Block _finallyBlock; 18645 Block _finallyBlock;
19943 18646
19944 /** 18647 /**
19945 * Initialize a newly created try statement. 18648 * Initialize a newly created try statement. The list of [catchClauses] can be
19946 * 18649 * `null` if there are no catch clauses. The [finallyKeyword] and
19947 * @param tryKeyword the token representing the 'try' keyword 18650 * [finallyBlock] can be `null` if there is no finally clause.
19948 * @param body the body of the statement
19949 * @param catchClauses the catch clauses contained in the try statement
19950 * @param finallyKeyword the token representing the 'finally' keyword
19951 * @param finallyBlock the finally block contained in the try statement
19952 */ 18651 */
19953 TryStatement(this.tryKeyword, Block body, List<CatchClause> catchClauses, 18652 TryStatement(this.tryKeyword, Block body, List<CatchClause> catchClauses,
19954 this.finallyKeyword, Block finallyBlock) { 18653 this.finallyKeyword, Block finallyBlock) {
19955 _body = becomeParentOf(body); 18654 _body = becomeParentOf(body);
19956 _catchClauses = new NodeList<CatchClause>(this, catchClauses); 18655 _catchClauses = new NodeList<CatchClause>(this, catchClauses);
19957 _finallyBlock = becomeParentOf(finallyBlock); 18656 _finallyBlock = becomeParentOf(finallyBlock);
19958 } 18657 }
19959 18658
19960 @override 18659 @override
19961 Token get beginToken => tryKeyword; 18660 Token get beginToken => tryKeyword;
19962 18661
19963 /** 18662 /**
19964 * Return the body of the statement. 18663 * Return the body of the statement.
19965 *
19966 * @return the body of the statement
19967 */ 18664 */
19968 Block get body => _body; 18665 Block get body => _body;
19969 18666
19970 /** 18667 /**
19971 * Set the body of the statement to the given block. 18668 * Set the body of the statement to the given [block].
19972 *
19973 * @param block the body of the statement
19974 */ 18669 */
19975 void set body(Block block) { 18670 void set body(Block block) {
19976 _body = becomeParentOf(block); 18671 _body = becomeParentOf(block);
19977 } 18672 }
19978 18673
19979 /** 18674 /**
19980 * Return the catch clauses contained in the try statement. 18675 * Return the catch clauses contained in the try statement.
19981 *
19982 * @return the catch clauses contained in the try statement
19983 */ 18676 */
19984 NodeList<CatchClause> get catchClauses => _catchClauses; 18677 NodeList<CatchClause> get catchClauses => _catchClauses;
19985 18678
19986 @override 18679 @override
19987 Iterable get childEntities => new ChildEntities() 18680 Iterable get childEntities => new ChildEntities()
19988 ..add(tryKeyword) 18681 ..add(tryKeyword)
19989 ..add(_body) 18682 ..add(_body)
19990 ..addAll(_catchClauses) 18683 ..addAll(_catchClauses)
19991 ..add(finallyKeyword) 18684 ..add(finallyKeyword)
19992 ..add(_finallyBlock); 18685 ..add(_finallyBlock);
19993 18686
19994 @override 18687 @override
19995 Token get endToken { 18688 Token get endToken {
19996 if (_finallyBlock != null) { 18689 if (_finallyBlock != null) {
19997 return _finallyBlock.endToken; 18690 return _finallyBlock.endToken;
19998 } else if (finallyKeyword != null) { 18691 } else if (finallyKeyword != null) {
19999 return finallyKeyword; 18692 return finallyKeyword;
20000 } else if (!_catchClauses.isEmpty) { 18693 } else if (!_catchClauses.isEmpty) {
20001 return _catchClauses.endToken; 18694 return _catchClauses.endToken;
20002 } 18695 }
20003 return _body.endToken; 18696 return _body.endToken;
20004 } 18697 }
20005 18698
20006 /** 18699 /**
20007 * Return the finally block contained in the try statement, or `null` if the s tatement does 18700 * Return the finally block contained in the try statement, or `null` if the
20008 * not contain a finally clause. 18701 * statement does not contain a finally clause.
20009 *
20010 * @return the finally block contained in the try statement
20011 */ 18702 */
20012 Block get finallyBlock => _finallyBlock; 18703 Block get finallyBlock => _finallyBlock;
20013 18704
20014 /** 18705 /**
20015 * Set the finally block contained in the try statement to the given block. 18706 * Set the finally block contained in the try statement to the given [block].
20016 *
20017 * @param block the finally block contained in the try statement
20018 */ 18707 */
20019 void set finallyBlock(Block block) { 18708 void set finallyBlock(Block block) {
20020 _finallyBlock = becomeParentOf(block); 18709 _finallyBlock = becomeParentOf(block);
20021 } 18710 }
20022 18711
20023 @override 18712 @override
20024 accept(AstVisitor visitor) => visitor.visitTryStatement(this); 18713 accept(AstVisitor visitor) => visitor.visitTryStatement(this);
20025 18714
20026 @override 18715 @override
20027 void visitChildren(AstVisitor visitor) { 18716 void visitChildren(AstVisitor visitor) {
20028 safelyVisitChild(_body, visitor); 18717 _safelyVisitChild(_body, visitor);
20029 _catchClauses.accept(visitor); 18718 _catchClauses.accept(visitor);
20030 safelyVisitChild(_finallyBlock, visitor); 18719 _safelyVisitChild(_finallyBlock, visitor);
20031 } 18720 }
20032 } 18721 }
20033 18722
20034 /** 18723 /**
20035 * The abstract class `TypeAlias` defines the behavior common to declarations of type aliases. 18724 * The declaration of a type alias.
20036 * 18725 *
20037 * <pre> 18726 * > typeAlias ::=
20038 * typeAlias ::= 18727 * > 'typedef' typeAliasBody
20039 * 'typedef' typeAliasBody 18728 * >
20040 * 18729 * > typeAliasBody ::=
20041 * typeAliasBody ::= 18730 * > classTypeAlias
20042 * classTypeAlias 18731 * > | functionTypeAlias
20043 * | functionTypeAlias
20044 * </pre>
20045 */ 18732 */
20046 abstract class TypeAlias extends CompilationUnitMember { 18733 abstract class TypeAlias extends CompilationUnitMember {
20047 /** 18734 /**
20048 * The token representing the 'typedef' keyword. 18735 * The token representing the 'typedef' keyword.
20049 */ 18736 */
20050 Token keyword; 18737 Token keyword;
20051 18738
20052 /** 18739 /**
20053 * The semicolon terminating the declaration. 18740 * The semicolon terminating the declaration.
20054 */ 18741 */
20055 Token semicolon; 18742 Token semicolon;
20056 18743
20057 /** 18744 /**
20058 * Initialize a newly created type alias. 18745 * Initialize a newly created type alias. Either or both of the [comment] and
20059 * 18746 * [metadata] can be `null` if the declaration does not have the corresponding
20060 * @param comment the documentation comment associated with this type alias 18747 * attribute.
20061 * @param metadata the annotations associated with this type alias
20062 * @param keyword the token representing the 'typedef' keyword
20063 * @param semicolon the semicolon terminating the declaration
20064 */ 18748 */
20065 TypeAlias(Comment comment, List<Annotation> metadata, this.keyword, 18749 TypeAlias(Comment comment, List<Annotation> metadata, this.keyword,
20066 this.semicolon) 18750 this.semicolon)
20067 : super(comment, metadata); 18751 : super(comment, metadata);
20068 18752
20069 @override 18753 @override
20070 Token get endToken => semicolon; 18754 Token get endToken => semicolon;
20071 18755
20072 @override 18756 @override
20073 Token get firstTokenAfterCommentAndMetadata => keyword; 18757 Token get firstTokenAfterCommentAndMetadata => keyword;
20074 } 18758 }
20075 18759
20076 /** 18760 /**
20077 * Instances of the class `TypeArgumentList` represent a list of type arguments. 18761 * A list of type arguments.
20078 * 18762 *
20079 * <pre> 18763 * > typeArguments ::=
20080 * typeArguments ::= 18764 * > '<' typeName (',' typeName)* '>'
20081 * '<' typeName (',' typeName)* '>'
20082 * </pre>
20083 */ 18765 */
20084 class TypeArgumentList extends AstNode { 18766 class TypeArgumentList extends AstNode {
20085 /** 18767 /**
20086 * The left bracket. 18768 * The left bracket.
20087 */ 18769 */
20088 Token leftBracket; 18770 Token leftBracket;
20089 18771
20090 /** 18772 /**
20091 * The type arguments associated with the type. 18773 * The type arguments associated with the type.
20092 */ 18774 */
20093 NodeList<TypeName> _arguments; 18775 NodeList<TypeName> _arguments;
20094 18776
20095 /** 18777 /**
20096 * The right bracket. 18778 * The right bracket.
20097 */ 18779 */
20098 Token rightBracket; 18780 Token rightBracket;
20099 18781
20100 /** 18782 /**
20101 * Initialize a newly created list of type arguments. 18783 * Initialize a newly created list of type arguments.
20102 *
20103 * @param leftBracket the left bracket
20104 * @param arguments the type arguments associated with the type
20105 * @param rightBracket the right bracket
20106 */ 18784 */
20107 TypeArgumentList(this.leftBracket, List<TypeName> arguments, 18785 TypeArgumentList(this.leftBracket, List<TypeName> arguments,
20108 this.rightBracket) { 18786 this.rightBracket) {
20109 _arguments = new NodeList<TypeName>(this, arguments); 18787 _arguments = new NodeList<TypeName>(this, arguments);
20110 } 18788 }
20111 18789
20112 /** 18790 /**
20113 * Return the type arguments associated with the type. 18791 * Return the type arguments associated with the type.
20114 *
20115 * @return the type arguments associated with the type
20116 */ 18792 */
20117 NodeList<TypeName> get arguments => _arguments; 18793 NodeList<TypeName> get arguments => _arguments;
20118 18794
20119 @override 18795 @override
20120 Token get beginToken => leftBracket; 18796 Token get beginToken => leftBracket;
20121 18797
20122 /** 18798 /**
20123 * TODO(paulberry): Add commas. 18799 * TODO(paulberry): Add commas.
20124 */ 18800 */
20125 @override 18801 @override
20126 Iterable get childEntities => new ChildEntities() 18802 Iterable get childEntities => new ChildEntities()
20127 ..add(leftBracket) 18803 ..add(leftBracket)
20128 ..addAll(_arguments) 18804 ..addAll(_arguments)
20129 ..add(rightBracket); 18805 ..add(rightBracket);
20130 18806
20131 @override 18807 @override
20132 Token get endToken => rightBracket; 18808 Token get endToken => rightBracket;
20133 18809
20134 @override 18810 @override
20135 accept(AstVisitor visitor) => visitor.visitTypeArgumentList(this); 18811 accept(AstVisitor visitor) => visitor.visitTypeArgumentList(this);
20136 18812
20137 @override 18813 @override
20138 void visitChildren(AstVisitor visitor) { 18814 void visitChildren(AstVisitor visitor) {
20139 _arguments.accept(visitor); 18815 _arguments.accept(visitor);
20140 } 18816 }
20141 } 18817 }
20142 18818
20143 /** 18819 /**
20144 * The abstract class `TypedLiteral` defines the behavior common to literals tha t have a type 18820 * A literal that has a type associated with it.
20145 * associated with them.
20146 * 18821 *
20147 * <pre> 18822 * > typedLiteral ::=
20148 * listLiteral ::= 18823 * > [ListLiteral]
20149 * [ListLiteral] 18824 * > | [MapLiteral]
20150 * | [MapLiteral]
20151 * </pre>
20152 */ 18825 */
20153 abstract class TypedLiteral extends Literal { 18826 abstract class TypedLiteral extends Literal {
20154 /** 18827 /**
20155 * The token representing the 'const' keyword, or `null` if the literal is not a constant. 18828 * The token representing the 'const' keyword, or `null` if the literal is not
18829 * a constant.
20156 */ 18830 */
20157 Token constKeyword; 18831 Token constKeyword;
20158 18832
20159 /** 18833 /**
20160 * The type argument associated with this literal, or `null` if no type argume nts were 18834 * The type argument associated with this literal, or `null` if no type
20161 * declared. 18835 * arguments were declared.
20162 */ 18836 */
20163 TypeArgumentList _typeArguments; 18837 TypeArgumentList _typeArguments;
20164 18838
20165 /** 18839 /**
20166 * Initialize a newly created typed literal. 18840 * Initialize a newly created typed literal. The [constKeyword] can be `null`\
20167 * 18841 * if the literal is not a constant. The [typeArguments] can be `null` if no
20168 * @param constKeyword the token representing the 'const' keyword 18842 * type arguments were declared.
20169 * @param typeArguments the type argument associated with this literal, or `nu ll` if no type
20170 * arguments were declared
20171 */ 18843 */
20172 TypedLiteral(this.constKeyword, TypeArgumentList typeArguments) { 18844 TypedLiteral(this.constKeyword, TypeArgumentList typeArguments) {
20173 _typeArguments = becomeParentOf(typeArguments); 18845 _typeArguments = becomeParentOf(typeArguments);
20174 } 18846 }
20175 18847
20176 /** 18848 /**
20177 * Return the type argument associated with this literal, or `null` if no type arguments 18849 * Return the type argument associated with this literal, or `null` if no type
20178 * were declared. 18850 * arguments were declared.
20179 *
20180 * @return the type argument associated with this literal
20181 */ 18851 */
20182 TypeArgumentList get typeArguments => _typeArguments; 18852 TypeArgumentList get typeArguments => _typeArguments;
20183 18853
20184 /** 18854 /**
20185 * Set the type argument associated with this literal to the given arguments. 18855 * Set the type argument associated with this literal to the given
20186 * 18856 * [typeArguments].
20187 * @param typeArguments the type argument associated with this literal
20188 */ 18857 */
20189 void set typeArguments(TypeArgumentList typeArguments) { 18858 void set typeArguments(TypeArgumentList typeArguments) {
20190 _typeArguments = becomeParentOf(typeArguments); 18859 _typeArguments = becomeParentOf(typeArguments);
20191 } 18860 }
20192 18861
20193 ChildEntities get _childEntities => new ChildEntities() 18862 ChildEntities get _childEntities => new ChildEntities()
20194 ..add(constKeyword) 18863 ..add(constKeyword)
20195 ..add(_typeArguments); 18864 ..add(_typeArguments);
20196 18865
20197 @override 18866 @override
20198 void visitChildren(AstVisitor visitor) { 18867 void visitChildren(AstVisitor visitor) {
20199 safelyVisitChild(_typeArguments, visitor); 18868 _safelyVisitChild(_typeArguments, visitor);
20200 } 18869 }
20201 } 18870 }
20202 18871
20203 /** 18872 /**
20204 * Instances of the class `TypeName` represent the name of a type, which can opt ionally 18873 * The name of a type, which can optionally include type arguments.
20205 * include type arguments.
20206 * 18874 *
20207 * <pre> 18875 * > typeName ::=
20208 * typeName ::= 18876 * > [Identifier] typeArguments?
20209 * [Identifier] typeArguments?
20210 * </pre>
20211 */ 18877 */
20212 class TypeName extends AstNode { 18878 class TypeName extends AstNode {
20213 /** 18879 /**
20214 * The name of the type. 18880 * The name of the type.
20215 */ 18881 */
20216 Identifier _name; 18882 Identifier _name;
20217 18883
20218 /** 18884 /**
20219 * The type arguments associated with the type, or `null` if there are no type arguments. 18885 * The type arguments associated with the type, or `null` if there are no type
18886 * arguments.
20220 */ 18887 */
20221 TypeArgumentList _typeArguments; 18888 TypeArgumentList _typeArguments;
20222 18889
20223 /** 18890 /**
20224 * The type being named, or `null` if the AST structure has not been resolved. 18891 * The type being named, or `null` if the AST structure has not been resolved.
20225 */ 18892 */
20226 DartType type; 18893 DartType type;
20227 18894
20228 /** 18895 /**
20229 * Initialize a newly created type name. 18896 * Initialize a newly created type name. The [typeArguments] can be `null` if
20230 * 18897 * there are no type arguments.
20231 * @param name the name of the type
20232 * @param typeArguments the type arguments associated with the type, or `null` if there are
20233 * no type arguments
20234 */ 18898 */
20235 TypeName(Identifier name, TypeArgumentList typeArguments) { 18899 TypeName(Identifier name, TypeArgumentList typeArguments) {
20236 _name = becomeParentOf(name); 18900 _name = becomeParentOf(name);
20237 _typeArguments = becomeParentOf(typeArguments); 18901 _typeArguments = becomeParentOf(typeArguments);
20238 } 18902 }
20239 18903
20240 @override 18904 @override
20241 Token get beginToken => _name.beginToken; 18905 Token get beginToken => _name.beginToken;
20242 18906
20243 @override 18907 @override
20244 Iterable get childEntities => new ChildEntities() 18908 Iterable get childEntities => new ChildEntities()
20245 ..add(_name) 18909 ..add(_name)
20246 ..add(_typeArguments); 18910 ..add(_typeArguments);
20247 18911
20248 @override 18912 @override
20249 Token get endToken { 18913 Token get endToken {
20250 if (_typeArguments != null) { 18914 if (_typeArguments != null) {
20251 return _typeArguments.endToken; 18915 return _typeArguments.endToken;
20252 } 18916 }
20253 return _name.endToken; 18917 return _name.endToken;
20254 } 18918 }
20255 18919
20256 /** 18920 /**
20257 * Return `true` if this type is a deferred type. 18921 * Return `true` if this type is a deferred type.
20258 * 18922 *
20259 * 15.1 Static Types: A type <i>T</i> is deferred iff it is of the form </i>p. T</i> where <i>p</i> 18923 * 15.1 Static Types: A type <i>T</i> is deferred iff it is of the form
20260 * is a deferred prefix. 18924 * </i>p.T</i> where <i>p</i> is a deferred prefix.
20261 *
20262 * @return `true` if this type is a deferred type
20263 */ 18925 */
20264 bool get isDeferred { 18926 bool get isDeferred {
20265 Identifier identifier = name; 18927 Identifier identifier = name;
20266 if (identifier is! PrefixedIdentifier) { 18928 if (identifier is! PrefixedIdentifier) {
20267 return false; 18929 return false;
20268 } 18930 }
20269 return (identifier as PrefixedIdentifier).isDeferred; 18931 return (identifier as PrefixedIdentifier).isDeferred;
20270 } 18932 }
20271 18933
20272 @override 18934 @override
20273 bool get isSynthetic => _name.isSynthetic && _typeArguments == null; 18935 bool get isSynthetic => _name.isSynthetic && _typeArguments == null;
20274 18936
20275 /** 18937 /**
20276 * Return the name of the type. 18938 * Return the name of the type.
20277 *
20278 * @return the name of the type
20279 */ 18939 */
20280 Identifier get name => _name; 18940 Identifier get name => _name;
20281 18941
20282 /** 18942 /**
20283 * Set the name of the type to the given identifier. 18943 * Set the name of the type to the given [identifier].
20284 *
20285 * @param identifier the name of the type
20286 */ 18944 */
20287 void set name(Identifier identifier) { 18945 void set name(Identifier identifier) {
20288 _name = becomeParentOf(identifier); 18946 _name = becomeParentOf(identifier);
20289 } 18947 }
20290 18948
20291 /** 18949 /**
20292 * Return the type arguments associated with the type, or `null` if there are no type 18950 * Return the type arguments associated with the type, or `null` if there are
20293 * arguments. 18951 * no type arguments.
20294 *
20295 * @return the type arguments associated with the type
20296 */ 18952 */
20297 TypeArgumentList get typeArguments => _typeArguments; 18953 TypeArgumentList get typeArguments => _typeArguments;
20298 18954
20299 /** 18955 /**
20300 * Set the type arguments associated with the type to the given type arguments . 18956 * Set the type arguments associated with the type to the given
20301 * 18957 * [typeArguments].
20302 * @param typeArguments the type arguments associated with the type
20303 */ 18958 */
20304 void set typeArguments(TypeArgumentList typeArguments) { 18959 void set typeArguments(TypeArgumentList typeArguments) {
20305 _typeArguments = becomeParentOf(typeArguments); 18960 _typeArguments = becomeParentOf(typeArguments);
20306 } 18961 }
20307 18962
20308 @override 18963 @override
20309 accept(AstVisitor visitor) => visitor.visitTypeName(this); 18964 accept(AstVisitor visitor) => visitor.visitTypeName(this);
20310 18965
20311 @override 18966 @override
20312 void visitChildren(AstVisitor visitor) { 18967 void visitChildren(AstVisitor visitor) {
20313 safelyVisitChild(_name, visitor); 18968 _safelyVisitChild(_name, visitor);
20314 safelyVisitChild(_typeArguments, visitor); 18969 _safelyVisitChild(_typeArguments, visitor);
20315 } 18970 }
20316 } 18971 }
20317 18972
20318 /** 18973 /**
20319 * Instances of the class `TypeParameter` represent a type parameter. 18974 * A type parameter.
20320 * 18975 *
20321 * <pre> 18976 * > typeParameter ::=
20322 * typeParameter ::= 18977 * > [SimpleIdentifier] ('extends' [TypeName])?
20323 * [SimpleIdentifier] ('extends' [TypeName])?
20324 * </pre>
20325 */ 18978 */
20326 class TypeParameter extends Declaration { 18979 class TypeParameter extends Declaration {
20327 /** 18980 /**
20328 * The name of the type parameter. 18981 * The name of the type parameter.
20329 */ 18982 */
20330 SimpleIdentifier _name; 18983 SimpleIdentifier _name;
20331 18984
20332 /** 18985 /**
20333 * The token representing the 'extends' keyword, or `null` if there was no exp licit upper 18986 * The token representing the 'extends' keyword, or `null` if there is no
20334 * bound. 18987 * explicit upper bound.
20335 */ 18988 */
20336 Token keyword; 18989 Token keyword;
20337 18990
20338 /** 18991 /**
20339 * The name of the upper bound for legal arguments, or `null` if there was no explicit upper 18992 * The name of the upper bound for legal arguments, or `null` if there is no
20340 * bound. 18993 * explicit upper bound.
20341 */ 18994 */
20342 TypeName _bound; 18995 TypeName _bound;
20343 18996
20344 /** 18997 /**
20345 * Initialize a newly created type parameter. 18998 * Initialize a newly created type parameter. Either or both of the [comment]
20346 * 18999 * and [metadata] can be `null` if the parameter does not have the
20347 * @param comment the documentation comment associated with the type parameter 19000 * corresponding attribute. The [keyword] and [bound] can be `null` if the
20348 * @param metadata the annotations associated with the type parameter 19001 * parameter does not have an upper bound.
20349 * @param name the name of the type parameter
20350 * @param keyword the token representing the 'extends' keyword
20351 * @param bound the name of the upper bound for legal arguments
20352 */ 19002 */
20353 TypeParameter(Comment comment, List<Annotation> metadata, 19003 TypeParameter(Comment comment, List<Annotation> metadata,
20354 SimpleIdentifier name, this.keyword, TypeName bound) 19004 SimpleIdentifier name, this.keyword, TypeName bound)
20355 : super(comment, metadata) { 19005 : super(comment, metadata) {
20356 _name = becomeParentOf(name); 19006 _name = becomeParentOf(name);
20357 _bound = becomeParentOf(bound); 19007 _bound = becomeParentOf(bound);
20358 } 19008 }
20359 19009
20360 /** 19010 /**
20361 * Return the name of the upper bound for legal arguments, or `null` if there was no 19011 * Return the name of the upper bound for legal arguments, or `null` if there
20362 * explicit upper bound. 19012 * is no explicit upper bound.
20363 *
20364 * @return the name of the upper bound for legal arguments
20365 */ 19013 */
20366 TypeName get bound => _bound; 19014 TypeName get bound => _bound;
20367 19015
20368 /** 19016 /**
20369 * Set the name of the upper bound for legal arguments to the given type name. 19017 * Set the name of the upper bound for legal arguments to the given
20370 * 19018 * [typeName].
20371 * @param typeName the name of the upper bound for legal arguments
20372 */ 19019 */
20373 void set bound(TypeName typeName) { 19020 void set bound(TypeName typeName) {
20374 _bound = becomeParentOf(typeName); 19021 _bound = becomeParentOf(typeName);
20375 } 19022 }
20376 19023
20377 @override 19024 @override
20378 Iterable get childEntities => super._childEntities 19025 Iterable get childEntities => super._childEntities
20379 ..add(_name) 19026 ..add(_name)
20380 ..add(keyword) 19027 ..add(keyword)
20381 ..add(_bound); 19028 ..add(_bound);
20382 19029
20383 @override 19030 @override
20384 TypeParameterElement get element => 19031 TypeParameterElement get element =>
20385 _name != null ? (_name.staticElement as TypeParameterElement) : null; 19032 _name != null ? (_name.staticElement as TypeParameterElement) : null;
20386 19033
20387 @override 19034 @override
20388 Token get endToken { 19035 Token get endToken {
20389 if (_bound == null) { 19036 if (_bound == null) {
20390 return _name.endToken; 19037 return _name.endToken;
20391 } 19038 }
20392 return _bound.endToken; 19039 return _bound.endToken;
20393 } 19040 }
20394 19041
20395 @override 19042 @override
20396 Token get firstTokenAfterCommentAndMetadata => _name.beginToken; 19043 Token get firstTokenAfterCommentAndMetadata => _name.beginToken;
20397 19044
20398 /** 19045 /**
20399 * Return the name of the type parameter. 19046 * Return the name of the type parameter.
20400 *
20401 * @return the name of the type parameter
20402 */ 19047 */
20403 SimpleIdentifier get name => _name; 19048 SimpleIdentifier get name => _name;
20404 19049
20405 /** 19050 /**
20406 * Set the name of the type parameter to the given identifier. 19051 * Set the name of the type parameter to the given [identifier].
20407 *
20408 * @param identifier the name of the type parameter
20409 */ 19052 */
20410 void set name(SimpleIdentifier identifier) { 19053 void set name(SimpleIdentifier identifier) {
20411 _name = becomeParentOf(identifier); 19054 _name = becomeParentOf(identifier);
20412 } 19055 }
20413 19056
20414 @override 19057 @override
20415 accept(AstVisitor visitor) => visitor.visitTypeParameter(this); 19058 accept(AstVisitor visitor) => visitor.visitTypeParameter(this);
20416 19059
20417 @override 19060 @override
20418 void visitChildren(AstVisitor visitor) { 19061 void visitChildren(AstVisitor visitor) {
20419 super.visitChildren(visitor); 19062 super.visitChildren(visitor);
20420 safelyVisitChild(_name, visitor); 19063 _safelyVisitChild(_name, visitor);
20421 safelyVisitChild(_bound, visitor); 19064 _safelyVisitChild(_bound, visitor);
20422 } 19065 }
20423 } 19066 }
20424 19067
20425 /** 19068 /**
20426 * Instances of the class `TypeParameterList` represent type parameters within a declaration. 19069 * Type parameters within a declaration.
20427 * 19070 *
20428 * <pre> 19071 * > typeParameterList ::=
20429 * typeParameterList ::= 19072 * > '<' [TypeParameter] (',' [TypeParameter])* '>'
20430 * '<' [TypeParameter] (',' [TypeParameter])* '>'
20431 * </pre>
20432 */ 19073 */
20433 class TypeParameterList extends AstNode { 19074 class TypeParameterList extends AstNode {
20434 /** 19075 /**
20435 * The left angle bracket. 19076 * The left angle bracket.
20436 */ 19077 */
20437 final Token leftBracket; 19078 final Token leftBracket;
20438 19079
20439 /** 19080 /**
20440 * The type parameters in the list. 19081 * The type parameters in the list.
20441 */ 19082 */
20442 NodeList<TypeParameter> _typeParameters; 19083 NodeList<TypeParameter> _typeParameters;
20443 19084
20444 /** 19085 /**
20445 * The right angle bracket. 19086 * The right angle bracket.
20446 */ 19087 */
20447 final Token rightBracket; 19088 final Token rightBracket;
20448 19089
20449 /** 19090 /**
20450 * Initialize a newly created list of type parameters. 19091 * Initialize a newly created list of type parameters.
20451 *
20452 * @param leftBracket the left angle bracket
20453 * @param typeParameters the type parameters in the list
20454 * @param rightBracket the right angle bracket
20455 */ 19092 */
20456 TypeParameterList(this.leftBracket, List<TypeParameter> typeParameters, 19093 TypeParameterList(this.leftBracket, List<TypeParameter> typeParameters,
20457 this.rightBracket) { 19094 this.rightBracket) {
20458 _typeParameters = new NodeList<TypeParameter>(this, typeParameters); 19095 _typeParameters = new NodeList<TypeParameter>(this, typeParameters);
20459 } 19096 }
20460 19097
20461 @override 19098 @override
20462 Token get beginToken => leftBracket; 19099 Token get beginToken => leftBracket;
20463 19100
20464 @override 19101 @override
20465 Iterable get childEntities => new ChildEntities() 19102 Iterable get childEntities => new ChildEntities()
20466 ..add(leftBracket) 19103 ..add(leftBracket)
20467 ..addAll(_typeParameters) 19104 ..addAll(_typeParameters)
20468 ..add(rightBracket); 19105 ..add(rightBracket);
20469 19106
20470 @override 19107 @override
20471 Token get endToken => rightBracket; 19108 Token get endToken => rightBracket;
20472 19109
20473 /** 19110 /**
20474 * Return the type parameters for the type. 19111 * Return the type parameters for the type.
20475 *
20476 * @return the type parameters for the type
20477 */ 19112 */
20478 NodeList<TypeParameter> get typeParameters => _typeParameters; 19113 NodeList<TypeParameter> get typeParameters => _typeParameters;
20479 19114
20480 @override 19115 @override
20481 accept(AstVisitor visitor) => visitor.visitTypeParameterList(this); 19116 accept(AstVisitor visitor) => visitor.visitTypeParameterList(this);
20482 19117
20483 @override 19118 @override
20484 void visitChildren(AstVisitor visitor) { 19119 void visitChildren(AstVisitor visitor) {
20485 _typeParameters.accept(visitor); 19120 _typeParameters.accept(visitor);
20486 } 19121 }
20487 } 19122 }
20488 19123
20489 /** 19124 /**
20490 * Instances of the class `UnifyingAstVisitor` implement an AST visitor that wil l recursively 19125 * An AST visitor that will recursively visit all of the nodes in an AST
20491 * visit all of the nodes in an AST structure (like instances of the class 19126 * structure (like instances of the class [RecursiveAstVisitor]). In addition,
20492 * [RecursiveAstVisitor]). In addition, every node will also be visited by using a single 19127 * every node will also be visited by using a single unified [visitNode] method.
20493 * unified [visitNode] method.
20494 * 19128 *
20495 * Subclasses that override a visit method must either invoke the overridden vis it method or 19129 * Subclasses that override a visit method must either invoke the overridden
20496 * explicitly invoke the more general [visitNode] method. Failure to do so will 19130 * visit method or explicitly invoke the more general [visitNode] method.
20497 * cause the children of the visited node to not be visited. 19131 * Failure to do so will cause the children of the visited node to not be
19132 * visited.
20498 */ 19133 */
20499 class UnifyingAstVisitor<R> implements AstVisitor<R> { 19134 class UnifyingAstVisitor<R> implements AstVisitor<R> {
20500 @override 19135 @override
20501 R visitAdjacentStrings(AdjacentStrings node) => visitNode(node); 19136 R visitAdjacentStrings(AdjacentStrings node) => visitNode(node);
20502 19137
20503 @override 19138 @override
20504 R visitAnnotation(Annotation node) => visitNode(node); 19139 R visitAnnotation(Annotation node) => visitNode(node);
20505 19140
20506 @override 19141 @override
20507 R visitArgumentList(ArgumentList node) => visitNode(node); 19142 R visitArgumentList(ArgumentList node) => visitNode(node);
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
20829 R visitWhileStatement(WhileStatement node) => visitNode(node); 19464 R visitWhileStatement(WhileStatement node) => visitNode(node);
20830 19465
20831 @override 19466 @override
20832 R visitWithClause(WithClause node) => visitNode(node); 19467 R visitWithClause(WithClause node) => visitNode(node);
20833 19468
20834 @override 19469 @override
20835 R visitYieldStatement(YieldStatement node) => visitNode(node); 19470 R visitYieldStatement(YieldStatement node) => visitNode(node);
20836 } 19471 }
20837 19472
20838 /** 19473 /**
20839 * The abstract class `UriBasedDirective` defines the behavior common to nodes t hat represent 19474 * A directive that references a URI.
20840 * a directive that references a URI.
20841 * 19475 *
20842 * <pre> 19476 * > uriBasedDirective ::=
20843 * uriBasedDirective ::= 19477 * > [ExportDirective]
20844 * [ExportDirective] 19478 * > | [ImportDirective]
20845 * | [ImportDirective] 19479 * > | [PartDirective]
20846 * | [PartDirective]
20847 * </pre>
20848 */ 19480 */
20849 abstract class UriBasedDirective extends Directive { 19481 abstract class UriBasedDirective extends Directive {
20850 /** 19482 /**
20851 * The prefix of a URI using the `dart-ext` scheme to reference a native code library. 19483 * The prefix of a URI using the `dart-ext` scheme to reference a native code
19484 * library.
20852 */ 19485 */
20853 static String _DART_EXT_SCHEME = "dart-ext:"; 19486 static String _DART_EXT_SCHEME = "dart-ext:";
20854 19487
20855 /** 19488 /**
20856 * The URI referenced by this directive. 19489 * The URI referenced by this directive.
20857 */ 19490 */
20858 StringLiteral _uri; 19491 StringLiteral _uri;
20859 19492
20860 /** 19493 /**
20861 * The content of the URI. 19494 * The content of the URI.
20862 */ 19495 */
20863 String uriContent; 19496 String uriContent;
20864 19497
20865 /** 19498 /**
20866 * The source to which the URI was resolved. 19499 * The source to which the URI was resolved.
20867 */ 19500 */
20868 Source source; 19501 Source source;
20869 19502
20870 /** 19503 /**
20871 * Initialize a newly create URI-based directive. 19504 * Initialize a newly create URI-based directive. Either or both of the
20872 * 19505 * [comment] and [metadata] can be `null` if the directive does not have the
20873 * @param comment the documentation comment associated with this directive 19506 * corresponding attribute.
20874 * @param metadata the annotations associated with the directive
20875 * @param uri the URI referenced by this directive
20876 */ 19507 */
20877 UriBasedDirective(Comment comment, List<Annotation> metadata, 19508 UriBasedDirective(Comment comment, List<Annotation> metadata,
20878 StringLiteral uri) 19509 StringLiteral uri)
20879 : super(comment, metadata) { 19510 : super(comment, metadata) {
20880 _uri = becomeParentOf(uri); 19511 _uri = becomeParentOf(uri);
20881 } 19512 }
20882 19513
20883 /** 19514 /**
20884 * Return the URI referenced by this directive. 19515 * Return the URI referenced by this directive.
20885 *
20886 * @return the URI referenced by this directive
20887 */ 19516 */
20888 StringLiteral get uri => _uri; 19517 StringLiteral get uri => _uri;
20889 19518
20890 /** 19519 /**
20891 * Set the URI referenced by this directive to the given URI. 19520 * Set the URI referenced by this directive to the given [uri].
20892 *
20893 * @param uri the URI referenced by this directive
20894 */ 19521 */
20895 void set uri(StringLiteral uri) { 19522 void set uri(StringLiteral uri) {
20896 _uri = becomeParentOf(uri); 19523 _uri = becomeParentOf(uri);
20897 } 19524 }
20898 19525
20899 /** 19526 /**
20900 * Return the element associated with the URI of this directive, or `null` if the AST 19527 * Return the element associated with the URI of this directive, or `null` if
20901 * structure has not been resolved or if the URI could not be resolved. Exampl es of the latter 19528 * the AST structure has not been resolved or if the URI could not be
20902 * case include a directive that contains an invalid URL or a URL that does no t exist. 19529 * resolved. Examples of the latter case include a directive that contains an
20903 * 19530 * invalid URL or a URL that does not exist.
20904 * @return the element associated with this directive
20905 */ 19531 */
20906 Element get uriElement; 19532 Element get uriElement;
20907 19533
20908 /** 19534 /**
20909 * Validate the given directive, but do not check for existence. 19535 * Validate this directive, but do not check for existence. Return a code
20910 * 19536 * indicating the problem if there is one, or `null` no problem
20911 * @return a code indicating the problem if there is one, or `null` no problem
20912 */ 19537 */
20913 UriValidationCode validate() { 19538 UriValidationCode validate() {
20914 StringLiteral uriLiteral = uri; 19539 StringLiteral uriLiteral = uri;
20915 if (uriLiteral is StringInterpolation) { 19540 if (uriLiteral is StringInterpolation) {
20916 return UriValidationCode.URI_WITH_INTERPOLATION; 19541 return UriValidationCode.URI_WITH_INTERPOLATION;
20917 } 19542 }
20918 String uriContent = this.uriContent; 19543 String uriContent = this.uriContent;
20919 if (uriContent == null) { 19544 if (uriContent == null) {
20920 return UriValidationCode.INVALID_URI; 19545 return UriValidationCode.INVALID_URI;
20921 } 19546 }
20922 if (this is ImportDirective && uriContent.startsWith(_DART_EXT_SCHEME)) { 19547 if (this is ImportDirective && uriContent.startsWith(_DART_EXT_SCHEME)) {
20923 return UriValidationCode.URI_WITH_DART_EXT_SCHEME; 19548 return UriValidationCode.URI_WITH_DART_EXT_SCHEME;
20924 } 19549 }
20925 try { 19550 try {
20926 parseUriWithException(Uri.encodeFull(uriContent)); 19551 parseUriWithException(Uri.encodeFull(uriContent));
20927 } on URISyntaxException catch (exception) { 19552 } on URISyntaxException catch (exception) {
20928 return UriValidationCode.INVALID_URI; 19553 return UriValidationCode.INVALID_URI;
20929 } 19554 }
20930 return null; 19555 return null;
20931 } 19556 }
20932 19557
20933 @override 19558 @override
20934 void visitChildren(AstVisitor visitor) { 19559 void visitChildren(AstVisitor visitor) {
20935 super.visitChildren(visitor); 19560 super.visitChildren(visitor);
20936 safelyVisitChild(_uri, visitor); 19561 _safelyVisitChild(_uri, visitor);
20937 } 19562 }
20938 } 19563 }
20939 19564
20940 /** 19565 /**
20941 * Validation codes returned by [UriBasedDirective.validate]. 19566 * Validation codes returned by [UriBasedDirective.validate].
20942 */ 19567 */
20943 class UriValidationCode { 19568 class UriValidationCode {
20944 static const UriValidationCode INVALID_URI = 19569 static const UriValidationCode INVALID_URI =
20945 const UriValidationCode('INVALID_URI'); 19570 const UriValidationCode('INVALID_URI');
20946 19571
(...skipping 11 matching lines...) Expand all
20958 /** 19583 /**
20959 * Initialize a newly created validation code to have the given [name]. 19584 * Initialize a newly created validation code to have the given [name].
20960 */ 19585 */
20961 const UriValidationCode(this.name); 19586 const UriValidationCode(this.name);
20962 19587
20963 @override 19588 @override
20964 String toString() => name; 19589 String toString() => name;
20965 } 19590 }
20966 19591
20967 /** 19592 /**
20968 * Instances of the class `VariableDeclaration` represent an identifier that has an initial 19593 * An identifier that has an initial value associated with it. Instances of this
20969 * value associated with it. Instances of this class are always children of the class 19594 * class are always children of the class [VariableDeclarationList].
20970 * [VariableDeclarationList].
20971 * 19595 *
20972 * <pre> 19596 * > variableDeclaration ::=
20973 * variableDeclaration ::= 19597 * > [SimpleIdentifier] ('=' [Expression])?
20974 * [SimpleIdentifier] ('=' [Expression])?
20975 * </pre>
20976 */ 19598 */
20977 class VariableDeclaration extends Declaration { 19599 class VariableDeclaration extends Declaration {
20978 /** 19600 /**
20979 * The name of the variable being declared. 19601 * The name of the variable being declared.
20980 */ 19602 */
20981 SimpleIdentifier _name; 19603 SimpleIdentifier _name;
20982 19604
20983 /** 19605 /**
20984 * The equal sign separating the variable name from the initial value, or `nul l` if the 19606 * The equal sign separating the variable name from the initial value, or
20985 * initial value was not specified. 19607 * `null` if the initial value was not specified.
20986 */ 19608 */
20987 Token equals; 19609 Token equals;
20988 19610
20989 /** 19611 /**
20990 * The expression used to compute the initial value for the variable, or `null ` if the 19612 * The expression used to compute the initial value for the variable, or
20991 * initial value was not specified. 19613 * `null` if the initial value was not specified.
20992 */ 19614 */
20993 Expression _initializer; 19615 Expression _initializer;
20994 19616
20995 /** 19617 /**
20996 * Initialize a newly created variable declaration. 19618 * Initialize a newly created variable declaration. Either or both of the
20997 * 19619 * [comment] and [metadata] can be `null` if the declaration does not have the
20998 * @param comment the documentation comment associated with this declaration 19620 * corresponding attribute. The [equals] and [initializer] can be `null` if
20999 * @param metadata the annotations associated with this member 19621 * there is no initializer.
21000 * @param name the name of the variable being declared
21001 * @param equals the equal sign separating the variable name from the initial value
21002 * @param initializer the expression used to compute the initial value for the variable
21003 */ 19622 */
21004 VariableDeclaration(Comment comment, List<Annotation> metadata, 19623 VariableDeclaration(Comment comment, List<Annotation> metadata,
21005 SimpleIdentifier name, this.equals, Expression initializer) 19624 SimpleIdentifier name, this.equals, Expression initializer)
21006 : super(comment, metadata) { 19625 : super(comment, metadata) {
21007 _name = becomeParentOf(name); 19626 _name = becomeParentOf(name);
21008 _initializer = becomeParentOf(initializer); 19627 _initializer = becomeParentOf(initializer);
21009 } 19628 }
21010 19629
21011 @override 19630 @override
21012 Iterable get childEntities => super._childEntities 19631 Iterable get childEntities => super._childEntities
21013 ..add(_name) 19632 ..add(_name)
21014 ..add(equals) 19633 ..add(equals)
21015 ..add(_initializer); 19634 ..add(_initializer);
21016 19635
21017 /** 19636 /**
21018 * This overridden implementation of getDocumentationComment() looks in the gr andparent node for 19637 * This overridden implementation of getDocumentationComment() looks in the
21019 * dartdoc comments if no documentation is specifically available on the node. 19638 * grandparent node for dartdoc comments if no documentation is specifically
19639 * available on the node.
21020 */ 19640 */
21021 @override 19641 @override
21022 Comment get documentationComment { 19642 Comment get documentationComment {
21023 Comment comment = super.documentationComment; 19643 Comment comment = super.documentationComment;
21024 if (comment == null) { 19644 if (comment == null) {
21025 if (parent != null && parent.parent != null) { 19645 if (parent != null && parent.parent != null) {
21026 AstNode node = parent.parent; 19646 AstNode node = parent.parent;
21027 if (node is AnnotatedNode) { 19647 if (node is AnnotatedNode) {
21028 return node.documentationComment; 19648 return node.documentationComment;
21029 } 19649 }
(...skipping 11 matching lines...) Expand all
21041 if (_initializer != null) { 19661 if (_initializer != null) {
21042 return _initializer.endToken; 19662 return _initializer.endToken;
21043 } 19663 }
21044 return _name.endToken; 19664 return _name.endToken;
21045 } 19665 }
21046 19666
21047 @override 19667 @override
21048 Token get firstTokenAfterCommentAndMetadata => _name.beginToken; 19668 Token get firstTokenAfterCommentAndMetadata => _name.beginToken;
21049 19669
21050 /** 19670 /**
21051 * Return the expression used to compute the initial value for the variable, o r `null` if 19671 * Return the expression used to compute the initial value for the variable,
21052 * the initial value was not specified. 19672 * or `null` if the initial value was not specified.
21053 *
21054 * @return the expression used to compute the initial value for the variable
21055 */ 19673 */
21056 Expression get initializer => _initializer; 19674 Expression get initializer => _initializer;
21057 19675
21058 /** 19676 /**
21059 * Set the expression used to compute the initial value for the variable to th e given expression. 19677 * Set the expression used to compute the initial value for the variable to
21060 * 19678 * the given [expression].
21061 * @param initializer the expression used to compute the initial value for the variable
21062 */ 19679 */
21063 void set initializer(Expression initializer) { 19680 void set initializer(Expression expression) {
21064 _initializer = becomeParentOf(initializer); 19681 _initializer = becomeParentOf(expression);
21065 } 19682 }
21066 19683
21067 /** 19684 /**
21068 * Return `true` if this variable was declared with the 'const' modifier. 19685 * Return `true` if this variable was declared with the 'const' modifier.
21069 *
21070 * @return `true` if this variable was declared with the 'const' modifier
21071 */ 19686 */
21072 bool get isConst { 19687 bool get isConst {
21073 AstNode parent = this.parent; 19688 AstNode parent = this.parent;
21074 return parent is VariableDeclarationList && parent.isConst; 19689 return parent is VariableDeclarationList && parent.isConst;
21075 } 19690 }
21076 19691
21077 /** 19692 /**
21078 * Return `true` if this variable was declared with the 'final' modifier. Vari ables that are 19693 * Return `true` if this variable was declared with the 'final' modifier.
21079 * declared with the 'const' modifier will return `false` even though they are implicitly 19694 * Variables that are declared with the 'const' modifier will return `false`
21080 * final. 19695 * even though they are implicitly final.
21081 *
21082 * @return `true` if this variable was declared with the 'final' modifier
21083 */ 19696 */
21084 bool get isFinal { 19697 bool get isFinal {
21085 AstNode parent = this.parent; 19698 AstNode parent = this.parent;
21086 return parent is VariableDeclarationList && parent.isFinal; 19699 return parent is VariableDeclarationList && parent.isFinal;
21087 } 19700 }
21088 19701
21089 /** 19702 /**
21090 * Return the name of the variable being declared. 19703 * Return the name of the variable being declared.
21091 *
21092 * @return the name of the variable being declared
21093 */ 19704 */
21094 SimpleIdentifier get name => _name; 19705 SimpleIdentifier get name => _name;
21095 19706
21096 /** 19707 /**
21097 * Set the name of the variable being declared to the given identifier. 19708 * Set the name of the variable being declared to the given [identifier].
21098 *
21099 * @param name the name of the variable being declared
21100 */ 19709 */
21101 void set name(SimpleIdentifier name) { 19710 void set name(SimpleIdentifier identifier) {
21102 _name = becomeParentOf(name); 19711 _name = becomeParentOf(identifier);
21103 } 19712 }
21104 19713
21105 @override 19714 @override
21106 accept(AstVisitor visitor) => visitor.visitVariableDeclaration(this); 19715 accept(AstVisitor visitor) => visitor.visitVariableDeclaration(this);
21107 19716
21108 @override 19717 @override
21109 void visitChildren(AstVisitor visitor) { 19718 void visitChildren(AstVisitor visitor) {
21110 super.visitChildren(visitor); 19719 super.visitChildren(visitor);
21111 safelyVisitChild(_name, visitor); 19720 _safelyVisitChild(_name, visitor);
21112 safelyVisitChild(_initializer, visitor); 19721 _safelyVisitChild(_initializer, visitor);
21113 } 19722 }
21114 } 19723 }
21115 19724
21116 /** 19725 /**
21117 * Instances of the class `VariableDeclarationList` represent the declaration of one or more 19726 * The declaration of one or more variables of the same type.
21118 * variables of the same type.
21119 * 19727 *
21120 * <pre> 19728 * > variableDeclarationList ::=
21121 * variableDeclarationList ::= 19729 * > finalConstVarOrType [VariableDeclaration] (',' [VariableDeclaration])*
21122 * finalConstVarOrType [VariableDeclaration] (',' [VariableDeclaration])* 19730 * >
21123 * 19731 * > finalConstVarOrType ::=
21124 * finalConstVarOrType ::= 19732 * > | 'final' [TypeName]?
21125 * | 'final' [TypeName]? 19733 * > | 'const' [TypeName]?
21126 * | 'const' [TypeName]? 19734 * > | 'var'
21127 * | 'var' 19735 * > | [TypeName]
21128 * | [TypeName]
21129 * </pre>
21130 */ 19736 */
21131 class VariableDeclarationList extends AnnotatedNode { 19737 class VariableDeclarationList extends AnnotatedNode {
21132 /** 19738 /**
21133 * The token representing the 'final', 'const' or 'var' keyword, or `null` if no keyword was 19739 * The token representing the 'final', 'const' or 'var' keyword, or `null` if
21134 * included. 19740 * no keyword was included.
21135 */ 19741 */
21136 Token keyword; 19742 Token keyword;
21137 19743
21138 /** 19744 /**
21139 * The type of the variables being declared, or `null` if no type was provided . 19745 * The type of the variables being declared, or `null` if no type was provided .
21140 */ 19746 */
21141 TypeName _type; 19747 TypeName _type;
21142 19748
21143 /** 19749 /**
21144 * A list containing the individual variables being declared. 19750 * A list containing the individual variables being declared.
21145 */ 19751 */
21146 NodeList<VariableDeclaration> _variables; 19752 NodeList<VariableDeclaration> _variables;
21147 19753
21148 /** 19754 /**
21149 * Initialize a newly created variable declaration list. 19755 * Initialize a newly created variable declaration list. Either or both of the
21150 * 19756 * [comment] and [metadata] can be `null` if the variable list does not have
21151 * @param comment the documentation comment associated with this declaration l ist 19757 * the corresponding attribute. The [keyword] can be `null` if a type was
21152 * @param metadata the annotations associated with this declaration list 19758 * specified. The [type] must be `null` if the keyword is 'var'.
21153 * @param keyword the token representing the 'final', 'const' or 'var' keyword
21154 * @param type the type of the variables being declared
21155 * @param variables a list containing the individual variables being declared
21156 */ 19759 */
21157 VariableDeclarationList(Comment comment, List<Annotation> metadata, 19760 VariableDeclarationList(Comment comment, List<Annotation> metadata,
21158 this.keyword, TypeName type, List<VariableDeclaration> variables) 19761 this.keyword, TypeName type, List<VariableDeclaration> variables)
21159 : super(comment, metadata) { 19762 : super(comment, metadata) {
21160 _type = becomeParentOf(type); 19763 _type = becomeParentOf(type);
21161 _variables = new NodeList<VariableDeclaration>(this, variables); 19764 _variables = new NodeList<VariableDeclaration>(this, variables);
21162 } 19765 }
21163 19766
21164 /** 19767 /**
21165 * TODO(paulberry): include commas. 19768 * TODO(paulberry): include commas.
(...skipping 11 matching lines...) Expand all
21177 Token get firstTokenAfterCommentAndMetadata { 19780 Token get firstTokenAfterCommentAndMetadata {
21178 if (keyword != null) { 19781 if (keyword != null) {
21179 return keyword; 19782 return keyword;
21180 } else if (_type != null) { 19783 } else if (_type != null) {
21181 return _type.beginToken; 19784 return _type.beginToken;
21182 } 19785 }
21183 return _variables.beginToken; 19786 return _variables.beginToken;
21184 } 19787 }
21185 19788
21186 /** 19789 /**
21187 * Return `true` if the variables in this list were declared with the 'const' modifier. 19790 * Return `true` if the variables in this list were declared with the 'const'
21188 * 19791 * modifier.
21189 * @return `true` if the variables in this list were declared with the 'const' modifier
21190 */ 19792 */
21191 bool get isConst => 19793 bool get isConst =>
21192 keyword is KeywordToken && (keyword as KeywordToken).keyword == Keyword.CO NST; 19794 keyword is KeywordToken && (keyword as KeywordToken).keyword == Keyword.CO NST;
21193 19795
21194 /** 19796 /**
21195 * Return `true` if the variables in this list were declared with the 'final' modifier. 19797 * Return `true` if the variables in this list were declared with the 'final'
21196 * Variables that are declared with the 'const' modifier will return `false` e ven though 19798 * modifier. Variables that are declared with the 'const' modifier will return
21197 * they are implicitly final. 19799 * `false` even though they are implicitly final. (In other words, this is a
21198 * 19800 * syntactic check rather than a semantic check.)
21199 * @return `true` if the variables in this list were declared with the 'final' modifier
21200 */ 19801 */
21201 bool get isFinal => 19802 bool get isFinal =>
21202 keyword is KeywordToken && (keyword as KeywordToken).keyword == Keyword.FI NAL; 19803 keyword is KeywordToken && (keyword as KeywordToken).keyword == Keyword.FI NAL;
21203 19804
21204 /** 19805 /**
21205 * Return the type of the variables being declared, or `null` if no type was p rovided. 19806 * Return the type of the variables being declared, or `null` if no type was
21206 * 19807 * provided.
21207 * @return the type of the variables being declared
21208 */ 19808 */
21209 TypeName get type => _type; 19809 TypeName get type => _type;
21210 19810
21211 /** 19811 /**
21212 * Set the type of the variables being declared to the given type name. 19812 * Set the type of the variables being declared to the given [typeName].
21213 *
21214 * @param typeName the type of the variables being declared
21215 */ 19813 */
21216 void set type(TypeName typeName) { 19814 void set type(TypeName typeName) {
21217 _type = becomeParentOf(typeName); 19815 _type = becomeParentOf(typeName);
21218 } 19816 }
21219 19817
21220 /** 19818 /**
21221 * Return a list containing the individual variables being declared. 19819 * Return a list containing the individual variables being declared.
21222 *
21223 * @return a list containing the individual variables being declared
21224 */ 19820 */
21225 NodeList<VariableDeclaration> get variables => _variables; 19821 NodeList<VariableDeclaration> get variables => _variables;
21226 19822
21227 @override 19823 @override
21228 accept(AstVisitor visitor) => visitor.visitVariableDeclarationList(this); 19824 accept(AstVisitor visitor) => visitor.visitVariableDeclarationList(this);
21229 19825
21230 @override 19826 @override
21231 void visitChildren(AstVisitor visitor) { 19827 void visitChildren(AstVisitor visitor) {
21232 super.visitChildren(visitor); 19828 super.visitChildren(visitor);
21233 safelyVisitChild(_type, visitor); 19829 _safelyVisitChild(_type, visitor);
21234 _variables.accept(visitor); 19830 _variables.accept(visitor);
21235 } 19831 }
21236 } 19832 }
21237 19833
21238 /** 19834 /**
21239 * Instances of the class `VariableDeclarationStatement` represent a list of var iables that 19835 * A list of variables that are being declared in a context where a statement is
21240 * are being declared in a context where a statement is required. 19836 * required.
21241 * 19837 *
21242 * <pre> 19838 * > variableDeclarationStatement ::=
21243 * variableDeclarationStatement ::= 19839 * > [VariableDeclarationList] ';'
21244 * [VariableDeclarationList] ';'
21245 * </pre>
21246 */ 19840 */
21247 class VariableDeclarationStatement extends Statement { 19841 class VariableDeclarationStatement extends Statement {
21248 /** 19842 /**
21249 * The variables being declared. 19843 * The variables being declared.
21250 */ 19844 */
21251 VariableDeclarationList _variableList; 19845 VariableDeclarationList _variableList;
21252 19846
21253 /** 19847 /**
21254 * The semicolon terminating the statement. 19848 * The semicolon terminating the statement.
21255 */ 19849 */
21256 Token semicolon; 19850 Token semicolon;
21257 19851
21258 /** 19852 /**
21259 * Initialize a newly created variable declaration statement. 19853 * Initialize a newly created variable declaration statement.
21260 *
21261 * @param variableList the fields being declared
21262 * @param semicolon the semicolon terminating the statement
21263 */ 19854 */
21264 VariableDeclarationStatement(VariableDeclarationList variableList, 19855 VariableDeclarationStatement(VariableDeclarationList variableList,
21265 this.semicolon) { 19856 this.semicolon) {
21266 _variableList = becomeParentOf(variableList); 19857 _variableList = becomeParentOf(variableList);
21267 } 19858 }
21268 19859
21269 @override 19860 @override
21270 Token get beginToken => _variableList.beginToken; 19861 Token get beginToken => _variableList.beginToken;
21271 19862
21272 @override 19863 @override
21273 Iterable get childEntities => new ChildEntities() 19864 Iterable get childEntities => new ChildEntities()
21274 ..add(_variableList) 19865 ..add(_variableList)
21275 ..add(semicolon); 19866 ..add(semicolon);
21276 19867
21277 @override 19868 @override
21278 Token get endToken => semicolon; 19869 Token get endToken => semicolon;
21279 19870
21280 /** 19871 /**
21281 * Return the variables being declared. 19872 * Return the variables being declared.
21282 *
21283 * @return the variables being declared
21284 */ 19873 */
21285 VariableDeclarationList get variables => _variableList; 19874 VariableDeclarationList get variables => _variableList;
21286 19875
21287 /** 19876 /**
21288 * Set the variables being declared to the given list of variables. 19877 * Set the variables being declared to the given list of [variables].
21289 *
21290 * @param variableList the variables being declared
21291 */ 19878 */
21292 void set variables(VariableDeclarationList variableList) { 19879 void set variables(VariableDeclarationList variables) {
21293 _variableList = becomeParentOf(variableList); 19880 _variableList = becomeParentOf(variables);
21294 } 19881 }
21295 19882
21296 @override 19883 @override
21297 accept(AstVisitor visitor) => visitor.visitVariableDeclarationStatement(this); 19884 accept(AstVisitor visitor) => visitor.visitVariableDeclarationStatement(this);
21298 19885
21299 @override 19886 @override
21300 void visitChildren(AstVisitor visitor) { 19887 void visitChildren(AstVisitor visitor) {
21301 safelyVisitChild(_variableList, visitor); 19888 _safelyVisitChild(_variableList, visitor);
21302 } 19889 }
21303 } 19890 }
21304 19891
21305 /** 19892 /**
21306 * Instances of the class `WhileStatement` represent a while statement. 19893 * A while statement.
21307 * 19894 *
21308 * <pre> 19895 * > whileStatement ::=
21309 * whileStatement ::= 19896 * > 'while' '(' [Expression] ')' [Statement]
21310 * 'while' '(' [Expression] ')' [Statement]
21311 * </pre>
21312 */ 19897 */
21313 class WhileStatement extends Statement { 19898 class WhileStatement extends Statement {
21314 /** 19899 /**
21315 * The token representing the 'while' keyword. 19900 * The token representing the 'while' keyword.
21316 */ 19901 */
21317 Token keyword; 19902 Token keyword;
21318 19903
21319 /** 19904 /**
21320 * The left parenthesis. 19905 * The left parenthesis.
21321 */ 19906 */
21322 Token leftParenthesis; 19907 Token leftParenthesis;
21323 19908
21324 /** 19909 /**
21325 * The expression used to determine whether to execute the body of the loop. 19910 * The expression used to determine whether to execute the body of the loop.
21326 */ 19911 */
21327 Expression _condition; 19912 Expression _condition;
21328 19913
21329 /** 19914 /**
21330 * The right parenthesis. 19915 * The right parenthesis.
21331 */ 19916 */
21332 Token rightParenthesis; 19917 Token rightParenthesis;
21333 19918
21334 /** 19919 /**
21335 * The body of the loop. 19920 * The body of the loop.
21336 */ 19921 */
21337 Statement _body; 19922 Statement _body;
21338 19923
21339 /** 19924 /**
21340 * Initialize a newly created while statement. 19925 * Initialize a newly created while statement.
21341 *
21342 * @param keyword the token representing the 'while' keyword
21343 * @param leftParenthesis the left parenthesis
21344 * @param condition the expression used to determine whether to execute the bo dy of the loop
21345 * @param rightParenthesis the right parenthesis
21346 * @param body the body of the loop
21347 */ 19926 */
21348 WhileStatement(this.keyword, this.leftParenthesis, Expression condition, 19927 WhileStatement(this.keyword, this.leftParenthesis, Expression condition,
21349 this.rightParenthesis, Statement body) { 19928 this.rightParenthesis, Statement body) {
21350 _condition = becomeParentOf(condition); 19929 _condition = becomeParentOf(condition);
21351 _body = becomeParentOf(body); 19930 _body = becomeParentOf(body);
21352 } 19931 }
21353 19932
21354 @override 19933 @override
21355 Token get beginToken => keyword; 19934 Token get beginToken => keyword;
21356 19935
21357 /** 19936 /**
21358 * Return the body of the loop. 19937 * Return the body of the loop.
21359 *
21360 * @return the body of the loop
21361 */ 19938 */
21362 Statement get body => _body; 19939 Statement get body => _body;
21363 19940
21364 /** 19941 /**
21365 * Set the body of the loop to the given statement. 19942 * Set the body of the loop to the given [statement].
21366 *
21367 * @param statement the body of the loop
21368 */ 19943 */
21369 void set body(Statement statement) { 19944 void set body(Statement statement) {
21370 _body = becomeParentOf(statement); 19945 _body = becomeParentOf(statement);
21371 } 19946 }
21372 19947
21373 @override 19948 @override
21374 Iterable get childEntities => new ChildEntities() 19949 Iterable get childEntities => new ChildEntities()
21375 ..add(keyword) 19950 ..add(keyword)
21376 ..add(leftParenthesis) 19951 ..add(leftParenthesis)
21377 ..add(_condition) 19952 ..add(_condition)
21378 ..add(rightParenthesis) 19953 ..add(rightParenthesis)
21379 ..add(_body); 19954 ..add(_body);
21380 19955
21381 /** 19956 /**
21382 * Return the expression used to determine whether to execute the body of the loop. 19957 * Return the expression used to determine whether to execute the body of the
21383 * 19958 * loop.
21384 * @return the expression used to determine whether to execute the body of the loop
21385 */ 19959 */
21386 Expression get condition => _condition; 19960 Expression get condition => _condition;
21387 19961
21388 /** 19962 /**
21389 * Set the expression used to determine whether to execute the body of the loo p to the given 19963 * Set the expression used to determine whether to execute the body of the
21390 * expression. 19964 * loop to the given [expression].
21391 *
21392 * @param expression the expression used to determine whether to execute the b ody of the loop
21393 */ 19965 */
21394 void set condition(Expression expression) { 19966 void set condition(Expression expression) {
21395 _condition = becomeParentOf(expression); 19967 _condition = becomeParentOf(expression);
21396 } 19968 }
21397 19969
21398 @override 19970 @override
21399 Token get endToken => _body.endToken; 19971 Token get endToken => _body.endToken;
21400 19972
21401 @override 19973 @override
21402 accept(AstVisitor visitor) => visitor.visitWhileStatement(this); 19974 accept(AstVisitor visitor) => visitor.visitWhileStatement(this);
21403 19975
21404 @override 19976 @override
21405 void visitChildren(AstVisitor visitor) { 19977 void visitChildren(AstVisitor visitor) {
21406 safelyVisitChild(_condition, visitor); 19978 _safelyVisitChild(_condition, visitor);
21407 safelyVisitChild(_body, visitor); 19979 _safelyVisitChild(_body, visitor);
21408 } 19980 }
21409 } 19981 }
21410 19982
21411 /** 19983 /**
21412 * Instances of the class `WithClause` represent the with clause in a class decl aration. 19984 * The with clause in a class declaration.
21413 * 19985 *
21414 * <pre> 19986 * > withClause ::=
21415 * withClause ::= 19987 * > 'with' [TypeName] (',' [TypeName])*
21416 * 'with' [TypeName] (',' [TypeName])*
21417 * </pre>
21418 */ 19988 */
21419 class WithClause extends AstNode { 19989 class WithClause extends AstNode {
21420 /** 19990 /**
21421 * The token representing the 'with' keyword. 19991 * The token representing the 'with' keyword.
21422 */ 19992 */
21423 Token withKeyword; 19993 Token withKeyword;
21424 19994
21425 /** 19995 /**
21426 * The names of the mixins that were specified. 19996 * The names of the mixins that were specified.
21427 */ 19997 */
21428 NodeList<TypeName> _mixinTypes; 19998 NodeList<TypeName> _mixinTypes;
21429 19999
21430 /** 20000 /**
21431 * Initialize a newly created with clause. 20001 * Initialize a newly created with clause.
21432 *
21433 * @param withKeyword the token representing the 'with' keyword
21434 * @param mixinTypes the names of the mixins that were specified
21435 */ 20002 */
21436 WithClause(this.withKeyword, List<TypeName> mixinTypes) { 20003 WithClause(this.withKeyword, List<TypeName> mixinTypes) {
21437 _mixinTypes = new NodeList<TypeName>(this, mixinTypes); 20004 _mixinTypes = new NodeList<TypeName>(this, mixinTypes);
21438 } 20005 }
21439 20006
21440 @override 20007 @override
21441 Token get beginToken => withKeyword; 20008 Token get beginToken => withKeyword;
21442 20009
21443 /** 20010 /**
21444 * TODO(paulberry): add commas. 20011 * TODO(paulberry): add commas.
21445 */ 20012 */
21446 @override 20013 @override
21447 Iterable get childEntities => new ChildEntities() 20014 Iterable get childEntities => new ChildEntities()
21448 ..add(withKeyword) 20015 ..add(withKeyword)
21449 ..addAll(_mixinTypes); 20016 ..addAll(_mixinTypes);
21450 20017
21451 @override 20018 @override
21452 Token get endToken => _mixinTypes.endToken; 20019 Token get endToken => _mixinTypes.endToken;
21453 20020
21454 /** 20021 /**
21455 * Set the token representing the 'with' keyword to the given token. 20022 * Set the token representing the 'with' keyword to the given [token].
21456 * 20023 *
21457 * @param withKeyword the token representing the 'with' keyword 20024 * Deprecated: Use withKeyword instead.
21458 */ 20025 */
21459 @deprecated 20026 @deprecated
21460 void set mixinKeyword(Token withKeyword) { 20027 void set mixinKeyword(Token token) {
21461 this.withKeyword = withKeyword; 20028 this.withKeyword = token;
21462 } 20029 }
21463 20030
21464 /** 20031 /**
21465 * Return the names of the mixins that were specified. 20032 * Return the names of the mixins that were specified.
21466 *
21467 * @return the names of the mixins that were specified
21468 */ 20033 */
21469 NodeList<TypeName> get mixinTypes => _mixinTypes; 20034 NodeList<TypeName> get mixinTypes => _mixinTypes;
21470 20035
21471 @override 20036 @override
21472 accept(AstVisitor visitor) => visitor.visitWithClause(this); 20037 accept(AstVisitor visitor) => visitor.visitWithClause(this);
21473 20038
21474 @override 20039 @override
21475 void visitChildren(AstVisitor visitor) { 20040 void visitChildren(AstVisitor visitor) {
21476 _mixinTypes.accept(visitor); 20041 _mixinTypes.accept(visitor);
21477 } 20042 }
21478 } 20043 }
21479 20044
21480 /** 20045 /**
21481 * Instances of the class `YieldStatement` implement a yield statement. 20046 * A yield statement.
20047 *
20048 * > yieldStatement ::=
20049 * > 'yield' '*'? [Expression] ‘;’
21482 */ 20050 */
21483 class YieldStatement extends Statement { 20051 class YieldStatement extends Statement {
21484 /** 20052 /**
21485 * The 'yield' keyword. 20053 * The 'yield' keyword.
21486 */ 20054 */
21487 Token yieldKeyword; 20055 Token yieldKeyword;
21488 20056
21489 /** 20057 /**
21490 * The star optionally following the 'yield' keyword. 20058 * The star optionally following the 'yield' keyword.
21491 */ 20059 */
21492 Token star; 20060 Token star;
21493 20061
21494 /** 20062 /**
21495 * The expression whose value will be yielded. 20063 * The expression whose value will be yielded.
21496 */ 20064 */
21497 Expression _expression; 20065 Expression _expression;
21498 20066
21499 /** 20067 /**
21500 * The semicolon following the expression. 20068 * The semicolon following the expression.
21501 */ 20069 */
21502 Token semicolon; 20070 Token semicolon;
21503 20071
21504 /** 20072 /**
21505 * Initialize a newly created yield expression. 20073 * Initialize a newly created yield expression. The [star] can be `null` if no
21506 * 20074 * star was provided.
21507 * @param yieldKeyword the 'yield' keyword
21508 * @param star the star following the 'yield' keyword
21509 * @param expression the expression whose value will be yielded
21510 * @param semicolon the semicolon following the expression
21511 */ 20075 */
21512 YieldStatement(this.yieldKeyword, this.star, Expression expression, 20076 YieldStatement(this.yieldKeyword, this.star, Expression expression,
21513 this.semicolon) { 20077 this.semicolon) {
21514 _expression = becomeParentOf(expression); 20078 _expression = becomeParentOf(expression);
21515 } 20079 }
21516 20080
21517 @override 20081 @override
21518 Token get beginToken { 20082 Token get beginToken {
21519 if (yieldKeyword != null) { 20083 if (yieldKeyword != null) {
21520 return yieldKeyword; 20084 return yieldKeyword;
(...skipping 14 matching lines...) Expand all
21535 @override 20099 @override
21536 Token get endToken { 20100 Token get endToken {
21537 if (semicolon != null) { 20101 if (semicolon != null) {
21538 return semicolon; 20102 return semicolon;
21539 } 20103 }
21540 return _expression.endToken; 20104 return _expression.endToken;
21541 } 20105 }
21542 20106
21543 /** 20107 /**
21544 * Return the expression whose value will be yielded. 20108 * Return the expression whose value will be yielded.
21545 *
21546 * @return the expression whose value will be yielded
21547 */ 20109 */
21548 Expression get expression => _expression; 20110 Expression get expression => _expression;
21549 20111
21550 /** 20112 /**
21551 * Set the expression whose value will be yielded to the given expression. 20113 * Set the expression whose value will be yielded to the given [expression].
21552 *
21553 * @param expression the expression whose value will be yielded
21554 */ 20114 */
21555 void set expression(Expression expression) { 20115 void set expression(Expression expression) {
21556 _expression = becomeParentOf(expression); 20116 _expression = becomeParentOf(expression);
21557 } 20117 }
21558 20118
21559 @override 20119 @override
21560 accept(AstVisitor visitor) => visitor.visitYieldStatement(this); 20120 accept(AstVisitor visitor) => visitor.visitYieldStatement(this);
21561 20121
21562 @override 20122 @override
21563 void visitChildren(AstVisitor visitor) { 20123 void visitChildren(AstVisitor visitor) {
21564 safelyVisitChild(_expression, visitor); 20124 _safelyVisitChild(_expression, visitor);
21565 } 20125 }
21566 } 20126 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698